Commit 7670ddcd authored by Sam Lantinga's avatar Sam Lantinga

Mike Nordell _really_ fixed Win32 windib shift state handling this time. :)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40573
parent 97c81738
...@@ -49,6 +49,7 @@ static char rcsid = ...@@ -49,6 +49,7 @@ static char rcsid =
/* The translation table from a Microsoft VK keysym to a SDL keysym */ /* The translation table from a Microsoft VK keysym to a SDL keysym */
static SDLKey VK_keymap[SDLK_LAST]; static SDLKey VK_keymap[SDLK_LAST];
static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed); 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 */ /* Masks for processing the windows KEYDOWN and KEYUP messages */
#define REPEATED_KEYMASK (1<<30) #define REPEATED_KEYMASK (1<<30)
...@@ -82,10 +83,12 @@ LONG ...@@ -82,10 +83,12 @@ LONG
break; break;
case VK_SHIFT: case VK_SHIFT:
/* EXTENDED trick doesn't work here */ /* EXTENDED trick doesn't work here */
if ( GetKeyState(VK_LSHIFT) & 0x8000 ) { if (!prev_shiftstates[0] && (GetKeyState(VK_LSHIFT) & 0x8000)) {
wParam = VK_LSHIFT; wParam = VK_LSHIFT;
} else if ( GetKeyState(VK_RSHIFT) & 0x8000 ) { prev_shiftstates[0] = TRUE;
} else if (!prev_shiftstates[1] && (GetKeyState(VK_RSHIFT) & 0x8000)) {
wParam = VK_RSHIFT; wParam = VK_RSHIFT;
prev_shiftstates[1] = TRUE;
} else { } else {
/* Huh? */ /* Huh? */
} }
...@@ -135,7 +138,15 @@ LONG ...@@ -135,7 +138,15 @@ LONG
break; break;
case VK_SHIFT: case VK_SHIFT:
/* EXTENDED trick doesn't work here */ /* EXTENDED trick doesn't work here */
wParam = VK_LSHIFT; if (prev_shiftstates[0] && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
wParam = VK_LSHIFT;
prev_shiftstates[0] = FALSE;
} else if (prev_shiftstates[1] && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
wParam = VK_RSHIFT;
prev_shiftstates[1] = FALSE;
} else {
/* Huh? */
}
break; break;
case VK_MENU: case VK_MENU:
if ( lParam&EXTENDED_KEYMASK ) if ( lParam&EXTENDED_KEYMASK )
...@@ -311,6 +322,9 @@ void DIB_InitOSKeymap(_THIS) ...@@ -311,6 +322,9 @@ void DIB_InitOSKeymap(_THIS)
VK_keymap[VK_SNAPSHOT] = SDLK_PRINT; VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
VK_keymap[VK_CANCEL] = SDLK_BREAK; VK_keymap[VK_CANCEL] = SDLK_BREAK;
VK_keymap[VK_APPS] = SDLK_MENU; 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) static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment