diff --git a/engine/client/input.c b/engine/client/input.c index 674dbfb0..c191a1b3 100644 --- a/engine/client/input.c +++ b/engine/client/input.c @@ -47,6 +47,10 @@ convar_t *cl_sidespeed; convar_t *cl_backspeed; convar_t *look_filter; +#if XASH_WIN32 +convar_t *m_rawinput; +#endif + /* ================ IN_CollectInputDevices @@ -118,6 +122,10 @@ void IN_StartupMouse( void ) m_yaw = Cvar_Get( "m_yaw", "0.022", FCVAR_ARCHIVE, "mouse yaw value" ); look_filter = Cvar_Get( "look_filter", "0", FCVAR_ARCHIVE, "filter look events making it smoother" ); +#if XASH_WIN32 + m_rawinput = Cvar_Get( "m_rawinput", "1", FCVAR_ARCHIVE, "enable mouse raw input" ); +#endif + // You can use -nomouse argument to prevent using mouse from client // -noenginemouse will disable all mouse input if( Sys_CheckParm( "-noenginemouse" )) return; @@ -207,8 +215,14 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) #if XASH_SDL SDL_SetWindowGrab( host.hWnd, SDL_TRUE ); #if SDL_VERSION_ATLEAST( 2, 0, 0 ) - if( clgame.dllFuncs.pfnLookEvent ) +#if XASH_WIN32 + if ( clgame.dllFuncs.pfnLookEvent || ( clgame.client_dll_uses_sdl && CVAR_TO_BOOL( m_rawinput ) ) ) +#else + if ( clgame.dllFuncs.pfnLookEvent ) +#endif // XASH_WIN32 + { SDL_SetRelativeMouseMode( SDL_TRUE ); + } #endif #endif // XASH_SDL } @@ -221,8 +235,14 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) #ifdef XASH_SDL SDL_SetWindowGrab(host.hWnd, SDL_FALSE); #if SDL_VERSION_ATLEAST( 2, 0, 0 ) - if( clgame.dllFuncs.pfnLookEvent ) +#if XASH_WIN32 + if ( clgame.dllFuncs.pfnLookEvent || ( clgame.client_dll_uses_sdl && CVAR_TO_BOOL( m_rawinput ) ) ) +#else + if ( clgame.dllFuncs.pfnLookEvent ) +#endif // XASH_WIN32 + { SDL_SetRelativeMouseMode( SDL_FALSE ); + } #endif #endif // XASH_SDL #if XASH_ANDROID diff --git a/engine/platform/sdl/in_sdl.c b/engine/platform/sdl/in_sdl.c index 216c6d53..fb6cc98e 100644 --- a/engine/platform/sdl/in_sdl.c +++ b/engine/platform/sdl/in_sdl.c @@ -64,10 +64,9 @@ Platform_MouseMove void Platform_MouseMove( float *x, float *y ) { int m_x, m_y; - SDL_GetMouseState( &m_x, &m_y ); + SDL_GetRelativeMouseState( &m_x, &m_y ); *x = (float)m_x; *y = (float)m_y; - } /*