Should We Support Getting Rid of Negative Axis Values for Gamepad Triggers?

I’m working on revamping @pspeed’s JoystickCompatibilityMappings class to handle some of the more bizarre gamepad configurations, and one issue recently stood out to me. For a lot of controllers, Xbox-based ones in particular, the L2 and R2 buttons show up as Axes rather than buttons. Now, this makes sense, considering that we have a range. However, many of these axes still range from -1 to 1 at the extremes. This makes a little less sense, as the default position of each axis will invariably be -1.

Now, many programmers don’t really care about the range and can just check if the axis is greater than 0 before triggering their action. Some applications, though, would find the range to be useful (acceleration pedals, for example). In this scenario, having the default sit at -1 would be intuitive, and also rather confusing for any gamepads that properly set their joysticks at value 0 at rest.

My solution is to add an extension to JoystickCompatibilityMappings that allows an optional provision for remapping the range of the axis. For example, if an axis is supposed to be a trigger, we can tell the properties file to remap the -1 – 1 range to 0 – 1. The syntax would look something like this:

Xbox\ 360\ Wireless\ Receiver.4=rz[0-1] # Remaps the range to go from 0 to 1 
# These remain unaffected, as there is no [X-Y] tag. This is to ensure
# backwards compatibility.
Xbox\ 360\ Wireless\ Receiver.pov_y=y
Xbox\ 360\ Wireless\ Receiver.pov_x=x

Personally, I see this as a rather useful addition, particularly for those who let users make their own remapper files. However, I’m wondering if there is something that could be lost here, or some other issue I’m not seeing.

What do you all think?

Check what happens to these values if you press the left and right triggers at the same time. Something in my memory is tickling that they affect each other… like halves of a rudder pedal.

…that may also factor into your analysis.

Yes, some gamepads will have the triggers map to the same axis, with one trigger handling the negative axis and the other handling the positive. My Xbox 360 Wireless Controllers do this when I’m using the jme3-lwjgl module. However, as long as the developer just picks either -lwjgl or -lwjgl3, they should be able to compensate appropriately (i.e., not using the range modifier in your scenario).

I will have to pull my test gamepads out again to check sometime. But I remember it being stranger than that in some cases.

Left/right triggers are all kinds of weird when looking across all gamepads.