Load controller db from file

This commit is contained in:
Sirius902 2022-03-27 18:47:53 -07:00 committed by KiritoDev
parent d528160684
commit dae8035314
1 changed files with 8 additions and 0 deletions

View File

@ -39,6 +39,14 @@ extern "C" {
exit(EXIT_FAILURE);
}
const char* controllerDb = "gamecontrollerdb.txt";
int mappingsAdded = SDL_GameControllerAddMappingsFromFile(controllerDb);
if (mappingsAdded >= 0) {
SPDLOG_INFO("Added SDL game controllers from \"{}\" ({})", controllerDb, mappingsAdded);
} else {
SPDLOG_ERROR("Failed add SDL game controller mappings from \"{}\" ({})", controllerDb, SDL_GetError());
}
// TODO: This for loop is debug. Burn it with fire.
for (size_t i = 0; i < SDL_NumJoysticks(); i++) {
if (SDL_IsGameController(i)) {