Mercurial > sdl-ios-xcode
diff src/video/win32/SDL_win32events.c @ 2317:f537a293b3da
Windows also remaps the numeric keypad... grrr
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 11 Feb 2008 21:06:32 +0000 |
parents | 012ec5192dfa |
children | 3202e4826c57 |
line wrap: on
line diff
--- a/src/video/win32/SDL_win32events.c Mon Feb 11 20:26:22 2008 +0000 +++ b/src/video/win32/SDL_win32events.c Mon Feb 11 21:06:32 2008 +0000 @@ -33,8 +33,8 @@ #endif /* Masks for processing the windows KEYDOWN and KEYUP messages */ -#define REPEATED_KEYMASK (1<<30) -#define EXTENDED_KEYMASK (1<<24) +#define REPEATED_KEYMASK (1<<30) +#define EXTENDED_KEYMASK (1<<24) #define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */ @@ -52,13 +52,13 @@ static WPARAM RemapVKEY(WPARAM wParam, LPARAM lParam) { + int i; + BYTE scancode = (BYTE)((lParam >> 16) & 0xFF); + /* Windows remaps alphabetic keys based on current layout. We try to provide USB scancodes, so undo this mapping. */ if (wParam >= 'A' && wParam <= 'Z') { - BYTE scancode = (BYTE)((lParam >> 16) & 0xFF); - int i; - if (scancode != alpha_scancodes[wParam - 'A']) { for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) { if (scancode == alpha_scancodes[i]) { @@ -68,6 +68,15 @@ } } } + + /* Keypad keys are a little trickier, we always scan for them. */ + for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) { + if (scancode == keypad_scancodes[i]) { + wParam = VK_NUMPAD0+i; + break; + } + } + return wParam; }