Repository: cloudstack
Updated Branches:
  refs/heads/master 7dbff9b42 -> 135460507


CLOUDSTACK-7373: Incorrect Japanese keyboard mapping with CentOS CLI guestOS on 
VMware host.
This fix is to correct the JP keyboard mapping for VMs with windows and centOS 
GUI
and CLI OS on VMware hypervisor. Also fixed some known issues on centOS CLI on 
XS
hypervisor. Fix is not causing any regression.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/13546050
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/13546050
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/13546050

Branch: refs/heads/master
Commit: 13546050732964403301e5ee3ddcf4ec99e21f2a
Parents: 7dbff9b
Author: Sanjay Tripathi <sanjay.tripa...@citrix.com>
Authored: Tue Aug 19 16:42:10 2014 +0530
Committer: Sanjay Tripathi <sanjay.tripa...@citrix.com>
Committed: Wed Aug 20 14:34:28 2014 +0530

----------------------------------------------------------------------
 .../consoleproxy/ConsoleProxyClientBase.java    |   2 +-
 systemvm/js/ajaxkeys.js                         | 120 +++++++++++++------
 systemvm/js/ajaxviewer.js                       |  18 ++-
 3 files changed, 99 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/13546050/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 eb38007..fc3bf4b 100644
--- 
a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java
+++ 
b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java
@@ -323,7 +323,7 @@ public abstract class ConsoleProxyClientBase implements 
ConsoleProxyClient, Cons
                 "<li><a href=\"#\" cmd=\"keyboard_jp\"><span>Japanese 
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 + "', tileMap, ",
+                "var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + 
"', '" + updateUrl + "', '" + locale + "', '" + guest + "', tileMap, ",
                 String.valueOf(width) + ", " + String.valueOf(height) + ", " + 
String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight) + ");",
 
                 "$(function() {", "ajaxViewer.start();", "});",

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/13546050/systemvm/js/ajaxkeys.js
----------------------------------------------------------------------
diff --git a/systemvm/js/ajaxkeys.js b/systemvm/js/ajaxkeys.js
index 8f78cc8..f186c1d 100644
--- a/systemvm/js/ajaxkeys.js
+++ b/systemvm/js/ajaxkeys.js
@@ -230,46 +230,46 @@ var       keyboardTables = [
                   //{keycode: JS_KEY_GRAVE_ACCENT,             entry : 
X11_KEY_GRAVE_ACCENT},
                   //[192 / 64 = "' @"]
                   {keycode: 192,       entry : 0x5b,   browser: "IE"},
-                  {keycode: 64,                entry : 0x5b,   browser: 
"Firefox"},
+                  {keycode: 64,                entry : 0x5b,   guestos: 
"windows",     browser: "Firefox"},
                   //{keycode: JS_KEY_ADD,                                      
entry : X11_KEY_ADD},
                   //[187 / 59 = "; +"]
                   {keycode: 187,       entry : 0x3a,   browser: "IE"},
-                  {keycode: 59,                entry : 0x3b,   browser: 
"Firefox"},
+                  {keycode: 59,                entry : 0x3b,   guestos: 
"windows",     browser: "Firefox"},
                   //{keycode: JS_KEY_OPEN_BRACKET,             entry : 
X11_KEY_OPEN_BRACKET},
                   //[219 = "[{"]
-                  {keycode: 219,       entry : 0x5d,   browser: "IE"},
-                  {keycode: 219,       entry : 0x5d,   browser: "Firefox"},
+                  {keycode: 219,       entry : 0x5d,   guestos: "windows",     
browser: "IE"},
+                  {keycode: 219,       entry : 0x5d,   guestos: "windows",     
browser: "Firefox"},
                   //{keycode: JS_KEY_CLOSE_BRACKET,            entry : 
X11_KEY_CLOSE_BRACKET},
                   //[221 = "]}"]
-                  {keycode: 221,       entry : 0x5c,   browser: "IE"},
-                  {keycode: 221,       entry : 0x5c,   browser: "Firefox"},
-                  {keycode: JS_KEY_BACK_SLASH,                 entry : 
X11_KEY_BACK_SLASH},
+                  {keycode: 221,       entry : 0x5c,   guestos: "windows",     
browser: "IE"},
+                  {keycode: 221,       entry : 0x5c,   guestos: "windows",     
browser: "Firefox"},
+                  {keycode: JS_KEY_BACK_SLASH,         entry : 
X11_KEY_BACK_SLASH,     guestos: "windows"},
                   //{keycode: JS_KEY_SINGLE_QUOTE,             entry : 
X11_KEY_SINGLE_QUOTE},
                   //[222 / 160 = "~^"]
-                  {keycode: 222,               entry : 0x3d,   browser: "IE"},
-                  {keycode: 160,               entry : 0x3d,   browser: 
"Firefox"},
+                  {keycode: 222,       entry : 0x3d,   browser: "IE"},
+                  {keycode: 160,       entry : 0x3d,   guestos: "windows",     
browser: "Firefox"},
                   //[173 = "-=" ] specific to Firefox browser
-                  {keycode: 173,               entry : 0x2d,   browser: 
"Firefox"},
-                  {keycode: JS_KEY_COMMA,                              entry : 
X11_KEY_COMMA},
-                  {keycode: JS_KEY_PERIOD,                             entry : 
X11_KEY_PERIOD},
-                  {keycode: JS_KEY_FORWARD_SLASH,              entry : 
X11_KEY_FORWARD_SLASH},
+                  {keycode: 173,       entry : 0x2d,   guestos: "windows",     
browser: "Firefox"},
+                  {keycode: JS_KEY_COMMA,                              entry : 
X11_KEY_COMMA, guestos: "windows"},
+                  {keycode: JS_KEY_PERIOD,                             entry : 
X11_KEY_PERIOD, guestos: "windows"},
+                  {keycode: JS_KEY_FORWARD_SLASH,              entry : 
X11_KEY_FORWARD_SLASH, guestos: "windows"},
                   {keycode: JS_KEY_DASH,                               entry : 
X11_KEY_DASH},
                   {keycode: JS_KEY_SEMI_COLON,                 entry : 
X11_KEY_SEMI_COLON},
-                  {keycode: JS_KEY_NUMPAD0,                            entry : 
X11_KEY_KP_0},
-                  {keycode: JS_KEY_NUMPAD1,                            entry : 
X11_KEY_KP_1},
-                  {keycode: JS_KEY_NUMPAD2,                            entry : 
X11_KEY_KP_2},
-                  {keycode: JS_KEY_NUMPAD3,                            entry : 
X11_KEY_KP_3},
-                  {keycode: JS_KEY_NUMPAD4,                            entry : 
X11_KEY_KP_4},
-                  {keycode: JS_KEY_NUMPAD5,                            entry : 
X11_KEY_KP_5},
-                  {keycode: JS_KEY_NUMPAD6,                            entry : 
X11_KEY_KP_6},
-                  {keycode: JS_KEY_NUMPAD7,                            entry : 
X11_KEY_KP_7},
-                  {keycode: JS_KEY_NUMPAD8,                            entry : 
X11_KEY_KP_8},
-                  {keycode: JS_KEY_NUMPAD9,                            entry : 
X11_KEY_KP_9},
-                  {keycode: JS_KEY_DECIMAL_POINT,              entry : 
X11_KEY_KP_Decimal},
-                  {keycode: JS_KEY_DIVIDE,                             entry : 
0xffaf},
-                  {keycode: JS_KEY_MULTIPLY,                   entry : 0xffaa},
-                  {keycode: JS_KEY_ADD,                                        
entry : 0xffab},
-                  {keycode: JS_KEY_SUBSTRACT,                  entry : 0xffad},
+                  {keycode: JS_KEY_NUMPAD0,                            entry : 
X11_KEY_NUMPAD0, guestos: "windows"},
+                  {keycode: JS_KEY_NUMPAD1,                            entry : 
X11_KEY_NUMPAD1, guestos: "windows"},
+                  {keycode: JS_KEY_NUMPAD2,                            entry : 
X11_KEY_NUMPAD2, guestos: "windows"},
+                  {keycode: JS_KEY_NUMPAD3,                            entry : 
X11_KEY_NUMPAD3, guestos: "windows"},
+                  {keycode: JS_KEY_NUMPAD4,                            entry : 
X11_KEY_NUMPAD4, guestos: "windows"},
+                  {keycode: JS_KEY_NUMPAD5,                            entry : 
X11_KEY_NUMPAD5, guestos: "windows"},
+                  {keycode: JS_KEY_NUMPAD6,                            entry : 
X11_KEY_NUMPAD6, guestos: "windows"},
+                  {keycode: JS_KEY_NUMPAD7,                            entry : 
X11_KEY_NUMPAD7, guestos: "windows"},
+                  {keycode: JS_KEY_NUMPAD8,                            entry : 
X11_KEY_NUMPAD8, guestos: "windows"},
+                  {keycode: JS_KEY_NUMPAD9,                            entry : 
X11_KEY_NUMPAD9, guestos: "windows"},
+                  {keycode: JS_KEY_DECIMAL_POINT,              entry : 
X11_KEY_PERIOD, guestos: "windows"},
+                  {keycode: JS_KEY_DIVIDE,                             entry : 
0xffaf, guestos: "windows"},
+                  {keycode: JS_KEY_MULTIPLY,                   entry : 0xffaa, 
guestos: "windows"},
+                  {keycode: JS_KEY_ADD,                                        
entry : 0xffab, guestos: "windows"},
+                  {keycode: JS_KEY_SUBSTRACT,                  entry : 0xffad, 
guestos: "windows"},
                   //Kanji Key = 243 / 244
                   {keycode: 243,       entry : 0x7e,   browser: "IE"},
                   {keycode: 244,       entry : 0x7e,   browser: "IE"},
@@ -286,14 +286,66 @@ var       keyboardTables = [
                    */
                   //[186 / 58 = "~^"]
                   {keycode: 186,               entry : 0x22, browser: "IE"},
-                  {keycode: 58,                entry : 0x22, browser: 
"Firefox"},
+                  {keycode: 58,                entry : 0x22, guestos: 
"windows",       browser: "Firefox"},
                   ],
                   keyPress: [
-                             {keycode: 61,      entry:  [
-                                                         {type: KEY_DOWN, 
code: X11_KEY_ADD, modifiers: 0, shift: false },
-                                                         {type: KEY_UP, code: 
X11_KEY_ADD, modifiers: 0, shift: false }
-                                                         ]},
-                                                         ]
+                                                       // 34 : " " "
+                                                       {keycode: 34,      
entry:  [{type: KEY_DOWN, code: 0x22, modifiers: 64, shift: true }]},
+                                                       {keycode: 42,      
entry:  0xffaa },
+                                                       // 39 : " ' " (shift+7)
+                             {keycode: 39,             entry: [
+                                                                               
                                 {type: KEY_DOWN, code: X11_KEY_SHIFT, 
modifiers: 0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x22, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: 0x22, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 
0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x22, modifiers: 0, 
shift: true },
+                                                                               
                                 {type: KEY_UP, code: 0x22, modifiers: 0, 
shift: true },
+                                                                               
                                 ]},                                            
        //58 : " : "
+                                                        {keycode: 58,          
entry: [
+                                                                               
                                 {type: KEY_DOWN, code: X11_KEY_SHIFT, 
modifiers: 0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x3a, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: 0x3a, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 
0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x3a, modifiers: 0, 
shift: true },
+                                                                               
                                 {type: KEY_UP, code: 0x3a, modifiers: 0, 
shift: true },
+                                                                               
                                 ]},                                            
         
+                                                       // 94 : "^"     
+                              {keycode: 94,            entry: [
+                                                                               
                                 {type: KEY_DOWN, code: X11_KEY_SHIFT, 
modifiers: 0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x36, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: 0x36, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 
0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x36, modifiers: 0, 
shift: true },
+                                                                               
                                 {type: KEY_UP, code: 0x36, modifiers: 0, 
shift: true },
+                                                                               
                                 ]},                                            
                                                                                
                                                                                
                 
+                                                       // 64 : "@"     
+                              {keycode: 64,            entry: [
+                                                                               
                                 {type: KEY_DOWN, code: X11_KEY_SHIFT, 
modifiers: 0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x32, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: 0x32, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 
0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x32, modifiers: 0, 
shift: true },
+                                                                               
                                 {type: KEY_UP, code: 0x32, modifiers: 0, 
shift: true },
+                                                                               
                                 ]},                                            
         
+                                                        // 96 : "'"    
+                              {keycode: 96,            entry: [
+                                                                               
                                 {type: KEY_DOWN, code: X11_KEY_SHIFT, 
modifiers: 0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x7e, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: 0x7e, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 
0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x7e, modifiers: 0, 
shift: true },
+                                                                               
                                 {type: KEY_UP, code: 0x7e, modifiers: 0, 
shift: true },
+                                                                               
                                 ]},
+                             // 61 : "="       
+                                                        {keycode: 61,          
entry: [
+                                                                               
                                 {type: KEY_DOWN, code: X11_KEY_SHIFT, 
modifiers: 0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x3d, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: 0x3d, modifiers: 0, 
shift: false },
+                                                                               
                                 {type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 
0, shift: false },
+                                                                               
                                 {type: KEY_DOWN, code: 0x3d, modifiers: 0, 
shift: true },
+                                                                               
                                 {type: KEY_UP, code: 0x3d, modifiers: 0, 
shift: true },
+                                                                               
                                 ]},
