From e2d1fc598f554120982b540d0ff602087734e954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Wed, 11 Feb 2009 22:16:05 +0000 Subject: [PATCH] prevent stuck keys when exiting the mapper, due to the mapper event preceding the addkey one (thanks to etillite, see sf bug #2581983 and posted patch) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3301 --- src/gui/sdl_gui.cpp | 8 ++++---- src/gui/sdl_mapper.cpp | 10 ++++------ src/gui/sdlmain.cpp | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/gui/sdl_gui.cpp b/src/gui/sdl_gui.cpp index 4ad029fc..775c7637 100644 --- a/src/gui/sdl_gui.cpp +++ b/src/gui/sdl_gui.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2008 The DOSBox Team + * Copyright (C) 2002-2009 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: sdl_gui.cpp,v 1.9 2009-02-01 16:06:26 qbix79 Exp $ */ +/* $Id: sdl_gui.cpp,v 1.10 2009-02-11 22:16:05 c2woody Exp $ */ #if 0 #include "SDL.h" @@ -561,7 +561,7 @@ public: running = false; } else if (arg == "Keyboard") { UI_Shutdown(dynamic_cast(getScreen())); - MAPPER_Run(true); + MAPPER_Run(false); UI_Startup(dynamic_cast(getScreen())); } else if (sname == "autoexec") { Section_line *section = static_cast(control->GetSection((const char *)sname)); @@ -629,4 +629,4 @@ void UI_Run(bool pressed) { UI_Shutdown(screen); delete screen; } -#endif \ No newline at end of file +#endif diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index 8a787ea2..949487b1 100644 --- a/src/gui/sdl_mapper.cpp +++ b/src/gui/sdl_mapper.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: sdl_mapper.cpp,v 1.56 2009-02-01 16:05:28 qbix79 Exp $ */ +/* $Id: sdl_mapper.cpp,v 1.57 2009-02-11 22:16:05 c2woody Exp $ */ #include #include @@ -2268,12 +2268,10 @@ void MAPPER_LosingFocus(void) { } void MAPPER_Run(bool pressed) { - if (!pressed) + if (pressed) return; - /* Deactive all running binds */ - for (CEventVector_it evit=events.begin();evit!=events.end();evit++) { - (*evit)->DeActivateAll(); - } + KEYBOARD_ClrBuffer(); //Clear buffer + GFX_LosingFocus(); //Release any keys pressed (buffer gets filled again). int cursor = SDL_ShowCursor(SDL_QUERY); SDL_ShowCursor(SDL_ENABLE); diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 6e49c917..951cc7dc 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2008 The DOSBox Team + * Copyright (C) 2002-2009 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: sdlmain.cpp,v 1.148 2009-02-01 16:32:33 qbix79 Exp $ */ +/* $Id: sdlmain.cpp,v 1.149 2009-02-11 22:16:05 c2woody Exp $ */ #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -897,7 +897,7 @@ void GFX_Start() { sdl.active=true; } -static void GUI_ShutDown(Section * sec) { +static void GUI_ShutDown(Section * /*sec*/) { GFX_Stop(); if (sdl.draw.callback) (sdl.draw.callback)( GFX_CallBackStop ); if (sdl.mouse.locked) GFX_CaptureMouse(); @@ -1026,8 +1026,8 @@ static void GUI_StartUp(Section * sec) { char* height = const_cast(strchr(fullresolution,'x')); if(height && * height) { *height = 0; - sdl.desktop.full.height = atoi(height+1); - sdl.desktop.full.width = atoi(res); + sdl.desktop.full.height = (Bit16u)atoi(height+1); + sdl.desktop.full.width = (Bit16u)atoi(res); } } } @@ -1043,22 +1043,22 @@ static void GUI_StartUp(Section * sec) { char* height = const_cast(strchr(windowresolution,'x')); if(height && *height) { *height = 0; - sdl.desktop.window.height = atoi(height+1); - sdl.desktop.window.width = atoi(res); + sdl.desktop.window.height = (Bit16u)atoi(height+1); + sdl.desktop.window.width = (Bit16u)atoi(res); } } } sdl.desktop.doublebuf=section->Get_bool("fulldouble"); if (!sdl.desktop.full.width) { #ifdef WIN32 - sdl.desktop.full.width=GetSystemMetrics(SM_CXSCREEN); + sdl.desktop.full.width=(Bit16u)GetSystemMetrics(SM_CXSCREEN); #else sdl.desktop.full.width=1024; #endif } if (!sdl.desktop.full.height) { #ifdef WIN32 - sdl.desktop.full.height=GetSystemMetrics(SM_CYSCREEN); + sdl.desktop.full.height=(Bit16u)GetSystemMetrics(SM_CYSCREEN); #else sdl.desktop.full.height=768; #endif @@ -1629,7 +1629,7 @@ int main(int argc, char* argv[]) { /* Init the keyMapper */ MAPPER_Init(); - if (control->cmdline->FindExist("-startmapper")) MAPPER_Run(true); + if (control->cmdline->FindExist("-startmapper")) MAPPER_Run(false); /* Start up main machine */ control->StartUp(); /* Shutdown everything */