# Positive gamepad axis directions

**URL:** <https://discourse.glfw.org/t/positive-gamepad-axis-directions/956>\
**Category:** support\
**Created:** [August 3, 2017, 5:43pm UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956 "2017-08-03T17:43:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![fractilegames](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/fractilegames/32/114_2.png) [@fractilegames](https://discourse.glfw.org/u/fractilegames)\
**Post date:** [August 3, 2017, 5:43pm UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/1 "2017-08-03T17:43:01Z")

</div>

[Now that](https://github.com/glfw/glfw/issues/900) 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.

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [August 3, 2017, 7:54pm UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/2 "2017-08-03T19:54:13Z")

</div>

> [@fractilegames](#):
>
> Can I trust that axes in GLFWgamepadstate have consistent positive directions? Positive stick direction right/forward?

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.

> [@fractilegames](#):
>
> 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 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.

---

<div class="post-metadata">

**Author:** ![fractilegames](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/fractilegames/32/114_2.png) [@fractilegames](https://discourse.glfw.org/u/fractilegames)\
**Post date:** [August 4, 2017, 8:25am UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/3 "2017-08-04T08:25:35Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [August 4, 2017, 10:01am UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/4 "2017-08-04T10:01:06Z")

</div>

> [@fractilegames](#):
>
> By the way, is there a way to set certain keyboard mapping “manually” even if the GUID does not match?

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?

---

<div class="post-metadata">

**Author:** ![fractilegames](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/fractilegames/32/114_2.png) [@fractilegames](https://discourse.glfw.org/u/fractilegames)\
**Post date:** [August 4, 2017, 10:13am UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/5 "2017-08-04T10:13:56Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![fractilegames](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/fractilegames/32/114_2.png) [@fractilegames](https://discourse.glfw.org/u/fractilegames)\
**Post date:** [August 4, 2017, 1:07pm UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/6 "2017-08-04T13:07:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [August 6, 2017, 12:48am UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/7 "2017-08-06T00:48:47Z")

</div>

> [@fractilegames](#):
>
> Linux: I had to add new mappings (GUIDs did not match existing mappings) for Xbox controller and PS4 controller.

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

> [@fractilegames](#):
>
> Where can I find information about the axis inversion support? Is it already supported by GLFW?

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.

---

<div class="post-metadata">

**Author:** ![fractilegames](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/fractilegames/32/114_2.png) [@fractilegames](https://discourse.glfw.org/u/fractilegames)\
**Post date:** [August 6, 2017, 1:57pm UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/8 "2017-08-06T13:57:26Z")

</div>

> [@elmindreda](#):
>
> > [@fractilegames](#):
> >
> > Linux: I had to add new mappings (GUIDs did not match existing mappings) for Xbox controller and PS4 controller.
> 
> That sounds a little worrisome. What GUIDs did they get?

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](http://generalarcade.com/gamepadtool/)):

```
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,

```

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [August 6, 2017, 4:00pm UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/9 "2017-08-06T16:00:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fractilegames](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/fractilegames/32/114_2.png) [@fractilegames](https://discourse.glfw.org/u/fractilegames)\
**Post date:** [August 6, 2017, 9:07pm UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/10 "2017-08-06T21:07:18Z")

</div>

> [@elmindreda](#):
>
> 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…

---

<div class="post-metadata">

**Author:** ![gestaltdevstudio](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/gestaltdevstudio/32/129_2.png) [@gestaltdevstudio](https://discourse.glfw.org/u/gestaltdevstudio)\
**Post date:** [September 27, 2017, 5:38am UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/11 "2017-09-27T05:38:34Z")

</div>

> [@elmindreda](#):
>
> 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.

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](https://github.com/glfw/glfw/blob/master/tests/joysticks.c) 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](http://html5gamepad.com/) 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.

Thanks!

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [September 27, 2017, 9:39pm UTC](https://discourse.glfw.org/t/positive-gamepad-axis-directions/956/12 "2017-09-27T21:39:08Z")

</div>

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