src/video/windib/SDL_dibevents.c
changeset 1282 217f5d5a49e5
parent 1280 f61f045343d3
child 1288 ea3888b472bf
--- a/src/video/windib/SDL_dibevents.c	Sun Jan 29 06:40:13 2006 +0000
+++ b/src/video/windib/SDL_dibevents.c	Sun Jan 29 07:57:13 2006 +0000
@@ -49,7 +49,6 @@
 /* The translation table from a Microsoft VK keysym to a SDL keysym */
 static SDLKey VK_keymap[SDLK_LAST];
 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed);
-static BOOL prev_shiftstates[2];
 
 /* Masks for processing the windows KEYDOWN and KEYUP messages */
 #define REPEATED_KEYMASK	(1<<30)
@@ -117,14 +116,16 @@
 					break;
 				case VK_SHIFT:
 					/* EXTENDED trick doesn't work here */
-					if (!prev_shiftstates[0] && (GetKeyState(VK_LSHIFT) & 0x8000)) {
+					{
+					Uint8 *state = SDL_GetKeyState(NULL);
+					if (state[SDLK_LSHIFT] == SDL_RELEASED && (GetKeyState(VK_LSHIFT) & 0x8000)) {
 						wParam = VK_LSHIFT;
-						prev_shiftstates[0] = TRUE;
-					} else if (!prev_shiftstates[1] && (GetKeyState(VK_RSHIFT) & 0x8000)) {
+					} else if (state[SDLK_RSHIFT] == SDL_RELEASED && (GetKeyState(VK_RSHIFT) & 0x8000)) {
 						wParam = VK_RSHIFT;
-						prev_shiftstates[1] = TRUE;
 					} else {
-						/* Huh? */
+						/* Probably a key repeat */
+						return(0);
+					}
 					}
 					break;
 				case VK_MENU:
@@ -178,14 +179,16 @@
 					break;
 				case VK_SHIFT:
 					/* EXTENDED trick doesn't work here */
-					if (prev_shiftstates[0] && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
+					{
+					Uint8 *state = SDL_GetKeyState(NULL);
+					if (state[SDLK_LSHIFT] == SDL_PRESSED && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
 						wParam = VK_LSHIFT;
-						prev_shiftstates[0] = FALSE;
-					} else if (prev_shiftstates[1] && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
+					} else if (state[SDLK_RSHIFT] == SDL_PRESSED && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
 						wParam = VK_RSHIFT;
-						prev_shiftstates[1] = FALSE;
 					} else {
-						/* Huh? */
+						/* Probably a key repeat */
+						return(0);
+					}
 					}
 					break;
 				case VK_MENU:
@@ -372,9 +375,6 @@
 	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
 	VK_keymap[VK_CANCEL] = SDLK_BREAK;
 	VK_keymap[VK_APPS] = SDLK_MENU;
-
-	prev_shiftstates[0] = FALSE;
-	prev_shiftstates[1] = FALSE;
 }
 
 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed)