comparison 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
comparison
equal deleted inserted replaced
2316:5e1f06dc5136 2317:f537a293b3da
31 #include <stdio.h> 31 #include <stdio.h>
32 #include "wmmsg.h" 32 #include "wmmsg.h"
33 #endif 33 #endif
34 34
35 /* Masks for processing the windows KEYDOWN and KEYUP messages */ 35 /* Masks for processing the windows KEYDOWN and KEYUP messages */
36 #define REPEATED_KEYMASK (1<<30) 36 #define REPEATED_KEYMASK (1<<30)
37 #define EXTENDED_KEYMASK (1<<24) 37 #define EXTENDED_KEYMASK (1<<24)
38 38
39 #define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */ 39 #define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */
40 40
41 /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */ 41 /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
42 #ifndef WM_XBUTTONDOWN 42 #ifndef WM_XBUTTONDOWN
50 #endif 50 #endif
51 51
52 static WPARAM 52 static WPARAM
53 RemapVKEY(WPARAM wParam, LPARAM lParam) 53 RemapVKEY(WPARAM wParam, LPARAM lParam)
54 { 54 {
55 int i;
56 BYTE scancode = (BYTE)((lParam >> 16) & 0xFF);
57
55 /* Windows remaps alphabetic keys based on current layout. 58 /* Windows remaps alphabetic keys based on current layout.
56 We try to provide USB scancodes, so undo this mapping. 59 We try to provide USB scancodes, so undo this mapping.
57 */ 60 */
58 if (wParam >= 'A' && wParam <= 'Z') { 61 if (wParam >= 'A' && wParam <= 'Z') {
59 BYTE scancode = (BYTE)((lParam >> 16) & 0xFF);
60 int i;
61
62 if (scancode != alpha_scancodes[wParam - 'A']) { 62 if (scancode != alpha_scancodes[wParam - 'A']) {
63 for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) { 63 for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
64 if (scancode == alpha_scancodes[i]) { 64 if (scancode == alpha_scancodes[i]) {
65 wParam = 'A' + i; 65 wParam = 'A' + i;
66 break; 66 break;
67 } 67 }
68 } 68 }
69 } 69 }
70 } 70 }
71
72 /* Keypad keys are a little trickier, we always scan for them. */
73 for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
74 if (scancode == keypad_scancodes[i]) {
75 wParam = VK_NUMPAD0+i;
76 break;
77 }
78 }
79
71 return wParam; 80 return wParam;
72 } 81 }
73 82
74 LRESULT CALLBACK 83 LRESULT CALLBACK
75 WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 84 WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)