Repository: cloudstack Updated Branches: refs/heads/master 05b2ec4f5 -> f73ad2e8b
console-proxy add support of AltGr key and FR azerty keyboard Signed-off-by: Rohit Yadav <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f73ad2e8 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f73ad2e8 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f73ad2e8 Branch: refs/heads/master Commit: f73ad2e8b3419a0d93c2831e66f97930b62c0140 Parents: 05b2ec4 Author: Axel Delahaye <[email protected]> Authored: Mon Dec 8 11:26:30 2014 +0100 Committer: Rohit Yadav <[email protected]> Committed: Mon Dec 8 18:05:43 2014 +0530 ---------------------------------------------------------------------- .../consoleproxy/ConsoleProxyClientBase.java | 3 +- systemvm/css/ajaxviewer.css | 2 +- systemvm/js/ajaxkeys.js | 334 ++++++++++++++++++- systemvm/js/ajaxviewer.js | 22 +- 4 files changed, 355 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f73ad2e8/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java ---------------------------------------------------------------------- diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java index fc3bf4b..6568f4d 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java @@ -320,7 +320,8 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons "<span><img align=\"left\" src=\"/resource/images/winlog.png\" alt=\"Keyboard\" style=\"width:16px;height:16px\"/>Keyboard</span>", "</a>", "<ul>", "<li><a href=\"#\" cmd=\"keyboard_us\"><span>Standard (US) keyboard</span></a></li>", "<li><a href=\"#\" cmd=\"keyboard_uk\"><span>UK keyboard</span></a></li>", - "<li><a href=\"#\" cmd=\"keyboard_jp\"><span>Japanese keyboard</span></a></li>", "</ul>", "</li>", "</ul>", + "<li><a href=\"#\" cmd=\"keyboard_jp\"><span>Japanese keyboard</span></a></li>", + "<li><a href=\"#\" cmd=\"keyboard_fr\"><span>French AZERTY keyboard</span></a></li>", "</ul>", "</li>", "</ul>", "<span id=\"light\" class=\"dark\" cmd=\"toggle_logwin\"></span>", "</div>", "<div id=\"main_panel\" tabindex=\"1\"></div>", "<script language=\"javascript\">", "var acceptLanguages = '" + sbLanguages.toString() + "';", "var tileMap = [ " + tileSequence + " ];", "var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', '" + locale + "', '" + guest + "', tileMap, ", http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f73ad2e8/systemvm/css/ajaxviewer.css ---------------------------------------------------------------------- diff --git a/systemvm/css/ajaxviewer.css b/systemvm/css/ajaxviewer.css index fd2fb3c..3e068140 100644 --- a/systemvm/css/ajaxviewer.css +++ b/systemvm/css/ajaxviewer.css @@ -91,7 +91,7 @@ body { position: absolute; top:32; width: 260; - height: 95; + height: 125; display: block; display: none; border-top: 1px solid black; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f73ad2e8/systemvm/js/ajaxkeys.js ---------------------------------------------------------------------- diff --git a/systemvm/js/ajaxkeys.js b/systemvm/js/ajaxkeys.js index 3053b7d..5ef4f9f 100644 --- a/systemvm/js/ajaxkeys.js +++ b/systemvm/js/ajaxkeys.js @@ -164,6 +164,7 @@ KEY_UP = 6; KEYBOARD_TYPE_COOKED = "us"; KEYBOARD_TYPE_JP = "jp"; KEYBOARD_TYPE_UK = "uk"; +KEYBOARD_TYPE_FR = "fr"; //JP keyboard type @@ -311,4 +312,335 @@ var keyboardTables = [ {keycode: 166, entry: [{type : KEY_DOWN, code : 0x60, modifiers : 896, shift : false}], guestos: "windows"} ] } - }] + }, + {tindex: 3, keyboardType: KEYBOARD_TYPE_FR, mappingTable:{ + X11: [ + // '*' doesn't work + {keycode: 220, browser: "Chrome", entry: 0x5c}, + {keycode: 170, browser: "Firefox", entry: 0x5c}, +//ROW 1 AltGr + //[50 = ~] + {keycode: 50, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x32, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x32, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[51 = #] + {keycode: 51, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x33, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x33, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[52 = {] + {keycode: 52, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x34, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x34, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[53 = [] + {keycode: 53, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x35, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x35, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[54 = |] + {keycode: 54, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x36, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x36, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[55 = `] + {keycode: 55, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x37, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x37, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[56 = \] + {keycode: 56, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x38, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x38, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[57 = ^] + {keycode: 57, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x39, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x39, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[48 = @] + {keycode: 48, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x30, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x30, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[219 = ]] + {keycode: 219, browser: "Chrome", entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x2d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x2d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[169 = ]] + {keycode: 169, browser: "Firefox", entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x2d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x2d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[187 = }] + {keycode: 187, browser: "Chrome", entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x3d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x3d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[61 = }] + {keycode: 61, browser: "Firefox", entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x3d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x3d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, +//ROW 2 AltGr + //[69 = â¬] + {keycode: 69, entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x65, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x65, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[186 = ¤] + {keycode: 186, browser: "Chrome", entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x5d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x5d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]}, + //[164 = ¤] + {keycode: 164, browser: "Firefox", entry: [ + {type: KEY_DOWN, code: 0xffea, modifiers: 0, altgr: true}, + {type: KEY_DOWN, code: 0x5d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0x5d, modifiers: 0, altgr: true}, + {type: KEY_UP, code: 0xffea, modifiers: 0, altgr: true} + ]} + ], + keyPress: [ +//ROW 1 + //[178 = ²] + {keycode: 178, entry: [ + {type: KEY_DOWN, code: 0x60, modifiers: 0}, + {type: KEY_UP, code: 0x60, modifiers: 0} + ]}, + //[38 = &] + {keycode: 38, entry: [ + {type: KEY_DOWN, code: 0x31, modifiers: 0}, + {type: KEY_UP, code: 0x31, modifiers: 0} + ]}, + //[233 = é] + {keycode: 233, entry: [ + {type: KEY_DOWN, code: 0x32, modifiers: 0}, + {type: KEY_UP, code: 0x32, modifiers: 0} + ]}, + //[34 = "] + {keycode: 34, entry: [ + {type: KEY_DOWN, code: 0x33, modifiers: 0}, + {type: KEY_UP, code: 0x33, modifiers: 0} + ]}, + //[39 = '] + {keycode: 39, entry: [ + {type: KEY_DOWN, code: 0x34, modifiers: 0}, + {type: KEY_UP, code: 0x34, modifiers: 0} + ]}, + //[40 = (] + {keycode: 40, entry: [ + {type: KEY_DOWN, code: 0x35, modifiers: 0}, + {type: KEY_UP, code: 0x35, modifiers: 0} + ]}, + //[45 = -] + {keycode: 45, entry: [ + {type: KEY_DOWN, code: 0x36, modifiers: 0}, + {type: KEY_UP, code: 0x36, modifiers: 0} + ]}, + //[232 = è] + {keycode: 232, entry: [ + {type: KEY_DOWN, code: 0x37, modifiers: 0}, + {type: KEY_UP, code: 0x37, modifiers: 0} + ]}, + //[95 = _] + {keycode: 95, entry: [ + {type: KEY_DOWN, code: 0x38, modifiers: 0}, + {type: KEY_UP, code: 0x38, modifiers: 0} + ]}, + //[231 = ç] + {keycode: 231, entry: [ + {type: KEY_DOWN, code: 0x39, modifiers: 0}, + {type: KEY_UP, code: 0x39, modifiers: 0} + ]}, + //[224 = à ] + {keycode: 224, entry: [ + {type: KEY_DOWN, code: 0x30, modifiers: 0}, + {type: KEY_UP, code: 0x30, modifiers: 0} + ]}, + //[41 = )] + {keycode: 41, entry: [ + {type: KEY_DOWN, code: 0x2d, modifiers: 0}, + {type: KEY_UP, code: 0x2d, modifiers: 0} + ]}, + //[176 = =] + {keycode: 176, entry: [ + {type: KEY_DOWN, code: 0x2d, modifiers: 64}, + {type: KEY_UP, code: 0x2d, modifiers: 64} + ]}, + //[181 = µ] + {keycode: 181, entry: [ + {type: KEY_DOWN, code: 0x5c, modifiers: 64}, + {type: KEY_UP, code: 0x5c, modifiers: 64} + ]}, + +//ROW 2 + //[97 = a] + {keycode: 97, entry: [ + {type: KEY_DOWN, code: 0x71, modifiers: 0}, + {type: KEY_UP, code: 0x71, modifiers: 0} + ]}, + //[65 = A] + {keycode: 65, entry: [ + {type: KEY_DOWN, code: 0x51, modifiers: 64}, + {type: KEY_UP, code: 0x51, modifiers: 64} + ]}, + //[122 = z] + {keycode: 122, entry: [ + {type: KEY_DOWN, code: 0x77, modifiers: 0}, + {type: KEY_UP, code: 0x77, modifiers: 0} + ]}, + //[90 = Z] + {keycode: 90, entry: [ + {type: KEY_DOWN, code: 0x57, modifiers: 64}, + {type: KEY_UP, code: 0x57, modifiers: 64} + ]}, + //[94 = ^] + {keycode: 94, entry: [ + {type: KEY_DOWN, code: 0x5b, modifiers: 0}, + {type: KEY_UP, code: 0x5b, modifiers: 0} + ]}, + //[168 = ¨] + {keycode: 168, entry: [ + {type: KEY_DOWN, code: 0x5b, modifiers: 64}, + {type: KEY_UP, code: 0x5b, modifiers: 64} + ]}, + //[36 = $] + {keycode: 36, entry: [ + {type: KEY_DOWN, code: 0x5d, modifiers: 0}, + {type: KEY_UP, code: 0x5d, modifiers: 0} + ]}, + //[163 = £] + {keycode: 163, entry: [ + {type: KEY_DOWN, code: 0x5d, modifiers: 64}, + {type: KEY_UP, code: 0x5d, modifiers: 64} + ]}, + +//ROW 3 + //[113 = q] + {keycode: 113, entry: [ + {type: KEY_DOWN, code: 0x61, modifiers: 0}, + {type: KEY_UP, code: 0x61, modifiers: 0} + ]}, + //[81 = Q] + {keycode: 81, entry: [ + {type: KEY_DOWN, code: 0x41, modifiers: 64}, + {type: KEY_UP, code: 0x41, modifiers: 64} + ]}, + //[109 = m] + {keycode: 109, entry: [ + {type: KEY_DOWN, code: 0x3b, modifiers: 0}, + {type: KEY_UP, code: 0x3b, modifiers: 0} + ]}, + //[77 = M] + {keycode: 77, entry: [ + {type: KEY_DOWN, code: 0x3b, modifiers: 64}, + {type: KEY_UP, code: 0x3b, modifiers: 64} + ]}, + //[249 = ù] + {keycode: 249, entry: [ + {type: KEY_DOWN, code: 0x27, modifiers: 0}, + {type: KEY_UP, code: 0x27, modifiers: 0} + ]}, + //[37 = %] + {keycode: 37, entry: [ + {type: KEY_DOWN, code: 0x27, modifiers: 64}, + {type: KEY_UP, code: 0x27, modifiers: 64} + ]}, + +//ROW 4 + //[60 = <] + {keycode: 60, entry: [ + {type: KEY_DOWN, code: 0xa6, modifiers: 0}, + {type: KEY_UP, code: 0xa6, modifiers: 0} + ]}, + //[62 = >] + {keycode: 62, entry: [ + {type: KEY_DOWN, code: 0xa6, modifiers: 64}, + {type: KEY_UP, code: 0xa6, modifiers: 64} + ]}, + //[119 = w] + {keycode: 119, entry: [ + {type: KEY_DOWN, code: 0x7a, modifiers: 0}, + {type: KEY_UP, code: 0x7a, modifiers: 0} + ]}, + //[87 = W] + {keycode: 87, entry: [ + {type: KEY_DOWN, code: 0x5a, modifiers: 64}, + {type: KEY_UP, code: 0x5a, modifiers: 64} + ]}, + //[44 = ,] + {keycode: 44, entry: [ + {type: KEY_DOWN, code: 0x6d, modifiers: 0}, + {type: KEY_UP, code: 0x6d, modifiers: 0} + ]}, + //[63 = ?] + {keycode: 63, entry: [ + {type: KEY_DOWN, code: 0x4d, modifiers: 64}, + {type: KEY_UP, code: 0x4d, modifiers: 64} + ]}, + //[59 = ;] + {keycode: 59, entry: [ + {type: KEY_DOWN, code: 0x2c, modifiers: 0}, + {type: KEY_UP, code: 0x2c, modifiers: 0} + ]}, + //[46 = .] + {keycode: 46, entry: [ + {type: KEY_DOWN, code: 0x2c, modifiers: 64}, + {type: KEY_UP, code: 0x2c, modifiers: 64} + ]}, + //[58 = :] + {keycode: 58, entry: [ + {type: KEY_DOWN, code: 0x2e, modifiers: 0}, + {type: KEY_UP, code: 0x2e, modifiers: 0} + ]}, + //[47 = /] + {keycode: 47, entry: [ + {type: KEY_DOWN, code: 0x2e, modifiers: 64}, + {type: KEY_UP, code: 0x2e, modifiers: 64} + ]}, + //[33 = !] + {keycode: 33, entry: [ + {type: KEY_DOWN, code: 0x2f, modifiers: 0}, + {type: KEY_UP, code: 0x2f, modifiers: 0} + ]}, + //[167 = §] + {keycode: 167, entry: [ + {type: KEY_DOWN, code: 0x2f, modifiers: 64}, + {type: KEY_UP, code: 0x2f, modifiers: 64} + ]}, + ] + }} +] http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f73ad2e8/systemvm/js/ajaxviewer.js ---------------------------------------------------------------------- diff --git a/systemvm/js/ajaxviewer.js b/systemvm/js/ajaxviewer.js index db5ed45..f5df103 100644 --- a/systemvm/js/ajaxviewer.js +++ b/systemvm/js/ajaxviewer.js @@ -100,12 +100,13 @@ function KeyboardMapper() { KeyboardMapper.KEYBOARD_TYPE_RAW = 0; KeyboardMapper.KEYBOARD_TYPE_COOKED = 1; KeyboardMapper.KEYBOARD_TYPE_UK = 2; +KeyboardMapper.KEYBOARD_TYPE_FR = 3; KeyboardMapper.prototype = { setKeyboardType : function(keyboardType) { this.keyboardType = keyboardType; - if(keyboardType == KeyboardMapper.KEYBOARD_TYPE_COOKED || keyboardType == KeyboardMapper.KEYBOARD_TYPE_UK) { + if(keyboardType == KeyboardMapper.KEYBOARD_TYPE_COOKED || keyboardType == KeyboardMapper.KEYBOARD_TYPE_UK || keyboardType == KeyboardMapper.KEYBOARD_TYPE_FR) { // initialize mapping for COOKED keyboard this.jsX11KeysymMap[AjaxViewer.JS_KEY_CAPSLOCK] = AjaxViewer.X11_KEY_CAPSLOCK; this.jsX11KeysymMap[AjaxViewer.JS_KEY_BACKSPACE] = AjaxViewer.X11_KEY_BACKSPACE; @@ -312,7 +313,14 @@ KeyboardMapper.prototype = { if(entry.shift ^ shift) return false; } - + + // Consider Alt+Ctrl as AltGr + if(entry.altgr != undefined){ + var altgr = ((modifiers & AjaxViewer.ALT_KEY_MASK) && (modifiers & AjaxViewer.CTRL_KEY_MASK)) != 0 ? true : false; + if(entry.altgr ^ altgr) + return false; + } + if(entry.guestos != undefined) { if(entry.guestos != guestos) return false; @@ -367,7 +375,7 @@ function AjaxViewer(panelId, imageUrl, updateUrl, locale, guestos, tileMap, widt this.tileHeight = tileHeight; this.maxTileZIndex = 1; - if (locale == AjaxViewer.KEYBOARD_TYPE_UK_ENGLISH || locale == AjaxViewer.KEYBOARD_TYPE_JAPANESE) + if (locale == AjaxViewer.KEYBOARD_TYPE_UK_ENGLISH || locale == AjaxViewer.KEYBOARD_TYPE_JAPANESE || locale == AjaxViewer.KEYBOARD_TYPE_FRENCH) this.currentKeyboard = locale; else this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_ENGLISH; @@ -419,6 +427,7 @@ AjaxViewer.STATUS_SENT = 4; AjaxViewer.KEYBOARD_TYPE_ENGLISH = "us"; AjaxViewer.KEYBOARD_TYPE_UK_ENGLISH = "uk"; AjaxViewer.KEYBOARD_TYPE_JAPANESE = "jp"; +AjaxViewer.KEYBOARD_TYPE_FRENCH = "fr"; AjaxViewer.JS_KEY_BACKSPACE = 8; AjaxViewer.JS_KEY_TAB = 9; @@ -688,6 +697,10 @@ AjaxViewer.prototype = { this.keyboardMappers[AjaxViewer.KEYBOARD_TYPE_JAPANESE] = mapper; mapper.setKeyboardType(KeyboardMapper.KEYBOARD_TYPE_RAW); + var mapper = new KeyboardMapper(); + this.keyboardMappers[AjaxViewer.KEYBOARD_TYPE_FRENCH] = mapper; + mapper.setKeyboardType(KeyboardMapper.KEYBOARD_TYPE_FR); + // JP keyboard plugged in a English host OS /* mapper.jsX11KeysymMap[AjaxViewer.JS_KEY_JP_COLON] = AjaxViewer.X11_KEY_COLON; @@ -822,6 +835,9 @@ AjaxViewer.prototype = { } else if(cmd == "keyboard_uk") { $("#toolbar").find(".pulldown").find("ul").hide(); this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_UK_ENGLISH; + } else if(cmd == "keyboard_fr") { + $("#toolbar").find(".pulldown").find("ul").hide(); + this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_FRENCH; } else if(cmd == "sendCtrlAltDel") { this.sendKeyboardEvent(AjaxViewer.KEY_DOWN, 0xffe9, 0); // X11 Alt this.sendKeyboardEvent(AjaxViewer.KEY_DOWN, 0xffe3, 0); // X11 Ctrl
