comparison src/video/win32/SDL_win32events.c @ 2311:54e21acfec5a

Friggin' Windows remaps alphabetic keys based on keyboard layout. We try to figure out what the actual layout independent values are.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 09 Feb 2008 22:28:27 +0000
parents 2f31ce8f1149
children bcec4b189f5b
comparison
equal deleted inserted replaced
2310:2f31ce8f1149 2311:54e21acfec5a
52 { 52 {
53 /* Windows remaps alphabetic keys based on current layout. 53 /* Windows remaps alphabetic keys based on current layout.
54 We try to provide USB scancodes, so undo this mapping. 54 We try to provide USB scancodes, so undo this mapping.
55 */ 55 */
56 if (wParam >= 'A' && wParam <= 'Z') { 56 if (wParam >= 'A' && wParam <= 'Z') {
57 /* Alphabetic scancodes for PC keyboards */
58 static BYTE scancodes[26] = {
59 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24,
60 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44
61 };
62 BYTE scancode = (lParam >> 16) & 0xFF; 57 BYTE scancode = (lParam >> 16) & 0xFF;
63 int i; 58 int i;
64 59
65 if (scancode != scancodes[wParam - 'A']) { 60 if (scancode != alpha_scancodes[wParam - 'A']) {
66 for (i = 0; i < SDL_arraysize(scancodes); ++i) { 61 for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
67 if (scancode == scancodes[i]) { 62 if (scancode == alpha_scancodes[i]) {
68 wParam = 'A' + i; 63 wParam = 'A' + i;
69 break; 64 break;
70 } 65 }
71 } 66 }
72 } 67 }
446 } 441 }
447 SDL_SendKeyboardText(data->videodata->keyboard, text); 442 SDL_SendKeyboardText(data->videodata->keyboard, text);
448 } 443 }
449 return (0); 444 return (0);
450 445
446 case WM_INPUTLANGCHANGE:
447 {
448 WIN_UpdateKeymap(data->videodata->keyboard);
449 }
450 return (1);
451
451 case WM_GETMINMAXINFO: 452 case WM_GETMINMAXINFO:
452 { 453 {
453 MINMAXINFO *info; 454 MINMAXINFO *info;
454 RECT size; 455 RECT size;
455 int x, y; 456 int x, y;