]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Manage resetting the key event state on video reinitialization centrally.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 5 Apr 2018 20:42:29 +0000 (20:42 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 5 Apr 2018 20:42:29 +0000 (20:42 +0000)
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
keys.h
vid_agl.c
vid_glx.c
vid_shared.c
vid_wgl.c

diff --git a/keys.c b/keys.c
index d233471b1618fbcc929343cdd8f0d11070d47fce..2f91c06c453c59907d1a75266ea5ea8c9d3656c8 100644 (file)
--- 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 a84eb4c6f7cced9246b4faaf430ffb851467ed28..7841e9d007df0354807ad4664fb96ca807907e8e 100644 (file)
--- 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);
 
index 4fd603ea4e3d308fdc8c4641ff39abf2eb76eaf9..ae4e871b12ab9b0ae2adc5cc77b696e374472925 100644 (file)
--- 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
index 2fb5228898e45394fc90a5d6fe3981b742f2a430..4c5c9c9d02f6b5b852b5dce49712289cd66a015d 100644 (file)
--- 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)
index 129641cfcfe1dd42586d710eac6143498123d6d8..7ee5b34f6d3d50fbef0dd0f6defe285d7a662787 100644 (file)
@@ -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;
index 329e57df415c15c76219e259713576a60b9369ad..7a4840886f0165fae39591890a582419c42a50a7 100644 (file)
--- 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;
 }