Positive gamepad axis directions

Now that support for SDL2’s game controller DB has been implemented, I have been thinking of dumping my own gamepad mapping code on top of GLFW. One thing bothers me though… Can I trust that axes in GLFWgamepadstate have consistent positive directions? Positive stick direction right/forward?

Looking at my own gamepad layouts I have had to invert Y-axes on sticks for all non-XInput gamepads (my solution outputs positive Y forward).

At some point I also had to add support for switching analog trigger value range between 0…1 and -1…1, but it’s not needed by any of the gamepads I have at hand. I can’t remember which gamepad required it.

The gamepad functions should be consistent across platforms and APIs now, to the same extent as SDL 2.0.4, but please do test and see. My collection of controllers is rather small and if I got a minus sign wrong somewhere we really need to know before release.

The mapping parser in SDL 2.0.5 (the most recent release) gained support for range and inversion modifiers for this exact reason, but SDL_GameControllerDB still doesn’t have any mappings that make use of it. It’s something GLFW will gain support for as well, but right now there’s no data.

That sounds good. I’ll rewrite my controller code then and report back how it goes.

By the way, is there a way to set certain keyboard mapping “manually” even if the GUID does not match? Not that I need it right now, just wondering…

There isn’t, but you can query the GUID with glfwGetJoystickGUID and add a new mapping for it with glfwUpdateGamepadMappings. That will replace any previous mapping for that GUID.

You were wanting to use it for remapping of game controls?

Not for remapping. My current system has support for manually setting gamepad type and it has been useful when a gamepad is not auto-detected (often due ambiguous device names), but is known to be compatible with some of the existing mappings. This should not be needed now that we’re using GUIDs…

It all seems to be working fairly well using latest DB from github, especially in Linux. I tested Wireless Xbox controller, PS4 controller, PS3 controller, Logitech F310 and 8Bitdo NES30 Pro gamepads.

Linux: I had to add new mappings (GUIDs did not match existing mappings) for Xbox controller and PS4 controller. Linux mapping for NES30 PRO was missing completely. Now they all work perfectly!

Windows: PS3 controller has never worked on Windows without some 3rd party software, but PS4 controller works perfectly. I had to fix A/B/X/Y -button order for NES30 PRO (hopefully this was just a bug in mappings), but it works fine now. I had some driver issues with wireless xbox dongle, so I couldn’t test it. Logitech gamepad worked otherwise fine, but stick Y axes were reversed!

Where can I find information about the axis inversion support? Is it already supported by GLFW?

That sounds a little worrisome. What GUIDs did they get?

I don’t really know where. I spotted it looking for SDL 2.0.4 > 2.0.5 GUID conversion, noticed it because I’d already considered adding something like that myself (but don’t want to embrace and extend a format they own).

It’s not supported by GLFW yet.

Database had multiple lines for PS4 controller and this line for wireless XBox controller:

030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,

These are the lines that I added (using the gamepad tool):

05000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,x:b4,y:b3,back:b10,start:b11,leftstick:b13,rightstick:b14,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a6,platform:Linux,
030000004c050000cc09000011810000,Sony Interactive Entertainment Wireless Controller,a:b0,b:b1,x:b3,y:b2,back:b8,guide:b10,start:b9,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Linux,
030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,x:b2,y:b3,back:b6,guide:b8,start:b7,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Linux,

You made those lines with the gamepad tool and they worked unmodified in GLFW?

I copy-pasted those lines from the gamepad tool to gamecontrollerdb.txt file that I load and pass to GLFW. At least it looked like it worked. I’ll double check tomorrow…

Hi elmidread, I’m sorry for insist in the Y axis of xbox gamepads (Xbox 360 and Xbox One here). But now that you asked for tests… In the Joysticks Test the positive value of Y axis is inverted compared to DS4 and DS3 on Windows (8 and 10 at least). On linux it’s ok ( all of the 4 models positive when down). The curious thing is that in Gamepad HTML5 Test the Y axis of Xbox gamepads is positive when down. In the Settings of Xbox gamepad on windows it’s not inverted too.

I’m now using the GLFWGamepadState and facing this issue. If you want me to test some branch or C file with these gamepads, please tell me.


Thank you! Please open an issue about this so it doesn’t get lost here.