Skip to content

Commit b6cb23c

Browse files
sanjaytripathiLikitha Shetty
authored andcommitted
CLOUDSTACK-957: Localization -- Add UK keyboard support.
1 parent 3a41a83 commit b6cb23c

4 files changed

Lines changed: 295 additions & 135 deletions

File tree

services/console-proxy/server/css/ajaxviewer.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ body {
9191
position: absolute;
9292
top:32;
9393
width: 260;
94-
height: 65;
94+
height: 95;
9595
display: block;
9696
display: none;
9797
border-top: 1px solid black;
98-
background-image:url(/resource/images/back.gif);
99-
background-repeat:repeat-x repeat-y;
98+
background-image:url(/resource/images/back.gif);
99+
background-repeat:repeat-x repeat-y;
100100
}
101101

102102
#toolbar ul li ul li {

services/console-proxy/server/js/ajaxkeys.js

Lines changed: 263 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,55 +23,286 @@ under the License.
2323
* They are used by the ajaxviewer.js
2424
*/
2525

26-
//client event type. corresponds to events in ajaxviewer.
27-
X11_KEY_CIRCUMFLEX_ACCENT = 0x5e; // ^
28-
X11_KEY_YEN_MARK = 0xa5;
26+
//client event type. corresponds to events in ajaxviewer.
27+
28+
29+
//use java AWT key modifier masks
30+
JS_KEY_BACKSPACE = 8;
31+
JS_KEY_TAB = 9;
32+
JS_KEY_ENTER = 13;
33+
JS_KEY_SHIFT = 16;
34+
JS_KEY_CTRL = 17;
35+
JS_KEY_ALT = 18;
36+
JS_KEY_CAPSLOCK = 20;
37+
JS_KEY_ESCAPE = 27;
38+
JS_KEY_PAGEUP = 33;
39+
JS_KEY_PAGEDOWN = 34;
40+
JS_KEY_END = 35;
41+
JS_KEY_HOME = 36;
42+
JS_KEY_LEFT = 37;
43+
JS_KEY_UP = 38;
44+
JS_KEY_RIGHT = 39;
45+
JS_KEY_DOWN = 40;
46+
JS_KEY_INSERT = 45;
47+
JS_KEY_DELETE = 46;
48+
JS_KEY_SELECT_KEY = 93;
49+
JS_KEY_NUMPAD0 = 96;
50+
JS_KEY_NUMPAD1 = 97;
51+
JS_KEY_NUMPAD2 = 98;
52+
JS_KEY_NUMPAD3 = 99;
53+
JS_KEY_NUMPAD4 = 100;
54+
JS_KEY_NUMPAD5 = 101;
55+
JS_KEY_NUMPAD6 = 102;
56+
JS_KEY_NUMPAD7 = 103;
57+
JS_KEY_NUMPAD8 = 104;
58+
JS_KEY_NUMPAD9 = 105;
59+
JS_KEY_MULTIPLY = 106;
60+
JS_KEY_ADD = 107;
61+
JS_KEY_SUBSTRACT = 109;
62+
JS_KEY_DECIMAL_POINT = 110;
63+
JS_KEY_DIVIDE = 111;
64+
JS_KEY_F1 = 112;
65+
JS_KEY_F2 = 113;
66+
JS_KEY_F3 = 114;
67+
JS_KEY_F4 = 115;
68+
JS_KEY_F5 = 116;
69+
JS_KEY_F6 = 117;
70+
JS_KEY_F7 = 118;
71+
JS_KEY_F8 = 119;
72+
JS_KEY_F9 = 120;
73+
JS_KEY_F10 = 121;
74+
JS_KEY_F11 = 122;
75+
JS_KEY_F12 = 123;
76+
JS_KEY_SEMI_COLON = 186; // ;
77+
JS_KEY_COMMA = 188; // ,
78+
JS_KEY_DASH = 189; // -
79+
JS_KEY_PERIOD = 190; // .
80+
JS_KEY_FORWARD_SLASH = 191; // /
81+
JS_KEY_GRAVE_ACCENT = 192; // `
82+
JS_KEY_OPEN_BRACKET = 219; // [
83+
JS_KEY_BACK_SLASH = 220; // \
84+
JS_KEY_CLOSE_BRACKET = 221; // ]
85+
JS_KEY_SINGLE_QUOTE = 222; // '
86+
87+
88+
//X11 keysym definitions
89+
X11_KEY_CAPSLOCK = 0xffe5;
90+
X11_KEY_BACKSPACE = 0xff08;
91+
X11_KEY_TAB = 0xff09;
92+
X11_KEY_ENTER = 0xff0d;
93+
X11_KEY_ESCAPE = 0xff1b;
94+
X11_KEY_INSERT = 0xff63;
95+
X11_KEY_DELETE = 0xffff;
96+
X11_KEY_HOME = 0xff50;
97+
X11_KEY_END = 0xff57;
98+
X11_KEY_PAGEUP = 0xff55;
99+
X11_KEY_PAGEDOWN = 0xff56;
100+
X11_KEY_LEFT = 0xff51;
101+
X11_KEY_UP = 0xff52;
102+
X11_KEY_RIGHT = 0xff53;
103+
X11_KEY_DOWN = 0xff54;
104+
X11_KEY_F1 = 0xffbe;
105+
X11_KEY_F2 = 0xffbf;
106+
X11_KEY_F3 = 0xffc0;
107+
X11_KEY_F4 = 0xffc1;
108+
X11_KEY_F5 = 0xffc2;
109+
X11_KEY_F6 = 0xffc3;
110+
X11_KEY_F7 = 0xffc4;
111+
X11_KEY_F8 = 0xffc5;
112+
X11_KEY_F9 = 0xffc6;
113+
X11_KEY_F10 = 0xffc7;
114+
X11_KEY_F11 = 0xffc8;
115+
X11_KEY_F12 = 0xffc9;
116+
X11_KEY_SHIFT = 0xffe1;
117+
X11_KEY_CTRL = 0xffe3;
118+
X11_KEY_ALT = 0xffe9;
119+
X11_KEY_GRAVE_ACCENT = 0x60;
120+
X11_KEY_SUBSTRACT = 0x2d;
121+
X11_KEY_ADD = 0x2b;
29122
X11_KEY_OPEN_BRACKET = 0x5b;
30123
X11_KEY_CLOSE_BRACKET = 0x5d;
124+
X11_KEY_BACK_SLASH = 0x7c;
125+
X11_KEY_REVERSE_SOLIUS = 0x5c; // another back slash (back slash on JP keyboard)
126+
X11_KEY_SINGLE_QUOTE = 0x22;
127+
X11_KEY_COMMA = 0x3c;
128+
X11_KEY_PERIOD = 0x3e;
129+
X11_KEY_FORWARD_SLASH = 0x3f;
130+
X11_KEY_DASH = 0x2d;
31131
X11_KEY_COLON = 0x3a;
32-
X11_KEY_REVERSE_SOLIUS = 0x5c; // another back slash (back slash on JP keyboard)
33-
X11_KEY_CAPSLOCK = 0xffe5;
34132
X11_KEY_SEMI_COLON = 0x3b;
35-
X11_KEY_SHIFT = 0xffe1;
36-
X11_KEY_ADD = 0x2b;
133+
X11_KEY_NUMPAD0 = 0x30;
134+
X11_KEY_NUMPAD1 = 0x31;
135+
X11_KEY_NUMPAD2 = 0x32;
136+
X11_KEY_NUMPAD3 = 0x33;
137+
X11_KEY_NUMPAD4 = 0x34;
138+
X11_KEY_NUMPAD5 = 0x35;
139+
X11_KEY_NUMPAD6 = 0x36;
140+
X11_KEY_NUMPAD7 = 0x37;
141+
X11_KEY_NUMPAD8 = 0x38;
142+
X11_KEY_NUMPAD9 = 0x39;
143+
X11_KEY_DECIMAL_POINT = 0x2e;
144+
X11_KEY_DIVIDE = 0x3f;
145+
X11_KEY_TILDE = 0x7e; // ~
146+
X11_KEY_CIRCUMFLEX_ACCENT = 0x5e; // ^
147+
X11_KEY_YEN_MARK = 0xa5; // Japanese YEN mark
148+
X11_KEY_ASTERISK = 0x2a;
37149

