@ -23,7 +23,7 @@
@@ -23,7 +23,7 @@
# include "keydefs.h"
# include "view.h"
# ifndef _WIN32
# if ! _WIN32
# define USE_SDL2
# endif
@ -114,7 +114,7 @@ static SDLFunction sdlFunctions[] = {
@@ -114,7 +114,7 @@ static SDLFunction sdlFunctions[] = {
} ;
# endif
# ifdef _WIN32
# if _WIN32
# include <process.h>
# else
typedef unsigned int DWORD ;
@ -151,14 +151,14 @@ extern cvar_t *cl_forwardspeed;
@@ -151,14 +151,14 @@ extern cvar_t *cl_forwardspeed;
extern cvar_t * cl_pitchspeed ;
extern cvar_t * cl_movespeedkey ;
# ifdef _WIN32
# if _WIN32
static double s_flRawInputUpdateTime = 0.0f ;
static bool m_bRawInput = false ;
static bool m_bMouseThread = false ;
bool isMouseRelative = false ;
# endif
# ifdef _WIN32
# if _WIN32
# include "progdefs.h"
extern globalvars_t * gpGlobals ;
# endif
@ -186,7 +186,7 @@ static cvar_t *m_customaccel_max;
@@ -186,7 +186,7 @@ static cvar_t *m_customaccel_max;
//Mouse move is raised to this power before being scaled by scale factor
static cvar_t * m_customaccel_exponent ;
# ifdef _WIN32
# if _WIN32
// if threaded mouse is enabled then the time to sleep between polls
static cvar_t * m_mousethread_sleep ;
# endif
@ -278,7 +278,7 @@ cvar_t *joy_wwhack2;
@@ -278,7 +278,7 @@ cvar_t *joy_wwhack2;
int joy_avail , joy_advancedinit , joy_haspov ;
# ifdef _WIN32
# if _WIN32
unsigned int s_hMouseThreadId = 0 ;
HANDLE s_hMouseThread = 0 ;
HANDLE s_hMouseQuitEvent = 0 ;
@ -302,7 +302,7 @@ void Force_CenterView_f (void)
@@ -302,7 +302,7 @@ void Force_CenterView_f (void)
}
}
# ifdef _WIN32
# if _WIN32
LONG mouseThreadActive = 0 ;
LONG mouseThreadCenterX = 0 ;
@ -384,14 +384,14 @@ void IN_SetMouseMode(bool enable)
@@ -384,14 +384,14 @@ void IN_SetMouseMode(bool enable)
if ( enable )
{
# ifdef _WIN32
# if _WIN32
if ( mouseparmsvalid )
restore_spi = SystemParametersInfo ( SPI_SETMOUSE , 0 , newmouseparms , 0 ) ;
m_bRawInput = CVAR_GET_FLOAT ( " m_rawinput " ) ! = 0 ;
if ( m_bRawInput )
{
# ifdef USE_SDL2
# if USE_SDL2
safe_pfnSDL_SetRelativeMouseMode ( SDL_TRUE ) ;
# endif
isMouseRelative = true ;
@ -404,10 +404,10 @@ void IN_SetMouseMode(bool enable)
@@ -404,10 +404,10 @@ void IN_SetMouseMode(bool enable)
}
else
{
# ifdef _WIN32
# if _WIN32
if ( isMouseRelative )
{
# ifdef USE_SDL2
# if USE_SDL2
safe_pfnSDL_SetRelativeMouseMode ( SDL_FALSE ) ;
# endif
isMouseRelative = false ;
@ -425,7 +425,7 @@ void IN_SetMouseMode(bool enable)
@@ -425,7 +425,7 @@ void IN_SetMouseMode(bool enable)
void IN_SetVisibleMouse ( bool visible )
{
# ifdef _WIN32
# if _WIN32
bool lockEntered = MouseThread_ActiveLock_Enter ( ) ;
# endif
@ -433,7 +433,7 @@ void IN_SetVisibleMouse(bool visible)
@@ -433,7 +433,7 @@ void IN_SetVisibleMouse(bool visible)
IN_SetMouseMode ( ! visible ) ;
# ifdef _WIN32
# if _WIN32
UpdateMouseThreadActive ( ) ;
if ( lockEntered ) MouseThread_ActiveLock_Exit ( ) ;
# endif
@ -450,7 +450,7 @@ void GoldSourceInput::IN_ActivateMouse (void)
@@ -450,7 +450,7 @@ void GoldSourceInput::IN_ActivateMouse (void)
{
if ( mouseinitialized )
{
# ifdef _WIN32
# if _WIN32
bool lockEntered = MouseThread_ActiveLock_Enter ( ) ;
# endif
@ -458,7 +458,7 @@ void GoldSourceInput::IN_ActivateMouse (void)
@@ -458,7 +458,7 @@ void GoldSourceInput::IN_ActivateMouse (void)
mouseactive = 1 ;
# ifdef _WIN32
# if _WIN32
UpdateMouseThreadActive ( ) ;
if ( lockEntered ) MouseThread_ActiveLock_Exit ( ) ;
# endif
@ -478,7 +478,7 @@ void GoldSourceInput::IN_DeactivateMouse (void)
@@ -478,7 +478,7 @@ void GoldSourceInput::IN_DeactivateMouse (void)
{
if ( mouseinitialized )
{
# ifdef _WIN32
# if _WIN32
bool lockEntered = MouseThread_ActiveLock_Enter ( ) ;
# endif
@ -486,7 +486,7 @@ void GoldSourceInput::IN_DeactivateMouse (void)
@@ -486,7 +486,7 @@ void GoldSourceInput::IN_DeactivateMouse (void)
mouseactive = 0 ;
# ifdef _WIN32
# if _WIN32
UpdateMouseThreadActive ( ) ;
if ( lockEntered ) MouseThread_ActiveLock_Exit ( ) ;
# endif
@ -504,7 +504,7 @@ void GoldSourceInput::IN_StartupMouse (void)
@@ -504,7 +504,7 @@ void GoldSourceInput::IN_StartupMouse (void)
return ;
mouseinitialized = 1 ;
# ifdef _WIN32
# if _WIN32
mouseparmsvalid = SystemParametersInfo ( SPI_GETMOUSE , 0 , originalmouseparms , 0 ) ;
if ( mouseparmsvalid )
@ -539,7 +539,7 @@ void GoldSourceInput::IN_Shutdown (void)
@@ -539,7 +539,7 @@ void GoldSourceInput::IN_Shutdown (void)
{
IN_DeactivateMouse ( ) ;
# ifdef _WIN32
# if _WIN32
if ( s_hMouseQuitEvent )
{
SetEvent ( s_hMouseQuitEvent ) ;
@ -599,7 +599,7 @@ FIXME: Call through to engine?
@@ -599,7 +599,7 @@ FIXME: Call through to engine?
void IN_ResetMouse ( void )
{
// no work to do in SDL
# ifdef _WIN32
# if _WIN32
// reset only if mouse is active and not in visible mode:
if ( mouseactive & & ! iVisibleMouse & & gEngfuncs . GetWindowCenterX & & gEngfuncs . GetWindowCenterY )
{
@ -714,7 +714,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
@@ -714,7 +714,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
if ( active )
{
int deltaX , deltaY ;
# ifdef _WIN32
# if _WIN32
if ( ! m_bRawInput )
{
if ( m_bMouseThread )
@ -748,7 +748,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
@@ -748,7 +748,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
# endif
}
# ifdef _WIN32
# if _WIN32
if ( ! m_bRawInput )
{
if ( m_bMouseThread )
@ -773,7 +773,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
@@ -773,7 +773,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
my_accum = 0 ;
// reset mouse position if required, so there is room to move:
# ifdef _WIN32
# if _WIN32
// do not reset if mousethread would do it:
if ( m_bRawInput | | ! m_bMouseThread )
# else
@ -781,7 +781,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
@@ -781,7 +781,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
# endif
IN_ResetMouse ( ) ;
# ifdef _WIN32
# if _WIN32
// update m_bRawInput occasionally:
if ( gpGlobals & & gpGlobals - > time - s_flRawInputUpdateTime > 1.0f )
{
@ -793,14 +793,14 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
@@ -793,14 +793,14 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
if ( m_bRawInput & & ! isMouseRelative )
{
# ifdef USE_SDL2
# if USE_SDL2
safe_pfnSDL_SetRelativeMouseMode ( SDL_TRUE ) ;
# endif
isMouseRelative = true ;
}
else if ( ! m_bRawInput & & isMouseRelative )
{
# ifdef USE_SDL2
# if USE_SDL2
safe_pfnSDL_SetRelativeMouseMode ( SDL_FALSE ) ;
# endif
isMouseRelative = false ;
@ -953,7 +953,7 @@ void GoldSourceInput::IN_Accumulate (void)
@@ -953,7 +953,7 @@ void GoldSourceInput::IN_Accumulate (void)
{
if ( mouseactive )
{
# ifdef _WIN32
# if _WIN32
if ( ! m_bRawInput )
{
if ( ! m_bMouseThread )
@ -981,7 +981,7 @@ void GoldSourceInput::IN_Accumulate (void)
@@ -981,7 +981,7 @@ void GoldSourceInput::IN_Accumulate (void)
}
// force the mouse to the center, so there's room to move
# ifdef _WIN32
# if _WIN32
// do not reset if mousethread would do it:
if ( m_bRawInput | | ! m_bMouseThread )
# else
@ -1595,7 +1595,7 @@ void GoldSourceInput::IN_Init (void)
@@ -1595,7 +1595,7 @@ void GoldSourceInput::IN_Init (void)
m_customaccel_max = gEngfuncs . pfnRegisterVariable ( " m_customaccel_max " , " 0 " , FCVAR_ARCHIVE ) ;
m_customaccel_exponent = gEngfuncs . pfnRegisterVariable ( " m_customaccel_exponent " , " 1 " , FCVAR_ARCHIVE ) ;
# ifdef _WIN32
# if _WIN32
m_bRawInput = CVAR_GET_FLOAT ( " m_rawinput " ) ! = 0 ;
m_bMouseThread = gEngfuncs . CheckParm ( " -mousethread " , NULL ) ! = NULL ;
m_mousethread_sleep = gEngfuncs . pfnRegisterVariable ( " m_mousethread_sleep " , " 1 " , FCVAR_ARCHIVE ) ; // default to less than 1000 Hz
@ -1626,7 +1626,7 @@ void GoldSourceInput::IN_Init (void)
@@ -1626,7 +1626,7 @@ void GoldSourceInput::IN_Init (void)
# endif
# ifdef USE_SDL2
# ifdef __APPLE__
# if __APPLE__
# define SDL2_FULL_LIBNAME "libsdl2-2.0.0.dylib"
# else
# define SDL2_FULL_LIBNAME "libSDL2-2.0.so.0"