engine: remove inclusion of SDL headers globally, helps to cleanup code before SDL3 migration
This commit is contained in:
parent
bbbd7711c1
commit
a5f0ca38f1
14 changed files with 59 additions and 52 deletions
|
@ -86,8 +86,4 @@ GNU General Public License for more details.
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#if defined XASH_SDL && !defined REF_DLL
|
|
||||||
#include <SDL.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // PORT_H
|
#endif // PORT_H
|
||||||
|
|
|
@ -13,6 +13,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if XASH_SDL
|
||||||
|
#include <SDL.h> // SDL_GetWindowPosition
|
||||||
|
#endif // XASH_SDL
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
|
@ -1180,14 +1180,6 @@ void Touch_Init( void )
|
||||||
Cvar_RegisterVariable( &touch_enable );
|
Cvar_RegisterVariable( &touch_enable );
|
||||||
Cvar_RegisterVariable( &touch_emulate );
|
Cvar_RegisterVariable( &touch_emulate );
|
||||||
|
|
||||||
// TODO: touch platform
|
|
||||||
#if SDL_VERSION_ATLEAST( 2, 0, 10 )
|
|
||||||
SDL_SetHint( SDL_HINT_MOUSE_TOUCH_EVENTS, "0" );
|
|
||||||
SDL_SetHint( SDL_HINT_TOUCH_MOUSE_EVENTS, "0" );
|
|
||||||
#elif defined( SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH )
|
|
||||||
SDL_SetHint( SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, "1" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
touch.initialized = true;
|
touch.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,9 +205,10 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IN_SetRelativeMouseMode( qboolean set, qboolean verbose )
|
void IN_SetRelativeMouseMode( qboolean set )
|
||||||
{
|
{
|
||||||
static qboolean s_bRawInput;
|
static qboolean s_bRawInput;
|
||||||
|
qboolean verbose = m_grab_debug.value ? true : false;
|
||||||
|
|
||||||
if( set && !s_bRawInput )
|
if( set && !s_bRawInput )
|
||||||
{
|
{
|
||||||
|
@ -231,9 +232,10 @@ static void IN_SetRelativeMouseMode( qboolean set, qboolean verbose )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IN_SetMouseGrab( qboolean set, qboolean verbose )
|
void IN_SetMouseGrab( qboolean set )
|
||||||
{
|
{
|
||||||
static qboolean s_bMouseGrab;
|
static qboolean s_bMouseGrab;
|
||||||
|
qboolean verbose = m_grab_debug.value ? true : false;
|
||||||
|
|
||||||
if( set && !s_bMouseGrab )
|
if( set && !s_bMouseGrab )
|
||||||
{
|
{
|
||||||
|
@ -258,7 +260,7 @@ static void IN_SetMouseGrab( qboolean set, qboolean verbose )
|
||||||
|
|
||||||
static void IN_CheckMouseState( qboolean active )
|
static void IN_CheckMouseState( qboolean active )
|
||||||
{
|
{
|
||||||
qboolean use_raw_input, verbose;
|
qboolean use_raw_input;
|
||||||
|
|
||||||
#if XASH_WIN32
|
#if XASH_WIN32
|
||||||
use_raw_input = ( m_rawinput.value && clgame.client_dll_uses_sdl ) || clgame.dllFuncs.pfnLookEvent != NULL;
|
use_raw_input = ( m_rawinput.value && clgame.client_dll_uses_sdl ) || clgame.dllFuncs.pfnLookEvent != NULL;
|
||||||
|
@ -266,20 +268,18 @@ static void IN_CheckMouseState( qboolean active )
|
||||||
use_raw_input = true; // always use SDL code
|
use_raw_input = true; // always use SDL code
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
verbose = m_grab_debug.value ? true : false;
|
|
||||||
|
|
||||||
if( m_ignore.value )
|
if( m_ignore.value )
|
||||||
active = false;
|
active = false;
|
||||||
|
|
||||||
if( active && use_raw_input && !host.mouse_visible && cls.state == ca_active )
|
if( active && use_raw_input && !host.mouse_visible && cls.state == ca_active )
|
||||||
IN_SetRelativeMouseMode( true, verbose );
|
IN_SetRelativeMouseMode( true );
|
||||||
else
|
else
|
||||||
IN_SetRelativeMouseMode( false, verbose );
|
IN_SetRelativeMouseMode( false );
|
||||||
|
|
||||||
if( active && !host.mouse_visible && cls.state == ca_active )
|
if( active && !host.mouse_visible && cls.state == ca_active )
|
||||||
IN_SetMouseGrab( true, verbose );
|
IN_SetMouseGrab( true );
|
||||||
else
|
else
|
||||||
IN_SetMouseGrab( false, verbose );
|
IN_SetMouseGrab( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -46,6 +46,9 @@ uint IN_CollectInputDevices( void );
|
||||||
void IN_LockInputDevices( qboolean lock );
|
void IN_LockInputDevices( qboolean lock );
|
||||||
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active );
|
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active );
|
||||||
|
|
||||||
|
void IN_SetRelativeMouseMode( qboolean set );
|
||||||
|
void IN_SetMouseGrab( qboolean set );
|
||||||
|
|
||||||
extern convar_t m_yaw;
|
extern convar_t m_yaw;
|
||||||
extern convar_t m_pitch;
|
extern convar_t m_pitch;
|
||||||
//
|
//
|
||||||
|
|
|
@ -16,6 +16,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if XASH_SDL
|
||||||
|
#include <SDL.h> // SDL_GetBasePath
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
|
|
|
@ -31,6 +31,7 @@ GNU General Public License for more details.
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
double Platform_DoubleTime( void );
|
double Platform_DoubleTime( void );
|
||||||
|
void Platform_Sleep( int msec );
|
||||||
void Platform_ShellExecute( const char *path, const char *parms );
|
void Platform_ShellExecute( const char *path, const char *parms );
|
||||||
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow );
|
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow );
|
||||||
void Platform_SetStatus( const char *status );
|
void Platform_SetStatus( const char *status );
|
||||||
|
@ -168,19 +169,6 @@ static inline void Platform_SetupSigtermHandling( void )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Platform_Sleep( int msec )
|
|
||||||
{
|
|
||||||
#if XASH_TIMER == TIMER_SDL
|
|
||||||
SDL_Delay( msec );
|
|
||||||
#elif XASH_TIMER == TIMER_POSIX
|
|
||||||
usleep( msec * 1000 );
|
|
||||||
#elif XASH_TIMER == TIMER_WIN32
|
|
||||||
Sleep( msec );
|
|
||||||
#else
|
|
||||||
// stub
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline qboolean Platform_NanoSleep( int nsec )
|
static inline qboolean Platform_NanoSleep( int nsec )
|
||||||
{
|
{
|
||||||
// SDL2 doesn't have nanosleep, so use low-level functions here
|
// SDL2 doesn't have nanosleep, so use low-level functions here
|
||||||
|
|
|
@ -17,9 +17,10 @@ GNU General Public License for more details.
|
||||||
// have backtrace() and backtrace_symbols() calls, which replace for us
|
// have backtrace() and backtrace_symbols() calls, which replace for us
|
||||||
// platform-specific code
|
// platform-specific code
|
||||||
#if HAVE_EXECINFO
|
#if HAVE_EXECINFO
|
||||||
#include "common.h"
|
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include "common.h"
|
||||||
|
#include "input.h"
|
||||||
|
|
||||||
void Sys_Crash( int signal, siginfo_t *si, void *context )
|
void Sys_Crash( int signal, siginfo_t *si, void *context )
|
||||||
{
|
{
|
||||||
|
@ -70,8 +71,8 @@ void Sys_Crash( int signal, siginfo_t *si, void *context )
|
||||||
|
|
||||||
// put MessageBox as Sys_Error
|
// put MessageBox as Sys_Error
|
||||||
Msg( "%s\n", message );
|
Msg( "%s\n", message );
|
||||||
#ifdef XASH_SDL
|
#if !XASH_DEDICATED
|
||||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
IN_SetMouseGrab( false );
|
||||||
#endif
|
#endif
|
||||||
host.crashed = true;
|
host.crashed = true;
|
||||||
Platform_MessageBox( "Xash Error", message, false );
|
Platform_MessageBox( "Xash Error", message, false );
|
||||||
|
|
|
@ -17,7 +17,7 @@ GNU General Public License for more details.
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "backtrace.h"
|
#include "backtrace.h"
|
||||||
|
#include "input.h"
|
||||||
|
|
||||||
static struct backtrace_state *g_bt_state;
|
static struct backtrace_state *g_bt_state;
|
||||||
static qboolean enable_libbacktrace;
|
static qboolean enable_libbacktrace;
|
||||||
|
@ -164,8 +164,8 @@ void Sys_CrashLibbacktrace( int signal, siginfo_t *si, void *context )
|
||||||
|
|
||||||
// put MessageBox as Sys_Error
|
// put MessageBox as Sys_Error
|
||||||
Msg( "%s\n", message );
|
Msg( "%s\n", message );
|
||||||
#ifdef XASH_SDL
|
#if !XASH_DEDICATED
|
||||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
IN_SetMouseGrab( false );
|
||||||
#endif
|
#endif
|
||||||
host.crashed = true;
|
host.crashed = true;
|
||||||
Platform_MessageBox( "Xash Error", message, false );
|
Platform_MessageBox( "Xash Error", message, false );
|
||||||
|
|
|
@ -26,6 +26,7 @@ GNU General Public License for more details.
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
|
#include "input.h"
|
||||||
|
|
||||||
void Sys_Crash( int signal, siginfo_t *si, void *context );
|
void Sys_Crash( int signal, siginfo_t *si, void *context );
|
||||||
void Sys_CrashLibbacktrace( int signal, siginfo_t *si, void *context );
|
void Sys_CrashLibbacktrace( int signal, siginfo_t *si, void *context );
|
||||||
|
@ -192,8 +193,8 @@ void Sys_Crash( int signal, siginfo_t *si, void *context )
|
||||||
|
|
||||||
// put MessageBox as Sys_Error
|
// put MessageBox as Sys_Error
|
||||||
Msg( "%s\n", message );
|
Msg( "%s\n", message );
|
||||||
#ifdef XASH_SDL
|
#if !XASH_DEDICATED
|
||||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
IN_SetMouseGrab( false );
|
||||||
#endif
|
#endif
|
||||||
host.crashed = true;
|
host.crashed = true;
|
||||||
Platform_MessageBox( "Xash Error", message, false );
|
Platform_MessageBox( "Xash Error", message, false );
|
||||||
|
|
|
@ -174,5 +174,10 @@ double Platform_DoubleTime( void )
|
||||||
#endif
|
#endif
|
||||||
return (double) ts.tv_sec + (double) ts.tv_nsec/1000000000.0;
|
return (double) ts.tv_sec + (double) ts.tv_nsec/1000000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Platform_Sleep( int msec )
|
||||||
|
{
|
||||||
|
usleep( msec * 1000 );
|
||||||
|
}
|
||||||
#endif // XASH_TIMER == TIMER_POSIX
|
#endif // XASH_TIMER == TIMER_POSIX
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@ double Platform_DoubleTime( void )
|
||||||
CurrentTime = SDL_GetPerformanceCounter();
|
CurrentTime = SDL_GetPerformanceCounter();
|
||||||
return (double)( CurrentTime - g_ClockStart ) / (double)( g_PerformanceFrequency );
|
return (double)( CurrentTime - g_ClockStart ) / (double)( g_PerformanceFrequency );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Platform_Sleep( int msec )
|
||||||
|
{
|
||||||
|
SDL_Delay( msec );
|
||||||
|
}
|
||||||
#endif // XASH_TIMER == TIMER_SDL
|
#endif // XASH_TIMER == TIMER_SDL
|
||||||
|
|
||||||
#if XASH_MESSAGEBOX == MSGBOX_SDL
|
#if XASH_MESSAGEBOX == MSGBOX_SDL
|
||||||
|
@ -109,8 +114,11 @@ void SDLash_Init( const char *basedir )
|
||||||
host.type = HOST_DEDICATED;
|
host.type = HOST_DEDICATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if XASH_SDL == 2
|
#if SDL_MAJOR_VERSION >= 2
|
||||||
SDL_SetHint( SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0" );
|
SDL_SetHint( SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0" );
|
||||||
|
SDL_SetHint( SDL_HINT_MOUSE_TOUCH_EVENTS, "0" );
|
||||||
|
SDL_SetHint( SDL_HINT_TOUCH_MOUSE_EVENTS, "0" );
|
||||||
|
|
||||||
SDL_StopTextInput();
|
SDL_StopTextInput();
|
||||||
#endif // XASH_SDL == 2
|
#endif // XASH_SDL == 2
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,17 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform/platform.h"
|
|
||||||
|
|
||||||
#define DBGHELP 1 // we always enable dbghelp.dll on Windows targets
|
|
||||||
|
|
||||||
#if DBGHELP
|
|
||||||
|
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
#include <dbghelp.h>
|
#include <dbghelp.h>
|
||||||
#include <psapi.h>
|
#include <psapi.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "platform/platform.h"
|
||||||
|
#include "input.h"
|
||||||
|
|
||||||
|
#define DBGHELP 1 // we always enable dbghelp.dll on Windows targets
|
||||||
|
|
||||||
|
#if DBGHELP
|
||||||
#ifndef XASH_SDL
|
#ifndef XASH_SDL
|
||||||
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
||||||
#endif
|
#endif
|
||||||
|
@ -268,8 +268,8 @@ static long _stdcall Sys_Crash( PEXCEPTION_POINTERS pInfo )
|
||||||
// check to avoid recursive call
|
// check to avoid recursive call
|
||||||
host.crashed = true;
|
host.crashed = true;
|
||||||
|
|
||||||
#ifdef XASH_SDL
|
#if !XASH_DEDICATED
|
||||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
IN_SetMouseGrab( false );
|
||||||
#endif // XASH_SDL
|
#endif // XASH_SDL
|
||||||
|
|
||||||
#if DBGHELP
|
#if DBGHELP
|
||||||
|
|
|
@ -36,6 +36,11 @@ double Platform_DoubleTime( void )
|
||||||
|
|
||||||
return (double)( CurrentTime.QuadPart - g_ClockStart.QuadPart ) / (double)( g_PerformanceFrequency.QuadPart );
|
return (double)( CurrentTime.QuadPart - g_ClockStart.QuadPart ) / (double)( g_PerformanceFrequency.QuadPart );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Platform_Sleep( int msec )
|
||||||
|
{
|
||||||
|
Sleep( msec );
|
||||||
|
}
|
||||||
#endif // XASH_TIMER == TIMER_WIN32
|
#endif // XASH_TIMER == TIMER_WIN32
|
||||||
|
|
||||||
void Win32_Init( qboolean con_showalways )
|
void Win32_Init( qboolean con_showalways )
|
||||||
|
|
Loading…
Add table
Reference in a new issue