[PR #781] [MERGED] SDLControllerInterface: Add support for optional game controller database #117

Closed
opened 2026-01-29 19:06:29 +00:00 by claunia · 0 comments
Owner

📋 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: masterHead: add-gamecontrollerdb


📝 Commits (1)

  • 1e10bef SDLControllerInterface: 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.txt file 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_CONTROLLERDEVICEADDED events 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.

## 📋 Pull Request Information **Original PR:** https://github.com/stenzek/duckstation/pull/781 **Author:** [@hhromic](https://github.com/hhromic) **Created:** 8/22/2020 **Status:** ✅ Merged **Merged:** 8/22/2020 **Merged by:** [@stenzek](https://github.com/stenzek) **Base:** `master` ← **Head:** `add-gamecontrollerdb` --- ### 📝 Commits (1) - [`1e10bef`](https://github.com/stenzek/duckstation/commit/1e10bef09e468bd4935563d15dc295fa9982ae05) SDLControllerInterface: Add support for optional game controller database ### 📊 Changes **2 files changed** (+20 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/frontend-common/sdl_controller_interface.cpp` (+17 -0) 📝 `src/frontend-common/sdl_controller_interface.h` (+3 -0) </details> ### 📄 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](https://github.com/spurious/SDL-mirror/blob/master/src/joystick/SDL_gamecontrollerdb.h), 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.txt` file 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_CONTROLLERDEVICEADDED` events on application startup. Fixes #731 (more context there as well) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 19:06:29 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/duckstation#117