[Windows] Fixes bug #1555, handle ALT+F4 on Windows

main
Gabriel Jacobo 2013-11-13 11:18:37 -03:00
parent f8e1d350a4
commit 5b8b403e3e
1 changed files with 11 additions and 1 deletions

View File

@ -535,9 +535,19 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_KEYUP:
{
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
/* Detect relevant keyboard shortcuts */
if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED ) {
/* ALT+F4: Close window */
if (code == SDL_SCANCODE_F4) {
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
}
}
if ( code != SDL_SCANCODE_UNKNOWN ) {
if (code == SDL_SCANCODE_PRINTSCREEN &&
SDL_GetKeyboardState(NULL)[code] == SDL_RELEASED) {
keyboardState[code] == SDL_RELEASED) {
SDL_SendKeyboardKey(SDL_PRESSED, code);
}
SDL_SendKeyboardKey(SDL_RELEASED, code);