1 /*
2 * ReactOS Hebrew Keyboard layout
3 * Copyright (C) 2005 - 2013 ReactOS
4 * License: LGPL, see: LGPL.txt
5 * Authors: Royce Mitchell III
6 * Baruch Rutman 2013
7 *
8 * Thanks to: http://www.barcodeman.com/altek/mule/scandoc.php
9 * and http://win.tue.nl/~aeb/linux/kbd/scancodes-1.html
10 */
11
12 #define WIN32_NO_STATUS
13 #include <stdarg.h>
14 #include <windef.h>
15 #include <winuser.h>
16 #include <ndk/kbd.h>
17
18 #ifdef _MSC_VER
19 #ifndef WINAPI
20 #define WINAPI __stdcall
21 #endif
22 #endif//_MSC_VER
23
24 #ifdef _M_IA64
25 #define ROSDATA static __declspec(allocate(".data"))
26 #else
27 #ifdef _MSC_VER
28 #pragma data_seg(".data")
29 #define ROSDATA static
30 #else
31 #define ROSDATA static __attribute__((section(".data")))
32 #endif
33 #endif
34
35 #define VK_EMPTY 0xff /* The non-existent VK */
36
37 #define KNUMS KBDNUMPAD|KBDSPECIAL /* Special + number pad */
38 #define KMEXT KBDEXT|KBDMULTIVK /* Multi + ext */
39
40 enum
41 {
42 // vowels, etc
43 SHEVA = 0x5B0,
44 HATAF_SEGOL,
45 HATAF_PATAH,
46 HATAF_QAMATS,
47 HIRIQ,
48 TSERE,
49 SEGOL,
50 PATAH,
51 QAMATS,
52 HOLAM,
53 QUBUTS = 0x5BB,
54 DAGESH,
55 MAPIQ = DAGESH,
56 METEG,
57 MAQAF,
58 RAFE,
59 PASEQ,
60 SHIN_DOT,
61 SIN_DOT,
62 SOF_PASUQ,
63 YIDDISH_DOUBLE_VAV = 0x5F0,
64 YIDDISH_VAV_YUD,
65 YIDDISH_DOUBLE_YUD,
66 GERESH,
67 GERSHAYIM,
68
69 // consonants
70 ALEF = 0x5D0,
71 BET,
72 GIMEL,
73 DALET,
74 HEY,
75 VAV,
76 ZAYIN,
77 HET,
78 TET,
79 YUD,
80 KAF_SOFIT,
81 KAF,
82 LAMED,
83 MEM_SOFIT,
84 MEM,
85 NUN_SOFIT,
86 NUN,
87 SAMEKH,
88 AYIN,
89 PEY_SOFIT,
90 PEY,
91 TSADI_SOFIT,
92 TSADI,
93 QOF,
94 RESH,
95 SHIN,
96 TAV,
97
98 // symbols
99 SHEQEL = 0x20AA
100 };
101
102 ROSDATA USHORT scancode_to_vk[] =
103 {
104 /* Numbers Row */
105
106 /* - 00 - */
107 VK_EMPTY, // 00: ?
108 VK_ESCAPE, // 01: esc
109 '1', // 02: '1'
110 '2', // 03: '2'
111 '3', // 04: '3'
112 '4', // 05: '4'
113 '5', // 06: '5'
114 '6', // 07: '6'
115 '7', // 08: '7'
116 '8', // 09: '8'
117 '9', // 0A: '9'
118 '0', // 0B: '0'
119 VK_OEM_MINUS, // 0C: '-'
120 VK_OEM_PLUS, // OD: '+'
121 VK_BACK, // OE: backspace
122
123 /* - 0f - */
124 /* First Letters Row */
125 VK_TAB, // 0F: tab
126 VK_OEM_2, // 10: 'Q'
127 VK_OEM_7, // 11: 'W'
128 'E', // 12: 'E'
129 'R', // 13: 'R'
130 'T', // 14: 'T'
131 'Y', // 15: 'Y'
132 'U', // 16: 'U'
133 'I', // 17: 'I'
134 'O', // 18: 'O'
135 'P', // 19: 'P'
136 VK_OEM_4, // 1A: '{'
137 VK_OEM_6, // 1B: '}'
138 VK_RETURN, // 1C: enter
139
140 /* - 1d - */
141 /* Second Letters Row */
142 VK_LCONTROL, // 1D: lctrl
143 'A', // 1E: 'A'
144 'S', // 1F: 'S'
145 'D', // 20: 'D'
146 'F', // 21: 'F'
147 'G', // 22: 'G'
148 'H', // 23: 'H'
149 'J', // 24: 'J'
150 'K', // 25: 'K'
151 'L', // 26: 'L'
152 VK_OEM_1, // 27: ';'
153 VK_OEM_COMMA, // 28: '\''
154 VK_OEM_3, // 29: ?
155 VK_LSHIFT, // 2A: lshift
156 VK_OEM_5, // 2B: ?
157
158 /* - 2c - */
159 /* Third letters row */
160 'Z', // 2C: 'Z'
161 'X', // 2D: 'X'
162 'C', // 2E: 'C'
163 'V', // 2F: 'V'
164 'B', // 30: 'B'
165 'N', // 31: 'N'
166 'M', // 32: 'M'
167 'Q', // 33: ','
168 'W', // 34: '.'
169 VK_OEM_PERIOD,// 35: '/'
170 VK_RSHIFT, // 36: rshift
171 /* - 37 - */
172 /* Bottom Row */
173 VK_MULTIPLY, // 37: ?
174 VK_LMENU, // 38: lalt
175 VK_SPACE, // 39: space
176 VK_CAPITAL, // 3A: CAPLOK lock?
177
178 /* - 3b - */
179 /* F-Keys */
180 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
181 VK_F7, VK_F8, VK_F9, VK_F10,
182 /* - 45 - */
183 /* Locks */
184 VK_NUMLOCK | KMEXT,
185 VK_SCROLL | KBDMULTIVK,
186 /* - 47 - */
187 /* Number-Pad */
188 VK_HOME | KNUMS, VK_UP | KNUMS, VK_PRIOR | KNUMS, VK_SUBTRACT,
189 VK_LEFT | KNUMS, VK_CLEAR | KNUMS, VK_RIGHT | KNUMS, VK_ADD,
190 VK_END | KNUMS, VK_DOWN | KNUMS, VK_NEXT | KNUMS,
191 VK_INSERT | KNUMS, VK_DELETE | KNUMS,
192 /* - 54 - */
193 /* Presumably PrtSc */
194 VK_SNAPSHOT,
195 /* - 55 - */
196 /* Oddities, and the remaining standard F-Keys */
197 VK_EMPTY, VK_EMPTY, VK_F11, VK_F12,
198 /* - 59 - */
199 VK_CLEAR, VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, /* EREOF */
200 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, /* ZOOM */
201 VK_HELP,
202 /* - 64 - */
203 /* Even more F-Keys (for example, NCR keyboards from the early 90's) */
204 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18, VK_F19, VK_F20,
205 VK_F21, VK_F22, VK_F23,
206 /* - 6f - */
207 /* Not sure who uses these codes */
208 VK_EMPTY, VK_EMPTY, VK_EMPTY,
209 /* - 72 - */
210 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY,
211 /* - 76 - */
212 /* One more f-key */
213 VK_F24,
214 /* - 77 - */
215 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY,
216 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, /* PA1 */
217 };
218
219 ROSDATA VSC_VK extcode0_to_vk[] = {
220 { 0x10, VK_MEDIA_PREV_TRACK | KBDEXT },
221 { 0x19, VK_MEDIA_NEXT_TRACK | KBDEXT },
222 { 0x1D, VK_RCONTROL | KBDEXT },
223 { 0x20, VK_VOLUME_MUTE | KBDEXT },
224 { 0x21, VK_LAUNCH_APP2 | KBDEXT },
225 { 0x22, VK_MEDIA_PLAY_PAUSE | KBDEXT },
226 { 0x24, VK_MEDIA_STOP | KBDEXT },
227 { 0x2E, VK_VOLUME_DOWN | KBDEXT },
228 { 0x30, VK_VOLUME_UP | KBDEXT },
229 { 0x32, VK_BROWSER_HOME | KBDEXT },
230 { 0x35, VK_DIVIDE | KBDEXT },
231 { 0x37, VK_SNAPSHOT | KBDEXT },
232 { 0x38, VK_RMENU | KBDEXT },
233 { 0x47, VK_HOME | KBDEXT },
234 { 0x48, VK_UP | KBDEXT },
235 { 0x49, VK_PRIOR | KBDEXT },
236 { 0x4B, VK_LEFT | KBDEXT },
237 { 0x4D, VK_RIGHT | KBDEXT },
238 { 0x4F, VK_END | KBDEXT },
239 { 0x50, VK_DOWN | KBDEXT },
240 { 0x51, VK_NEXT | KBDEXT },
241 { 0x52, VK_INSERT | KBDEXT },
242 { 0x53, VK_DELETE | KBDEXT },
243 { 0x5B, VK_LWIN | KBDEXT },
244 { 0x5C, VK_RWIN | KBDEXT },
245 { 0x5D, VK_APPS | KBDEXT },
246 { 0x5F, VK_SLEEP | KBDEXT },
247 { 0x65, VK_BROWSER_SEARCH | KBDEXT },
248 { 0x66, VK_BROWSER_FAVORITES | KBDEXT },
249 { 0x67, VK_BROWSER_REFRESH | KBDEXT },
250 { 0x68, VK_BROWSER_STOP | KBDEXT },
251 { 0x69, VK_BROWSER_FORWARD | KBDEXT },
252 { 0x6A, VK_BROWSER_BACK | KBDEXT },
253 { 0x6B, VK_LAUNCH_APP1 | KBDEXT },
254 { 0x6C, VK_LAUNCH_MAIL | KBDEXT },
255 { 0x6D, VK_LAUNCH_MEDIA_SELECT | KBDEXT },
256 { 0x1C, VK_RETURN | KBDEXT },
257 { 0x46, VK_CANCEL | KBDEXT },
258 { 0, 0 },
259 };
260
261 ROSDATA VSC_VK extcode1_to_vk[] = {
262 { 0x1d, VK_PAUSE },
263 { 0, 0 },
264 };
265
266 ROSDATA VK_TO_BIT modifier_keys[] = {
267 { VK_SHIFT, KBDSHIFT },
268 { VK_CONTROL, KBDCTRL },
269 { VK_MENU, KBDALT },
270 { 0, 0 }
271 };
272
273 ROSDATA MODIFIERS modifier_bits = {
274 modifier_keys,
275 3,
276 { 0, 1, 2, 3 } /* Modifier bit order, NONE, SHIFT, CTRL, ALT */
277 };
278
279 ROSDATA VK_TO_WCHARS2 key_to_chars_2mod[] = {
280 /* Normal vs Shifted */
281 /* The numbers */
282 { '1', 0, {'1', '!'} },
283 /* Ctrl-2 generates NUL */
284 { '3', 0, {'3', '#'} },
285 { '4', 0, {'4', '$'} },
286 { '5', 0, {'5', '%'} },
287 /* Ctrl-6 generates RS */
288 { '7', 0, {'7', '&'} },
289 { '8', 0, {'8', '*'} },
290 { '9', 0, {'9', '('} },
291 { '0', 0, {'0', ')'} },
292
293 /* Specials */
294 /* Ctrl-_ generates ? */
295 { VK_OEM_PLUS, 0, {'=', '+'} },
296 { VK_OEM_1, 0, {PEY_SOFIT, ':'} },
297 { 'Q', 0, {TAV, '>'} },
298 { 'W', 0, {TSADI_SOFIT, '<'} },
299 { VK_OEM_7, CAPLOK, {'\'','W'} },
300 { VK_OEM_3, 0, {';', '~'} },
301 { VK_OEM_COMMA, 0, {',', '\"'} },
302 { VK_OEM_PERIOD, 0, {'.', '?'} },
303 { VK_OEM_2, CAPLOK, {'/', 'Q'} },
304 /* Keys that do not have shift states */
305 { VK_TAB, 0, {'\t','\t'} },
306 { VK_ADD, 0, {'+', '+'} },
307 { VK_SUBTRACT,0, {'-', '-'} },
308 { VK_MULTIPLY,0, {'*', '*'} },
309 { VK_DIVIDE, 0, {'/', '/'} },
310 { VK_ESCAPE, 0, {0x1b,0x1b} },
311 { VK_SPACE, 0, {' ', ' '} },
312 { 0, 0 }
313 };
314
315 ROSDATA VK_TO_WCHARS3 key_to_chars_3mod[] = {
316 /* Normal, Shifted, Ctrl */
317 /* Legacy (telnet-style) ascii escapes */
318 { VK_OEM_4, 0, {'[', '{', 0x1b /* ESC */} },
319 { VK_OEM_6, 0, {']', '}', 0x1d /* GS */} },
320 { VK_OEM_5, 0, {'\\','|', 0x1c /* FS */} },
321 { VK_RETURN,0, {'\r', '\r', '\n'} },
322 { 0,0 }
323 };
324
325 ROSDATA VK_TO_WCHARS4 key_to_chars_4mod[] = {
326 /* Normal, Shifted, Ctrl, C-S-x */
327
328 /* The alphabet */
329 { 'A', CAPLOK, {SHIN, 'A', 0x01, 0x01} },
330 { 'B', CAPLOK, {NUN, 'B', 0x02, 0x02} },
331 { 'C', CAPLOK, {BET, 'C', 0x03, 0x03} },
332 { 'D', CAPLOK, {GIMEL, 'D', 0x04, 0x04} },
333 { 'E', CAPLOK, {QOF, 'E', 0x05, 0x05} },
334 { 'F', CAPLOK, {KAF, 'F', 0x06, 0x06} },
335 { 'G', CAPLOK, {AYIN, 'G', 0x07, 0x07} },
336 { 'H', CAPLOK, {YUD, 'H', 0x08, 0x08} },
337 { 'I', CAPLOK, {NUN_SOFIT, 'I', 0x09, 0x09} },
338 { 'J', CAPLOK, {HET, 'J', 0x0a, 0x0a} },
339 { 'K', CAPLOK, {LAMED, 'K', 0x0b, 0x0b} },
340 { 'L', CAPLOK, {KAF_SOFIT, 'L', 0x0c, 0x0c} },
341 { 'M', CAPLOK, {TSADI, 'M', 0x0d, 0x0d} },
342 { 'N', CAPLOK, {MEM, 'N', 0x0e, 0x0e} },
343 { 'O', CAPLOK, {MEM_SOFIT, 'O', 0x0f, 0x0f} },
344 { 'P', CAPLOK, {PEY, 'P', 0x10, 0x10} },
345 { VK_OEM_2, CAPLOK, {'/', 'Q', 0x11, 0x11} },
346 { 'R', CAPLOK, {RESH, 'R', 0x12, 0x12} },
347 { 'S', CAPLOK, {DALET, 'S', 0x13, 0x13} },
348 { 'T', CAPLOK, {ALEF, 'T', 0x14, 0x14} },
349 { 'U', CAPLOK, {VAV, 'U', 0x15, 0x15} },
350 { 'V', CAPLOK, {HEY, 'V', 0x16, 0x16} },
351 { VK_OEM_7, CAPLOK, {'\'', 'W', 0x17, 0x17} },
352 { 'X', CAPLOK, {SAMEKH, 'X', 0x18, 0x18} },
353 { 'Y', CAPLOK, {TET, 'Y', 0x19, 0x19} },
354 { 'Z', CAPLOK, {ZAYIN, 'Z', 0x1a, 0x1a} },
355
356 /* Legacy Ascii generators */
357 { '2', 0, {'2', '@', WCH_NONE, 0} },
358 { '6', 0, {'6', '^', WCH_NONE, 0x1e /* RS */} },
359 { VK_OEM_MINUS, 0, {'-', '_', WCH_NONE, 0x1f /* US */} },
360 { 0, 0 }
361 };
362
363 ROSDATA VK_TO_WCHARS1 keypad_numbers[] =
364 {
365 { VK_NUMPAD0, 0, {'0'} },
366 { VK_NUMPAD1, 0, {'1'} },
367 { VK_NUMPAD2, 0, {'2'} },
368 { VK_NUMPAD3, 0, {'3'} },
369 { VK_NUMPAD4, 0, {'4'} },
370 { VK_NUMPAD5, 0, {'5'} },
371 { VK_NUMPAD6, 0, {'6'} },
372 { VK_NUMPAD7, 0, {'7'} },
373 { VK_NUMPAD8, 0, {'8'} },
374 { VK_NUMPAD9, 0, {'9'} },
375 { VK_DECIMAL, 0, {'.'} },
376 { VK_BACK, 0, {'\010'} },
377 { 0,0 }
378 };
379
380 #define vk_master(n,x) { (PVK_TO_WCHARS1)x, n, sizeof(x[0]) }
381
382 ROSDATA VK_TO_WCHAR_TABLE vk_to_wchar_master_table[] =
383 {
384 vk_master(1,keypad_numbers),
385 vk_master(2,key_to_chars_2mod),
386 vk_master(3,key_to_chars_3mod),
387 vk_master(4,key_to_chars_4mod),
388 { 0,0,0 }
389 };
390
391 ROSDATA VSC_LPWSTR key_names[] =
392 {
393 { 0x00, L"" },
394 { 0x01, L"Esc" },
395 { 0x0e, L"Backspace" },
396 { 0x0f, L"Tab" },
397 { 0x1c, L"Enter" },
398 { 0x1d, L"Ctrl" },
399 { 0x2a, L"Shift" },
400 { 0x36, L"Right Shift" },
401 { 0x37, L"Num *" },
402 { 0x38, L"Alt" },
403 { 0x39, L"Space" },
404 { 0x3a, L"CAPLOK Lock" },
405 { 0x3b, L"F1" },
406 { 0x3c, L"F2" },
407 { 0x3d, L"F3" },
408 { 0x3e, L"F4" },
409 { 0x3f, L"F5" },
410 { 0x40, L"F6" },
411 { 0x41, L"F7" },
412 { 0x42, L"F8" },
413 { 0x43, L"F9" },
414 { 0x44, L"F10" },
415 { 0x45, L"Pause" },
416 { 0x46, L"Scroll Lock" },
417 { 0x47, L"Num 7" },
418 { 0x48, L"Num 8" },
419 { 0x49, L"Num 9" },
420 { 0x4a, L"Num -" },
421 { 0x4b, L"Num 4" },
422 { 0x4c, L"Num 5" },
423 { 0x4d, L"Num 6" },
424 { 0x4e, L"Num +" },
425 { 0x4f, L"Num 1" },
426 { 0x50, L"Num 2" },
427 { 0x51, L"Num 3" },
428 { 0x52, L"Num 0" },
429 { 0x53, L"Num Del" },
430 { 0x54, L"Sys Req" },
431 { 0x57, L"F11" },
432 { 0x58, L"F12" },
433 { 0x7c, L"F13" },
434 { 0x7d, L"F14" },
435 { 0x7e, L"F15" },
436 { 0x7f, L"F16" },
437 { 0x80, L"F17" },
438 { 0x81, L"F18" },
439 { 0x82, L"F19" },
440 { 0x83, L"F20" },
441 { 0x84, L"F21" },
442 { 0x85, L"F22" },
443 { 0x86, L"F23" },
444 { 0x87, L"F24" },
445 { 0, NULL },
446 };
447
448 ROSDATA VSC_LPWSTR extended_key_names[] =
449 {
450 { 0x1c, L"Num Enter" },
451 { 0x1d, L"Right Ctrl" },
452 { 0x35, L"Num /" },
453 { 0x37, L"Prnt Scrn" },
454 { 0x38, L"Right Alt" },
455 { 0x45, L"Num Lock" },
456 { 0x46, L"Break" },
457 { 0x47, L"Home" },
458 { 0x48, L"Up" },
459 { 0x49, L"Page Up" },
460 { 0x4b, L"Left" },
461 { 0x4c, L"Center" },
462 { 0x4d, L"Right" },
463 { 0x4f, L"End" },
464 { 0x50, L"Down" },
465 { 0x51, L"Page Down" },
466 { 0x52, L"Insert" },
467 { 0x53, L"Delete" },
468 { 0x54, L"<ReactOS>" },
469 { 0x55, L"Help" },
470 { 0x56, L"Left Windows" },
471 { 0x5b, L"Right Windows" },
472 { 0, NULL },
473 };
474
475 /* Finally, the master table */
476 ROSDATA KBDTABLES keyboard_layout_table =
477 {
478 /* modifier assignments */
479 &modifier_bits,
480
481 /* character from vk tables */
482 vk_to_wchar_master_table,
483
484 /* diacritical marks -- currently implemented by wine code */
485 NULL,
486
487 /* Key names */
488 (VSC_LPWSTR *)key_names,
489 (VSC_LPWSTR *)extended_key_names,
490 NULL, /* Dead key names */
491
492 /* scan code to virtual key maps */
493 scancode_to_vk,
494 RTL_NUMBER_OF(scancode_to_vk),
495 extcode0_to_vk,
496 extcode1_to_vk,
497
498 MAKELONG(0, 1), /* Version 1.0 */
499
500 /* Ligatures -- The Standard Hebrew Keyboard doesn't have any */
501 0,
502 0,
503 NULL
504 };
505
KbdLayerDescriptor(VOID)506 PKBDTABLES WINAPI KbdLayerDescriptor(VOID)
507 {
508 return &keyboard_layout_table;
509 }
510
511