mirror of https://github.com/apache/cloudstack.git
bug 10765: add japanese keyboard support for linux OSes
This commit is contained in:
parent
e231ea1ab2
commit
0421eafba0
|
|
@ -198,12 +198,14 @@ KeyboardMapper.prototype = {
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class AjaxViewer
|
||||
//
|
||||
function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWidth, tileHeight, rawKeyboard) {
|
||||
function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWidth, tileHeight, rawKeyboard, linuxGuest) {
|
||||
// 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
|
||||
g_logger = new Logger();
|
||||
g_logger.enable(false);
|
||||
g_logger.enable(true);
|
||||
g_logger.open();
|
||||
g_logger.log(Logger.LEVEL_INFO, 'rawKeyboard: ' + rawKeyboard);
|
||||
|
||||
var ajaxViewer = this;
|
||||
this.rawKeyboard = rawKeyboard;
|
||||
|
|
@ -226,6 +228,8 @@ function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWi
|
|||
|
||||
this.currentKeyboard = 0;
|
||||
this.keyboardMappers = [];
|
||||
|
||||
this.linuxGuest = linuxGuest;
|
||||
|
||||
this.timer = 0;
|
||||
this.eventQueue = [];
|
||||
|
|
@ -620,21 +624,110 @@ AjaxViewer.prototype = {
|
|||
var charCodeMap = [];
|
||||
var shiftedCharCodeMap = [];
|
||||
|
||||
keyCodeMap[106] = { code: 222, shift : 1 }; // JP NUM *
|
||||
charCodeMap[42] = { code: 34, shift : 1 };
|
||||
if(this.linuxGuest) {
|
||||
// for LINUX guest OSes
|
||||
|
||||
shiftedKeyCodeMap[50] = { code: 222, shift: 1 } ; // JP SHIFT + 2 -> "
|
||||
shiftedCharCodeMap[64] = { code: 34, shift: 1 };
|
||||
|
||||
shiftedKeyCodeMap[54] = { code: 55, shift : 1 }; // JP SHIFT + 6 -> &
|
||||
shiftedCharCodeMap[94] = { code: 38, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[55] = { code: 222, shift : 0 }; // JP SHIFT + 7 -> '
|
||||
shiftedCharCodeMap[38] = { code: 39, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[56] = { code: 57, shift : 1 }; // JP SHIFT + 8 -> (
|
||||
shiftedCharCodeMap[42] = { code: 40, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[57] = { code: 48, shift : 1 }; // JP SHIFT + 9 -> )
|
||||
shiftedCharCodeMap[40] = { code: 41, shift : 1 };
|
||||
|
||||
keyCodeMap[107] = { code: 59, shift : 1 }; // JP NUM +
|
||||
charCodeMap[43] = { code: 42, shift : 1 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
shiftedKeyCodeMap[48] = { code: 192, shift : 1 }; // JP SHIFT + 0 -> ~
|
||||
shiftedCharCodeMap[41] = { code: 126, shift : 1 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
|
||||
shiftedKeyCodeMap[109] = { code: 107, shift : 1 }; // JP SHIFT + (-=), keycode/charcode(109, 95) from Firefox
|
||||
shiftedCharCodeMap[95] = { code: 61, shift : 0 };
|
||||
|
||||
shiftedKeyCodeMap[189] = { code: 107, shift : 1 }; // JP SHIFT + (-=), keycode/charcode(109, 95) from Chrome/Safari/MSIE
|
||||
shiftedCharCodeMap[95] = { code: 61, shift : 0 };
|
||||
|
||||
shiftedKeyCodeMap[222] = { code: 192, shift : 1 }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[126] = { code: 126, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
keyCodeMap[107] = { code: 107, shift : 1, defer : true }; // JP NUM +, keycode/charcode (107, 43) from Firefox
|
||||
charCodeMap[43] = { code: 43, shift : 1, keyCode: 43 };
|
||||
charCodeMap[61] = { code: 94, shift : 0, keyCode: 94 }; // JP (~^), keycode/charcode (107, 61) from Firefox
|
||||
|
||||
shiftedKeyCodeMap[107] = { code: 192, shift : 1 }; // JP SHIFT + (!^)
|
||||
shiftedCharCodeMap[43] = { code: 126, shift : 1 };
|
||||
} else {
|
||||
keyCodeMap[187] = { code: 54, shift: 1, defer: true }; // JP ~^
|
||||
charCodeMap[61] = { code: 94, shift: 0, keyCode: 94 };
|
||||
|
||||
shiftedKeyCodeMap[187] = { code: 192, shift : 1 }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[43] = { code: 126, shift : 1 };
|
||||
|
||||
keyCodeMap[107] = { code: 107, shift : 0, defer: true }; // JP NUM +, keycode/charcode(107, 43)
|
||||
charCodeMap[43] = { code: 43, shift : 1, keyCode: 43 };
|
||||
}
|
||||
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift : 1, charCode: 124 }; // JP (|-, key before backspace), Japanese Yen mark
|
||||
|
||||
keyCodeMap[219] = { code: 192, shift : 0 }; // JP @`
|
||||
charCodeMap[91] = { code: 96, shift : 0 };
|
||||
shiftedKeyCodeMap[219] = { code: 50, shift : 1 }; // JP SHIFT + (@`)
|
||||
shiftedCharCodeMap[123] = { code: 64, shift : 1 };
|
||||
|
||||
keyCodeMap[221] = { code: 219, shift : 0 }; // JP [{
|
||||
charCodeMap[93] = { code: 91, shift : 0 };
|
||||
shiftedKeyCodeMap[221] = { code: 219, shift : 1 };
|
||||
shiftedCharCodeMap[125] = { code: 123, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
shiftedKeyCodeMap[59] = { code: 107, shift : 1, defer: true }; // JP ;+
|
||||
shiftedCharCodeMap[58] = { code: 43, shift : 1, keyCode: 43 };
|
||||
} else {
|
||||
shiftedKeyCodeMap[186] = { code: 107, shift : 1, defer: true }; // JP ;+
|
||||
shiftedCharCodeMap[58] = { code: 43, shift : 1, keyCode: 43 };
|
||||
}
|
||||
|
||||
keyCodeMap[222] = { code: 59, shift : 0, defer : true }; // JP :*
|
||||
charCodeMap[39] = { code: 59, shift : 0, keyCode: 58 };
|
||||
shiftedKeyCodeMap[222] = { code: 56, shift : 1 };
|
||||
shiftedCharCodeMap[34] = { code: 42, shift : 1 };
|
||||
|
||||
keyCodeMap[220] = { code: 221, shift : 0 }; // JP ]}
|
||||
charCodeMap[92] = { code: 93, shift : 0 };
|
||||
shiftedKeyCodeMap[220] = { code: 221, shift : 1 };
|
||||
shiftedCharCodeMap[124] = { code: 125, shift : 1 };
|
||||
|
||||
keyCodeMap[106] = { code: 222, shift : 1, defer: true }; // JP NUM *
|
||||
charCodeMap[42] = { code: 42, shift : 1, keyCode: 42 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
|
||||
} else {
|
||||
// for windows guest OSes
|
||||
keyCodeMap[106] = { code: 222, shift : 1 }; // JP NUM *
|
||||
charCodeMap[42] = { code: 34, shift : 1 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
}
|
||||
this.keyboardMappers[AjaxViewer.KEYBOARD_TYPE_JAPAN_EN_OS_TO_JP_VM] = new KeyboardMapper(false, keyCodeMap, shiftedKeyCodeMap,
|
||||
charCodeMap, shiftedCharCodeMap);
|
||||
},
|
||||
|
|
@ -645,76 +738,136 @@ AjaxViewer.prototype = {
|
|||
var charCodeMap = [];
|
||||
var shiftedCharCodeMap = [];
|
||||
|
||||
shiftedKeyCodeMap[50] = { code: 50, shift: 1, defer: true }; // JP SHIFT + 2 -> "
|
||||
shiftedCharCodeMap[34] = { code: 0, shift : 1, keyCode: 50 };
|
||||
|
||||
shiftedKeyCodeMap[55] = { code: 222, shift : 0, defer:true }; // JP SHIFT + 7 -> '
|
||||
shiftedCharCodeMap[39] = { code: 0, shift : 1, keyCode: 55 };
|
||||
|
||||
keyCodeMap[222] = { code: 107, shift: 0 }; // JP ~^
|
||||
charCodeMap[94] = { code: 59, shift: 0 };
|
||||
|
||||
shiftedKeyCodeMap[222] = { code: 107, shift : 1 }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[126] = { code: 43, shift : 1 };
|
||||
|
||||
keyCodeMap[192] = { code: 219, shift : 0 }; // JP @`
|
||||
charCodeMap[64] = { code: 91, shift : 0 };
|
||||
shiftedKeyCodeMap[192] = { code: 219, shift : 1 }; // JP SHIFT + (@`)
|
||||
shiftedCharCodeMap[96] = { code: 123, shift : 1 };
|
||||
|
||||
keyCodeMap[219] = { code: 221, shift : 0 }; // JP [{
|
||||
charCodeMap[91] = { code: 93, shift : 0 };
|
||||
shiftedKeyCodeMap[219] = { code: 221, shift : 1 };
|
||||
shiftedCharCodeMap[123] = { code: 125, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
// Note, keycode 107 is duplicated with "+" key at NUM pad
|
||||
keyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[107] = { code: 59, shift : 1 };
|
||||
shiftedCharCodeMap[43] = { code: 42, shift : 1 };
|
||||
|
||||
// keyCodeMap[107] = { code: 59, shift : 1 }; // JP NUM +
|
||||
charCodeMap[43] = { code: 42, shift : 1, keyCode: 59 };
|
||||
} else {
|
||||
keyCodeMap[187] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[187] = { code: 59, shift : 1 };
|
||||
shiftedCharCodeMap[43] = { code: 42, shift : 1 };
|
||||
|
||||
keyCodeMap[107] = { code: 59, shift : 1 }; // JP NUM +
|
||||
charCodeMap[43] = { code: 42, shift : 1 };
|
||||
}
|
||||
|
||||
if($.browser.mozilla) {
|
||||
keyCodeMap[59] = { code: 222, shift : 0 }; // JP :*
|
||||
charCodeMap[58] = { code: 39, shift : 0 };
|
||||
shiftedKeyCodeMap[59] = { code: 222, shift : 1 };
|
||||
shiftedCharCodeMap[42] = { code: 34, shift : 1 };
|
||||
} else {
|
||||
keyCodeMap[186] = { code: 222, shift : 0 }; // JP :*
|
||||
charCodeMap[58] = { code: 39, shift : 0 };
|
||||
shiftedKeyCodeMap[186] = { code: 222, shift : 1 };
|
||||
shiftedCharCodeMap[42] = { code: 34, shift : 1 };
|
||||
}
|
||||
|
||||
keyCodeMap[221] = { code: 220, shift : 0 }; // JP ]}
|
||||
charCodeMap[93] = { code: 92, shift : 0 };
|
||||
shiftedKeyCodeMap[221] = { code: 220, shift : 1 };
|
||||
shiftedCharCodeMap[125] = { code: 124, shift : 1 };
|
||||
|
||||
keyCodeMap[106] = { code: 222, shift : 1 }; // JP NUM *
|
||||
charCodeMap[42] = { code: 34, shift : 1 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
if(this.linuxGuest) {
|
||||
shiftedKeyCodeMap[50] = { code: 50, shift: 1, defer: true }; // JP SHIFT + 2 -> "
|
||||
shiftedCharCodeMap[34] = { code: 34, shift : 1, keyCode: 34 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
shiftedKeyCodeMap[54] = { code: 55, shift : 1 }; // JP SHIFT + 6 -> &
|
||||
shiftedCharCodeMap[94] = { code: 38, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[55] = { code: 222, shift : 0, defer:true }; // JP SHIFT + 7 -> '
|
||||
shiftedCharCodeMap[39] = { code: 39, shift : 1, keyCode: 39 };
|
||||
|
||||
shiftedKeyCodeMap[56] = { code: 57, shift : 1 }; // JP SHIFT + 8 -> (
|
||||
shiftedCharCodeMap[42] = { code: 40, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[57] = { code: 48, shift : 1 }; // JP SHIFT + 9 -> )
|
||||
shiftedCharCodeMap[40] = { code: 41, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[48] = { code: 192, shift : 1 }; // JP SHIFT + 0 -> ~
|
||||
shiftedCharCodeMap[41] = { code: 126, shift : 1 };
|
||||
|
||||
keyCodeMap[222] = { code: 107, shift: 0, defer: true }; // JP ~^
|
||||
charCodeMap[94] = { code: 94, shift: 0, keyCode: 94 };
|
||||
shiftedKeyCodeMap[222] = { code: 192, shift : 1, defer: true }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[126] = { code: 126, shift : 1 };
|
||||
|
||||
shiftedKeyCodeMap[192] = { code: 50, shift : 1 }; // JP SHIFT + (@`)
|
||||
shiftedCharCodeMap[96] = { code: 64, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
shiftedKeyCodeMap[109] = { code: 107, shift : 1 }; // JP SHIFT + (-=), keycode/charcode(109, 95) from Firefox
|
||||
|
||||
// Note, keycode 107 is duplicated with "+" key at NUM pad
|
||||
keyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
charCodeMap[43] = { code: 43, shift : 1, keyCode: 43 }; // JP NUM +
|
||||
|
||||
shiftedKeyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
shiftedCharCodeMap[43] = { code: 43, shift : 1, keyCode: 43 };
|
||||
|
||||
keyCodeMap[59] = { code: 59, shift : 0, defer : true }; // JP :*
|
||||
charCodeMap[58] = { code: 58, shift : 0, keyCode: 58 };
|
||||
} else {
|
||||
shiftedKeyCodeMap[189] = { code: 107, shift : 1 }; // JP SHIFT + (-=), keycode/charcode(109, 95) from Chrome/Safari/MSIE
|
||||
shiftedCharCodeMap[95] = { code: 61, shift : 0 };
|
||||
|
||||
keyCodeMap[187] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[187] = { code: 59, shift : 1, defer: true };
|
||||
shiftedCharCodeMap[43] = { code: 43, shift : 1, keyCode: 43 };
|
||||
|
||||
keyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP NUM +
|
||||
charCodeMap[43] = { code: 43, shift : 1, keyCode: 43};
|
||||
|
||||
keyCodeMap[186] = { code: 59, shift : 0, defer: true }; // JP :*
|
||||
charCodeMap[58] = { code: 58, shift : 0, keyCode: 58 };
|
||||
}
|
||||
|
||||
keyCodeMap[226] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[226] = { code: 189, shift: 1 };
|
||||
|
||||
} else {
|
||||
// windows guest
|
||||
shiftedKeyCodeMap[50] = { code: 50, shift: 1, defer: true }; // JP SHIFT + 2 -> "
|
||||
shiftedCharCodeMap[34] = { code: 0, shift : 1, keyCode: 50 };
|
||||
|
||||
shiftedKeyCodeMap[55] = { code: 222, shift : 0, defer:true }; // JP SHIFT + 7 -> '
|
||||
shiftedCharCodeMap[39] = { code: 0, shift : 1, keyCode: 55 };
|
||||
|
||||
keyCodeMap[222] = { code: 107, shift: 0 }; // JP ~^
|
||||
charCodeMap[94] = { code: 59, shift: 0 };
|
||||
|
||||
shiftedKeyCodeMap[222] = { code: 107, shift : 1 }; // JP SHIFT + (~^)
|
||||
shiftedCharCodeMap[126] = { code: 43, shift : 1 };
|
||||
|
||||
keyCodeMap[192] = { code: 219, shift : 0 }; // JP @`
|
||||
charCodeMap[64] = { code: 91, shift : 0 };
|
||||
shiftedKeyCodeMap[192] = { code: 219, shift : 1 }; // JP SHIFT + (@`)
|
||||
shiftedCharCodeMap[96] = { code: 123, shift : 1 };
|
||||
|
||||
keyCodeMap[219] = { code: 221, shift : 0 }; // JP [{
|
||||
charCodeMap[91] = { code: 93, shift : 0 };
|
||||
shiftedKeyCodeMap[219] = { code: 221, shift : 1 };
|
||||
shiftedCharCodeMap[123] = { code: 125, shift : 1 };
|
||||
|
||||
if($.browser.mozilla) {
|
||||
// Note, keycode 107 is duplicated with "+" key at NUM pad
|
||||
keyCodeMap[107] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[107] = { code: 59, shift : 0 };
|
||||
shiftedCharCodeMap[43] = { code: 42, shift : 0 };
|
||||
|
||||
charCodeMap[43] = { code: 42, shift : 1, keyCode: 59 };
|
||||
} else {
|
||||
keyCodeMap[187] = { code: 59, shift : 0, defer: true }; // JP ;+
|
||||
charCodeMap[59] = { code: 58, shift : 0, keyCode: 59 };
|
||||
shiftedKeyCodeMap[187] = { code: 59, shift : 1 };
|
||||
shiftedCharCodeMap[43] = { code: 42, shift : 1 };
|
||||
|
||||
keyCodeMap[107] = { code: 59, shift : 1 }; // JP NUM +
|
||||
charCodeMap[43] = { code: 42, shift : 1 };
|
||||
}
|
||||
|
||||
if($.browser.mozilla) {
|
||||
keyCodeMap[59] = { code: 222, shift : 0 }; // JP :*
|
||||
charCodeMap[58] = { code: 39, shift : 0 };
|
||||
shiftedKeyCodeMap[59] = { code: 222, shift : 1 };
|
||||
shiftedCharCodeMap[42] = { code: 34, shift : 1 };
|
||||
} else {
|
||||
keyCodeMap[186] = { code: 222, shift : 0 }; // JP :*
|
||||
charCodeMap[58] = { code: 39, shift : 0 };
|
||||
shiftedKeyCodeMap[186] = { code: 222, shift : 1 };
|
||||
shiftedCharCodeMap[42] = { code: 34, shift : 1 };
|
||||
}
|
||||
|
||||
keyCodeMap[221] = { code: 220, shift : 0 }; // JP ]}
|
||||
charCodeMap[93] = { code: 92, shift : 0 };
|
||||
shiftedKeyCodeMap[221] = { code: 220, shift : 1 };
|
||||
shiftedCharCodeMap[125] = { code: 124, shift : 1 };
|
||||
|
||||
keyCodeMap[106] = { code: 222, shift : 1 }; // JP NUM *
|
||||
charCodeMap[42] = { code: 34, shift : 1 };
|
||||
|
||||
keyCodeMap[110] = { code: 190, shift : 0 }; // JP NUM .
|
||||
charCodeMap[46] = { code: 46, shift : 0 };
|
||||
|
||||
keyCodeMap[193] = { code: 220, shift : 0, charCode: 92 }; // JP key left to right shift on JP keyboard
|
||||
shiftedKeyCodeMap[193] = { code: 189, shift: 1, charCode: 64 };
|
||||
|
||||
keyCodeMap[255] = { code: 220, shift : 0, charCode: 92 }; // JP Japanese Yen mark on JP keyboard
|
||||
shiftedKeyCodeMap[255] = { code: 220, shift: 1, charCode: 95 };
|
||||
}
|
||||
this.keyboardMappers[AjaxViewer.KEYBOARD_TYPE_JAPAN_JP_OS_TO_JP_VM] = new KeyboardMapper(false, keyCodeMap, shiftedKeyCodeMap,
|
||||
charCodeMap, shiftedCharCodeMap);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
|||
String tag = queryMap.get("tag");
|
||||
String ticket = queryMap.get("ticket");
|
||||
String ajaxSessionIdStr = queryMap.get("sess");
|
||||
String eventStr = queryMap.get("event");
|
||||
String eventStr = queryMap.get("event");
|
||||
|
||||
if(tag == null)
|
||||
tag = "";
|
||||
|
||||
|
|
@ -171,8 +172,9 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
|||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Ajax request indicates a fresh client start");
|
||||
|
||||
String title = queryMap.get("t");
|
||||
handleClientStart(t, viewer, title != null ? title : "");
|
||||
String title = queryMap.get("t");
|
||||
String guest = queryMap.get("guest");
|
||||
handleClientStart(t, viewer, title != null ? title : "", guest);
|
||||
} else {
|
||||
|
||||
if(s_logger.isTraceEnabled())
|
||||
|
|
@ -392,9 +394,9 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleClientStart(HttpExchange t, ConsoleProxyViewer viewer, String title) throws IOException {
|
||||
private void handleClientStart(HttpExchange t, ConsoleProxyViewer viewer, String title, String guest) throws IOException {
|
||||
List<String> languages = t.getRequestHeaders().get("Accept-Language");
|
||||
String response = viewer.onAjaxClientStart(title, languages);
|
||||
String response = viewer.onAjaxClientStart(title, languages, guest);
|
||||
|
||||
Headers hds = t.getResponseHeaders();
|
||||
hds.set("Content-Type", "text/html");
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ public class ConsoleProxyAjaxKeyMapper {
|
|||
js2javaCodeMap.put(new Integer(18), new Integer(0xffe9));
|
||||
|
||||
// for SHIFT transaction at proxy side
|
||||
shiftedKeyCharMap = new HashMap<Integer, Integer>();
|
||||
shiftedKeyCharMap = new HashMap<Integer, Integer>();
|
||||
shiftedKeyCharMap.put(new Integer('1'), new Integer('!'));
|
||||
shiftedKeyCharMap.put(new Integer('2'), new Integer('@'));
|
||||
shiftedKeyCharMap.put(new Integer('3'), new Integer('#'));
|
||||
|
|
@ -190,7 +190,7 @@ public class ConsoleProxyAjaxKeyMapper {
|
|||
shiftedKeyCharMap.put(new Integer('9'), new Integer('('));
|
||||
shiftedKeyCharMap.put(new Integer('0'), new Integer(')'));
|
||||
shiftedKeyCharMap.put(new Integer('-'), new Integer('_'));
|
||||
shiftedKeyCharMap.put(new Integer('='), new Integer('+'));
|
||||
//shiftedKeyCharMap.put(new Integer('='), new Integer('+'));
|
||||
shiftedKeyCharMap.put(new Integer('`'), new Integer('~'));
|
||||
shiftedKeyCharMap.put(new Integer('['), new Integer('{'));
|
||||
shiftedKeyCharMap.put(new Integer(']'), new Integer('}'));
|
||||
|
|
@ -239,7 +239,7 @@ public class ConsoleProxyAjaxKeyMapper {
|
|||
return vkCode.intValue();
|
||||
}
|
||||
|
||||
public int getJvmKeyCode(int jsKeyCode) {
|
||||
public int getJvmKeyCode(int jsKeyCode) {
|
||||
Integer code = js2javaCodeMap.get(jsKeyCode);
|
||||
if(code != null)
|
||||
return code.intValue();
|
||||
|
|
|
|||
|
|
@ -924,7 +924,7 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
"</p></div></body></html>";
|
||||
}
|
||||
|
||||
public String onAjaxClientStart(String title, List<String> languages) {
|
||||
public String onAjaxClientStart(String title, List<String> languages, String guest) {
|
||||
if(!waitForViewerReady())
|
||||
return onAjaxClientConnectFailed();
|
||||
|
||||
|
|
@ -1005,11 +1005,11 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
*/
|
||||
return getAjaxViewerPageContent(sbTileSequence.toString(), imgUrl,
|
||||
updateUrl, width, height, tileWidth, tileHeight, title,
|
||||
ConsoleProxy.keyboardType == ConsoleProxy.KEYBOARD_RAW, languages);
|
||||
ConsoleProxy.keyboardType == ConsoleProxy.KEYBOARD_RAW, languages, guest);
|
||||
}
|
||||
|
||||
private String getAjaxViewerPageContent(String tileSequence, String imgUrl, String updateUrl, int width,
|
||||
int height, int tileWidth, int tileHeight, String title, boolean rawKeyboard, List<String> languages) {
|
||||
int height, int tileWidth, int tileHeight, String title, boolean rawKeyboard, List<String> languages, String guest) {
|
||||
|
||||
StringBuffer sbLanguages = new StringBuffer("");
|
||||
if(languages != null) {
|
||||
|
|
@ -1020,6 +1020,10 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
sbLanguages.append(lang);
|
||||
}
|
||||
}
|
||||
|
||||
boolean linuxGuest = true;
|
||||
if(guest != null && guest.equalsIgnoreCase("windows"))
|
||||
linuxGuest = false;
|
||||
|
||||
String[] content = new String[] {
|
||||
"<html>",
|
||||
|
|
@ -1066,7 +1070,8 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
"var acceptLanguages = '" + sbLanguages.toString() + "';",
|
||||
"var tileMap = [ " + tileSequence + " ];",
|
||||
"var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', tileMap, ",
|
||||
String.valueOf(width) + ", " + String.valueOf(height) + ", " + String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight) + ", " + (rawKeyboard ? "true" : "false") + ");",
|
||||
String.valueOf(width) + ", " + String.valueOf(height) + ", " + String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight)
|
||||
+ ", " + (rawKeyboard ? "true" : "false") + ", " + (linuxGuest ? "true" : "false") + ");",
|
||||
|
||||
"$(function() {",
|
||||
"ajaxViewer.start();",
|
||||
|
|
@ -1276,13 +1281,13 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendClientRawKeyboardEvent(int event, int code, int modifiers) {
|
||||
code = ConsoleProxyAjaxKeyMapper.getInstance().getJvmKeyCode(code);
|
||||
switch(event) {
|
||||
case 4 : // Key press
|
||||
//
|
||||
// special handling for ' and " (keycode: 222, char code : 39 and 34
|
||||
// special handling for ' and " (keycode: 222, char code : 39 and 34)
|
||||
//
|
||||
if(code == 39 || code == 34) {
|
||||
writeKeyboardEvent(KeyEvent.KEY_PRESSED, 222, (char)code, getAwtModifiers(modifiers));
|
||||
|
|
@ -1307,8 +1312,33 @@ public class ConsoleProxyViewer implements java.lang.Runnable, RfbViewer, RfbPro
|
|||
getAwtModifiers(modifiers));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public void sendClientRawKeyboardEvent(int event, int code, int modifiers) {
|
||||
// code = ConsoleProxyAjaxKeyMapper.getInstance().getJvmKeyCode(code);
|
||||
switch(event) {
|
||||
case 4 : // Key press
|
||||
break;
|
||||
|
||||
case 5 : // Key down
|
||||
if((modifiers & ConsoleProxyViewer.CTRL_KEY_MASK) != 0 && (modifiers & ConsoleProxyViewer.ALT_KEY_MASK) != 0 && code == KeyEvent.VK_INSERT) {
|
||||
code = KeyEvent.VK_DELETE;
|
||||
}
|
||||
|
||||
writeKeyboardEvent(KeyEvent.KEY_PRESSED, code,
|
||||
(char)code,
|
||||
getAwtModifiers(modifiers));
|
||||
break;
|
||||
|
||||
case 6 : // Key Up
|
||||
writeKeyboardEvent(KeyEvent.KEY_RELEASED, code,
|
||||
(char)code,
|
||||
getAwtModifiers(modifiers));
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
public void sendClientKeyboardEvent(int event, int code, int modifiers) {
|
||||
int vkCode;
|
||||
switch(event) {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
|
|
@ -324,6 +325,12 @@ public class ConsoleProxyServlet extends HttpServlet {
|
|||
sb.append("&tag=").append(tag);
|
||||
sb.append("&ticket=").append(ticket);
|
||||
|
||||
// for console access, we need guest OS type to help implement keyboard
|
||||
long guestOs = vm.getGuestOSId();
|
||||
GuestOSVO guestOsVo = _ms.getGuestOs(guestOs);
|
||||
if(guestOsVo.getCategoryId() == 6)
|
||||
sb.append("&guest=windows");
|
||||
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Compose console url: " + sb.toString());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue