Gamepad Database Tentative Design

This is a tentative design for a simple gamepad database, containing both SDL2 mappings of gamepads and layout descriptions.

The database is a keyfile containing 3 kind of groups:

  • GUID groups, named with just a GUID and listing gamepads having this GUIS. The list of gamepads can't be empty and should in the best case have only one element. Having multiple gamepad names allow to support different gamepads with the same GUID.
  • Gamepad groups, describing the gamepad, giving a displayable name, its SDL2 mapping and its layout name.
  • Layout groups, describing the name of the various inputs of t he gamepad.

To use it, compute your gamepad's SDL2 GUID, and lookup the corresponding group. If there is one, check the corresponding gamepad list, and from the gamepad check the corresponding layouts.

[030000004c0500006802000011010000]
Gamepads=030000004c0500006802000011010000;

[0000000058626f782047616d65706100]
Gamepads=0000000058626f782047616d65706100;

[Gamepad 030000004c0500006802000011010000]
Name=PS3 Controller
DisplayName=PlayStation 3 Controller
DisplayName[fr_FR]=Manette PlayStation 3
StandardMapping=a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,
Layout=PS3

[Gamepad 0000000058626f782047616d65706100]
Name=Xbox Gamepad (userspace driver)
DisplayName=Xbox Controller
DisplayName[fr_FR]=Manette Xbox
StandardMapping=a:b0,b:b1,x:b2,y:b3,start:b7,back:b6,guide:b8,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,lefttrigger:a5,righttrigger:a4,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a2,righty:a3,
Layout=Xbox

[Layout PS3]
A=⨯
AColor=#7CB2E8
B=○
BColor=#FF6666
X=□
XColor=#FF69F8
Y=△
YColor=#40E2A0
L=L1
R=R1
L2=L2
R2=R2
L3=L3
R3=R3
Start=Start
Back=Select
Guide=PS

[Layout Xbox]
A=A
B=B
X=X
Y=Y
L=LB
R=RB
L2=LT
R2=RT
L3=Left Stick
L3[fr_FR]=Stick gauche
R3=Right Stick
R3[fr_FR]=Stick droit
Start=Start
Back=Back
Guide=Guide

Discussion and Ideas

  • We should have a shared gamepad info database we could share with SDL and whoever wants to use it (SFML?)?
  • How to handle gamepads other than the "standard" ones? Probably just by having multiple mappings per gamepad (StandardMapping, WiiRemoteMapping…)

  • How to handle gamepads with multiple modes? Probably as different gamepads sharing the same UID, kind of as it's done by the Switch for the Joy-Con: press the main L and R on each Joy-Con and you use both, press the side L and R on one Joy-Con and you use it alone in side mode.

Design/Playground/Games/GamepadDB (last edited 2017-10-17 06:08:43 by AdrienPlazas)