Skip to content

Commit

Permalink
Mike Nordell _really_ fixed Win32 windib shift state handling this ti…
Browse files Browse the repository at this point in the history
…me. :)
  • Loading branch information
slouken committed Jan 20, 2003
1 parent 008323b commit e7ecfd8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/video/windib/SDL_dibevents.c
Expand Up @@ -49,6 +49,7 @@ static char rcsid =
/* 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)
Expand Down Expand Up @@ -82,10 +83,12 @@ LONG
break;
case VK_SHIFT:
/* EXTENDED trick doesn't work here */
if ( GetKeyState(VK_LSHIFT) & 0x8000 ) {
if (!prev_shiftstates[0] && (GetKeyState(VK_LSHIFT) & 0x8000)) {
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;
prev_shiftstates[1] = TRUE;
} else {
/* Huh? */
}
Expand Down Expand Up @@ -135,7 +138,15 @@ LONG
break;
case VK_SHIFT:
/* 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;
case VK_MENU:
if ( lParam&EXTENDED_KEYMASK )
Expand Down Expand Up @@ -311,6 +322,9 @@ void DIB_InitOSKeymap(_THIS)
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)
Expand Down

0 comments on commit e7ecfd8

Please sign in to comment.