+                            ]
            }
            }, {tindex: 2, keyboardType: KEYBOARD_TYPE_UK, mappingTable:
                  {X11: [

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/13546050/systemvm/js/ajaxviewer.js
----------------------------------------------------------------------
diff --git a/systemvm/js/ajaxviewer.js b/systemvm/js/ajaxviewer.js
index ff899b1..5394077 100644
--- a/systemvm/js/ajaxviewer.js
+++ b/systemvm/js/ajaxviewer.js
@@ -161,7 +161,7 @@ KeyboardMapper.prototype = {
                        }
                        
                        var X11Keysym = code;
-                       if(this.jsX11KeysymMap[code] != undefined) {
+                       if(this.jsX11KeysymMap[code] != undefined && (guestos 
== 'windows' || modifiers != AjaxViewer.SHIFT_KEY_MASK)) {
                                X11Keysym = this.jsX11KeysymMap[code];
                                if(typeof this.jsX11KeysymMap[code] == 
"boolean") {
                                        return;
@@ -175,15 +175,15 @@ KeyboardMapper.prototype = {
                                } else {
                                        this.mappedInput.push({type : 
eventType, code: X11Keysym, modifiers: modifiers});
                                }
-                       } else {
+                       } else if(guestos == 'windows' || ((modifiers & 
(AjaxViewer.CTRL_KEY_MASK | AjaxViewer.ALT_KEY_MASK)) != 0)){
                                this.mappedInput.push({type : eventType, code: 
X11Keysym, modifiers: modifiers});
                        }
 
                        // special handling for ALT/CTRL key
-                       if(eventType == AjaxViewer.KEY_UP && (code == 
AjaxViewer.JS_KEY_ALT || code == code == AjaxViewer.JS_KEY_CTRL))
+                       if(eventType == AjaxViewer.KEY_UP && (code == 
AjaxViewer.JS_KEY_ALT || code == AjaxViewer.JS_KEY_CTRL))
                                this.mappedInput.push({type : eventType, code: 
this.jsX11KeysymMap[code], modifiers: modifiers});
                        
-               } else if(eventType == AjaxViewer.KEY_PRESS) {
+               } else if(eventType == AjaxViewer.KEY_PRESS && guestos == 
'null') {
                        var X11Keysym = code;
                        X11Keysym = this.jsKeyPressX11KeysymMap[code];
                        if(X11Keysym) {
@@ -196,6 +196,9 @@ KeyboardMapper.prototype = {
                                        this.mappedInput.push({type : 
AjaxViewer.KEY_DOWN, code: X11Keysym, modifiers: modifiers});
                                        this.mappedInput.push({type : 
AjaxViewer.KEY_UP, code: X11Keysym, modifiers: modifiers});
                                }
+                       } else {
+                               this.mappedInput.push({type : 
AjaxViewer.KEY_DOWN, code: code, modifiers: modifiers});
+                               this.mappedInput.push({type : 
AjaxViewer.KEY_UP, code: code, modifiers: modifiers});
                        }
                }
        },
@@ -332,7 +335,7 @@ KeyboardMapper.prototype = {
 /////////////////////////////////////////////////////////////////////////////
 // class AjaxViewer
 //
-function AjaxViewer(panelId, imageUrl, updateUrl, locale, tileMap, width, 
height, tileWidth, tileHeight) {
+function AjaxViewer(panelId, imageUrl, updateUrl, locale, guestos, tileMap, 
width, height, tileWidth, tileHeight) {
        // logging is disabled by default so that it won't have negative impact 
on performance
        // however, a back door key-sequence can trigger to open the logger 
window, it is designed to help
        // trouble-shooting
@@ -352,6 +355,7 @@ function AjaxViewer(panelId, imageUrl, updateUrl, locale, 
tileMap, width, height
        
        this.updateUrl = updateUrl;
        this.tileMap = tileMap;
+       this.guestos = guestos;
        this.dirty = true;
        this.width = width;
        this.height = height;
@@ -745,7 +749,9 @@ AjaxViewer.prototype = {
                        for (var j = 0; j < x11Maps.length; j++) {
                                var code = x11Maps[j].keycode;
                                var mappedEntry = x11Maps[j].entry;
-                               
this.keyboardMappers[keyboardType].jsX11KeysymMap[code] = mappedEntry;
+                               if(x11Maps[j].guestos == undefined || 
x11Maps[j].guestos == this.guestos) {
+                                       
this.keyboardMappers[keyboardType].jsX11KeysymMap[code] = mappedEntry;
+                               }
                        }
                        var keyPressMaps = mappings.keyPress;
                        for (var j = 0; j < keyPressMaps.length; j++) {

Reply via email to