Skip to content

Commit

Permalink
Load game controller database via an SDL hint.
Browse files Browse the repository at this point in the history
Hopefully this will eliminate any possibility of a joystick being opened
before the game controller database is loaded.

See #356.
  • Loading branch information
tom-seddon committed Jul 20, 2024
1 parent 658e05b commit 9f95270
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/b2/b2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -758,8 +760,6 @@ static bool InitSystem(

SDL_StartTextInput();

SDL_GameControllerAddMappingsFromFile(GetAssetPath("gamecontrollerdb.txt").c_str());

#if SYSTEM_OSX
InitHIDCallback(init_messages);
#endif
Expand Down

0 comments on commit 9f95270

Please sign in to comment.