engine: client: m_rawinput support on windows

This commit is contained in:
Velaron 2020-08-24 18:43:15 +03:00 committed by Alibek Omarov
parent b4aecfbf23
commit d015e97eae
2 changed files with 23 additions and 4 deletions

View File

@ -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

View File

@ -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;
}
/*