Skip to content

Commit 1354605

Browse files
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.
1 parent 7dbff9b commit 1354605

3 files changed

Lines changed: 99 additions & 41 deletions

File tree

services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ private String getAjaxViewerPageContent(String tileSequence, String imgUrl, Stri
323323
"<li><a href=\"#\" cmd=\"keyboard_jp\"><span>Japanese keyboard</span></a></li>", "</ul>", "</li>", "</ul>",
324324
"<span id=\"light\" class=\"dark\" cmd=\"toggle_logwin\"></span>", "</div>", "<div id=\"main_panel\" tabindex=\"1\"></div>",
325325
"<script language=\"javascript\">", "var acceptLanguages = '" + sbLanguages.toString() + "';", "var tileMap = [ " + tileSequence + " ];",
326-
"var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', '" + locale + "', tileMap, ",
326+
"var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', '" + locale + "', '" + guest + "', tileMap, ",
327327
String.valueOf(width) + ", " + String.valueOf(height) + ", " + String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight) + ");",
328328

329329
"$(function() {", "ajaxViewer.start();", "});",

systemvm/js/ajaxkeys.js

Lines changed: 86 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -230,46 +230,46 @@ var keyboardTables = [
230230
//{keycode: JS_KEY_GRAVE_ACCENT, entry : X11_KEY_GRAVE_ACCENT},
231231
//[192 / 64 = "' @"]
232232
{keycode: 192, entry : 0x5b, browser: "IE"},
233-
{keycode: 64, entry : 0x5b, browser: "Firefox"},
233+
{keycode: 64, entry : 0x5b, guestos: "windows", browser: "Firefox"},
234234
//{keycode: JS_KEY_ADD, entry : X11_KEY_ADD},
235235
//[187 / 59 = "; +"]
236236
{keycode: 187, entry : 0x3a, browser: "IE"},
237-
{keycode: 59, entry : 0x3b, browser: "Firefox"},
237+
{keycode: 59, entry : 0x3b, guestos: "windows", browser: "Firefox"},
238238
//{keycode: JS_KEY_OPEN_BRACKET, entry : X11_KEY_OPEN_BRACKET},
239239
//[219 = "[{"]
240-
{keycode: 219, entry : 0x5d, browser: "IE"},
241-
{keycode: 219, entry : 0x5d, browser: "Firefox"},
240+
{keycode: 219, entry : 0x5d, guestos: "windows", browser: "IE"},
241+
{keycode: 219, entry : 0x5d, guestos: "windows", browser: "Firefox"},
242242
//{keycode: JS_KEY_CLOSE_BRACKET, entry : X11_KEY_CLOSE_BRACKET},
243243
//[221 = "]}"]
244-
{keycode: 221, entry : 0x5c, browser: "IE"},
245-
{keycode: 221, entry : 0x5c, browser: "Firefox"},
246-
{keycode: JS_KEY_BACK_SLASH, entry : X11_KEY_BACK_SLASH},
244+
{keycode: 221, entry : 0x5c, guestos: "windows", browser: "IE"},
245+
{keycode: 221, entry : 0x5c, guestos: "windows", browser: "Firefox"},
246+
{keycode: JS_KEY_BACK_SLASH, entry : X11_KEY_BACK_SLASH, guestos: "windows"},
247247
//{keycode: JS_KEY_SINGLE_QUOTE, entry : X11_KEY_SINGLE_QUOTE},
248248
//[222 / 160 = "~^"]
249-
{keycode: 222, entry : 0x3d, browser: "IE"},
250-
{keycode: 160, entry : 0x3d, browser: "Firefox"},
249+
{keycode: 222, entry : 0x3d, browser: "IE"},
250+
{keycode: 160, entry : 0x3d, guestos: "windows", browser: "Firefox"},
251251
//[173 = "-=" ] specific to Firefox browser
252-
{keycode: 173, entry : 0x2d, browser: "Firefox"},
253-
{keycode: JS_KEY_COMMA, entry : X11_KEY_COMMA},
254-
{keycode: JS_KEY_PERIOD, entry : X11_KEY_PERIOD},
255-
{keycode: JS_KEY_FORWARD_SLASH, entry : X11_KEY_FORWARD_SLASH},
252+
{keycode: 173, entry : 0x2d, guestos: "windows", browser: "Firefox"},
253+
{keycode: JS_KEY_COMMA, entry : X11_KEY_COMMA, guestos: "windows"},
254+
{keycode: JS_KEY_PERIOD, entry : X11_KEY_PERIOD, guestos: "windows"},
255+
{keycode: JS_KEY_FORWARD_SLASH, entry : X11_KEY_FORWARD_SLASH, guestos: "windows"},
256256
{keycode: JS_KEY_DASH, entry : X11_KEY_DASH},
257257
{keycode: JS_KEY_SEMI_COLON, entry : X11_KEY_SEMI_COLON},
258-
{keycode: JS_KEY_NUMPAD0, entry : X11_KEY_KP_0},
259-
{keycode: JS_KEY_NUMPAD1, entry : X11_KEY_KP_1},
260-
{keycode: JS_KEY_NUMPAD2, entry : X11_KEY_KP_2},
261-
{keycode: JS_KEY_NUMPAD3, entry : X11_KEY_KP_3},
262-
{keycode: JS_KEY_NUMPAD4, entry : X11_KEY_KP_4},
263-
{keycode: JS_KEY_NUMPAD5, entry : X11_KEY_KP_5},
264-
{keycode: JS_KEY_NUMPAD6, entry : X11_KEY_KP_6},
265-
{keycode: JS_KEY_NUMPAD7, entry : X11_KEY_KP_7},
266-
{keycode: JS_KEY_NUMPAD8, entry : X11_KEY_KP_8},
267-
{keycode: JS_KEY_NUMPAD9, entry : X11_KEY_KP_9},
268-
{keycode: JS_KEY_DECIMAL_POINT, entry : X11_KEY_KP_Decimal},
269-
{keycode: JS_KEY_DIVIDE, entry : 0xffaf},
270-
{keycode: JS_KEY_MULTIPLY, entry : 0xffaa},
271-
{keycode: JS_KEY_ADD, entry : 0xffab},
272-
{keycode: JS_KEY_SUBSTRACT, entry : 0xffad},
258+
{keycode: JS_KEY_NUMPAD0, entry : X11_KEY_NUMPAD0, guestos: "windows"},
259+
{keycode: JS_KEY_NUMPAD1, entry : X11_KEY_NUMPAD1, guestos: "windows"},
260+
{keycode: JS_KEY_NUMPAD2, entry : X11_KEY_NUMPAD2, guestos: "windows"},
261+
{keycode: JS_KEY_NUMPAD3, entry : X11_KEY_NUMPAD3, guestos: "windows"},
262+
{keycode: JS_KEY_NUMPAD4, entry : X11_KEY_NUMPAD4, guestos: "windows"},
263+
{keycode: JS_KEY_NUMPAD5, entry : X11_KEY_NUMPAD5, guestos: "windows"},
264+
{keycode: JS_KEY_NUMPAD6, entry : X11_KEY_NUMPAD6, guestos: "windows"},
265+
{keycode: JS_KEY_NUMPAD7, entry : X11_KEY_NUMPAD7, guestos: "windows"},
266+
{keycode: JS_KEY_NUMPAD8, entry : X11_KEY_NUMPAD8, guestos: "windows"},
267+
{keycode: JS_KEY_NUMPAD9, entry : X11_KEY_NUMPAD9, guestos: "windows"},
268+
{keycode: JS_KEY_DECIMAL_POINT, entry : X11_KEY_PERIOD, guestos: "windows"},
269+
{keycode: JS_KEY_DIVIDE, entry : 0xffaf, guestos: "windows"},
270+
{keycode: JS_KEY_MULTIPLY, entry : 0xffaa, guestos: "windows"},
271+
{keycode: JS_KEY_ADD, entry : 0xffab, guestos: "windows"},
272+
{keycode: JS_KEY_SUBSTRACT, entry : 0xffad, guestos: "windows"},
273273
//Kanji Key = 243 / 244
274274
{keycode: 243, entry : 0x7e, browser: "IE"},
275275
{keycode: 244, entry : 0x7e, browser: "IE"},
@@ -286,14 +286,66 @@ var keyboardTables = [
286286
*/
287287
//[186 / 58 = "~^"]
288288
{keycode: 186, entry : 0x22, browser: "IE"},
289-
{keycode: 58, entry : 0x22, browser: "Firefox"},
289+
{keycode: 58, entry : 0x22, guestos: "windows", browser: "Firefox"},
290290
],
291291
keyPress: [
292-
{keycode: 61, entry: [
293-
{type: KEY_DOWN, code: X11_KEY_ADD, modifiers: 0, shift: false },
294-
{type: KEY_UP, code: X11_KEY_ADD, modifiers: 0, shift: false }
295-
]},
296-
]
292+
// 34 : " " "
293+
{keycode: 34, entry: [{type: KEY_DOWN, code: 0x22, modifiers: 64, shift: true }]},
294+
{keycode: 42, entry: 0xffaa },
295+
// 39 : " ' " (shift+7)
296+
{keycode: 39, entry: [
297+
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
298+
{type: KEY_DOWN, code: 0x22, modifiers: 0, shift: false },
299+
{type: KEY_UP, code: 0x22, modifiers: 0, shift: false },
300+
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
301+
{type: KEY_DOWN, code: 0x22, modifiers: 0, shift: true },
302+
{type: KEY_UP, code: 0x22, modifiers: 0, shift: true },
303+
]}, //58 : " : "
304+
{keycode: 58, entry: [
305+
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
306+
{type: KEY_DOWN, code: 0x3a, modifiers: 0, shift: false },
307+
{type: KEY_UP, code: 0x3a, modifiers: 0, shift: false },
308+
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
309+
{type: KEY_DOWN, code: 0x3a, modifiers: 0, shift: true },
310+
{type: KEY_UP, code: 0x3a, modifiers: 0, shift: true },
311+
]},
312+
// 94 : "^"
313+
{keycode: 94, entry: [
314+
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
315+
{type: KEY_DOWN, code: 0x36, modifiers: 0, shift: false },
316+
{type: KEY_UP, code: 0x36, modifiers: 0, shift: false },
317+
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
318+
{type: KEY_DOWN, code: 0x36, modifiers: 0, shift: true },
319+
{type: KEY_UP, code: 0x36, modifiers: 0, shift: true },
320+
]},
321+
// 64 : "@"
322+
{keycode: 64, entry: [
323+
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
324+
{type: KEY_DOWN, code: 0x32, modifiers: 0, shift: false },
325+
{type: KEY_UP, code: 0x32, modifiers: 0, shift: false },
326+
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
327+
{type: KEY_DOWN, code: 0x32, modifiers: 0, shift: true },
328+
{type: KEY_UP, code: 0x32, modifiers: 0, shift: true },
329+
]},
330+
// 96 : "'"
331+
{keycode: 96, entry: [
332+
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
333+
{type: KEY_DOWN, code: 0x7e, modifiers: 0, shift: false },
334+
{type: KEY_UP, code: 0x7e, modifiers: 0, shift: false },
335+
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
336+
{type: KEY_DOWN, code: 0x7e, modifiers: 0, shift: true },
337+
{type: KEY_UP, code: 0x7e, modifiers: 0, shift: true },
338+
]},
339+
// 61 : "="
340+
{keycode: 61, entry: [
341+
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
342+
{type: KEY_DOWN, code: 0x3d, modifiers: 0, shift: false },
343+
{type: KEY_UP, code: 0x3d, modifiers: 0, shift: false },
344+
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
345+
{type: KEY_DOWN, code: 0x3d, modifiers: 0, shift: true },
346+
{type: KEY_UP, code: 0x3d, modifiers: 0, shift: true },
347+
]},
348+
]
297349
}
298350
}, {tindex: 2, keyboardType: KEYBOARD_TYPE_UK, mappingTable:
299351
{X11: [

systemvm/js/ajaxviewer.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ KeyboardMapper.prototype = {
161161
}
162162

163163
var X11Keysym = code;
164-
if(this.jsX11KeysymMap[code] != undefined) {
164+
if(this.jsX11KeysymMap[code] != undefined && (guestos == 'windows' || modifiers != AjaxViewer.SHIFT_KEY_MASK)) {
165165
X11Keysym = this.jsX11KeysymMap[code];
166166
if(typeof this.jsX11KeysymMap[code] == "boolean") {
167167
return;
@@ -175,15 +175,15 @@ KeyboardMapper.prototype = {
175175
} else {
176176
this.mappedInput.push({type : eventType, code: X11Keysym, modifiers: modifiers});
177177
}
178-
} else {
178+
} else if(guestos == 'windows' || ((modifiers & (AjaxViewer.CTRL_KEY_MASK | AjaxViewer.ALT_KEY_MASK)) != 0)){
179179
this.mappedInput.push({type : eventType, code: X11Keysym, modifiers: modifiers});
180180
}
181181

182182
// special handling for ALT/CTRL key
183-
if(eventType == AjaxViewer.KEY_UP && (code == AjaxViewer.JS_KEY_ALT || code == code == AjaxViewer.JS_KEY_CTRL))
183+
if(eventType == AjaxViewer.KEY_UP && (code == AjaxViewer.JS_KEY_ALT || code == AjaxViewer.JS_KEY_CTRL))
184184
this.mappedInput.push({type : eventType, code: this.jsX11KeysymMap[code], modifiers: modifiers});
185185

186-
} else if(eventType == AjaxViewer.KEY_PRESS) {
186+
} else if(eventType == AjaxViewer.KEY_PRESS && guestos == 'null') {
187187
var X11Keysym = code;
188188
X11Keysym = this.jsKeyPressX11KeysymMap[code];
189189
if(X11Keysym) {
@@ -196,6 +196,9 @@ KeyboardMapper.prototype = {
196196
this.mappedInput.push({type : AjaxViewer.KEY_DOWN, code: X11Keysym, modifiers: modifiers});
197197
this.mappedInput.push({type : AjaxViewer.KEY_UP, code: X11Keysym, modifiers: modifiers});
198198
}
199+
} else {
200+
this.mappedInput.push({type : AjaxViewer.KEY_DOWN, code: code, modifiers: modifiers});
201+
this.mappedInput.push({type : AjaxViewer.KEY_UP, code: code, modifiers: modifiers});
199202
}
200203
}
201204
},
@@ -332,7 +335,7 @@ KeyboardMapper.prototype = {
332335
/////////////////////////////////////////////////////////////////////////////
333336
// class AjaxViewer
334337
//
335-
function AjaxViewer(panelId, imageUrl, updateUrl, locale, tileMap, width, height, tileWidth, tileHeight) {
338+
function AjaxViewer(panelId, imageUrl, updateUrl, locale, guestos, tileMap, width, height, tileWidth, tileHeight) {
336339
// logging is disabled by default so that it won't have negative impact on performance
337340
// however, a back door key-sequence can trigger to open the logger window, it is designed to help
338341
// trouble-shooting
@@ -352,6 +355,7 @@ function AjaxViewer(panelId, imageUrl, updateUrl, locale, tileMap, width, height
352355

353356
this.updateUrl = updateUrl;
354357
this.tileMap = tileMap;
358+
this.guestos = guestos;
355359
this.dirty = true;
356360
this.width = width;
357361
this.height = height;
@@ -745,7 +749,9 @@ AjaxViewer.prototype = {
745749
for (var j = 0; j < x11Maps.length; j++) {
746750
var code = x11Maps[j].keycode;
747751
var mappedEntry = x11Maps[j].entry;
748-
this.keyboardMappers[keyboardType].jsX11KeysymMap[code] = mappedEntry;
752+
if(x11Maps[j].guestos == undefined || x11Maps[j].guestos == this.guestos) {
753+
this.keyboardMappers[keyboardType].jsX11KeysymMap[code] = mappedEntry;
754+
}
749755
}
750756
var keyPressMaps = mappings.keyPress;
751757
for (var j = 0; j < keyPressMaps.length; j++) {

0 commit comments

Comments
 (0)