From 9f95270c17b6f63f6da95e61622f0b7cce406dc4 Mon Sep 17 00:00:00 2001 From: Tom Seddon Date: Sat, 20 Jul 2024 01:00:24 +0100 Subject: [PATCH] Load game controller database via an SDL hint. Hopefully this will eliminate any possibility of a joystick being opened before the game controller database is loaded. See #356. --- src/b2/b2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/b2/b2.cpp b/src/b2/b2.cpp index 9512f532..edfd8e56 100644 --- a/src/b2/b2.cpp +++ b/src/b2/b2.cpp @@ -741,6 +741,8 @@ static bool InitSystem( Messages *init_messages) { (void)options; + SDL_SetHint(SDL_HINT_GAMECONTROLLERCONFIG_FILE, GetAssetPath("gamecontrollerdb.txt").c_str()); + // Initialise SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) != 0) { init_messages->e.f("FATAL: SDL_Init failed: %s\n", SDL_GetError()); @@ -758,8 +760,6 @@ static bool InitSystem( SDL_StartTextInput(); - SDL_GameControllerAddMappingsFromFile(GetAssetPath("gamecontrollerdb.txt").c_str()); - #if SYSTEM_OSX InitHIDCallback(init_messages); #endif