diff --git a/src/backends/generic/header/input.h b/src/backends/generic/header/input.h index 245ee158..7c9656f5 100644 --- a/src/backends/generic/header/input.h +++ b/src/backends/generic/header/input.h @@ -29,6 +29,11 @@ #include "../../../common/header/shared.h" +/* + * Saves the time of the last input event. + */ +extern int sys_frame_time; + /* * Initializes the input backend */ diff --git a/src/backends/sdl/input.c b/src/backends/sdl/input.c index cead9d91..8edeaa0c 100644 --- a/src/backends/sdl/input.c +++ b/src/backends/sdl/input.c @@ -68,6 +68,7 @@ static int mouse_x, mouse_y; static int old_mouse_x, old_mouse_y; static qboolean mlooking; +int sys_frame_time; #if SDL_VERSION_ATLEAST(2, 0, 0) static float joystick_yaw, joystick_pitch; @@ -701,9 +702,12 @@ IN_Update(void) /* calling GLimp_GrabInput() each is a bit ugly but simple and should work. * + the called SDL functions return after a cheap check, if there's - * nothing to do, anyway - */ + * nothing to do, anyway. */ GLimp_GrabInput(want_grab); + + /* We need to save the frame time so other subsystems know the + * exact time of the last input events. */ + sys_frame_time = Sys_Milliseconds(); } /* diff --git a/src/backends/unix/system.c b/src/backends/unix/system.c index 3d1a140a..04fd3fe6 100644 --- a/src/backends/unix/system.c +++ b/src/backends/unix/system.c @@ -53,9 +53,6 @@ qboolean stdin_active = true; // Console logfile extern FILE *logfile; -// TODO -unsigned sys_frame_time; - /* ================================================================ */ void @@ -526,18 +523,3 @@ Sys_LoadLibrary(const char *path, const char *sym, void **handle) return entry; } - -/* ================================================================ */ - -// TODO: Remove. - -void -Sys_SendKeyEvents(void) -{ -#ifndef DEDICATED_ONLY - IN_Update(); -#endif - - /* grab frame time */ - sys_frame_time = Sys_Milliseconds(); -} diff --git a/src/backends/windows/system.c b/src/backends/windows/system.c index bcb3d23b..6d4866ad 100644 --- a/src/backends/windows/system.c +++ b/src/backends/windows/system.c @@ -50,7 +50,6 @@ static size_t console_textlen; // TODO qboolean is_portable; -unsigned int sys_frame_time; /* ================================================================ */ @@ -672,18 +671,3 @@ Sys_SetHighDPIMode(void) SetProcessDPIAware(); } } - -/* ======================================================================= */ - -// TODO: Remove. - -void -Sys_SendKeyEvents(void) -{ -#ifndef DEDICATED_ONLY - IN_Update(); -#endif - - /* grab frame time */ - sys_frame_time = timeGetTime(); -} diff --git a/src/client/cl_input.c b/src/client/cl_input.c index 71ad0889..6c6e310f 100644 --- a/src/client/cl_input.c +++ b/src/client/cl_input.c @@ -30,7 +30,6 @@ cvar_t *cl_nodelta; -extern unsigned sys_frame_time; unsigned frame_msec; unsigned old_sys_frame_time; diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 73e9b69a..df2f5fcb 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -365,7 +365,7 @@ CL_Skins_f(void) SCR_UpdateScreen(); - Sys_SendKeyEvents(); /* pump message loop */ + IN_Update(); /* pump message loop */ CL_ParseClientinfo(i); } @@ -755,7 +755,7 @@ CL_Frame(int packetdelta, int renderdelta, int timedelta, qboolean packetframe, { CL_ReadPackets(); CL_UpdateWindowedMouse(); - Sys_SendKeyEvents(); + IN_Update(); Cbuf_Execute(); CL_FixCvarCheats(); diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c index 229b08f0..aacb1cc3 100644 --- a/src/client/cl_parse.c +++ b/src/client/cl_parse.c @@ -25,6 +25,7 @@ */ #include "header/client.h" +#include "../backends/generic/header/input.h" void CL_DownloadFileName(char *dest, int destlen, char *fn); void CL_ParseDownload(void); @@ -73,7 +74,7 @@ CL_RegisterSounds(void) } cl.sound_precache[i] = S_RegisterSound(cl.configstrings[CS_SOUNDS + i]); - Sys_SendKeyEvents(); + IN_Update(); } S_EndRegistration(); diff --git a/src/client/cl_view.c b/src/client/cl_view.c index 404e341c..2ff53a39 100644 --- a/src/client/cl_view.c +++ b/src/client/cl_view.c @@ -25,6 +25,7 @@ */ #include "header/client.h" +#include "../backends/generic/header/input.h" /* development tools for weapons */ int gun_frame; @@ -281,7 +282,7 @@ CL_PrepRefresh(void) } SCR_UpdateScreen(); - Sys_SendKeyEvents(); + IN_Update(); if (name[0] == '#') { @@ -321,7 +322,7 @@ CL_PrepRefresh(void) for (i = 1; i < MAX_IMAGES && cl.configstrings[CS_IMAGES + i][0]; i++) { cl.image_precache[i] = Draw_FindPic(cl.configstrings[CS_IMAGES + i]); - Sys_SendKeyEvents(); + IN_Update(); } Com_Printf(" \r"); @@ -335,7 +336,7 @@ CL_PrepRefresh(void) Com_Printf("client %i\r", i); SCR_UpdateScreen(); - Sys_SendKeyEvents(); + IN_Update(); CL_ParseClientinfo(i); Com_Printf(" \r"); } diff --git a/src/common/header/common.h b/src/common/header/common.h index a9d18d5b..130f7001 100644 --- a/src/common/header/common.h +++ b/src/common/header/common.h @@ -789,9 +789,6 @@ void *Sys_LoadLibrary(const char *path, const char *sym, void **handle); void *Sys_GetGameAPI(void *parms); void Sys_UnloadGame(void); -// TODO: Remove -void Sys_SendKeyEvents(void); - // Windows only (system.c) #ifdef _WIN32 void Sys_RedirectStdout(void);