Skip to content

Commit a6100a8

Browse files
author
briaguya
committed
add GameControllerDB mappings before initializing the SDL gamecontroller subsystem
1 parent 3a6518f commit a6100a8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/public/libultra/os.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ int32_t osContInit(OSMesgQueue* mq, uint8_t* controllerBits, OSContStatus* statu
1414
*controllerBits = 0;
1515
status->status |= 1;
1616

17-
SDL_SetHint(SDL_HINT_JOYSTICK_THREAD, "1");
18-
if (SDL_Init(SDL_INIT_GAMECONTROLLER) != 0) {
19-
SPDLOG_ERROR("Failed to initialize SDL game controllers ({})", SDL_GetError());
20-
exit(EXIT_FAILURE);
21-
}
22-
2317
std::string controllerDb = Ship::Context::LocateFileAcrossAppDirs("gamecontrollerdb.txt");
2418
int mappingsAdded = SDL_GameControllerAddMappingsFromFile(controllerDb.c_str());
2519
if (mappingsAdded >= 0) {
@@ -28,6 +22,12 @@ int32_t osContInit(OSMesgQueue* mq, uint8_t* controllerBits, OSContStatus* statu
2822
SPDLOG_ERROR("Failed add SDL game controller mappings from \"{}\" ({})", controllerDb, SDL_GetError());
2923
}
3024

25+
SDL_SetHint(SDL_HINT_JOYSTICK_THREAD, "1");
26+
if (SDL_Init(SDL_INIT_GAMECONTROLLER) != 0) {
27+
SPDLOG_ERROR("Failed to initialize SDL game controllers ({})", SDL_GetError());
28+
exit(EXIT_FAILURE);
29+
}
30+
3131
Ship::Context::GetInstance()->GetControlDeck()->Init(controllerBits);
3232

3333
return 0;

0 commit comments

Comments
 (0)