From 93bb0f95089e74eb4540d48554cb12afb22d68ca Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 Nov 2012 12:54:17 +0900 Subject: [PATCH 1/4] add "send backslash" button. it's impossible to send a plain backslash keysym without ALT using MacBookPro with JP keyboard. option+yen produces a backslash but, because noVNC maps option key to ALT, it ends up with sending ALT+backslash to the server. --- vnc_auto.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/vnc_auto.html b/vnc_auto.html index a6273256..a7e72a79 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -26,6 +26,8 @@ @@ -66,9 +68,10 @@ return false; } function updateState(rfb, state, oldstate, msg) { - var s, sb, cad, level; + var s, sb, bs, cad, level; s = $D('noVNC_status'); sb = $D('noVNC_status_bar'); + bs = $D('sendBackslashButton'); cad = $D('sendCtrlAltDelButton'); switch (state) { case 'failed': level = "error"; break; @@ -79,8 +82,13 @@ default: level = "warn"; break; } - if (state === "normal") { cad.disabled = false; } - else { cad.disabled = true; } + if (state === "normal") { + bs.disabled = false; + cad.disabled = false; + } else { + bs.disabled = true; + cad.disabled = true; + } if (typeof(msg) !== 'undefined') { sb.setAttribute("class", "noVNC_status_" + level); @@ -91,6 +99,11 @@ window.onscriptsload = function () { var host, port, password, path, token; + $D('sendBackslashButton').style.display = "inline"; + $D('sendBackslashButton').onclick = function() { + rfb.sendKey(0x5C); + return false; + } $D('sendCtrlAltDelButton').style.display = "inline"; $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel; From c24d98138bbfc102aa1715bb2174cff1e0064961 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 7 Nov 2012 14:08:29 +0900 Subject: [PATCH 2/4] code cleanup --- vnc_auto.html | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/vnc_auto.html b/vnc_auto.html index a7e72a79..1a67ef1b 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -49,6 +49,14 @@ var rfb; + var buttons = [ + {name: 'sendBackslashButton', onclick: function() { + rfb.sendKey(0x5C); + return false; + }}, + {name: 'sendCtrlAltDelButton', onclick: sendCtrlAltDel} + ]; + function passwordRequired(rfb) { var msg; msg = '
Date: Wed, 7 Nov 2012 14:51:45 +0900 Subject: [PATCH 3/4] implement "send backslash" button for vnc.html --- images/backslash.png | Bin 0 -> 279 bytes include/ui.js | 8 ++++++++ vnc.html | 3 +++ 3 files changed, 11 insertions(+) create mode 100644 images/backslash.png diff --git a/images/backslash.png b/images/backslash.png new file mode 100644 index 0000000000000000000000000000000000000000..cc55c401153965dcfdb17bde87393e00178a0928 GIT binary patch literal 279 zcmeAS@N?(olHy`uVBq!ia0vp^k|4~%1|*NXY)uAIY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPaH#@5q+u=7?Rsn^Uc)B=-cpQH_c_U}DgM{1uh;$C= z?@t12Qe{U zV0t=h_oSKc^*!A^)fK)QoNVBdIJ@Fg)h3x2Kh_m*G`x^v{O(xVjGUNBX0xq7u>IQV zdH%2Y-o{xownVd>WIE@1Dfp6Okk-pLsl|Ucu1vmEKmE($N#7bJG#JbkH1fJ@8Gcnb VPVo?xsRO!~!PC{xWt~$(697&yYQz8l literal 0 HcmV?d00001 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 @@
+ From 0cb3aa2a6c255aaa733e62e26ca0ffef773a7a6e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 8 Nov 2012 17:20:51 +0900 Subject: [PATCH 4/4] implement ctrl-lock and alt-lock for vnc_auto.html --- include/rfb.js | 29 ++++++++++++++++++++++++++++- vnc_auto.html | 14 +++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) 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/vnc_auto.html b/vnc_auto.html index 1a67ef1b..6f1af127 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -25,7 +25,13 @@
Loading
+
-
Loading
+
+ + + +