mdqinc / SDL_GameControllerDB

A community sourced database of game controller mappings to be used with SDL2 Game Controller functionality
http://libsdl.org
zlib License
1.38k stars 520 forks source link

Add device layout information to DB #692

Closed stephanbogner closed 1 year ago

stephanbogner commented 1 year ago

Goal:

In my game I want to show the appropriate image for a controller with its button mapping.

If it's a PS5 controller show the image of a PS5 controller, if it's an Xbox Series controller, show an image for an Xbox Series controller.

Problem:

There are many controllers that share the same layout but have different names or IDs.

Solution

Add another value to the entries that describes their basic layout, e.g. xbox-series-controller or wii-remote. This is not the same as the controller platform, as explained below.

Complications (only one example each):

A possible (and incomplete list) of values could be:

ps-controller, ps2-controller, ps3-controller, ps4-controller, ps5-controller, xbox-controller, xbox-360-controller, xbox-series-controller, xbox-one-controller, joycon-right, joycon-left, joycon-pair, steam-deck, steam-controller, wii-remote, gamecube-controller, ouya-controller, luna-controller and so on.

Personal note:

This can get quite complex. For my game I am planning on only covering the most common controllers, but I wanted to bring this up, because likely more people have the same issue and I would not have a problem contributing.

Early Godot code I am thinking of using ```Python match (device_name): # --- Xbox --- "Xbox 360 Controller", "Hori Fighting Commander Xbox 360", "GameStop Xbox 360 Controller": return "xbox-360-controller" "Xbox One Controller", "Xbox One S Controller", "Xbox One Elite", "Xbox One Elite 2 Controller", "Xbox Elite Controller Series 2", "Xbox One PowerA Controller": return "xbox-one-controller" "Xbox Series Controller": return "xbox-series-controller" # --- Playstation --- "PS3 Controller": return "ps3-controller" "PS4 Controller": return "ps4-controller" "PS5 Controller": return "ps5-controller" # --- Other --- "Steam Controller": return "steam-controller" "Steam Deck": return "steam-deck" # If unknown we use a generic gamepad return "generic-controller" ```
offalynne commented 1 year ago

This is beyond the scope of this DB. You should take this up with Godot. This DB is for SDL2 2.0.16 and forward. That Godot and other projects use it is incidental.

SDL has it's own list of types here: https://github.com/libsdl-org/SDL/blob/main/src/joystick/controller_list.h

I maintain a DB of types for those not upstreamed to SDL for an unrelated project here: https://github.com/JujuAdams/Input/blob/community-data/community_gamepad_type.txt

If you propose this downstream to Godot and it receives an adequate response, I am willing to break that out into it's own repo and/or help contribute to what you're proposing, but this repo is not the place for this issue.

stephanbogner commented 1 year ago

Thank you very much for the quick response, the clarifications and the offer to help out :heart:

The two resources you mentioned look very handy indeed! I am gonna have a closer look and think about what a good proposal regarding Godot would be.