Hi there, lately I’ve been digging to understand controller mapping concept and already asked a question related to it: SDL Game controller button mapping issue
Before that I realized that I should understand every concept about mapping and I’m doing observations.
I connected 2 of my controllers and I use https://gamepad-tester.com/ for my observations
This is when I press leftmost button of the right button group (X for XBox, Rectangle for PS4, “4” for my usb controller)
On PS4: Button 2 is highlighted
On USB Generic: Button 3 is highlighted
The result says they have different correspondance, which might be OK for every distict controller. This is my first observation.
The other observation is, when I use SDL_GameControllerGetButton() to read button states:
state = SDL_GameControllerGetButton(m_pGameController, (SDL_GameControllerButton)bIndex)
The leftmost button (X, Rectangle, “4”) of right button group always corresponds to index 2 (index starts with 0). What I mean is when I press the leftmost button and then use SDL_GameControllerGetButton(m_pGameController, (SDL_GameControllerButton)2), then I’m able to read the the button state, for both USB and PS4 controller. This is my second observation.
So, can I state this conclusion/generalisation?
Game controllers’ physical button correspondance with SDL_GameControllerGetButton() is always the same. Whatever the controller is:
Right Button Group:
left = SDL_GameControllerGetButton(2) // Rectangle, 4
right = SDL_GameControllerGetButton(3) // Triangle, 2
bottom = SDL_GameControllerGetButton(0) // X, 3
up = SDL_GameControllerGetButton(1) // Circle, 1
Middle Button Group:
back = SDL_GameControllerGetButton(4)
guide= (not exist on USB controller)
start= SDL_GameControllerGetButton(6)
touch= (not exist on USB controller)
DPad:
left = SDL_GameControllerGetButton(13)
right = SDL_GameControllerGetButton(14)
up= SDL_GameControllerGetButton(11)
down= SDL_GameControllerGetButton(12)
Back Group:
RT = SDL_GameControllerGetButton(10)
RB = SDL_GameControllerGetAxis(5)
LT = SDL_GameControllerGetButton(9)
LB = SDL_GameControllerGetAxis(4)
(So if I had an XBox controller and press X button (left button) then I should use SDL_GameControllerGetButton(2) to read its state?)