Incorporate SDL_GameControllerDB

This commit is contained in:
Luke Street
2026-05-12 00:05:58 -06:00
parent d1e9d5af2f
commit a0f42c0c80
2 changed files with 2255 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+16
View File
@@ -453,6 +453,14 @@ static void LanguageInit() {
selectedLanguage = static_cast<u8>(dusk::getSettings().game.language.getValue());
}
static std::string asset_path(const char* assetName) {
const char* basePath = SDL_GetBasePath();
if (basePath != nullptr && basePath[0] != '\0') {
return std::string(basePath) + "res/" + assetName;
}
return std::string("res/") + assetName;
}
// =========================================================================
// PC ENTRY POINT
// =========================================================================
@@ -508,6 +516,14 @@ int game_main(int argc, char* argv[]) {
// TODO: How to handle this?
// PADSetDefaultMapping(&defaultPadMapping, PAD_TYPE_STANDARD);
{
// Load mappings from https://github.com/mdqinc/SDL_GameControllerDB
const auto mappingsPath = asset_path("gamecontrollerdb.txt");
if (SDL_AddGamepadMappingsFromFile(mappingsPath.c_str()) < 0) {
DuskLog.warn("Failed to load gamecontrollerdb.txt: {}", SDL_GetError());
}
}
{
const auto configPathString = dusk::ConfigPath.u8string();
AuroraConfig config{};