diff 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
line wrap: on
line diff
--- a/src/video/win32/SDL_win32events.c	Sat Feb 09 07:18:38 2008 +0000
+++ b/src/video/win32/SDL_win32events.c	Sat Feb 09 22:28:27 2008 +0000
@@ -54,17 +54,12 @@
        We try to provide USB scancodes, so undo this mapping.
      */
     if (wParam >= 'A' && wParam <= 'Z') {
-        /* Alphabetic scancodes for PC keyboards */
-        static BYTE scancodes[26] = {
-            30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24,
-            25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44
-        };
         BYTE scancode = (lParam >> 16) & 0xFF;
         int i;
 
-        if (scancode != scancodes[wParam - 'A']) {
-            for (i = 0; i < SDL_arraysize(scancodes); ++i) {
-                if (scancode == scancodes[i]) {
+        if (scancode != alpha_scancodes[wParam - 'A']) {
+            for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
+                if (scancode == alpha_scancodes[i]) {
                     wParam = 'A' + i;
                     break;
                 }
@@ -448,6 +443,12 @@
         }
         return (0);
 
+    case WM_INPUTLANGCHANGE:
+        {
+            WIN_UpdateKeymap(data->videodata->keyboard);
+        }
+        return (1);
+
     case WM_GETMINMAXINFO:
         {
             MINMAXINFO *info;