Browse Source

input: various fixes: fix mistyped pitch/yaw, replace SDL_GetMouseState by SDL_GetRelativeMouseState, fix disabling mouse with -nomouse argument

pull/2/head
Alibek Omarov 6 years ago
parent
commit
6ba7781a61
  1. 12
      engine/client/input.c

12
engine/client/input.c

@ -155,7 +155,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
SDL_WarpMouseInWindow( host.hWnd, host.window_center_x, host.window_center_y ); SDL_WarpMouseInWindow( host.hWnd, host.window_center_x, host.window_center_y );
SDL_SetWindowGrab( host.hWnd, SDL_TRUE ); SDL_SetWindowGrab( host.hWnd, SDL_TRUE );
if( clgame.dllFuncs.pfnLookEvent ) if( clgame.dllFuncs.pfnLookEvent )
SDL_SetRelativeMouseMode( SDL_FALSE ); SDL_SetRelativeMouseMode( SDL_TRUE );
} }
#endif // XASH_SDL #endif // XASH_SDL
if( cls.initialized ) if( cls.initialized )
@ -493,15 +493,15 @@ void IN_JoyAppendMove( usercmd_t *cmd, float forwardmove, float sidemove )
} }
} }
void IN_CollectInput( float *forward, float *side, float *pitch, float *yaw, qboolean includeSdlMouse ) void IN_CollectInput( float *forward, float *side, float *pitch, float *yaw, qboolean includeMouse, qboolean includeSdlMouse )
{ {
if( !m_ignore->value ) if( !m_ignore->value || includeMouse )
{ {
#if XASH_INPUT == INPUT_SDL #if XASH_INPUT == INPUT_SDL
if( includeSdlMouse ) if( includeSdlMouse )
{ {
int x, y; int x, y;
SDL_GetMouseState( &x, &y ); SDL_GetRelativeMouseState( &x, &y );
*pitch += y * m_pitch->value; *pitch += y * m_pitch->value;
*yaw -= x * m_yaw->value; *yaw -= x * m_yaw->value;
} }
@ -557,7 +557,7 @@ void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
{ {
float sensitivity = ( (float)RI.fov_x / (float)90.0f ); float sensitivity = ( (float)RI.fov_x / (float)90.0f );
IN_CollectInput( &forward, &side, &yaw, &pitch, m_enginemouse->value ); IN_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized, m_enginemouse->value );
IN_JoyAppendMove( cmd, forward, side ); IN_JoyAppendMove( cmd, forward, side );
@ -587,7 +587,7 @@ void Host_InputFrame( void )
if( clgame.dllFuncs.pfnLookEvent ) if( clgame.dllFuncs.pfnLookEvent )
{ {
IN_CollectInput( &forward, &side, &yaw, &pitch, in_mouseinitialized ); IN_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized, true );
if( cls.key_dest == key_game ) if( cls.key_dest == key_game )
{ {

Loading…
Cancel
Save