Commit 69b676ff authored by Sam Lantinga's avatar Sam Lantinga

Undo keyboard layout based alphabetic key mapping. Grr.... HACK HACK HACK...

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402722
parent 9533cd16
...@@ -47,6 +47,33 @@ ...@@ -47,6 +47,33 @@
#define GET_XBUTTON_WPARAM(w) (HIWORD(w)) #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
#endif #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 LRESULT CALLBACK
WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
...@@ -310,6 +337,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -310,6 +337,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
} }
index = data->videodata->keyboard; index = data->videodata->keyboard;
wParam = RemapVKEY(wParam, lParam);
switch (wParam) { switch (wParam) {
case VK_CONTROL: case VK_CONTROL:
if (lParam & EXTENDED_KEYMASK) if (lParam & EXTENDED_KEYMASK)
...@@ -353,6 +381,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -353,6 +381,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
int index; int index;
index = data->videodata->keyboard; index = data->videodata->keyboard;
wParam = RemapVKEY(wParam, lParam);
switch (wParam) { switch (wParam) {
case VK_CONTROL: case VK_CONTROL:
if (lParam & EXTENDED_KEYMASK) if (lParam & EXTENDED_KEYMASK)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment