Browse Source

engine: move some input code

pull/2/head
Velaron 4 years ago committed by Alibek Omarov
parent
commit
b4aecfbf23
  1. 17
      engine/client/input.c
  2. 15
      engine/platform/sdl/in_sdl.c

17
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 ) 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; float x, y;
Platform_MouseMove( &x, &y ); Platform_MouseMove( &x, &y );
*pitch += y * m_pitch->value; *pitch += y * m_pitch->value;
*yaw -= x * m_yaw->value; *yaw -= x * m_yaw->value;
#endif // SDL
#ifdef XASH_USE_EVDEV #ifdef XASH_USE_EVDEV
IN_EvdevMove( yaw, pitch ); IN_EvdevMove( yaw, pitch );

15
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 ); 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 Platform_GetClipobardText

Loading…
Cancel
Save