Browse Source

engine: client: m_rawinput support on windows

pull/2/head
Velaron 4 years ago committed by Alibek Omarov
parent
commit
d015e97eae
  1. 24
      engine/client/input.c
  2. 3
      engine/platform/sdl/in_sdl.c

24
engine/client/input.c

@ -47,6 +47,10 @@ convar_t *cl_sidespeed; @@ -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 ) @@ -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 ) @@ -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 ) @@ -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

3
engine/platform/sdl/in_sdl.c

@ -64,10 +64,9 @@ Platform_MouseMove @@ -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;
}
/*

Loading…
Cancel
Save