VirtualBox

Ticket #10185: KeyboardTranslator.as

File KeyboardTranslator.as, 49.3 KB (added by Klaus Espenlaub, 13 years ago)

translation code/tables for US/DE layouts - (c) Oracle, published to allow users to contribute tables for other keyboard layouts to Oracle.

Line 
1/*
2 * Copyright (C) 2009-2010 Oracle Corporation
3 *
4 * All rights reserved
5 */
6
7package com.sun.network.rdp
8{
9 import flash.events.KeyboardEvent;
10 import flash.ui.KeyLocation;
11 import flash.utils.ByteArray;
12
13 internal class KeyboardTranslator
14 {
15 private var mClient:RDPClient;
16
17 /* Current keycode array. Assigned to a corresponding keyCodeXX array.
18 * ActionScript reference: "Array assignment is by reference rather than by value."
19 */
20 private var mKeyCodeTable:Array;
21 private var mCurrentLayout:String;
22
23 /* The array maps a KeyboardEvent.keyCode to an index in a scancode sequences array.
24 *
25 * KeyboardEvent.keyCode is an index in the array. An element of the keyCode array is:
26 * { numScancodes:uint, scancodesIndex:uint } for every "location".
27 *
28 * To retrieve:
29 * numScancodes = keyCodeUS[8 * keyCode + keyLocation * 2];
30 * indexScancodes = keyCodeUS[8 * keyCode + keyLocation * 2 + 1];
31 * switch (numScancodes)
32 * {
33 * case 1: scancodes[0] = scancodes1[indexScancodes]; return 1;
34 * case 2: scancodes[0] = scancodes2[2 * indexScancodes];
35 * scancodes[1] = scancodes2[2 * indexScancodes + 1]; return 2;
36 * }
37 */
38 private static const keyCodeUS:Array =
39 [
40 /* numSc,index */
41 /* keycode Std Left Right NumPad */
42
43 /* 0x00 ( 0) */ 0, -1, 0, -1, 0, -1, 0, -1,
44 /* 0x01 ( 1) */ 0, -1, 0, -1, 0, -1, 0, -1,
45 /* 0x02 ( 2) */ 0, -1, 0, -1, 0, -1, 0, -1,
46 /* 0x03 ( 3) */ 2, 4, 0, -1, 0, -1, 0, -1, /* Ctrl-Break (tested) */
47 /* 0x04 ( 4) */ 0, -1, 0, -1, 0, -1, 0, -1,
48 /* 0x05 ( 5) */ 0, -1, 0, -1, 0, -1, 0, -1,
49 /* 0x06 ( 6) */ 0, -1, 0, -1, 0, -1, 0, -1,
50 /* 0x07 ( 7) */ 0, -1, 0, -1, 0, -1, 0, -1,
51 /* 0x08 ( 8) */ 1, 13, 0, -1, 0, -1, 0, -1, /* BACKSPACE */
52 /* 0x09 ( 9) */ 1, 14, 0, -1, 0, -1, 0, -1, /* TAB */
53 /* 0x0a ( 10) */ 0, -1, 0, -1, 0, -1, 0, -1,
54 /* 0x0b ( 11) */ 0, -1, 0, -1, 0, -1, 0, -1,
55 /* 0x0c ( 12) */ 1, 75, 0, -1, 0, -1, 1, 75, /* NumPad 5 (tested) */
56 /* 0x0d ( 13) */ 1, 27, 0, -1, 0, -1, 2, 0, /* ENTER */
57 /* 0x0e ( 14) */ 0, -1, 0, -1, 0, -1, 0, -1,
58 /* 0x0f ( 15) */ 1, -1, 0, -1, 0, -1, 0, -1, /* COMMAND */
59 /* 0x10 ( 16) */ 1, 41, 1, 41, 1, 53, 0, -1, /* SHIFT */
60 /* 0x11 ( 17) */ 1, 28, 1, 28, 2, 1, 0, -1, /* CONTROL */
61 /* 0x12 ( 18) */ 1, 55, 1, 55, 2, 3, 0, -1, /* ALTERNATE */
62 /* 0x13 ( 19) */ 0, -1, 0, -1, 0, -1, 0, -1, /* Break (tested) @todo which scancode? */
63 /* 0x14 ( 20) */ 1, 57, 0, -1, 0, -1, 0, -1, /* CAPS_LOCK */
64 /* 0x15 ( 21) */ 1, 68, 0, -1, 0, -1, 1, 68, /* NUMPAD */
65 /* 0x16 ( 22) */ 0, -1, 0, -1, 0, -1, 0, -1,
66 /* 0x17 ( 23) */ 0, -1, 0, -1, 0, -1, 0, -1,
67 /* 0x18 ( 24) */ 0, -1, 0, -1, 0, -1, 0, -1,
68 /* 0x19 ( 25) */ 0, -1, 0, -1, 0, -1, 0, -1,
69 /* 0x1a ( 26) */ 0, -1, 0, -1, 0, -1, 0, -1,
70 /* 0x1b ( 27) */ 1, 0, 0, -1, 0, -1, 0, -1, /* ESCAPE */
71 /* 0x1c ( 28) */ 0, -1, 0, -1, 0, -1, 0, -1,
72 /* 0x1d ( 29) */ 0, -1, 0, -1, 0, -1, 0, -1,
73 /* 0x1e ( 30) */ 0, -1, 0, -1, 0, -1, 0, -1,
74 /* 0x1f ( 31) */ 0, -1, 0, -1, 0, -1, 0, -1,
75 /* 0x20 ( 32) */ 1, 56, 0, -1, 0, -1, 0, -1, /* SPACE */
76 /* 0x21 ( 33) */ 2, 7, 0, -1, 0, -1, 1, 72, /* PAGE_UP */
77 /* 0x22 ( 34) */ 2, 12, 0, -1, 0, -1, 1, 80, /* PAGE_DOWN */
78 /* 0x23 ( 35) */ 2, 10, 0, -1, 0, -1, 1, 78, /* END */
79 /* 0x24 ( 36) */ 2, 5, 0, -1, 0, -1, 1, 70, /* HOME */
80 /* 0x25 ( 37) */ 2, 8, 0, -1, 0, -1, 1, 74, /* LEFT */
81 /* 0x26 ( 38) */ 2, 6, 0, -1, 0, -1, 1, 71, /* UP */
82 /* 0x27 ( 39) */ 2, 9, 0, -1, 0, -1, 1, 76, /* RIGHT */
83 /* 0x28 ( 40) */ 2, 11, 0, -1, 0, -1, 1, 79, /* DOWN */
84 /* 0x29 ( 41) */ 0, -1, 0, -1, 0, -1, 0, -1,
85 /* 0x2a ( 42) */ 0, -1, 0, -1, 0, -1, 0, -1,
86 /* 0x2b ( 43) */ 0, -1, 0, -1, 0, -1, 0, -1,
87 /* 0x2c ( 44) */ 1, 83, 0, -1, 0, -1, 0, -1, /* Prt Scr/Sys Rq (tested) */
88 /* 0x2d ( 45) */ 2, 13, 0, -1, 0, -1, 1, 81, /* INSERT */
89 /* 0x2e ( 46) */ 2, 14, 0, -1, 0, -1, 1, 82, /* DELETE */
90 /* 0x2f ( 47) */ 0, -1, 0, -1, 0, -1, 0, -1,
91 /* 0x30 ( 48) */ 1, 10, 0, -1, 0, -1, 0, -1, /* NUMBER_0 */
92 /* 0x31 ( 49) */ 1, 1, 0, -1, 0, -1, 0, -1, /* NUMBER_1 */
93 /* 0x32 ( 50) */ 1, 2, 0, -1, 0, -1, 0, -1, /* NUMBER_2 */
94 /* 0x33 ( 51) */ 1, 3, 0, -1, 0, -1, 0, -1, /* NUMBER_3 */
95 /* 0x34 ( 52) */ 1, 4, 0, -1, 0, -1, 0, -1, /* NUMBER_4 */
96 /* 0x35 ( 53) */ 1, 5, 0, -1, 0, -1, 0, -1, /* NUMBER_5 */
97 /* 0x36 ( 54) */ 1, 6, 0, -1, 0, -1, 0, -1, /* NUMBER_6 */
98 /* 0x37 ( 55) */ 1, 7, 0, -1, 0, -1, 0, -1, /* NUMBER_7 */
99 /* 0x38 ( 56) */ 1, 8, 0, -1, 0, -1, 0, -1, /* NUMBER_8 */
100 /* 0x39 ( 57) */ 1, 9, 0, -1, 0, -1, 0, -1, /* NUMBER_9 */
101 /* 0x3a ( 58) */ 0, -1, 0, -1, 0, -1, 0, -1,
102 /* 0x3b ( 59) */ 0, -1, 0, -1, 0, -1, 0, -1,
103 /* 0x3c ( 60) */ 0, -1, 0, -1, 0, -1, 0, -1,
104 /* 0x3d ( 61) */ 0, -1, 0, -1, 0, -1, 0, -1,
105 /* 0x3e ( 62) */ 0, -1, 0, -1, 0, -1, 0, -1,
106 /* 0x3f ( 63) */ 0, -1, 0, -1, 0, -1, 0, -1,
107 /* 0x40 ( 64) */ 0, -1, 0, -1, 0, -1, 0, -1,
108 /* 0x41 ( 65) */ 1, 29, 0, -1, 0, -1, 0, -1, /* A */
109 /* 0x42 ( 66) */ 1, 47, 0, -1, 0, -1, 0, -1, /* B */
110 /* 0x43 ( 67) */ 1, 45, 0, -1, 0, -1, 0, -1, /* C */
111 /* 0x44 ( 68) */ 1, 31, 0, -1, 0, -1, 0, -1, /* D */
112 /* 0x45 ( 69) */ 1, 17, 0, -1, 0, -1, 0, -1, /* E */
113 /* 0x46 ( 70) */ 1, 32, 0, -1, 0, -1, 0, -1, /* F */
114 /* 0x47 ( 71) */ 1, 33, 0, -1, 0, -1, 0, -1, /* G */
115 /* 0x48 ( 72) */ 1, 34, 0, -1, 0, -1, 0, -1, /* H */
116 /* 0x49 ( 73) */ 1, 22, 0, -1, 0, -1, 0, -1, /* I */
117 /* 0x4a ( 74) */ 1, 35, 0, -1, 0, -1, 0, -1, /* J */
118 /* 0x4b ( 75) */ 1, 36, 0, -1, 0, -1, 0, -1, /* K */
119 /* 0x4c ( 76) */ 1, 37, 0, -1, 0, -1, 0, -1, /* L */
120 /* 0x4d ( 77) */ 1, 49, 0, -1, 0, -1, 0, -1, /* M */
121 /* 0x4e ( 78) */ 1, 48, 0, -1, 0, -1, 0, -1, /* N */
122 /* 0x4f ( 79) */ 1, 23, 0, -1, 0, -1, 0, -1, /* O */
123 /* 0x50 ( 80) */ 1, 24, 0, -1, 0, -1, 0, -1, /* P */
124 /* 0x51 ( 81) */ 1, 15, 0, -1, 0, -1, 0, -1, /* Q */
125 /* 0x52 ( 82) */ 1, 18, 0, -1, 0, -1, 0, -1, /* R */
126 /* 0x53 ( 83) */ 1, 30, 0, -1, 0, -1, 0, -1, /* S */
127 /* 0x54 ( 84) */ 1, 19, 0, -1, 0, -1, 0, -1, /* T */
128 /* 0x55 ( 85) */ 1, 21, 0, -1, 0, -1, 0, -1, /* U */
129 /* 0x56 ( 86) */ 1, 46, 0, -1, 0, -1, 0, -1, /* V */
130 /* 0x57 ( 87) */ 1, 16, 0, -1, 0, -1, 0, -1, /* W */
131 /* 0x58 ( 88) */ 1, 44, 0, -1, 0, -1, 0, -1, /* X */
132 /* 0x59 ( 89) */ 1, 20, 0, -1, 0, -1, 0, -1, /* Y */
133 /* 0x5a ( 90) */ 1, 43, 0, -1, 0, -1, 0, -1, /* Z */
134 /* 0x5b ( 91) */ 2, 15, 0, -1, 0, -1, 0, -1, /* Left Windows key */
135 /* 0x5c ( 92) */ 2, 16, 0, -1, 0, -1, 0, -1, /* Right Windows key */
136 /* 0x5d ( 93) */ 2, 17, 0, -1, 0, -1, 0, -1, /* Menu */
137 /* 0x5e ( 94) */ 0, -1, 0, -1, 0, -1, 0, -1,
138 /* 0x5f ( 95) */ 0, -1, 0, -1, 0, -1, 0, -1,
139 /* 0x60 ( 96) */ 1, 81, 0, -1, 0, -1, 1, 81, /* NUMPAD_0 */
140 /* 0x61 ( 97) */ 1, 78, 0, -1, 0, -1, 1, 78, /* NUMPAD_1 */
141 /* 0x62 ( 98) */ 1, 79, 0, -1, 0, -1, 1, 79, /* NUMPAD_2 */
142 /* 0x63 ( 99) */ 1, 80, 0, -1, 0, -1, 1, 80, /* NUMPAD_3 */
143 /* 0x64 (100) */ 1, 74, 0, -1, 0, -1, 1, 74, /* NUMPAD_4 */
144 /* 0x65 (101) */ 1, 75, 0, -1, 0, -1, 1, 75, /* NUMPAD_5 */
145 /* 0x66 (102) */ 1, 76, 0, -1, 0, -1, 1, 76, /* NUMPAD_6 */
146 /* 0x67 (103) */ 1, 70, 0, -1, 0, -1, 1, 70, /* NUMPAD_7 */
147 /* 0x68 (104) */ 1, 71, 0, -1, 0, -1, 1, 71, /* NUMPAD_8 */
148 /* 0x69 (105) */ 1, 72, 0, -1, 0, -1, 1, 72, /* NUMPAD_9 */
149 /* 0x6a (106) */ 1, 54, 0, -1, 0, -1, 1, 54, /* NUMPAD_MULTIPLY */
150 /* 0x6b (107) */ 1, 77, 0, -1, 0, -1, 1, 77, /* NUMPAD_ADD */
151 /* 0x6c (108) */ 2, 0, 0, -1, 0, -1, 2, 0, /* NUMPAD_ENTER */
152 /* 0x6d (109) */ 1, 73, 0, -1, 0, -1, 1, 73, /* NUMPAD_SUBTRACT */
153 /* 0x6e (110) */ 1, 82, 0, -1, 0, -1, 1, 82, /* NUMPAD_DECIMAL */
154 /* 0x6f (111) */ 2, 2, 0, -1, 0, -1, 2, 2, /* NUMPAD_DIVIDE */
155 /* 0x70 (112) */ 1, 58, 0, -1, 0, -1, 0, -1, /* F1 */
156 /* 0x71 (113) */ 1, 59, 0, -1, 0, -1, 0, -1, /* F2 */
157 /* 0x72 (114) */ 1, 60, 0, -1, 0, -1, 0, -1, /* F3 */
158 /* 0x73 (115) */ 1, 61, 0, -1, 0, -1, 0, -1, /* F4 */
159 /* 0x74 (116) */ 1, 62, 0, -1, 0, -1, 0, -1, /* F5 */
160 /* 0x75 (117) */ 1, 63, 0, -1, 0, -1, 0, -1, /* F6 */
161 /* 0x76 (118) */ 1, 64, 0, -1, 0, -1, 0, -1, /* F7 */
162 /* 0x77 (119) */ 1, 65, 0, -1, 0, -1, 0, -1, /* F8 */
163 /* 0x78 (120) */ 1, 66, 0, -1, 0, -1, 0, -1, /* F9 */
164 /* 0x79 (121) */ 1, 67, 0, -1, 0, -1, 0, -1, /* F10 */
165 /* 0x7a (122) */ 1, 84, 0, -1, 0, -1, 0, -1, /* F11 */
166 /* 0x7b (123) */ 1, 85, 0, -1, 0, -1, 0, -1, /* F12 */
167 /* 0x7c (124) */ 1, -1, 0, -1, 0, -1, 0, -1, /* F13 */
168 /* 0x7d (125) */ 1, -1, 0, -1, 0, -1, 0, -1, /* F14 */
169 /* 0x7e (126) */ 1, -1, 0, -1, 0, -1, 0, -1, /* F15 */
170 /* 0x7f (127) */ 0, -1, 0, -1, 0, -1, 0, -1,
171 /* 0x80 (128) */ 0, -1, 0, -1, 0, -1, 0, -1,
172 /* 0x81 (129) */ 0, -1, 0, -1, 0, -1, 0, -1,
173 /* 0x82 (130) */ 0, -1, 0, -1, 0, -1, 0, -1,
174 /* 0x83 (131) */ 0, -1, 0, -1, 0, -1, 0, -1,
175 /* 0x84 (132) */ 0, -1, 0, -1, 0, -1, 0, -1,
176 /* 0x85 (133) */ 0, -1, 0, -1, 0, -1, 0, -1,
177 /* 0x86 (134) */ 0, -1, 0, -1, 0, -1, 0, -1,
178 /* 0x87 (135) */ 0, -1, 0, -1, 0, -1, 0, -1,
179 /* 0x88 (136) */ 0, -1, 0, -1, 0, -1, 0, -1,
180 /* 0x89 (137) */ 0, -1, 0, -1, 0, -1, 0, -1,
181 /* 0x8a (138) */ 0, -1, 0, -1, 0, -1, 0, -1,
182 /* 0x8b (139) */ 0, -1, 0, -1, 0, -1, 0, -1,
183 /* 0x8c (140) */ 0, -1, 0, -1, 0, -1, 0, -1,
184 /* 0x8d (141) */ 0, -1, 0, -1, 0, -1, 0, -1,
185 /* 0x8e (142) */ 0, -1, 0, -1, 0, -1, 0, -1,
186 /* 0x8f (143) */ 0, -1, 0, -1, 0, -1, 0, -1,
187 /* 0x90 (144) */ 1, 68, 0, -1, 0, -1, 1, 68, /* NumLock (tested) */
188 /* 0x91 (145) */ 1, 69, 0, -1, 0, -1, 0, -1, /* ScrollLock (tested) */
189 /* 0x92 (146) */ 0, -1, 0, -1, 0, -1, 0, -1,
190 /* 0x93 (147) */ 0, -1, 0, -1, 0, -1, 0, -1,
191 /* 0x94 (148) */ 0, -1, 0, -1, 0, -1, 0, -1,
192 /* 0x95 (149) */ 0, -1, 0, -1, 0, -1, 0, -1,
193 /* 0x96 (150) */ 0, -1, 0, -1, 0, -1, 0, -1,
194 /* 0x97 (151) */ 0, -1, 0, -1, 0, -1, 0, -1,
195 /* 0x98 (152) */ 0, -1, 0, -1, 0, -1, 0, -1,
196 /* 0x99 (153) */ 0, -1, 0, -1, 0, -1, 0, -1,
197 /* 0x9a (154) */ 0, -1, 0, -1, 0, -1, 0, -1,
198 /* 0x9b (155) */ 0, -1, 0, -1, 0, -1, 0, -1,
199 /* 0x9c (156) */ 0, -1, 0, -1, 0, -1, 0, -1,
200 /* 0x9d (157) */ 0, -1, 0, -1, 0, -1, 0, -1,
201 /* 0x9e (158) */ 0, -1, 0, -1, 0, -1, 0, -1,
202 /* 0x9f (159) */ 0, -1, 0, -1, 0, -1, 0, -1,
203 /* 0xa0 (160) */ 0, -1, 0, -1, 0, -1, 0, -1,
204 /* 0xa1 (161) */ 0, -1, 0, -1, 0, -1, 0, -1,
205 /* 0xa2 (162) */ 0, -1, 0, -1, 0, -1, 0, -1,
206 /* 0xa3 (163) */ 0, -1, 0, -1, 0, -1, 0, -1,
207 /* 0xa4 (164) */ 0, -1, 0, -1, 0, -1, 0, -1,
208 /* 0xa5 (165) */ 0, -1, 0, -1, 0, -1, 0, -1,
209 /* 0xa6 (166) */ 0, -1, 0, -1, 0, -1, 0, -1,
210 /* 0xa7 (167) */ 0, -1, 0, -1, 0, -1, 0, -1,
211 /* 0xa8 (168) */ 0, -1, 0, -1, 0, -1, 0, -1,
212 /* 0xa9 (169) */ 0, -1, 0, -1, 0, -1, 0, -1,
213 /* 0xaa (170) */ 0, -1, 0, -1, 0, -1, 0, -1,
214 /* 0xab (171) */ 0, -1, 0, -1, 0, -1, 0, -1,
215 /* 0xac (172) */ 0, -1, 0, -1, 0, -1, 0, -1,
216 /* 0xad (173) */ 0, -1, 0, -1, 0, -1, 0, -1,
217 /* 0xae (174) */ 0, -1, 0, -1, 0, -1, 0, -1,
218 /* 0xaf (175) */ 0, -1, 0, -1, 0, -1, 0, -1,
219 /* 0xb0 (176) */ 0, -1, 0, -1, 0, -1, 0, -1,
220 /* 0xb1 (177) */ 0, -1, 0, -1, 0, -1, 0, -1,
221 /* 0xb2 (178) */ 0, -1, 0, -1, 0, -1, 0, -1,
222 /* 0xb3 (179) */ 0, -1, 0, -1, 0, -1, 0, -1,
223 /* 0xb4 (180) */ 0, -1, 0, -1, 0, -1, 0, -1,
224 /* 0xb5 (181) */ 0, -1, 0, -1, 0, -1, 0, -1,
225 /* 0xb6 (182) */ 0, -1, 0, -1, 0, -1, 0, -1,
226 /* 0xb7 (183) */ 0, -1, 0, -1, 0, -1, 0, -1,
227 /* 0xb8 (184) */ 0, -1, 0, -1, 0, -1, 0, -1,
228 /* 0xb9 (185) */ 0, -1, 0, -1, 0, -1, 0, -1,
229 /* 0xba (186) */ 1, 38, 0, -1, 0, -1, 0, -1, /* SEMICOLON */
230 /* 0xbb (187) */ 1, 12, 0, -1, 0, -1, 0, -1, /* EQUAL */
231 /* 0xbc (188) */ 1, 50, 0, -1, 0, -1, 0, -1, /* COMMA */
232 /* 0xbd (189) */ 1, 11, 0, -1, 0, -1, 1, 73, /* MINUS */
233 /* 0xbe (190) */ 1, 51, 0, -1, 0, -1, 0, -1, /* PERIOD */
234 /* 0xbf (191) */ 1, 52, 0, -1, 0, -1, 0, -1, /* SLASH */
235 /* 0xc0 (192) */ 1, 40, 0, -1, 0, -1, 0, -1, /* BACKQUOTE */
236 /* 0xc1 (193) */ 0, -1, 0, -1, 0, -1, 0, -1,
237 /* 0xc2 (194) */ 0, -1, 0, -1, 0, -1, 0, -1,
238 /* 0xc3 (195) */ 0, -1, 0, -1, 0, -1, 0, -1,
239 /* 0xc4 (196) */ 0, -1, 0, -1, 0, -1, 0, -1,
240 /* 0xc5 (197) */ 0, -1, 0, -1, 0, -1, 0, -1,
241 /* 0xc6 (198) */ 0, -1, 0, -1, 0, -1, 0, -1,
242 /* 0xc7 (199) */ 0, -1, 0, -1, 0, -1, 0, -1,
243 /* 0xc8 (200) */ 0, -1, 0, -1, 0, -1, 0, -1,
244 /* 0xc9 (201) */ 0, -1, 0, -1, 0, -1, 0, -1,
245 /* 0xca (202) */ 0, -1, 0, -1, 0, -1, 0, -1,
246 /* 0xcb (203) */ 0, -1, 0, -1, 0, -1, 0, -1,
247 /* 0xcc (204) */ 0, -1, 0, -1, 0, -1, 0, -1,
248 /* 0xcd (205) */ 0, -1, 0, -1, 0, -1, 0, -1,
249 /* 0xce (206) */ 0, -1, 0, -1, 0, -1, 0, -1,
250 /* 0xcf (207) */ 0, -1, 0, -1, 0, -1, 0, -1,
251 /* 0xd0 (208) */ 0, -1, 0, -1, 0, -1, 0, -1,
252 /* 0xd1 (209) */ 0, -1, 0, -1, 0, -1, 0, -1,
253 /* 0xd2 (210) */ 0, -1, 0, -1, 0, -1, 0, -1,
254 /* 0xd3 (211) */ 0, -1, 0, -1, 0, -1, 0, -1,
255 /* 0xd4 (212) */ 0, -1, 0, -1, 0, -1, 0, -1,
256 /* 0xd5 (213) */ 0, -1, 0, -1, 0, -1, 0, -1,
257 /* 0xd6 (214) */ 0, -1, 0, -1, 0, -1, 0, -1,
258 /* 0xd7 (215) */ 0, -1, 0, -1, 0, -1, 0, -1,
259 /* 0xd8 (216) */ 0, -1, 0, -1, 0, -1, 0, -1,
260 /* 0xd9 (217) */ 0, -1, 0, -1, 0, -1, 0, -1,
261 /* 0xda (218) */ 0, -1, 0, -1, 0, -1, 0, -1,
262 /* 0xdb (219) */ 1, 25, 0, -1, 0, -1, 0, -1, /* LEFTBRACKET [ */
263 /* 0xdc (220) */ 1, 42, 0, -1, 0, -1, 0, -1, /* BACKSLASH */
264 /* 0xdd (221) */ 1, 26, 0, -1, 0, -1, 0, -1, /* RIGHTBRACKET ] */
265 /* 0xde (222) */ 1, 39, 0, -1, 0, -1, 0, -1, /* QUOTE */
266 /* 0xdf (223) */ 0, -1, 0, -1, 0, -1, 0, -1,
267 /* 0xe0 (224) */ 0, -1, 0, -1, 0, -1, 0, -1,
268 /* 0xe1 (225) */ 0, -1, 0, -1, 0, -1, 0, -1,
269 /* 0xe2 (226) */ 1, 86, 0, -1, 0, -1, 0, -1, /* BACKSLASH near left shift */
270 /* 0xe3 (227) */ 0, -1, 0, -1, 0, -1, 0, -1,
271 /* 0xe4 (228) */ 0, -1, 0, -1, 0, -1, 0, -1,
272 /* 0xe5 (229) */ 0, -1, 0, -1, 0, -1, 0, -1,
273 /* 0xe6 (230) */ 0, -1, 0, -1, 0, -1, 0, -1,
274 /* 0xe7 (231) */ 0, -1, 0, -1, 0, -1, 0, -1,
275 /* 0xe8 (232) */ 0, -1, 0, -1, 0, -1, 0, -1,
276 /* 0xe9 (233) */ 0, -1, 0, -1, 0, -1, 0, -1,
277 /* 0xea (234) */ 0, -1, 0, -1, 0, -1, 0, -1,
278 /* 0xeb (235) */ 0, -1, 0, -1, 0, -1, 0, -1,
279 /* 0xec (236) */ 0, -1, 0, -1, 0, -1, 0, -1,
280 /* 0xed (237) */ 0, -1, 0, -1, 0, -1, 0, -1,
281 /* 0xee (238) */ 0, -1, 0, -1, 0, -1, 0, -1,
282 /* 0xef (239) */ 0, -1, 0, -1, 0, -1, 0, -1,
283 /* 0xf0 (240) */ 0, -1, 0, -1, 0, -1, 0, -1,
284 /* 0xf1 (241) */ 0, -1, 0, -1, 0, -1, 0, -1,
285 /* 0xf2 (242) */ 0, -1, 0, -1, 0, -1, 0, -1,
286 /* 0xf3 (243) */ 0, -1, 0, -1, 0, -1, 0, -1,
287 /* 0xf4 (244) */ 0, -1, 0, -1, 0, -1, 0, -1,
288 /* 0xf5 (245) */ 0, -1, 0, -1, 0, -1, 0, -1,
289 /* 0xf6 (246) */ 0, -1, 0, -1, 0, -1, 0, -1,
290 /* 0xf7 (247) */ 0, -1, 0, -1, 0, -1, 0, -1,
291 /* 0xf8 (248) */ 0, -1, 0, -1, 0, -1, 0, -1,
292 /* 0xf9 (249) */ 0, -1, 0, -1, 0, -1, 0, -1,
293 /* 0xfa (250) */ 0, -1, 0, -1, 0, -1, 0, -1,
294 /* 0xfb (251) */ 0, -1, 0, -1, 0, -1, 0, -1,
295 /* 0xfc (252) */ 0, -1, 0, -1, 0, -1, 0, -1,
296 /* 0xfd (253) */ 0, -1, 0, -1, 0, -1, 0, -1,
297 /* 0xfe (254) */ 0, -1, 0, -1, 0, -1, 0, -1,
298 /* 0xff (255) */ 0, -1, 0, -1, 0, -1, 0, -1,
299 ];
300
301 private static const keyCodeDE:Array =
302 [
303 /* numSc,index */
304 /* keycode Std Left Right NumPad */
305
306 /* de 0x00 ( 0) */ 0, -1, 0, -1, 0, -1, 0, -1,
307 /* de 0x01 ( 1) */ 0, -1, 0, -1, 0, -1, 0, -1,
308 /* de 0x02 ( 2) */ 0, -1, 0, -1, 0, -1, 0, -1,
309 /* de 0x03 ( 3) */ 2, 4, 0, -1, 0, -1, 0, -1, /* Ctrl-Break (tested) */
310 /* de 0x04 ( 4) */ 0, -1, 0, -1, 0, -1, 0, -1,
311 /* de 0x05 ( 5) */ 0, -1, 0, -1, 0, -1, 0, -1,
312 /* de 0x06 ( 6) */ 0, -1, 0, -1, 0, -1, 0, -1,
313 /* de 0x07 ( 7) */ 0, -1, 0, -1, 0, -1, 0, -1,
314 /* de 0x08 ( 8) */ 1, 13, 0, -1, 0, -1, 0, -1, /* BACKSPACE */
315 /* de 0x09 ( 9) */ 1, 14, 0, -1, 0, -1, 0, -1, /* TAB */
316 /* de 0x0a ( 10) */ 0, -1, 0, -1, 0, -1, 0, -1,
317 /* de 0x0b ( 11) */ 0, -1, 0, -1, 0, -1, 0, -1,
318 /* de 0x0c ( 12) */ 1, 75, 0, -1, 0, -1, 1, 75, /* NumPad 5 (tested) */
319 /* de 0x0d ( 13) */ 1, 27, 0, -1, 0, -1, 2, 0, /* ENTER */
320 /* de 0x0e ( 14) */ 0, -1, 0, -1, 0, -1, 0, -1,
321 /* de 0x0f ( 15) */ 1, -1, 0, -1, 0, -1, 0, -1, /* COMMAND */
322 /* de 0x10 ( 16) */ 1, 41, 1, 41, 1, 53, 0, -1, /* SHIFT */
323 /* de 0x11 ( 17) */ 1, 28, 1, 28, 2, 1, 0, -1, /* CONTROL */
324 /* de 0x12 ( 18) */ 1, 55, 1, 55, 2, 3, 0, -1, /* ALTERNATE */
325 /* de 0x13 ( 19) */ 0, -1, 0, -1, 0, -1, 0, -1, /* Break (tested) @todo which scancode? */
326 /* de 0x14 ( 20) */ 1, 57, 0, -1, 0, -1, 0, -1, /* CAPS_LOCK */
327 /* de 0x15 ( 21) */ 1, 68, 0, -1, 0, -1, 1, 68, /* NUMPAD */
328 /* de 0x16 ( 22) */ 0, -1, 0, -1, 0, -1, 0, -1,
329 /* de 0x17 ( 23) */ 0, -1, 0, -1, 0, -1, 0, -1,
330 /* de 0x18 ( 24) */ 0, -1, 0, -1, 0, -1, 0, -1,
331 /* de 0x19 ( 25) */ 0, -1, 0, -1, 0, -1, 0, -1,
332 /* de 0x1a ( 26) */ 0, -1, 0, -1, 0, -1, 0, -1,
333 /* de 0x1b ( 27) */ 1, 0, 0, -1, 0, -1, 0, -1, /* ESCAPE */
334 /* de 0x1c ( 28) */ 0, -1, 0, -1, 0, -1, 0, -1,
335 /* de 0x1d ( 29) */ 0, -1, 0, -1, 0, -1, 0, -1,
336 /* de 0x1e ( 30) */ 0, -1, 0, -1, 0, -1, 0, -1,
337 /* de 0x1f ( 31) */ 0, -1, 0, -1, 0, -1, 0, -1,
338 /* de 0x20 ( 32) */ 1, 56, 0, -1, 0, -1, 0, -1, /* SPACE */
339 /* de 0x21 ( 33) */ 2, 7, 0, -1, 0, -1, 1, 72, /* PAGE_UP */
340 /* de 0x22 ( 34) */ 2, 12, 0, -1, 0, -1, 1, 80, /* PAGE_DOWN */
341 /* de 0x23 ( 35) */ 2, 10, 0, -1, 0, -1, 1, 78, /* END */
342 /* de 0x24 ( 36) */ 2, 5, 0, -1, 0, -1, 1, 70, /* HOME */
343 /* de 0x25 ( 37) */ 2, 8, 0, -1, 0, -1, 1, 74, /* LEFT */
344 /* de 0x26 ( 38) */ 2, 6, 0, -1, 0, -1, 1, 71, /* UP */
345 /* de 0x27 ( 39) */ 2, 9, 0, -1, 0, -1, 1, 76, /* RIGHT */
346 /* de 0x28 ( 40) */ 2, 11, 0, -1, 0, -1, 1, 79, /* DOWN */
347 /* de 0x29 ( 41) */ 0, -1, 0, -1, 0, -1, 0, -1,
348 /* de 0x2a ( 42) */ 0, -1, 0, -1, 0, -1, 0, -1,
349 /* de 0x2b ( 43) */ 0, -1, 0, -1, 0, -1, 0, -1,
350 /* de 0x2c ( 44) */ 1, 83, 0, -1, 0, -1, 0, -1, /* Prt Scr/Sys Rq (tested) */
351 /* de 0x2d ( 45) */ 2, 13, 0, -1, 0, -1, 1, 81, /* INSERT */
352 /* de 0x2e ( 46) */ 2, 14, 0, -1, 0, -1, 1, 82, /* DELETE */
353 /* de 0x2f ( 47) */ 0, -1, 0, -1, 0, -1, 0, -1,
354 /* de 0x30 ( 48) */ 1, 10, 0, -1, 0, -1, 0, -1, /* NUMBER_0 */
355 /* de 0x31 ( 49) */ 1, 1, 0, -1, 0, -1, 0, -1, /* NUMBER_1 */
356 /* de 0x32 ( 50) */ 1, 2, 0, -1, 0, -1, 0, -1, /* NUMBER_2 */
357 /* de 0x33 ( 51) */ 1, 3, 0, -1, 0, -1, 0, -1, /* NUMBER_3 */
358 /* de 0x34 ( 52) */ 1, 4, 0, -1, 0, -1, 0, -1, /* NUMBER_4 */
359 /* de 0x35 ( 53) */ 1, 5, 0, -1, 0, -1, 0, -1, /* NUMBER_5 */
360 /* de 0x36 ( 54) */ 1, 6, 0, -1, 0, -1, 0, -1, /* NUMBER_6 */
361 /* de 0x37 ( 55) */ 1, 7, 0, -1, 0, -1, 0, -1, /* NUMBER_7 */
362 /* de 0x38 ( 56) */ 1, 8, 0, -1, 0, -1, 0, -1, /* NUMBER_8 */
363 /* de 0x39 ( 57) */ 1, 9, 0, -1, 0, -1, 0, -1, /* NUMBER_9 */
364 /* de 0x3a ( 58) */ 0, -1, 0, -1, 0, -1, 0, -1,
365 /* de 0x3b ( 59) */ 0, -1, 0, -1, 0, -1, 0, -1,
366 /* de 0x3c ( 60) */ 0, -1, 0, -1, 0, -1, 0, -1,
367 /* de 0x3d ( 61) */ 0, -1, 0, -1, 0, -1, 0, -1,
368 /* de 0x3e ( 62) */ 0, -1, 0, -1, 0, -1, 0, -1,
369 /* de 0x3f ( 63) */ 0, -1, 0, -1, 0, -1, 0, -1,
370 /* de 0x40 ( 64) */ 0, -1, 0, -1, 0, -1, 0, -1,
371 /* de 0x41 ( 65) */ 1, 29, 0, -1, 0, -1, 0, -1, /* A */
372 /* de 0x42 ( 66) */ 1, 47, 0, -1, 0, -1, 0, -1, /* B */
373 /* de 0x43 ( 67) */ 1, 45, 0, -1, 0, -1, 0, -1, /* C */
374 /* de 0x44 ( 68) */ 1, 31, 0, -1, 0, -1, 0, -1, /* D */
375 /* de 0x45 ( 69) */ 1, 17, 0, -1, 0, -1, 0, -1, /* E */
376 /* de 0x46 ( 70) */ 1, 32, 0, -1, 0, -1, 0, -1, /* F */
377 /* de 0x47 ( 71) */ 1, 33, 0, -1, 0, -1, 0, -1, /* G */
378 /* de 0x48 ( 72) */ 1, 34, 0, -1, 0, -1, 0, -1, /* H */
379 /* de 0x49 ( 73) */ 1, 22, 0, -1, 0, -1, 0, -1, /* I */
380 /* de 0x4a ( 74) */ 1, 35, 0, -1, 0, -1, 0, -1, /* J */
381 /* de 0x4b ( 75) */ 1, 36, 0, -1, 0, -1, 0, -1, /* K */
382 /* de 0x4c ( 76) */ 1, 37, 0, -1, 0, -1, 0, -1, /* L */
383 /* de 0x4d ( 77) */ 1, 49, 0, -1, 0, -1, 0, -1, /* M */
384 /* de 0x4e ( 78) */ 1, 48, 0, -1, 0, -1, 0, -1, /* N */
385 /* de 0x4f ( 79) */ 1, 23, 0, -1, 0, -1, 0, -1, /* O */
386 /* de 0x50 ( 80) */ 1, 24, 0, -1, 0, -1, 0, -1, /* P */
387 /* de 0x51 ( 81) */ 1, 15, 0, -1, 0, -1, 0, -1, /* Q */
388 /* de 0x52 ( 82) */ 1, 18, 0, -1, 0, -1, 0, -1, /* R */
389 /* de 0x53 ( 83) */ 1, 30, 0, -1, 0, -1, 0, -1, /* S */
390 /* de 0x54 ( 84) */ 1, 19, 0, -1, 0, -1, 0, -1, /* T */
391 /* de 0x55 ( 85) */ 1, 21, 0, -1, 0, -1, 0, -1, /* U */
392 /* de 0x56 ( 86) */ 1, 46, 0, -1, 0, -1, 0, -1, /* V */
393 /* de 0x57 ( 87) */ 1, 16, 0, -1, 0, -1, 0, -1, /* W */
394 /* de 0x58 ( 88) */ 1, 44, 0, -1, 0, -1, 0, -1, /* X */
395 /* de 0x59 ( 89) */ 1, 43, 0, -1, 0, -1, 0, -1, /* Y */
396 /* de 0x5a ( 90) */ 1, 20, 0, -1, 0, -1, 0, -1, /* Z */
397 /* de 0x5b ( 91) */ 2, 15, 0, -1, 0, -1, 0, -1, /* Left Windows key */
398 /* de 0x5c ( 92) */ 2, 16, 0, -1, 0, -1, 0, -1, /* Right Windows key */
399 /* de 0x5d ( 93) */ 2, 17, 0, -1, 0, -1, 0, -1, /* Menu */
400 /* de 0x5e ( 94) */ 0, -1, 0, -1, 0, -1, 0, -1,
401 /* de 0x5f ( 95) */ 0, -1, 0, -1, 0, -1, 0, -1,
402 /* de 0x60 ( 96) */ 1, 81, 0, -1, 0, -1, 1, 81, /* NUMPAD_0 */
403 /* de 0x61 ( 97) */ 1, 78, 0, -1, 0, -1, 1, 78, /* NUMPAD_1 */
404 /* de 0x62 ( 98) */ 1, 79, 0, -1, 0, -1, 1, 79, /* NUMPAD_2 */
405 /* de 0x63 ( 99) */ 1, 80, 0, -1, 0, -1, 1, 80, /* NUMPAD_3 */
406 /* de 0x64 (100) */ 1, 74, 0, -1, 0, -1, 1, 74, /* NUMPAD_4 */
407 /* de 0x65 (101) */ 1, 75, 0, -1, 0, -1, 1, 75, /* NUMPAD_5 */
408 /* de 0x66 (102) */ 1, 76, 0, -1, 0, -1, 1, 76, /* NUMPAD_6 */
409 /* de 0x67 (103) */ 1, 70, 0, -1, 0, -1, 1, 70, /* NUMPAD_7 */
410 /* de 0x68 (104) */ 1, 71, 0, -1, 0, -1, 1, 71, /* NUMPAD_8 */
411 /* de 0x69 (105) */ 1, 72, 0, -1, 0, -1, 1, 72, /* NUMPAD_9 */
412 /* de 0x6a (106) */ 1, 54, 0, -1, 0, -1, 1, 54, /* NUMPAD_MULTIPLY */
413 /* de 0x6b (107) */ 1, 77, 0, -1, 0, -1, 1, 77, /* NUMPAD_ADD */
414 /* de 0x6c (108) */ 2, 0, 0, -1, 0, -1, 2, 0, /* NUMPAD_ENTER */
415 /* de 0x6d (109) */ 1, 73, 0, -1, 0, -1, 1, 73, /* NUMPAD_SUBTRACT */
416 /* de 0x6e (110) */ 1, 82, 0, -1, 0, -1, 1, 82, /* NUMPAD_DECIMAL */
417 /* de 0x6f (111) */ 2, 2, 0, -1, 0, -1, 2, 2, /* NUMPAD_DIVIDE */
418 /* de 0x70 (112) */ 1, 58, 0, -1, 0, -1, 0, -1, /* F1 */
419 /* de 0x71 (113) */ 1, 59, 0, -1, 0, -1, 0, -1, /* F2 */
420 /* de 0x72 (114) */ 1, 60, 0, -1, 0, -1, 0, -1, /* F3 */
421 /* de 0x73 (115) */ 1, 61, 0, -1, 0, -1, 0, -1, /* F4 */
422 /* de 0x74 (116) */ 1, 62, 0, -1, 0, -1, 0, -1, /* F5 */
423 /* de 0x75 (117) */ 1, 63, 0, -1, 0, -1, 0, -1, /* F6 */
424 /* de 0x76 (118) */ 1, 64, 0, -1, 0, -1, 0, -1, /* F7 */
425 /* de 0x77 (119) */ 1, 65, 0, -1, 0, -1, 0, -1, /* F8 */
426 /* de 0x78 (120) */ 1, 66, 0, -1, 0, -1, 0, -1, /* F9 */
427 /* de 0x79 (121) */ 1, 67, 0, -1, 0, -1, 0, -1, /* F10 */
428 /* de 0x7a (122) */ 1, 84, 0, -1, 0, -1, 0, -1, /* F11 */
429 /* de 0x7b (123) */ 1, 85, 0, -1, 0, -1, 0, -1, /* F12 */
430 /* de 0x7c (124) */ 1, -1, 0, -1, 0, -1, 0, -1, /* F13 */
431 /* de 0x7d (125) */ 1, -1, 0, -1, 0, -1, 0, -1, /* F14 */
432 /* de 0x7e (126) */ 1, -1, 0, -1, 0, -1, 0, -1, /* F15 */
433 /* de 0x7f (127) */ 0, -1, 0, -1, 0, -1, 0, -1,
434 /* de 0x80 (128) */ 0, -1, 0, -1, 0, -1, 0, -1,
435 /* de 0x81 (129) */ 0, -1, 0, -1, 0, -1, 0, -1,
436 /* de 0x82 (130) */ 0, -1, 0, -1, 0, -1, 0, -1,
437 /* de 0x83 (131) */ 0, -1, 0, -1, 0, -1, 0, -1,
438 /* de 0x84 (132) */ 0, -1, 0, -1, 0, -1, 0, -1,
439 /* de 0x85 (133) */ 0, -1, 0, -1, 0, -1, 0, -1,
440 /* de 0x86 (134) */ 0, -1, 0, -1, 0, -1, 0, -1,
441 /* de 0x87 (135) */ 0, -1, 0, -1, 0, -1, 0, -1,
442 /* de 0x88 (136) */ 0, -1, 0, -1, 0, -1, 0, -1,
443 /* de 0x89 (137) */ 0, -1, 0, -1, 0, -1, 0, -1,
444 /* de 0x8a (138) */ 0, -1, 0, -1, 0, -1, 0, -1,
445 /* de 0x8b (139) */ 0, -1, 0, -1, 0, -1, 0, -1,
446 /* de 0x8c (140) */ 0, -1, 0, -1, 0, -1, 0, -1,
447 /* de 0x8d (141) */ 0, -1, 0, -1, 0, -1, 0, -1,
448 /* de 0x8e (142) */ 0, -1, 0, -1, 0, -1, 0, -1,
449 /* de 0x8f (143) */ 0, -1, 0, -1, 0, -1, 0, -1,
450 /* de 0x90 (144) */ 1, 68, 0, -1, 0, -1, 1, 68, /* NumLock (tested) */
451 /* de 0x91 (145) */ 1, 69, 0, -1, 0, -1, 0, -1, /* ScrollLock (tested) */
452 /* de 0x92 (146) */ 0, -1, 0, -1, 0, -1, 0, -1,
453 /* de 0x93 (147) */ 0, -1, 0, -1, 0, -1, 0, -1,
454 /* de 0x94 (148) */ 0, -1, 0, -1, 0, -1, 0, -1,
455 /* de 0x95 (149) */ 0, -1, 0, -1, 0, -1, 0, -1,
456 /* de 0x96 (150) */ 0, -1, 0, -1, 0, -1, 0, -1,
457 /* de 0x97 (151) */ 0, -1, 0, -1, 0, -1, 0, -1,
458 /* de 0x98 (152) */ 0, -1, 0, -1, 0, -1, 0, -1,
459 /* de 0x99 (153) */ 0, -1, 0, -1, 0, -1, 0, -1,
460 /* de 0x9a (154) */ 0, -1, 0, -1, 0, -1, 0, -1,
461 /* de 0x9b (155) */ 0, -1, 0, -1, 0, -1, 0, -1,
462 /* de 0x9c (156) */ 0, -1, 0, -1, 0, -1, 0, -1,
463 /* de 0x9d (157) */ 0, -1, 0, -1, 0, -1, 0, -1,
464 /* de 0x9e (158) */ 0, -1, 0, -1, 0, -1, 0, -1,
465 /* de 0x9f (159) */ 0, -1, 0, -1, 0, -1, 0, -1,
466 /* de 0xa0 (160) */ 0, -1, 0, -1, 0, -1, 0, -1,
467 /* de 0xa1 (161) */ 0, -1, 0, -1, 0, -1, 0, -1,
468 /* de 0xa2 (162) */ 0, -1, 0, -1, 0, -1, 0, -1,
469 /* de 0xa3 (163) */ 0, -1, 0, -1, 0, -1, 0, -1,
470 /* de 0xa4 (164) */ 0, -1, 0, -1, 0, -1, 0, -1,
471 /* de 0xa5 (165) */ 0, -1, 0, -1, 0, -1, 0, -1,
472 /* de 0xa6 (166) */ 0, -1, 0, -1, 0, -1, 0, -1,
473 /* de 0xa7 (167) */ 0, -1, 0, -1, 0, -1, 0, -1,
474 /* de 0xa8 (168) */ 0, -1, 0, -1, 0, -1, 0, -1,
475 /* de 0xa9 (169) */ 0, -1, 0, -1, 0, -1, 0, -1,
476 /* de 0xaa (170) */ 0, -1, 0, -1, 0, -1, 0, -1,
477 /* de 0xab (171) */ 0, -1, 0, -1, 0, -1, 0, -1,
478 /* de 0xac (172) */ 0, -1, 0, -1, 0, -1, 0, -1,
479 /* de 0xad (173) */ 0, -1, 0, -1, 0, -1, 0, -1,
480 /* de 0xae (174) */ 0, -1, 0, -1, 0, -1, 0, -1,
481 /* de 0xaf (175) */ 0, -1, 0, -1, 0, -1, 0, -1,
482 /* de 0xb0 (176) */ 0, -1, 0, -1, 0, -1, 0, -1,
483 /* de 0xb1 (177) */ 0, -1, 0, -1, 0, -1, 0, -1,
484 /* de 0xb2 (178) */ 0, -1, 0, -1, 0, -1, 0, -1,
485 /* de 0xb3 (179) */ 0, -1, 0, -1, 0, -1, 0, -1,
486 /* de 0xb4 (180) */ 0, -1, 0, -1, 0, -1, 0, -1,
487 /* de 0xb5 (181) */ 0, -1, 0, -1, 0, -1, 0, -1,
488 /* de 0xb6 (182) */ 0, -1, 0, -1, 0, -1, 0, -1,
489 /* de 0xb7 (183) */ 0, -1, 0, -1, 0, -1, 0, -1,
490 /* de 0xb8 (184) */ 0, -1, 0, -1, 0, -1, 0, -1,
491 /* de 0xb9 (185) */ 0, -1, 0, -1, 0, -1, 0, -1,
492 /* de 0xba (186) */ 1, 25, 0, -1, 0, -1, 0, -1, /* [{ */
493 /* de 0xbb (187) */ 1, 26, 0, -1, 0, -1, 0, -1, /* ]} */
494 /* de 0xbc (188) */ 1, 50, 0, -1, 0, -1, 0, -1, /* COMMA */
495 /* de 0xbd (189) */ 1, 52, 0, -1, 0, -1, 1, 73, /* /? */
496 /* de 0xbe (190) */ 1, 51, 0, -1, 0, -1, 0, -1, /* PERIOD */
497 /* de 0xbf (191) */ 1, 42, 0, -1, 0, -1, 0, -1, /* \| on the right near Enter */
498 /* de 0xc0 (192) */ 1, 38, 0, -1, 0, -1, 0, -1, /* ;: */
499 /* de 0xc1 (193) */ 0, -1, 0, -1, 0, -1, 0, -1,
500 /* de 0xc2 (194) */ 0, -1, 0, -1, 0, -1, 0, -1,
501 /* de 0xc3 (195) */ 0, -1, 0, -1, 0, -1, 0, -1,
502 /* de 0xc4 (196) */ 0, -1, 0, -1, 0, -1, 0, -1,
503 /* de 0xc5 (197) */ 0, -1, 0, -1, 0, -1, 0, -1,
504 /* de 0xc6 (198) */ 0, -1, 0, -1, 0, -1, 0, -1,
505 /* de 0xc7 (199) */ 0, -1, 0, -1, 0, -1, 0, -1,
506 /* de 0xc8 (200) */ 0, -1, 0, -1, 0, -1, 0, -1,
507 /* de 0xc9 (201) */ 0, -1, 0, -1, 0, -1, 0, -1,
508 /* de 0xca (202) */ 0, -1, 0, -1, 0, -1, 0, -1,
509 /* de 0xcb (203) */ 0, -1, 0, -1, 0, -1, 0, -1,
510 /* de 0xcc (204) */ 0, -1, 0, -1, 0, -1, 0, -1,
511 /* de 0xcd (205) */ 0, -1, 0, -1, 0, -1, 0, -1,
512 /* de 0xce (206) */ 0, -1, 0, -1, 0, -1, 0, -1,
513 /* de 0xcf (207) */ 0, -1, 0, -1, 0, -1, 0, -1,
514 /* de 0xd0 (208) */ 0, -1, 0, -1, 0, -1, 0, -1,
515 /* de 0xd1 (209) */ 0, -1, 0, -1, 0, -1, 0, -1,
516 /* de 0xd2 (210) */ 0, -1, 0, -1, 0, -1, 0, -1,
517 /* de 0xd3 (211) */ 0, -1, 0, -1, 0, -1, 0, -1,
518 /* de 0xd4 (212) */ 0, -1, 0, -1, 0, -1, 0, -1,
519 /* de 0xd5 (213) */ 0, -1, 0, -1, 0, -1, 0, -1,
520 /* de 0xd6 (214) */ 0, -1, 0, -1, 0, -1, 0, -1,
521 /* de 0xd7 (215) */ 0, -1, 0, -1, 0, -1, 0, -1,
522 /* de 0xd8 (216) */ 0, -1, 0, -1, 0, -1, 0, -1,
523 /* de 0xd9 (217) */ 0, -1, 0, -1, 0, -1, 0, -1,
524 /* de 0xda (218) */ 0, -1, 0, -1, 0, -1, 0, -1,
525 /* de 0xdb (219) */ 1, 11, 0, -1, 0, -1, 0, -1, /* -_ */
526 /* de 0xdc (220) */ 1, 40, 0, -1, 0, -1, 0, -1, /* `~ on the left of 1 */
527 /* de 0xdd (221) */ 1, 12, 0, -1, 0, -1, 0, -1, /* =+ */
528 /* de 0xde (222) */ 1, 39, 0, -1, 0, -1, 0, -1, /* QUOTE */
529 /* de 0xdf (223) */ 0, -1, 0, -1, 0, -1, 0, -1,
530 /* de 0xe0 (224) */ 0, -1, 0, -1, 0, -1, 0, -1,
531 /* de 0xe1 (225) */ 0, -1, 0, -1, 0, -1, 0, -1,
532 /* de 0xe2 (226) */ 1, 86, 0, -1, 0, -1, 0, -1, /* BACKSLASH near left shift */
533 /* de 0xe3 (227) */ 0, -1, 0, -1, 0, -1, 0, -1,
534 /* de 0xe4 (228) */ 0, -1, 0, -1, 0, -1, 0, -1,
535 /* de 0xe5 (229) */ 0, -1, 0, -1, 0, -1, 0, -1,
536 /* de 0xe6 (230) */ 0, -1, 0, -1, 0, -1, 0, -1,
537 /* de 0xe7 (231) */ 0, -1, 0, -1, 0, -1, 0, -1,
538 /* de 0xe8 (232) */ 0, -1, 0, -1, 0, -1, 0, -1,
539 /* de 0xe9 (233) */ 0, -1, 0, -1, 0, -1, 0, -1,
540 /* de 0xea (234) */ 0, -1, 0, -1, 0, -1, 0, -1,
541 /* de 0xeb (235) */ 0, -1, 0, -1, 0, -1, 0, -1,
542 /* de 0xec (236) */ 0, -1, 0, -1, 0, -1, 0, -1,
543 /* de 0xed (237) */ 0, -1, 0, -1, 0, -1, 0, -1,
544 /* de 0xee (238) */ 0, -1, 0, -1, 0, -1, 0, -1,
545 /* de 0xef (239) */ 0, -1, 0, -1, 0, -1, 0, -1,
546 /* de 0xf0 (240) */ 0, -1, 0, -1, 0, -1, 0, -1,
547 /* de 0xf1 (241) */ 0, -1, 0, -1, 0, -1, 0, -1,
548 /* de 0xf2 (242) */ 0, -1, 0, -1, 0, -1, 0, -1,
549 /* de 0xf3 (243) */ 0, -1, 0, -1, 0, -1, 0, -1,
550 /* de 0xf4 (244) */ 0, -1, 0, -1, 0, -1, 0, -1,
551 /* de 0xf5 (245) */ 0, -1, 0, -1, 0, -1, 0, -1,
552 /* de 0xf6 (246) */ 0, -1, 0, -1, 0, -1, 0, -1,
553 /* de 0xf7 (247) */ 0, -1, 0, -1, 0, -1, 0, -1,
554 /* de 0xf8 (248) */ 0, -1, 0, -1, 0, -1, 0, -1,
555 /* de 0xf9 (249) */ 0, -1, 0, -1, 0, -1, 0, -1,
556 /* de 0xfa (250) */ 0, -1, 0, -1, 0, -1, 0, -1,
557 /* de 0xfb (251) */ 0, -1, 0, -1, 0, -1, 0, -1,
558 /* de 0xfc (252) */ 0, -1, 0, -1, 0, -1, 0, -1,
559 /* de 0xfd (253) */ 0, -1, 0, -1, 0, -1, 0, -1,
560 /* de 0xfe (254) */ 0, -1, 0, -1, 0, -1, 0, -1,
561 /* de 0xff (255) */ 0, -1, 0, -1, 0, -1, 0, -1,
562 ];
563
564 /*
565 * Arrays of scancodes referenced in the keyCodes table by index.
566 */
567 private static const scancodes2:Array =
568 [
569 /* sc US key, index */
570 0xe0, 0x1c, /* (Enter) 0
571 * Note: NumPad Enter produces keyCode 13 and keyLocation 0 just like normal Enter
572 * in Flash here. Make the array element anyway since Flash defines a NUMPAD_ENTER keycode.
573 */
574 0xe0, 0x1d, /* (RCtrl) 1 */
575 0xe0, 0x35, /* (Keypad-/) 2 */
576 0xe0, 0x38, /* (RAlt) 3 @todo intercepted by browser/player. */
577 0xe0, 0x46, /* (Ctrl-Break) 4 */
578 0xe0, 0x47, /* (Grey Home) 5 */
579 0xe0, 0x48, /* (Grey Up) 6 */
580 0xe0, 0x49, /* (Grey PgUp) 7 */
581 0xe0, 0x4b, /* (Grey Left) 8 */
582 0xe0, 0x4d, /* (Grey Right) 9 */
583 0xe0, 0x4f, /* (Grey End) 10 */
584 0xe0, 0x50, /* (Grey Down) 11 */
585 0xe0, 0x51, /* (Grey PgDn) 12 */
586 0xe0, 0x52, /* (Grey Insert) 13 */
587 0xe0, 0x53, /* (Grey Delete) 14 */
588 0xe0, 0x5b, /* (LWin) 15 */
589 0xe0, 0x5c, /* (RWin) 16 */
590 0xe0, 0x5d, /* (Menu) 17 */
591
592
593 ];
594
595 private static const scancodes1:Array =
596 [
597 /* sc, US key,index*/
598 0x01, /* (Esc) 0 */
599 0x02, /* (1!) 1 */
600 0x03, /* (2@) 2 */
601 0x04, /* (3#) 3 */
602 0x05, /* (4$) 4 */
603 0x06, /* (5%) 5 */
604 0x07, /* (6^) 6 */
605 0x08, /* (7&) 7 */
606 0x09, /* (8*) 8 */
607 0x0a, /* (9() 9 */
608 0x0b, /* (0)) 10 */
609 0x0c, /* (-_) 11 */
610 0x0d, /* (=+) 12 */
611 0x0e, /* (Backspace) 13 */
612 0x0f, /* (Tab) 14 */
613 0x10, /* (Q) 15 */
614 0x11, /* (W) 16 */
615 0x12, /* (E) 17 */
616 0x13, /* (R) 18 */
617 0x14, /* (T) 19 */
618 0x15, /* (Y) 20 */
619 0x16, /* (U) 21 */
620 0x17, /* (I) 22 */
621 0x18, /* (O) 23 */
622 0x19, /* (P) 24 */
623 0x1a, /* ([{) 25 */
624 0x1b, /* (]}) 26 */
625 0x1c, /* (Enter) 27 */
626 0x1d, /* (LCtrl) 28 */
627 0x1e, /* (A) 29 */
628 0x1f, /* (S) 30 */
629 0x20, /* (D) 31 */
630 0x21, /* (F) 32 */
631 0x22, /* (G) 33 */
632 0x23, /* (H) 34 */
633 0x24, /* (J) 35 */
634 0x25, /* (K) 36 */
635 0x26, /* (L) 37 */
636 0x27, /* (;:) 38 */
637 0x28, /* ('") 39 */
638 0x29, /* (`~) 40 */
639 0x2a, /* (LShift) 41 */
640 0x2b, /* (\|) 42 */
641 0x2c, /* (Z) 43 */
642 0x2d, /* (X) 44 */
643 0x2e, /* (C) 45 */
644 0x2f, /* (V) 46 */
645 0x30, /* (B) 47 */
646 0x31, /* (N) 48 */
647 0x32, /* (M) 49 */
648 0x33, /* (,<) 50 */
649 0x34, /* (.>) 51 */
650 0x35, /* (/?) 52 */
651 0x36, /* (RShift) 53 */
652 0x37, /* (Keypad-*) 54 */
653 0x38, /* (LAlt) 55 @todo Alt is intercepted by the browser/player */
654 0x39, /* (Space bar) 56 */
655 0x3a, /* (CapsLock) 57 */
656 0x3b, /* (F1) 58 */
657 0x3c, /* (F2) 59 */
658 0x3d, /* (F3) 60 */
659 0x3e, /* (F4) 61 */
660 0x3f, /* (F5) 62 */
661 0x40, /* (F6) 63 */
662 0x41, /* (F7) 64 */
663 0x42, /* (F8) 65 */
664 0x43, /* (F9) 66 */
665 0x44, /* (F10) 67 */
666 0x45, /* (NumLock) 68 */
667 0x46, /* (ScrollLock) 69 */
668 0x47, /* (Keypad-7/Home) 70 */
669 0x48, /* (Keypad-8/Up) 71 */
670 0x49, /* (Keypad-9/PgUp) 72 */
671 0x4a, /* (Keypad--) 73 */
672 0x4b, /* (Keypad-4/Left) 74 */
673 0x4c, /* (Keypad-5) 75 */
674 0x4d, /* (Keypad-6/Right) 76 */
675 0x4e, /* (Keypad-+) 77 */
676 0x4f, /* (Keypad-1/End) 78 */
677 0x50, /* (Keypad-2/Down) 79 */
678 0x51, /* (Keypad-3/PgDn) 80 */
679 0x52, /* (Keypad-0/Ins) 81 */
680 0x53, /* (Keypad-./Del) 82 */
681 0x54, /* (Alt-SysRq) 83 @todo sometimes not passed to flash */
682 0x57, /* (F11) 84 */
683 0x58, /* (F12) 85 */
684 0x56, /* (\|) 86 near Left Shift */
685 ];
686
687 private var mfRightShiftPressed:Boolean;
688
689 public function KeyboardTranslator(aClient:RDPClient)
690 {
691 mClient = aClient;
692
693 mClient.debug().msg("KeyboardTranslator\n");
694
695 mfRightShiftPressed = false;
696
697 /* By default use US keyboard. */
698 SetLayout("en");
699 }
700
701 private function scancode (scancodes:ByteArray, event:KeyboardEvent, keyCodeArray:Array):uint
702 {
703 /* US event -> US scancodes. */
704 if (event.keyCode >= 256)
705 {
706 return 0; /* means: no scancodes, ignore the event. */
707 }
708
709 var keyLocation:uint;
710
711 switch (event.keyLocation)
712 {
713 default:
714 case KeyLocation.STANDARD:
715 keyLocation = 0;
716 break;
717
718 case KeyLocation.LEFT:
719 keyLocation = 1;
720 break;
721
722 case KeyLocation.RIGHT:
723 keyLocation = 2;
724 break;
725
726 case KeyLocation.NUM_PAD:
727 keyLocation = 3;
728 break;
729 }
730
731 var indexKeyRecord:uint = 8 * event.keyCode + 2 * keyLocation;
732
733 var numScancodes:uint = keyCodeArray[indexKeyRecord];
734 var indexScancodes:uint = keyCodeArray[indexKeyRecord + 1];
735
736 if (indexScancodes == -1)
737 {
738 return 0;
739 }
740
741 if (numScancodes == 1)
742 {
743 if (indexScancodes >= scancodes1.length)
744 {
745 return 0;
746 }
747
748 scancodes[0] = scancodes1[indexScancodes];
749 }
750 else if (numScancodes == 2)
751 {
752 if (indexScancodes >= scancodes2.length / 2)
753 {
754 return 0;
755 }
756
757 scancodes[0] = scancodes2[2 * indexScancodes];
758 scancodes[1] = scancodes2[2 * indexScancodes + 1];
759 }
760 else
761 {
762 return 0;
763 }
764
765 /* Successful return, all failures return a 0 above. */
766 return numScancodes;
767 }
768
769 public function Scancode (scancodes:ByteArray, event:KeyboardEvent, pressed:Boolean):uint
770 {
771 /* Convert the event to a scancode sequence of a US keyboard,
772 * because the client claims it is using the US one. Note: it does not
773 * matter for the server because the client will send scancodes, and the
774 * server will translate scancodes to the server keyboard layout.
775 *
776 * Return how many bytes were written to the scancodes array.
777 *
778 * @todo Take into account the current client keyboard layout: Y/Z US/DE?
779 */
780 var numScancodes:uint = scancode (scancodes, event, mKeyCodeTable);
781
782 /* Workaround for Left/Right key mismatch.
783 * Flash for example report the Right-Shift down/up as Right-Shift down + Left-Shift up.
784 */
785 if (numScancodes == 1)
786 {
787 if (scancodes[0] == 0x36) /* RShift */
788 {
789 mfRightShiftPressed = pressed;
790 }
791 else if (scancodes[0] == 0x2a) /* LShift */
792 {
793 if (!pressed && mfRightShiftPressed)
794 {
795 scancodes[0] = 0x36;
796 mfRightShiftPressed = false;
797 }
798 }
799 }
800
801 return numScancodes;
802 }
803
804 public function SupportedLayouts():String
805 {
806 return "en,de";
807 }
808
809 public function CurrentLayout():String
810 {
811 return mCurrentLayout;
812 }
813
814 public function SetLayout(layout:String):void
815 {
816 layout = layout.toLowerCase();
817
818 if (layout == "de")
819 {
820 mKeyCodeTable = keyCodeDE;
821 mCurrentLayout = layout;
822 }
823 else
824 {
825 /* Everything else is EN. */
826 mKeyCodeTable = keyCodeUS;
827 mCurrentLayout = layout;
828 }
829 mClient.debug().msg("KeyboardTranslator: SetLayout req [" + layout + "], set [" + mCurrentLayout + "]\n");
830 return;
831 }
832 }
833}

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy