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?