diff --git a/images/backslash.png b/images/backslash.png new file mode 100644 index 00000000..cc55c401 Binary files /dev/null and b/images/backslash.png differ diff --git a/include/rfb.js b/include/rfb.js index b7be99f8..4e318eed 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -126,7 +126,12 @@ var that = {}, // Public API methods mouse_buttonMask = 0, mouse_arr = [], viewportDragging = false, - viewportDragPos = {}; + viewportDragPos = {}, + + /* Soft key */ + wrapWithSoftKeyLock, + softKeyState = {}, + softKey = { CtrlLock: 0xFFE3, AltLock: 0xFFE9 }; // Configuration attributes Util.conf_defaults(conf, that, defaults, [ @@ -596,12 +601,26 @@ checkEvents = function() { setTimeout(checkEvents, conf.check_rate); }; +wrapWithSoftKeyLock = function(arr) { + var k; + for (k in softKeyState) { + if (softKeyState[k]) { + arr = keyEvent(softKey[k], 1).concat(arr); + arr = arr.concat(keyEvent(softKey[k], 0)); + } + } + return arr; +} + keyPress = function(keysym, down) { var arr; if (conf.view_only) { return; } // View only, skip keyboard events arr = keyEvent(keysym, down); + if (down) { + arr = wrapWithSoftKeyLock(arr); + } arr = arr.concat(fbUpdateRequests()); ws.send(arr); }; @@ -1829,15 +1848,23 @@ that.sendKey = function(code, down) { if (typeof down !== 'undefined') { Util.Info("Sending key code (" + (down ? "down" : "up") + "): " + code); arr = arr.concat(keyEvent(code, down ? 1 : 0)); + if (down) { + arr = wrapWithSoftKeyLock(arr); + } } else { Util.Info("Sending key code (down + up): " + code); arr = arr.concat(keyEvent(code, 1)); + arr = wrapWithSoftKeyLock(arr); arr = arr.concat(keyEvent(code, 0)); } arr = arr.concat(fbUpdateRequests()); ws.send(arr); }; +that.updateSoftKeyState = function(name, value) { + softKeyState[name] = value; +}; + that.clipboardPasteFrom = function(text) { if (rfb_state !== "normal") { return; } //Util.Debug(">> clipboardPasteFrom: " + text.substr(0,40) + "..."); diff --git a/include/ui.js b/include/ui.js index 25bf162b..c287ee9c 100644 --- a/include/ui.js +++ b/include/ui.js @@ -143,6 +143,7 @@ addMouseHandlers: function() { //$D("keyboardinput").onkeydown = function (event) { onKeyDown(event); }; $D("keyboardinput").onblur = UI.keyInputBlur; + $D("sendBackslashButton").onclick = UI.sendBackslash; $D("sendCtrlAltDelButton").onclick = UI.sendCtrlAltDel; $D("clipboardButton").onclick = UI.toggleClipboardPanel; $D("settingsButton").onclick = UI.toggleSettingsPanel; @@ -391,6 +392,11 @@ setPassword: function() { return false; }, +sendBackslash: function() { + UI.rfb.sendKey(0x5C); + return false; +}, + sendCtrlAltDel: function() { UI.rfb.sendCtrlAltDel(); }, @@ -489,11 +495,13 @@ updateVisualState: function() { UI.setMouseButton(1); $D('clipboardButton').style.display = "inline"; $D('showKeyboard').style.display = "inline"; + $D('sendBackslashButton').style.display = "inline"; $D('sendCtrlAltDelButton').style.display = "inline"; } else { UI.setMouseButton(); $D('clipboardButton').style.display = "none"; $D('showKeyboard').style.display = "none"; + $D('sendBackslashButton').style.display = "none"; $D('sendCtrlAltDelButton').style.display = "none"; } // State change disables viewport dragging. diff --git a/vnc.html b/vnc.html index 9d699c9e..dcb6c9fe 100644 --- a/vnc.html +++ b/vnc.html @@ -70,6 +70,9 @@