diff --git a/3rdparty/extras/xash-extras b/3rdparty/extras/xash-extras index 1bdeab2d..4982e5ed 160000 --- a/3rdparty/extras/xash-extras +++ b/3rdparty/extras/xash-extras @@ -1 +1 @@ -Subproject commit 1bdeab2d8f25a920cef68860e709f3ad6805e3c3 +Subproject commit 4982e5edb0a50ca99b2927b12b91c54968733b55 diff --git a/engine/platform/sdl/in_sdl.c b/engine/platform/sdl/in_sdl.c index 1dcc9573..3b0155da 100644 --- a/engine/platform/sdl/in_sdl.c +++ b/engine/platform/sdl/in_sdl.c @@ -224,6 +224,23 @@ static int SDLash_JoyInit_Old( int numjoy ) } #if SDL_VERSION_ATLEAST( 2, 0, 0 ) +static void SDLash_GameControllerAddMappings( const char *name ) +{ + fs_offset_t len = 0; + byte *p = FS_LoadFile( name, &len, false ); + + if( !p ) + return; + + if( len > 0 && len < INT32_MAX ) // function accepts int, SDL3 fixes this + { + SDL_RWops *rwops = SDL_RWFromConstMem( p, len ); + SDL_GameControllerAddMappingsFromRW( rwops, true ); + } + + Mem_Free( p ); +} + /* ============= SDLash_JoyInit_New @@ -242,7 +259,8 @@ static int SDLash_JoyInit_New( int numjoy ) return 0; } - SDL_GameControllerAddMappingsFromFile( "controllermappings.txt" ); + SDLash_GameControllerAddMappings( "gamecontrollerdb.txt" ); // shipped in extras.pk3 + SDLash_GameControllerAddMappings( "controllermappings.txt" ); count = 0; numJoysticks = SDL_NumJoysticks();