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 VK_EMPTY, 218 /* - 80 - */ 219 0 220 }; 221 222 ROSDATA VSC_VK extcode0_to_vk[] = { 223 { 0x10, VK_MEDIA_PREV_TRACK | KBDEXT }, 224 { 0x19, VK_MEDIA_NEXT_TRACK | KBDEXT }, 225 { 0x1D, VK_RCONTROL | KBDEXT }, 226 { 0x20, VK_VOLUME_MUTE | KBDEXT }, 227 { 0x21, VK_LAUNCH_APP2 | KBDEXT }, 228 { 0x22, VK_MEDIA_PLAY_PAUSE | KBDEXT }, 229 { 0x24, VK_MEDIA_STOP | KBDEXT }, 230 { 0x2E, VK_VOLUME_DOWN | KBDEXT }, 231 { 0x30, VK_VOLUME_UP | KBDEXT }, 232 { 0x32, VK_BROWSER_HOME | KBDEXT }, 233 { 0x35, VK_DIVIDE | KBDEXT }, 234 { 0x37, VK_SNAPSHOT | KBDEXT }, 235 { 0x38, VK_RMENU | KBDEXT }, 236 { 0x47, VK_HOME | KBDEXT }, 237 { 0x48, VK_UP | KBDEXT }, 238 { 0x49, VK_PRIOR | KBDEXT }, 239 { 0x4B, VK_LEFT | KBDEXT }, 240 { 0x4D, VK_RIGHT | KBDEXT }, 241 { 0x4F, VK_END | KBDEXT }, 242 { 0x50, VK_DOWN | KBDEXT }, 243 { 0x51, VK_NEXT | KBDEXT }, 244 { 0x52, VK_INSERT | KBDEXT }, 245 { 0x53, VK_DELETE | KBDEXT }, 246 { 0x5B, VK_LWIN | KBDEXT }, 247 { 0x5C, VK_RWIN | KBDEXT }, 248 { 0x5D, VK_APPS | KBDEXT }, 249 { 0x5F, VK_SLEEP | KBDEXT }, 250 { 0x65, VK_BROWSER_SEARCH | KBDEXT }, 251 { 0x66, VK_BROWSER_FAVORITES | KBDEXT }, 252 { 0x67, VK_BROWSER_REFRESH | KBDEXT }, 253 { 0x68, VK_BROWSER_STOP | KBDEXT }, 254 { 0x69, VK_BROWSER_FORWARD | KBDEXT }, 255 { 0x6A, VK_BROWSER_BACK | KBDEXT }, 256 { 0x6B, VK_LAUNCH_APP1 | KBDEXT }, 257 { 0x6C, VK_LAUNCH_MAIL | KBDEXT }, 258 { 0x6D, VK_LAUNCH_MEDIA_SELECT | KBDEXT }, 259 { 0x1C, VK_RETURN | KBDEXT }, 260 { 0x46, VK_CANCEL | KBDEXT }, 261 { 0, 0 }, 262 }; 263 264 ROSDATA VSC_VK extcode1_to_vk[] = { 265 { 0x1d, VK_PAUSE }, 266 { 0, 0 }, 267 }; 268 269 ROSDATA VK_TO_BIT modifier_keys[] = { 270 { VK_SHIFT, KBDSHIFT }, 271 { VK_CONTROL, KBDCTRL }, 272 { VK_MENU, KBDALT }, 273 { 0, 0 } 274 }; 275 276 ROSDATA MODIFIERS modifier_bits = { 277 modifier_keys, 278 3, 279 { 0, 1, 2, 3 } /* Modifier bit order, NONE, SHIFT, CTRL, ALT */ 280 }; 281 282 ROSDATA VK_TO_WCHARS2 key_to_chars_2mod[] = { 283 /* Normal vs Shifted */ 284 /* The numbers */ 285 { '1', 0, {'1', '!'} }, 286 /* Ctrl-2 generates NUL */ 287 { '3', 0, {'3', '#'} }, 288 { '4', 0, {'4', '$'} }, 289 { '5', 0, {'5', '%'} }, 290 /* Ctrl-6 generates RS */ 291 { '7', 0, {'7', '&'} }, 292 { '8', 0, {'8', '*'} }, 293 { '9', 0, {'9', '('} }, 294 { '0', 0, {'0', ')'} }, 295 296 /* Specials */ 297 /* Ctrl-_ generates ? */ 298 { VK_OEM_PLUS, 0, {'=', '+'} }, 299 { VK_OEM_1, 0, {PEY_SOFIT, ':'} }, 300 { 'Q', 0, {TAV, '>'} }, 301 { 'W', 0, {TSADI_SOFIT, '<'} }, 302 { VK_OEM_7, CAPLOK, {'\'','W'} }, 303 { VK_OEM_3, 0, {';', '~'} }, 304 { VK_OEM_COMMA, 0, {',', '\"'} }, 305 { VK_OEM_PERIOD, 0, {'.', '?'} }, 306 { VK_OEM_2, CAPLOK, {'/', 'Q'} }, 307 /* Keys that do not have shift states */ 308 { VK_TAB, 0, {'\t','\t'} }, 309 { VK_ADD, 0, {'+', '+'} }, 310 { VK_SUBTRACT,0, {'-', '-'} }, 311 { VK_MULTIPLY,0, {'*', '*'} }, 312 { VK_DIVIDE, 0, {'/', '/'} }, 313 { VK_ESCAPE, 0, {0x1b,0x1b} }, 314 { VK_SPACE, 0, {' ', ' '} }, 315 { 0, 0 } 316 }; 317 318 ROSDATA VK_TO_WCHARS3 key_to_chars_3mod[] = { 319 /* Normal, Shifted, Ctrl */ 320 /* Legacy (telnet-style) ascii escapes */ 321 { VK_OEM_4, 0, {'[', '{', 0x1b /* ESC */} }, 322 { VK_OEM_6, 0, {']', '}', 0x1d /* GS */} }, 323 { VK_OEM_5, 0, {'\\','|', 0x1c /* FS */} }, 324 { VK_RETURN,0, {'\r', '\r', '\n'} }, 325 { 0,0 } 326 }; 327 328 ROSDATA VK_TO_WCHARS4 key_to_chars_4mod[] = { 329 /* Normal, Shifted, Ctrl, C-S-x */ 330 331 /* The alphabet */ 332 { 'A', CAPLOK, {SHIN, 'A', 0x01, 0x01} }, 333 { 'B', CAPLOK, {NUN, 'B', 0x02, 0x02} }, 334 { 'C', CAPLOK, {BET, 'C', 0x03, 0x03} }, 335 { 'D', CAPLOK, {GIMEL, 'D', 0x04, 0x04} }, 336 { 'E', CAPLOK, {QOF, 'E', 0x05, 0x05} }, 337 { 'F', CAPLOK, {KAF, 'F', 0x06, 0x06} }, 338 { 'G', CAPLOK, {AYIN, 'G', 0x07, 0x07} }, 339 { 'H', CAPLOK, {YUD, 'H', 0x08, 0x08} }, 340 { 'I', CAPLOK, {NUN_SOFIT, 'I', 0x09, 0x09} }, 341 { 'J', CAPLOK, {HET, 'J', 0x0a, 0x0a} }, 342 { 'K', CAPLOK, {LAMED, 'K', 0x0b, 0x0b} }, 343 { 'L', CAPLOK, {KAF_SOFIT, 'L', 0x0c, 0x0c} }, 344 { 'M', CAPLOK, {TSADI, 'M', 0x0d, 0x0d} }, 345 { 'N', CAPLOK, {MEM, 'N', 0x0e, 0x0e} }, 346 { 'O', CAPLOK, {MEM_SOFIT, 'O', 0x0f, 0x0f} }, 347 { 'P', CAPLOK, {PEY, 'P', 0x10, 0x10} }, 348 { VK_OEM_2, CAPLOK, {'/', 'Q', 0x11, 0x11} }, 349 { 'R', CAPLOK, {RESH, 'R', 0x12, 0x12} }, 350 { 'S', CAPLOK, {DALET, 'S', 0x13, 0x13} }, 351 { 'T', CAPLOK, {ALEF, 'T', 0x14, 0x14} }, 352 { 'U', CAPLOK, {VAV, 'U', 0x15, 0x15} }, 353 { 'V', CAPLOK, {HEY, 'V', 0x16, 0x16} }, 354 { VK_OEM_7, CAPLOK, {'\'', 'W', 0x17, 0x17} }, 355 { 'X', CAPLOK, {SAMEKH, 'X', 0x18, 0x18} }, 356 { 'Y', CAPLOK, {TET, 'Y', 0x19, 0x19} }, 357 { 'Z', CAPLOK, {ZAYIN, 'Z', 0x1a, 0x1a} }, 358 359 /* Legacy Ascii generators */ 360 { '2', 0, {'2', '@', WCH_NONE, 0} }, 361 { '6', 0, {'6', '^', WCH_NONE, 0x1e /* RS */} }, 362 { VK_OEM_MINUS, 0, {'-', '_', WCH_NONE, 0x1f /* US */} }, 363 { 0, 0 } 364 }; 365 366 ROSDATA VK_TO_WCHARS1 keypad_numbers[] = 367 { 368 { VK_NUMPAD0, 0, {'0'} }, 369 { VK_NUMPAD1, 0, {'1'} }, 370 { VK_NUMPAD2, 0, {'2'} }, 371 { VK_NUMPAD3, 0, {'3'} }, 372 { VK_NUMPAD4, 0, {'4'} }, 373 { VK_NUMPAD5, 0, {'5'} }, 374 { VK_NUMPAD6, 0, {'6'} }, 375 { VK_NUMPAD7, 0, {'7'} }, 376 { VK_NUMPAD8, 0, {'8'} }, 377 { VK_NUMPAD9, 0, {'9'} }, 378 { VK_DECIMAL, 0, {'.'} }, 379 { VK_BACK, 0, {'\010'} }, 380 { 0,0 } 381 }; 382 383 #define vk_master(n,x) { (PVK_TO_WCHARS1)x, n, sizeof(x[0]) } 384 385 ROSDATA VK_TO_WCHAR_TABLE vk_to_wchar_master_table[] = 386 { 387 vk_master(1,keypad_numbers), 388 vk_master(2,key_to_chars_2mod), 389 vk_master(3,key_to_chars_3mod), 390 vk_master(4,key_to_chars_4mod), 391 { 0,0,0 } 392 }; 393 394 ROSDATA VSC_LPWSTR key_names[] = 395 { 396 { 0x00, L"" }, 397 { 0x01, L"Esc" }, 398 { 0x0e, L"Backspace" }, 399 { 0x0f, L"Tab" }, 400 { 0x1c, L"Enter" }, 401 { 0x1d, L"Ctrl" }, 402 { 0x2a, L"Shift" }, 403 { 0x36, L"Right Shift" }, 404 { 0x37, L"Num *" }, 405 { 0x38, L"Alt" }, 406 { 0x39, L"Space" }, 407 { 0x3a, L"CAPLOK Lock" }, 408 { 0x3b, L"F1" }, 409 { 0x3c, L"F2" }, 410 { 0x3d, L"F3" }, 411 { 0x3e, L"F4" }, 412 { 0x3f, L"F5" }, 413 { 0x40, L"F6" }, 414 { 0x41, L"F7" }, 415 { 0x42, L"F8" }, 416 { 0x43, L"F9" }, 417 { 0x44, L"F10" }, 418 { 0x45, L"Pause" }, 419 { 0x46, L"Scroll Lock" }, 420 { 0x47, L"Num 7" }, 421 { 0x48, L"Num 8" }, 422 { 0x49, L"Num 9" }, 423 { 0x4a, L"Num -" }, 424 { 0x4b, L"Num 4" }, 425 { 0x4c, L"Num 5" }, 426 { 0x4d, L"Num 6" }, 427 { 0x4e, L"Num +" }, 428 { 0x4f, L"Num 1" }, 429 { 0x50, L"Num 2" }, 430 { 0x51, L"Num 3" }, 431 { 0x52, L"Num 0" }, 432 { 0x53, L"Num Del" }, 433 { 0x54, L"Sys Req" }, 434 { 0x57, L"F11" }, 435 { 0x58, L"F12" }, 436 { 0x7c, L"F13" }, 437 { 0x7d, L"F14" }, 438 { 0x7e, L"F15" }, 439 { 0x7f, L"F16" }, 440 { 0x80, L"F17" }, 441 { 0x81, L"F18" }, 442 { 0x82, L"F19" }, 443 { 0x83, L"F20" }, 444 { 0x84, L"F21" }, 445 { 0x85, L"F22" }, 446 { 0x86, L"F23" }, 447 { 0x87, L"F24" }, 448 { 0, NULL }, 449 }; 450 451 ROSDATA VSC_LPWSTR extended_key_names[] = 452 { 453 { 0x1c, L"Num Enter" }, 454 { 0x1d, L"Right Ctrl" }, 455 { 0x35, L"Num /" }, 456 { 0x37, L"Prnt Scrn" }, 457 { 0x38, L"Right Alt" }, 458 { 0x45, L"Num Lock" }, 459 { 0x46, L"Break" }, 460 { 0x47, L"Home" }, 461 { 0x48, L"Up" }, 462 { 0x49, L"Page Up" }, 463 { 0x4a, L"Left" }, 464 { 0x4c, L"Center" }, 465 { 0x4d, L"Right" }, 466 { 0x4f, L"End" }, 467 { 0x50, L"Down" }, 468 { 0x51, L"Page Down" }, 469 { 0x52, L"Insert" }, 470 { 0x53, L"Delete" }, 471 { 0x54, L"<ReactOS>" }, 472 { 0x55, L"Help" }, 473 { 0x56, L"Left Windows" }, 474 { 0x5b, L"Right Windows" }, 475 { 0, NULL }, 476 }; 477 478 /* Finally, the master table */ 479 ROSDATA KBDTABLES keyboard_layout_table = 480 { 481 /* modifier assignments */ 482 &modifier_bits, 483 484 /* character from vk tables */ 485 vk_to_wchar_master_table, 486 487 /* diacritical marks -- currently implemented by wine code */ 488 NULL, 489 490 /* Key names */ 491 (VSC_LPWSTR *)key_names, 492 (VSC_LPWSTR *)extended_key_names, 493 NULL, /* Dead key names */ 494 495 /* scan code to virtual key maps */ 496 scancode_to_vk, 497 sizeof(scancode_to_vk) / sizeof(scancode_to_vk[0]), 498 extcode0_to_vk, 499 extcode1_to_vk, 500 501 MAKELONG(0, 1), /* Version 1.0 */ 502 503 /* Ligatures -- The Standard Hebrew Keyboard doesn't have any */ 504 0, 505 0, 506 NULL 507 }; 508 509 PKBDTABLES WINAPI KbdLayerDescriptor(VOID) 510 { 511 return &keyboard_layout_table; 512 } 513 514