From bd0d6644e0452980e6b9f07de2ed9eb41121f66a Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 24 Dec 2024 09:59:47 +0300 Subject: [PATCH] engine: move Sys_SendKeyEvents to platform/win32 --- engine/client/input.c | 2 +- engine/common/system.c | 16 ---------------- engine/platform/platform.h | 8 ++++++++ engine/platform/win32/sys_win.c | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/engine/client/input.c b/engine/client/input.c index 8e3d2c29..704c9b43 100644 --- a/engine/client/input.c +++ b/engine/client/input.c @@ -633,7 +633,7 @@ Called every frame, even if not generating commands */ void Host_InputFrame( void ) { - Sys_SendKeyEvents (); + Platform_SendKeyEvents(); IN_Commands(); diff --git a/engine/common/system.c b/engine/common/system.c index dbc210df..f42a61ed 100644 --- a/engine/common/system.c +++ b/engine/common/system.c @@ -234,22 +234,6 @@ qboolean Sys_GetIntFromCmdLine( const char* argName, int *out ) return true; } -void Sys_SendKeyEvents( void ) -{ -#if XASH_WIN32 - MSG msg; - - while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE )) - { - if( !GetMessage( &msg, NULL, 0, 0 )) - Sys_Quit (); - - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } -#endif -} - //======================================================================= // DLL'S MANAGER SYSTEM //======================================================================= diff --git a/engine/platform/platform.h b/engine/platform/platform.h index cc801860..dc1dc92c 100644 --- a/engine/platform/platform.h +++ b/engine/platform/platform.h @@ -227,6 +227,14 @@ static inline void Platform_SetTimer( float time ) #endif } +#if XASH_WIN32 +void Platform_SendKeyEvents( void ); +#else +static inline void Platform_SendKeyEvents( void ) +{ +} +#endif + /* ============================================================================== diff --git a/engine/platform/win32/sys_win.c b/engine/platform/win32/sys_win.c index 2c783862..eacfad69 100644 --- a/engine/platform/win32/sys_win.c +++ b/engine/platform/win32/sys_win.c @@ -55,3 +55,18 @@ void Platform_MessageBox( const char *title, const char *message, qboolean paren MessageBox( parentMainWindow ? host.hWnd : NULL, message, title, MB_OK|MB_SETFOREGROUND|MB_ICONSTOP ); } #endif // XASH_MESSAGEBOX == MSGBOX_WIN32 + +// I don't know why we need this or what this does +void Platform_SendKeyEvents( void ) +{ + MSG msg; + + while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE )) + { + if( !GetMessage( &msg, NULL, 0, 0 )) + Sys_Quit (); + + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } +}