comparison src/video/windib/SDL_dibevents.c @ 572:4c740ee76027

Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)
author Sam Lantinga <slouken@libsdl.org>
date Mon, 20 Jan 2003 02:11:07 +0000
parents 2312d983e1fe
children ab0656314eef
comparison
equal deleted inserted replaced
571:8e3ce997621c 572:4c740ee76027
47 #endif 47 #endif
48 48
49 /* The translation table from a Microsoft VK keysym to a SDL keysym */ 49 /* The translation table from a Microsoft VK keysym to a SDL keysym */
50 static SDLKey VK_keymap[SDLK_LAST]; 50 static SDLKey VK_keymap[SDLK_LAST];
51 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed); 51 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed);
52 static BOOL prev_shiftstates[2];
52 53
53 /* Masks for processing the windows KEYDOWN and KEYUP messages */ 54 /* Masks for processing the windows KEYDOWN and KEYUP messages */
54 #define REPEATED_KEYMASK (1<<30) 55 #define REPEATED_KEYMASK (1<<30)
55 #define EXTENDED_KEYMASK (1<<24) 56 #define EXTENDED_KEYMASK (1<<24)
56 57
80 else 81 else
81 wParam = VK_LCONTROL; 82 wParam = VK_LCONTROL;
82 break; 83 break;
83 case VK_SHIFT: 84 case VK_SHIFT:
84 /* EXTENDED trick doesn't work here */ 85 /* EXTENDED trick doesn't work here */
85 if ( GetKeyState(VK_LSHIFT) & 0x8000 ) { 86 if (!prev_shiftstates[0] && (GetKeyState(VK_LSHIFT) & 0x8000)) {
86 wParam = VK_LSHIFT; 87 wParam = VK_LSHIFT;
87 } else if ( GetKeyState(VK_RSHIFT) & 0x8000 ) { 88 prev_shiftstates[0] = TRUE;
89 } else if (!prev_shiftstates[1] && (GetKeyState(VK_RSHIFT) & 0x8000)) {
88 wParam = VK_RSHIFT; 90 wParam = VK_RSHIFT;
91 prev_shiftstates[1] = TRUE;
89 } else { 92 } else {
90 /* Huh? */ 93 /* Huh? */
91 } 94 }
92 break; 95 break;
93 case VK_MENU: 96 case VK_MENU:
133 else 136 else
134 wParam = VK_LCONTROL; 137 wParam = VK_LCONTROL;
135 break; 138 break;
136 case VK_SHIFT: 139 case VK_SHIFT:
137 /* EXTENDED trick doesn't work here */ 140 /* EXTENDED trick doesn't work here */
138 wParam = VK_LSHIFT; 141 if (prev_shiftstates[0] && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
142 wParam = VK_LSHIFT;
143 prev_shiftstates[0] = FALSE;
144 } else if (prev_shiftstates[1] && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
145 wParam = VK_RSHIFT;
146 prev_shiftstates[1] = FALSE;
147 } else {
148 /* Huh? */
149 }
139 break; 150 break;
140 case VK_MENU: 151 case VK_MENU:
141 if ( lParam&EXTENDED_KEYMASK ) 152 if ( lParam&EXTENDED_KEYMASK )
142 wParam = VK_RMENU; 153 wParam = VK_RMENU;
143 else 154 else
309 VK_keymap[VK_PRINT] = SDLK_PRINT; 320 VK_keymap[VK_PRINT] = SDLK_PRINT;
310 #endif 321 #endif
311 VK_keymap[VK_SNAPSHOT] = SDLK_PRINT; 322 VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
312 VK_keymap[VK_CANCEL] = SDLK_BREAK; 323 VK_keymap[VK_CANCEL] = SDLK_BREAK;
313 VK_keymap[VK_APPS] = SDLK_MENU; 324 VK_keymap[VK_APPS] = SDLK_MENU;
325
326 prev_shiftstates[0] = FALSE;
327 prev_shiftstates[1] = FALSE;
314 } 328 }
315 329
316 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed) 330 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed)
317 { 331 {
318 /* Set the keysym information */ 332 /* Set the keysym information */