mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-04 05:04:33 +00:00
[PR #781] [MERGED] SDLControllerInterface: Add support for optional game controller database #117
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/stenzek/duckstation/pull/781
Author: @hhromic
Created: 8/22/2020
Status: ✅ Merged
Merged: 8/22/2020
Merged by: @stenzek
Base:
master← Head:add-gamecontrollerdb📝 Commits (1)
1e10befSDLControllerInterface: Add support for optional game controller database📊 Changes
2 files changed (+20 additions, -0 deletions)
View changed files
📝
src/frontend-common/sdl_controller_interface.cpp(+17 -0)📝
src/frontend-common/sdl_controller_interface.h(+3 -0)📄 Description
At present, DuckStation's SDL input interface (i.e. used by the Qt frontend) is using SDL2's GameController API, which requires devices to have known controller mappings. SDL2 provides an embedded database of recognised controllers in its own source code, however it is rather small and thus limited in practice.
This trivial PR improves game controller compatibility out of the box by implementing support for loading an optional game controller database file. If an optional
gamecontrollerdb.txtfile exists in the user directory, then SDL game controller mappings will be loaded from it. In portable mode, the database can be placed alongside the DS executable.There is an officially endorsed community sourced database in https://github.com/gabomdq/SDL_GameControllerDB
Users can also create their own custom controller mappings using readily available tools (see community repository).
I followed the existing code style as much as possible, but let me know if you want something implemented in a different way.
Note: The mappings are loaded before initialising the game controller subsystem because otherwise already connected controllers present in the database file do not trigger
SDL_CONTROLLERDEVICEADDEDevents on application startup.Fixes #731 (more context there as well)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.