38150
KEY_DOWN = 5;
39151
KEY_UP = 6;
40152

153+
KEYBOARD_TYPE_COOKED = "us";
154+
KEYBOARD_TYPE_JP = "jp";
155+
KEYBOARD_TYPE_UK = "uk";
156+
41157
//JP keyboard type
42-
//
158+
//
43159
var keyboardTables = [
44-
{tindex: 0, keyboardType: "EN-Cooked", mappingTable:
45-
{X11: [ {keycode: 222, entry: X11_KEY_CIRCUMFLEX_ACCENT},
160+
{tindex: 0, keyboardType: KEYBOARD_TYPE_COOKED, mappingTable:
161+
{X11: [ {keycode: 222, entry: X11_KEY_CIRCUMFLEX_ACCENT},
46162
{keycode: 220, entry: X11_KEY_YEN_MARK},
47-
{keycode: 219, entry: X11_KEY_OPEN_BRACKET},
48-
{keycode: 221, entry: X11_KEY_CLOSE_BRACKET},
49-
{keycode: 59, entry: X11_KEY_COLON, browser: "Firefox"},
50163
{keycode: 186, entry: X11_KEY_COLON, browser: "Chrome"},
51164
{keycode: 9, entry: 9, guestos: "XenServer"},
52165
{keycode: 226, entry: X11_KEY_REVERSE_SOLIUS},
166+
53167
{keycode: 240, entry: [
54168
{type: KEY_DOWN, code: X11_KEY_CAPSLOCK, modifiers: 0 },
55169
{type: KEY_UP, code: X11_KEY_CAPSLOCK, modifiers: 0 },
56170
]
171+
}
172+
],
173+
keyPress: [
174+
{keycode: 59, entry: [
175+
{type: KEY_DOWN, code: X11_KEY_SEMI_COLON, modifiers: 0 },
176+
{type: KEY_UP, code: X11_KEY_SEMI_COLON, modifiers: 0 },
177+
]
57178
},
58-
],
59-
keyPress: [
60-
{keycode: 59, entry: [
61-
{type: KEY_DOWN, code: X11_KEY_SEMI_COLON, modifiers: 0 },
62-
{type: KEY_UP, code: X11_KEY_SEMI_COLON, modifiers: 0 },
63-
]
64-
},
65-
{keycode: 43, entry: [
66-
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
67-
{type: KEY_DOWN, code: X11_KEY_ADD, modifiers: 0, shift: false },
68-
{type: KEY_UP, code: X11_KEY_ADD, modifiers: 0, shift: false },
69-
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
70-
{type: KEY_DOWN, code: X11_KEY_ADD, modifiers: 0, shift: true },
71-
{type: KEY_UP, code: X11_KEY_ADD, modifiers: 0, shift: true },
72-
]
73-
},
74-
]
75-
}
76-
} ]
179+
{keycode: 43, entry: [
180+
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
181+
{type: KEY_DOWN, code: X11_KEY_ADD, modifiers: 0, shift: false },
182+
{type: KEY_UP, code: X11_KEY_ADD, modifiers: 0, shift: false },
183+
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
184+
{type: KEY_DOWN, code: X11_KEY_ADD, modifiers: 0, shift: true },
185+
{type: KEY_UP, code: X11_KEY_ADD, modifiers: 0, shift: true },
186+
]
187+
}
188+
]
189+
}
190+
}, {tindex: 1, keyboardType: KEYBOARD_TYPE_JP, mappingTable:
191+
// intialize keyboard mapping for RAW keyboard
192+
{X11: [
193+
{keycode: JS_KEY_CAPSLOCK, entry : X11_KEY_CAPSLOCK},
194+
{keycode: JS_KEY_BACKSPACE, entry : X11_KEY_BACKSPACE},
195+
{keycode: JS_KEY_TAB, entry : X11_KEY_TAB},
196+
{keycode: JS_KEY_ENTER, entry : X11_KEY_ENTER},
197+
{keycode: JS_KEY_ESCAPE, entry : X11_KEY_ESCAPE},
198+
{keycode: JS_KEY_INSERT, entry : X11_KEY_INSERT},
199+
{keycode: JS_KEY_DELETE, entry : X11_KEY_DELETE},
200+
{keycode: JS_KEY_HOME, entry : X11_KEY_HOME},
201+
{keycode: JS_KEY_END, entry : X11_KEY_END},
202+
{keycode: JS_KEY_PAGEUP, entry : X11_KEY_PAGEUP},
203+
{keycode: JS_KEY_PAGEDOWN, entry : X11_KEY_PAGEDOWN},
204+
{keycode: JS_KEY_LEFT, entry : X11_KEY_LEFT},
205+
{keycode: JS_KEY_UP, entry : X11_KEY_UP},
206+
{keycode: JS_KEY_RIGHT, entry : X11_KEY_RIGHT},
207+
{keycode: JS_KEY_DOWN, entry : X11_KEY_DOWN},
208+
{keycode: JS_KEY_F1, entry : X11_KEY_F1},
209+
{keycode: JS_KEY_F2, entry : X11_KEY_F2},
210+
{keycode: JS_KEY_F3, entry : X11_KEY_F3},
211+
{keycode: JS_KEY_F4, entry : X11_KEY_F4},
212+
{keycode: JS_KEY_F5, entry : X11_KEY_F5},
213+
{keycode: JS_KEY_F6, entry : X11_KEY_F6},
214+
{keycode: JS_KEY_F7, entry : X11_KEY_F7},
215+
{keycode: JS_KEY_F8, entry : X11_KEY_F8},
216+
{keycode: JS_KEY_F9, entry : X11_KEY_F9},
217+
{keycode: JS_KEY_F10, entry : X11_KEY_F10},
218+
{keycode: JS_KEY_F11, entry : X11_KEY_F11},
219+
{keycode: JS_KEY_F12, entry : X11_KEY_F12},
220+
{keycode: JS_KEY_SHIFT, entry : X11_KEY_SHIFT},
221+
{keycode: JS_KEY_CTRL, entry : X11_KEY_CTRL},
222+
{keycode: JS_KEY_ALT, entry : X11_KEY_ALT},
223+
{keycode: JS_KEY_GRAVE_ACCENT, entry : X11_KEY_GRAVE_ACCENT},
224+
{keycode: JS_KEY_SUBSTRACT, entry : X11_KEY_SUBSTRACT},
225+
{keycode: JS_KEY_ADD, entry : X11_KEY_ADD},
226+
{keycode: JS_KEY_OPEN_BRACKET, entry : X11_KEY_OPEN_BRACKET},
227+
{keycode: JS_KEY_CLOSE_BRACKET, entry : X11_KEY_CLOSE_BRACKET},
228+
{keycode: JS_KEY_BACK_SLASH, entry : X11_KEY_BACK_SLASH},
229+
{keycode: JS_KEY_SINGLE_QUOTE, entry : X11_KEY_SINGLE_QUOTE},
230+
{keycode: JS_KEY_COMMA, entry : X11_KEY_COMMA},
231+
{keycode: JS_KEY_PERIOD, entry : X11_KEY_PERIOD},
232+
{keycode: JS_KEY_FORWARD_SLASH, entry : X11_KEY_FORWARD_SLASH},
233+
{keycode: JS_KEY_DASH, entry : X11_KEY_DASH},
234+
{keycode: JS_KEY_SEMI_COLON, entry : X11_KEY_SEMI_COLON},
235+
{keycode: JS_KEY_NUMPAD0, entry : X11_KEY_NUMPAD0},
236+
{keycode: JS_KEY_NUMPAD1, entry : X11_KEY_NUMPAD1},
237+
{keycode: JS_KEY_NUMPAD2, entry : X11_KEY_NUMPAD2},
238+
{keycode: JS_KEY_NUMPAD3, entry : X11_KEY_NUMPAD3},
239+
{keycode: JS_KEY_NUMPAD4, entry : X11_KEY_NUMPAD4},
240+
{keycode: JS_KEY_NUMPAD5, entry : X11_KEY_NUMPAD5},
241+
{keycode: JS_KEY_NUMPAD6, entry : X11_KEY_NUMPAD6},
242+
{keycode: JS_KEY_NUMPAD7, entry : X11_KEY_NUMPAD7},
243+
{keycode: JS_KEY_NUMPAD8, entry : X11_KEY_NUMPAD8},
244+
{keycode: JS_KEY_NUMPAD9, entry : X11_KEY_NUMPAD9},
245+
{keycode: JS_KEY_DECIMAL_POINT, entry : X11_KEY_DECIMAL_POINT},
246+
{keycode: JS_KEY_DIVIDE, entry : X11_KEY_DIVIDE},
77247

248+
{keycode: JS_KEY_MULTIPLY, entry : [
249+
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0 },
250+
{type: KEY_DOWN, code: X11_KEY_ASTERISK, modifiers: 0 },
251+
{type: KEY_UP, code: X11_KEY_ASTERISK, modifiers: 0 },
252+
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0 }
253+
]},
254+
{keycode: JS_KEY_ADD, entry : false}
255+
],
256+
keyPress: [
257+
{keycode: 61, entry: [
258+
{type: KEY_DOWN, code: X11_KEY_ADD, modifiers: 0, shift: false },
259+
{type: KEY_UP, code: X11_KEY_ADD, modifiers: 0, shift: false }
260+
]},
261+
{keycode: 43, entry: [
262+
{type: KEY_DOWN, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
263+
{type: KEY_DOWN, code: X11_KEY_ADD, modifiers: 0, shift: false },
264+
{type: KEY_UP, code: X11_KEY_ADD, modifiers: 0, shift: false },
265+
{type: KEY_UP, code: X11_KEY_SHIFT, modifiers: 0, shift: false },
266+
{type: KEY_DOWN, code: X11_KEY_ADD, modifiers: 0, shift: true },
267+
{type: KEY_UP, code: X11_KEY_ADD, modifiers: 0, shift: true }
268+
]}
269+
]
270+
}
271+
}, {tindex: 2, keyboardType: KEYBOARD_TYPE_UK, mappingTable:
272+
{X11: [],
273+
keyPress: [
274+
//[34 = "]
275+
{keycode: 34, entry:
276+
[{type : KEY_DOWN, code : 0x40, modifiers : 64, shift : true}]
277+
},
278+
//[35 = #]
279+
{keycode: 35, entry:
280+
[{type : KEY_DOWN, code : 0x5c, modifiers : 0, shift : false}]
281+
},
282+
// [64 = @]
283+
{keycode: 64, entry:
284+
[{type : KEY_DOWN, code : 0x22, modifiers : 64, shift : true}]
285+
},
286+
// [92 = \]
287+
{keycode: 92, entry:
288+
[{type : KEY_DOWN, code : 0xa6, modifiers : 0, shift : false}]
289+
},
290+
// [126 = ~]
291+
{keycode: 126, entry:
292+
[{type : KEY_DOWN, code : 0x7c, modifiers : 64, shift : true}]
293+
},
294+
// [163 = £]
295+
{keycode: 163, entry:
296+
[{type : KEY_DOWN, code : 0x23, modifiers : 64, shift : true}]
297+
},
298+
// [172 = ¬]
299+
{keycode: 172, entry:
300+
[{type : KEY_DOWN, code : 0x7e, modifiers : 64, shift : true}]
301+
},
302+
// [166 = ¦]
303+
{keycode: 166, entry:
304+
[{type : KEY_DOWN, code : 0x60, modifiers : 896, shift : false}]
305+
}
306+
]
307+
}
308+
}]

0 commit comments

Comments
 (0)