I love GLFW so far, keep up the good work!
I do have a problem with reading the joystick though.
I am testing with a PS3 controller.
I have found that the values returned by GLFW do not correspond to the actual values from the device. (I compared them with jstest values.)
Issues I found:
On left and right thumbsticks, GLFW returns positive values for moving the stick up.
The device though uses negative for up.
The right trigger value is inverted.
When released, the left trigger returns -1.
When released, the right trigger returns +1.
When pressed, the left trigger returns +1.
When pressed, the right trigger returns -1.
The raw device values do not exhibit this behavior:
both left and right triggers will return positive values when pressed.
Is this on purpose? If so with what rationale?
Ugh... I found the offending code in x11_joystick.c
Uneven numbered axes are inverted.
That's pretty ugly, if you ask me.
It also explains why the LEFT and RIGHT triggers behave differently.
It says it is according to GLFW spec, but you may want to change the spec.
It is impossible to implement the spec, since you have no knowledge about the axes.
It could be a thumbstick, but what if it is a brake pedal?
There is no complete joystick database that will tell you how each axis functions on a device.
// We need to change the sign for the Y axes, so that
// positive = up/forward, according to the GLFW spec.
if (e.number & 1)
BTW, the win32_joystick.c is even worse off:
This code assumes that the nr of axes are even, and will probably crash upon uneven axis count.
axes[(*count)++] = calcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax);
axes[(*count)++] = -calcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax);
And it also does the uneven axis inversion like x11 does.
I will address this in 3.0.4 or 3.1. Thank you for detailing it!
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.