engine: platform: sdl: enable building with SDL as old as 2.0.8, it should satisfy everybody masturbating to old software

This commit is contained in:
Alibek Omarov
2025-04-30 17:45:05 +03:00
parent d457d7d093
commit 47c4844024
4 changed files with 22 additions and 7 deletions

View File

@@ -464,10 +464,12 @@ static void SDLash_EventHandler( SDL_Event *event )
case SDL_CONTROLLERBUTTONUP:
case SDL_CONTROLLERDEVICEADDED:
case SDL_CONTROLLERDEVICEREMOVED:
#if SDL_VERSION_ATLEAST( 2, 0, 14 )
case SDL_CONTROLLERTOUCHPADDOWN:
case SDL_CONTROLLERTOUCHPADMOTION:
case SDL_CONTROLLERTOUCHPADUP:
case SDL_CONTROLLERSENSORUPDATE:
#endif
SDLash_HandleGameControllerEvent( event );
break;

View File

@@ -121,18 +121,16 @@ static void SDLash_GameControllerAddMappings( const char *name )
static void SDLash_SetActiveGameController( SDL_JoystickID id )
{
SDL_GameController *oldgc;
if( g_current_gamepad_id == id )
return;
g_current_gamepad_id = id;
oldgc = g_current_gamepad;
#if SDL_VERSION_ATLEAST( 2, 0, 14 )
SDL_GameControllerSetSensorEnabled( oldgc, SDL_SENSOR_GYRO, SDL_FALSE );
// going to change active controller, disable gyro events in old
SDL_GameControllerSetSensorEnabled( g_current_gamepad, SDL_SENSOR_GYRO, SDL_FALSE );
#endif // SDL_VERSION_ATLEAST( 2, 0, 14 )
g_current_gamepad_id = id;
if( id < 0 )
{
g_current_gamepad = NULL;
@@ -231,6 +229,7 @@ static void SDLash_GameControllerRemoved( SDL_JoystickID id )
}
}
#if SDL_VERSION_ATLEAST( 2, 0, 14 )
static void SDLash_GameControllerSensorUpdate( SDL_ControllerSensorEvent sensor )
{
vec3_t data;
@@ -256,6 +255,7 @@ static void SDLash_GameControllerSensorUpdate( SDL_ControllerSensorEvent sensor
VectorSubtract( sensor.data, gyrocal.calibrated_values, data );
Joy_GyroEvent( data );
}
#endif
void SDLash_HandleGameControllerEvent( SDL_Event *ev )
{

View File

@@ -116,7 +116,10 @@ void SDLash_Init( const char *basedir )
#if SDL_MAJOR_VERSION >= 2
SDL_SetHint( SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0" );
#ifdef SDL_HINT_MOUSE_TOUCH_EVENTS
SDL_SetHint( SDL_HINT_MOUSE_TOUCH_EVENTS, "0" );
#endif // SDL_HINT_MOUSE_TOUCH_EVENTS
SDL_SetHint( SDL_HINT_TOUCH_MOUSE_EVENTS, "0" );
SDL_StopTextInput();

View File

@@ -257,8 +257,12 @@ static void R_InitVideoModes( void )
{
char buf[MAX_VA_STRING];
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
#if SDL_VERSION_ATLEAST( 2, 24, 0 )
SDL_Point point = { window_xpos.value, window_ypos.value };
int displayIndex = SDL_GetPointDisplayIndex( &point );
#else
int displayIndex = 0;
#endif
int i, modes;
num_vidmodes = 0;
@@ -1060,8 +1064,14 @@ qboolean R_Init_Video( const int type )
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_DisplayMode displayMode;
#if SDL_VERSION_ATLEAST( 2, 24, 0 )
SDL_Point point = { window_xpos.value, window_ypos.value };
SDL_GetCurrentDisplayMode( SDL_GetPointDisplayIndex( &point ), &displayMode );
int displayIndex = SDL_GetPointDisplayIndex( &point );
#else
int displayIndex = 0;
#endif
SDL_GetCurrentDisplayMode( displayIndex, &displayMode );
refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format );
#else
refState.desktopBitsPixel = 16;