Chromium Code Reviews| Index: remoting/webapp/crd/js/client_plugin_impl.js |
| diff --git a/remoting/webapp/crd/js/client_plugin_impl.js b/remoting/webapp/crd/js/client_plugin_impl.js |
| index 2b94066106976bde8ff46ae30fff920046818932..5bfefb5d40cf037e440cececb31c1525ec752103 100644 |
| --- a/remoting/webapp/crd/js/client_plugin_impl.js |
| +++ b/remoting/webapp/crd/js/client_plugin_impl.js |
| @@ -98,6 +98,9 @@ remoting.ClientPluginImpl = function(container, |
| /** @private {remoting.CredentialsProvider} */ |
| this.credentials_ = null; |
| + |
| + /** @private {string} */ |
| + this.keyRemappings_ = ''; |
| }; |
| /** |
| @@ -495,6 +498,73 @@ remoting.ClientPluginImpl.prototype.releaseAllKeys = function() { |
| }; |
| /** |
| + * Sets and stores the key remapping setting for the current host. |
| + * |
| + * @param {string} remappings Comma separated list of key remappings. |
| + */ |
| +remoting.ClientPluginImpl.prototype.setRemapKeys = |
|
kelvinp
2015/03/19 00:25:15
moved from desktop_connected_view.js
|
| + function(remappings) { |
| + // Cancel any existing remappings and apply the new ones. |
| + this.applyRemapKeys_(this.keyRemappings_, false); |
| + this.applyRemapKeys_(remappings, true); |
| + this.keyRemappings_ = remappings; |
| +}; |
| + |
| +/** |
| + * Applies the configured key remappings to the session, or resets them. |
| + * |
| + * @param {string} remapKeys |
| + * @param {boolean} apply True to apply remappings, false to cancel them. |
| + */ |
|
garykac
2015/03/19 01:20:57
nit: add @private
kelvinp
2015/03/19 17:28:20
Done.
|
| +remoting.ClientPluginImpl.prototype.applyRemapKeys_ = |
| + function(remapKeys, apply) { |
| + if (remapKeys == '') { |
| + return; |
| + } |
| + |
| + var remappings = remapKeys.split(','); |
| + for (var i = 0; i < remappings.length; ++i) { |
| + var keyCodes = remappings[i].split('>'); |
| + if (keyCodes.length != 2) { |
| + console.log('bad remapKey: ' + remappings[i]); |
| + continue; |
| + } |
| + var fromKey = parseInt(keyCodes[0], 0); |
| + var toKey = parseInt(keyCodes[1], 0); |
| + if (!fromKey || !toKey) { |
| + console.log('bad remapKey code: ' + remappings[i]); |
| + continue; |
| + } |
| + if (apply) { |
| + console.log('remapKey 0x' + fromKey.toString(16) + |
| + '>0x' + toKey.toString(16)); |
| + this.remapKey(fromKey, toKey); |
| + } else { |
| + console.log('cancel remapKey 0x' + fromKey.toString(16)); |
| + this.remapKey(fromKey, fromKey); |
| + } |
| + } |
| +}; |
| + |
| +/** |
| + * Sends a key combination to the remoting host, by sending down events for |
| + * the given keys, followed by up events in reverse order. |
| + * |
| + * @param {Array<number>} keys Key codes to be sent. |
| + * @return {void} Nothing. |
| + * @private |
| + */ |
| +remoting.ClientPluginImpl.prototype.injectKeyCombination = |
|
garykac
2015/03/19 01:20:57
nit: This is @private and should have an underscor
kelvinp
2015/03/19 17:28:20
This is not a private. Referenced in DestopConnect
garykac
2015/03/19 17:53:25
The comment blocks her says that it is @private.
|
| + function(keys) { |
| + for (var i = 0; i < keys.length; i++) { |
| + this.injectKeyEvent(keys[i], true); |
| + } |
| + for (var i = 0; i < keys.length; i++) { |
| + this.injectKeyEvent(keys[i], false); |
| + } |
| +}; |
| + |
| +/** |
| * Send a key event to the host. |
| * |
| * @param {number} usbKeycode The USB-style code of the key to inject. |