# HG changeset patch # User Sam Lantinga # Date 1202541518 0 # Node ID 2f31ce8f114927ede44354f464e8a768b49f0596 # Parent 21591ae7355db5f7034f58936068beccbe0af8a1 Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK... diff -r 21591ae7355d -r 2f31ce8f1149 src/video/win32/SDL_win32events.c --- a/src/video/win32/SDL_win32events.c Sat Feb 09 06:47:46 2008 +0000 +++ b/src/video/win32/SDL_win32events.c Sat Feb 09 07:18:38 2008 +0000 @@ -47,6 +47,33 @@ #define GET_XBUTTON_WPARAM(w) (HIWORD(w)) #endif +static WPARAM +RemapVKEY(WPARAM wParam, LPARAM lParam) +{ + /* Windows remaps alphabetic keys based on current layout. + 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]) { + wParam = 'A' + i; + break; + } + } + } + } + return wParam; +} + LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -310,6 +337,7 @@ } index = data->videodata->keyboard; + wParam = RemapVKEY(wParam, lParam); switch (wParam) { case VK_CONTROL: if (lParam & EXTENDED_KEYMASK) @@ -353,6 +381,7 @@ int index; index = data->videodata->keyboard; + wParam = RemapVKEY(wParam, lParam); switch (wParam) { case VK_CONTROL: if (lParam & EXTENDED_KEYMASK)