From 23c0263b3a939c4922e648dff406c430713e89c6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 27 Jan 2010 05:14:22 +0000 Subject: [PATCH] Fixed bug #743 The arrow keys and keypad arrow keys have almost the same scancodes! --- src/video/win32/SDL_vkeys.h | 1 + src/video/win32/SDL_win32events.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/video/win32/SDL_vkeys.h b/src/video/win32/SDL_vkeys.h index e69b925c5..f4b4a2c44 100644 --- a/src/video/win32/SDL_vkeys.h +++ b/src/video/win32/SDL_vkeys.h @@ -73,4 +73,5 @@ #define VK_APOSTROPHE 0xDE #define VK_BACKTICK 0xDF #define VK_OEM_102 0xE2 + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32events.c b/src/video/win32/SDL_win32events.c index f76edc4f7..58033c39c 100644 --- a/src/video/win32/SDL_win32events.c +++ b/src/video/win32/SDL_win32events.c @@ -84,11 +84,16 @@ RemapVKEY(WPARAM wParam, LPARAM lParam) } } - /* 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; + /* Keypad keys are a little trickier, we always scan for them. + Keypad arrow keys have the same scancode as normal arrow keys, + except they don't have the extended bit (0x1000000) set. + */ + if (!(lParam & 0x1000000)) { + for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) { + if (scancode == keypad_scancodes[i]) { + wParam = VK_NUMPAD0 + i; + break; + } } }