From 266705612d92dbb9db2465dfc2c78a00a17c34ce Mon Sep 17 00:00:00 2001 From: sezero Date: Sun, 21 Oct 2012 11:33:10 +0000 Subject: [PATCH] added IN_UpdateForKeydest() as a new helper who does stuff if the key_dest changes matter to the keyboard driver, e.g. sending KP_ key decisions, or SDL unicode stuff. we run it every frame either before Sys_SendKeyEvents() or from within Key_ForceDest() for now. (merged from uhexen2.) git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@773 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/host.c | 3 +-- Quake/in_sdl.c | 14 ++++++++------ Quake/input.h | 3 +++ Quake/keys.c | 2 ++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Quake/host.c b/Quake/host.c index a790a985..a3c7427b 100644 --- a/Quake/host.c +++ b/Quake/host.c @@ -687,6 +687,7 @@ void _Host_Frame (float time) // get new key events Key_ForceDest (); + //IN_UpdateForKeydest (); Sys_SendKeyEvents (); // allow mice or other external controllers to add commands @@ -726,9 +727,7 @@ void _Host_Frame (float time) // fetch results from server if (cls.state == ca_connected) - { CL_ReadFromServer (); - } // update video if (host_speeds.value) diff --git a/Quake/in_sdl.c b/Quake/in_sdl.c index 61babf80..3f2d61cf 100644 --- a/Quake/in_sdl.c +++ b/Quake/in_sdl.c @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "SDL.h" #endif -static qboolean prev_gamekey; +static qboolean prev_gamekey, gamekey; #ifdef __APPLE__ /* Mouse acceleration needs to be disabled on OS X */ @@ -300,12 +300,8 @@ void IN_ClearStates (void) { } -void IN_SendKeyEvents (void) +void IN_UpdateForKeydest (void) { - SDL_Event event; - int sym, state, modstate; - qboolean gamekey; - gamekey = ((key_dest == key_game && !con_forcedup) || m_keys_bind_grab); if (gamekey != prev_gamekey) { @@ -313,6 +309,12 @@ void IN_SendKeyEvents (void) Key_ClearStates(); SDL_EnableUNICODE(!gamekey); } +} + +void IN_SendKeyEvents (void) +{ + SDL_Event event; + int sym, state, modstate; while (SDL_PollEvent(&event)) { diff --git a/Quake/input.h b/Quake/input.h index fc65c75c..cb751b80 100644 --- a/Quake/input.h +++ b/Quake/input.h @@ -39,6 +39,9 @@ void IN_MouseMove(int dx, int dy); void IN_SendKeyEvents (void); // used as a callback for Sys_SendKeyEvents() by some drivers +void IN_UpdateForKeydest (void); +// do stuff if key_dest changes matter to the keyboard driver + void IN_Move (usercmd_t *cmd); // add additional movement on top of the keyboard move cmd diff --git a/Quake/keys.c b/Quake/keys.c index 40db42f7..198f7b77 100644 --- a/Quake/keys.c +++ b/Quake/keys.c @@ -1077,5 +1077,7 @@ void Key_ForceDest (void) forced = false; break; } + + IN_UpdateForKeydest (); }