Hi.
I’ve ben working with Generic USB Controllers & vJoy virtual controller on my application. Lately I bought an PS4 Wireless controller but it seems some mapping/binding characterictics are differerent regarding button mapping.
My purpose is to have 1-1 button and axes mapping with physical and virtual controller, say when I press button no X on physical, virtual should also behave as if button X is pressed and I validate this behaviour by using PES 2016 conttroller visualisation tool (see last image).
I’m using SDL_GameControllerGetBindForAxis() and SDL_GameControllerGetBindForButton() functions to decide mapping of each physical controller. This is an example mapping image I get from one of these Generic controllers.
Button0 => Bind Button 2
Button 1 => Bind BUtton 1
Button 2 => Bind Button 3
Button 3 => Bind Button 0
…
…
As my understanding, this mapping means the corresponding (vJoy) button number when SDL_GameControllerGetButton() method is called. For example if I call SDL_GameControllerGetButton(controller, (SDL_GameControllerButton)0),I read the button value at index 0 which means button_2, because of button mapping(see image above). Since 0 maps to 2, I command vJoy controller button 2 to be high. With this method, all of my generic controllers were working fine even if they have different mappings.
The issue is My PS4 controller returns 1-1 mapping for buttons, which means after calling SDL_GameControllerGetBindForButton() for each button I get this:
Button0 => Bind Button 0
Button 1 => Bind Button 1
Button 2 => Bind Button 2
Button 3 => Bind Button 3
…
…
I try what I did with generic ones but buttons are scrambled this time. They are not corresponding to same buttons. I suspect SDL or my mapping method is source of the problem because buttons are 1-1 identical on PES 2016 controller when I press PS4 physical buttons. e.g when I press Triangle, Button Y is highlighted (because controller is XBox image, Triangle => Y) and it corresponds to button 3, which is correct… Same for the rest… This means PES tool can understand controler inputs correctly, while SDL & 1-1 mapping method generates incorrect mapping.
My validation method is like this: I use PES 2016 Controller visualisation tool.
I switch controller between physical and virtual ones through combobox and observing if same buttons are highlighted when I press one of the buttons of physical controller.