From b4aecfbf23a3ee54a39e95931d8cbb9e3e8acc02 Mon Sep 17 00:00:00 2001 From: Velaron Date: Fri, 21 Aug 2020 13:39:01 +0300 Subject: [PATCH] engine: move some input code --- engine/client/input.c | 17 +++++------------ engine/platform/sdl/in_sdl.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/engine/client/input.c b/engine/client/input.c index adf540bc..674dbfb0 100644 --- a/engine/client/input.c +++ b/engine/client/input.c @@ -567,23 +567,16 @@ static void IN_JoyAppendMove( usercmd_t *cmd, float forwardmove, float sidemove void IN_CollectInput( float *forward, float *side, float *pitch, float *yaw, qboolean includeMouse, qboolean includeSdlMouse ) { - if( includeMouse ) + if( includeMouse +#if XASH_SDL + && includeSdlMouse +#endif + ) { -#if XASH_INPUT == INPUT_SDL - /// TODO: check if we may move this to platform - if( includeSdlMouse ) - { - int x, y; - SDL_GetRelativeMouseState( &x, &y ); - *pitch += y * m_pitch->value; - *yaw -= x * m_yaw->value; - } -#else float x, y; Platform_MouseMove( &x, &y ); *pitch += y * m_pitch->value; *yaw -= x * m_yaw->value; -#endif // SDL #ifdef XASH_USE_EVDEV IN_EvdevMove( yaw, pitch ); diff --git a/engine/platform/sdl/in_sdl.c b/engine/platform/sdl/in_sdl.c index 2556044f..216c6d53 100644 --- a/engine/platform/sdl/in_sdl.c +++ b/engine/platform/sdl/in_sdl.c @@ -55,6 +55,21 @@ void GAME_EXPORT Platform_SetMousePos( int x, int y ) SDL_WarpMouseInWindow( host.hWnd, x, y ); } +/* +======================== +Platform_MouseMove + +======================== +*/ +void Platform_MouseMove( float *x, float *y ) +{ + int m_x, m_y; + SDL_GetMouseState( &m_x, &m_y ); + *x = (float)m_x; + *y = (float)m_y; + +} + /* ============= Platform_GetClipobardText