From 23fba558a074bc8f7b32f9dceae4a2eb96f1789a Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 5 Apr 2018 20:42:29 +0000 Subject: [PATCH] Manage resetting the key event state on video reinitialization centrally. Fixes: - No key state clear when SDL gets restarted. - Key state clear was the wrong action - it allows all keys to get pressed again, but does not actually release anything in cl_input.c, so e.g. +jump binds stay pressed on vid_restart. Only vid_wgl.c retains some vid-specific handling (reset of key state when alt-tabbing out and back in) - there's a chance that we may need similar logic in the other vid drivers; if so, it may be possible to do this in a shared place too by watching for changes to vid_activewindow. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12362 d7cf8633-e32d-0410-b094-e92efae38249 --- keys.c | 11 ----------- keys.h | 1 - vid_agl.c | 1 - vid_glx.c | 1 - vid_shared.c | 2 ++ vid_wgl.c | 2 +- 6 files changed, 3 insertions(+), 15 deletions(-) diff --git a/keys.c b/keys.c index d233471b..2f91c06c 100644 --- a/keys.c +++ b/keys.c @@ -1989,14 +1989,3 @@ Key_ReleaseAll (void) // now all keys are guaranteed down (once the event queue is unblocked) // and only future events count } - -/* -=================== -Key_ClearStates -=================== -*/ -void -Key_ClearStates (void) -{ - memset(keydown, 0, sizeof(keydown)); -} diff --git a/keys.h b/keys.h index a84eb4c6..7841e9d0 100644 --- a/keys.h +++ b/keys.h @@ -378,7 +378,6 @@ void Key_Shutdown(void); void Key_Init_Cvars(void); void Key_Event(int key, int ascii, qboolean down); void Key_ReleaseAll (void); -void Key_ClearStates (void); // FIXME: should this function still exist? Or should Key_ReleaseAll be used instead when shutting down a vid driver? void Key_EventQueue_Block(void); void Key_EventQueue_Unblock(void); diff --git a/vid_agl.c b/vid_agl.c index 4fd603ea..ae4e871b 100644 --- a/vid_agl.c +++ b/vid_agl.c @@ -361,7 +361,6 @@ void VID_Shutdown(void) vid_isfullscreen = false; GL_CloseLibrary(); - Key_ClearStates (); } // Since the event handler can be called at any time, we store the events for later processing diff --git a/vid_glx.c b/vid_glx.c index 2fb52288..4c5c9c9d 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -881,7 +881,6 @@ void VID_Shutdown(void) ctx = NULL; GL_CloseLibrary(); - Key_ClearStates (); } static void signal_handler(int sig) diff --git a/vid_shared.c b/vid_shared.c index 129641cf..7ee5b34f 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -1850,6 +1850,7 @@ static int VID_Mode(int fullscreen, int width, int height, int bpp, float refres static void VID_OpenSystems(void) { + Key_ReleaseAll(); R_Modules_Start(); S_Startup(); } @@ -1858,6 +1859,7 @@ static void VID_CloseSystems(void) { S_Shutdown(); R_Modules_Shutdown(); + Key_ReleaseAll(); } qboolean vid_commandlinecheck = true; diff --git a/vid_wgl.c b/vid_wgl.c index 329e57df..7a484088 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -429,7 +429,7 @@ ClearAllStates */ static void ClearAllStates (void) { - Key_ClearStates (); + Key_ReleaseAll(); if (vid_usingmouse) mouse_oldbuttonstate = 0; } -- 2.39.2