Skip to content

Commit ec13b6f

Browse files
committed
added SDL_GameControllerDB support
added `SDL_GameControllerAddMappingsFromFile` to allow support for SDL_GameControllerDB as a option, for those who prefer Community-driven Gamepad database (tends to be far more up-to-date than main SDL)
1 parent 2afc092 commit ec13b6f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

UnleashedRecomp/hid/driver/sdl_hid.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,13 @@ void hid::Init()
344344
SDL_AddEventWatch(HID_OnSDLEvent, nullptr);
345345

346346
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
347+
348+
// Load SDL_GameControllerDB mappings from file
349+
const char* mappingFile = "gamecontrollerdb.txt";
350+
int mappingsAdded = SDL_GameControllerAddMappingsFromFile(mappingFile);
351+
if (mappingsAdded > 0) {
352+
LOGFN("Loaded {} controller mapping(s) from SDL_GameControllerDB file", mappingsAdded, mappingFile);
353+
}
347354
}
348355

349356
uint32_t hid::GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState)

0 commit comments

Comments
 (0)