Skip to content

Commit

Permalink
Removed WIN_GetKeyboardState().
Browse files Browse the repository at this point in the history
It causes problems on modern Windows, when a player ALT-Tab's out of a window.
When they ALT-Tab back, the keystate gets confused.

Fixes Bugzilla #659.
  • Loading branch information
icculus committed Sep 9, 2011
1 parent 4c1bc1e commit 09980c6
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions src/video/wincommon/SDL_sysevents.c
Expand Up @@ -241,53 +241,6 @@ static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme)
}
#endif /* WM_MOUSELEAVE */

/* Function to retrieve the current keyboard modifiers */
static void WIN_GetKeyboardState(void)
{
#ifndef NO_GETKEYBOARDSTATE
SDLMod state;
BYTE keyboard[256];
Uint8 *kstate = SDL_GetKeyState(NULL);

state = KMOD_NONE;
if ( GetKeyboardState(keyboard) ) {
if ( keyboard[VK_LSHIFT] & 0x80) {
state |= KMOD_LSHIFT;
kstate[SDLK_LSHIFT] = SDL_PRESSED;
}
if ( keyboard[VK_RSHIFT] & 0x80) {
state |= KMOD_RSHIFT;
kstate[SDLK_RSHIFT] = SDL_PRESSED;
}
if ( keyboard[VK_LCONTROL] & 0x80) {
state |= KMOD_LCTRL;
kstate[SDLK_LCTRL] = SDL_PRESSED;
}
if ( keyboard[VK_RCONTROL] & 0x80) {
state |= KMOD_RCTRL;
kstate[SDLK_RCTRL] = SDL_PRESSED;
}
if ( keyboard[VK_LMENU] & 0x80) {
state |= KMOD_LALT;
kstate[SDLK_LALT] = SDL_PRESSED;
}
if ( keyboard[VK_RMENU] & 0x80) {
state |= KMOD_RALT;
kstate[SDLK_RALT] = SDL_PRESSED;
}
if ( keyboard[VK_NUMLOCK] & 0x01) {
state |= KMOD_NUM;
kstate[SDLK_NUMLOCK] = SDL_PRESSED;
}
if ( keyboard[VK_CAPITAL] & 0x01) {
state |= KMOD_CAPS;
kstate[SDLK_CAPSLOCK] = SDL_PRESSED;
}
}
SDL_SetModState(state);
#endif /* !NO_GETKEYBOARDSTATE */
}

/* The main Win32 event handler
DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it
*/
Expand Down Expand Up @@ -337,7 +290,6 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
#endif
posted = SDL_PrivateAppActive(1, appstate);
WIN_GetKeyboardState();
} else {
/* Lose the following states */
appstate = SDL_APPINPUTFOCUS;
Expand Down

0 comments on commit 09980c6

Please sign in to comment.