Windows also remaps the numeric keypad... grrr
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402729
This commit is contained in:
parent
f520bc7066
commit
1af0c41561
3 changed files with 25 additions and 5 deletions
|
@ -33,8 +33,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Masks for processing the windows KEYDOWN and KEYUP messages */
|
/* Masks for processing the windows KEYDOWN and KEYUP messages */
|
||||||
#define REPEATED_KEYMASK (1<<30)
|
#define REPEATED_KEYMASK (1<<30)
|
||||||
#define EXTENDED_KEYMASK (1<<24)
|
#define EXTENDED_KEYMASK (1<<24)
|
||||||
|
|
||||||
#define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */
|
#define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */
|
||||||
|
|
||||||
|
@ -52,13 +52,13 @@
|
||||||
static WPARAM
|
static WPARAM
|
||||||
RemapVKEY(WPARAM wParam, LPARAM lParam)
|
RemapVKEY(WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
BYTE scancode = (BYTE)((lParam >> 16) & 0xFF);
|
||||||
|
|
||||||
/* Windows remaps alphabetic keys based on current layout.
|
/* Windows remaps alphabetic keys based on current layout.
|
||||||
We try to provide USB scancodes, so undo this mapping.
|
We try to provide USB scancodes, so undo this mapping.
|
||||||
*/
|
*/
|
||||||
if (wParam >= 'A' && wParam <= 'Z') {
|
if (wParam >= 'A' && wParam <= 'Z') {
|
||||||
BYTE scancode = (BYTE)((lParam >> 16) & 0xFF);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (scancode != alpha_scancodes[wParam - 'A']) {
|
if (scancode != alpha_scancodes[wParam - 'A']) {
|
||||||
for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
|
for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
|
||||||
if (scancode == alpha_scancodes[i]) {
|
if (scancode == alpha_scancodes[i]) {
|
||||||
|
@ -68,6 +68,15 @@ 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return wParam;
|
return wParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,9 @@ BYTE alpha_scancodes[26] = {
|
||||||
30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24,
|
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
|
25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44
|
||||||
};
|
};
|
||||||
|
BYTE keypad_scancodes[10] = {
|
||||||
|
82, 79, 80, 81, 75, 76, 77, 71, 72, 73
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
WIN_InitKeyboard(_THIS)
|
WIN_InitKeyboard(_THIS)
|
||||||
|
@ -57,6 +60,13 @@ printf("Fixing alpha scancode map, assuming US QWERTY layout!\nPlease send the f
|
||||||
printf("%d = %d\n", i, alpha_scancodes[i]);
|
printf("%d = %d\n", i, alpha_scancodes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (MapVirtualKey(VK_NUMPAD0, MAPVK_VK_TO_VSC) != keypad_scancodes[0]) {
|
||||||
|
printf("Fixing keypad scancode map!\nPlease send the following 10 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
|
||||||
|
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
|
||||||
|
keypad_scancodes[i] = MapVirtualKey(VK_NUMPAD0+i, MAPVK_VK_TO_VSC);
|
||||||
|
printf("%d = %d\n", i, keypad_scancodes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data->key_layout = win32_scancode_table;
|
data->key_layout = win32_scancode_table;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define _SDL_win32keyboard_h
|
#define _SDL_win32keyboard_h
|
||||||
|
|
||||||
extern BYTE alpha_scancodes[26];
|
extern BYTE alpha_scancodes[26];
|
||||||
|
extern BYTE keypad_scancodes[10];
|
||||||
|
|
||||||
extern void WIN_InitKeyboard(_THIS);
|
extern void WIN_InitKeyboard(_THIS);
|
||||||
extern void WIN_UpdateKeymap(int keyboard);
|
extern void WIN_UpdateKeymap(int keyboard);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue