Game Controller Axis Names

Hi all… I have a strange thing going on here. I’ve hooked up my PS3 remote to my computer as well as my GameCube controller with a Mayflash adapter, and I’ve been hauling away on getting controller support working in my game.

After much toil and travail, I’ve created a really, really flexible configuration system for loading controllers up in my game. I request the user for various inputs (action button, back button, etc.), then store the button names. The button part is going really well, because it seems button names stay constant. However, I’ve had a small problem which has led to an important question when trying to implement axis discovery.

Before, I was identifying axes by their “axis.descriptor” key. The problem was that this value wasn’t constant for an axis. Sometimes the left stick’s axes would be defined as “Joystick 1: Axis n” and sometimes as “Joystick 2: Axis n”. I’ve since switched to using axis.number instead. It seems to be constant so far, but I want to make sure. Does an axis always return the same value for axis.number? Can I be assured that, if axis #4 shows up as a controller’s left stick Y axis, axis #4 will remain that axis and not be reassigned no matter how many times I disconnect the controller and restart my game?

  • Caleb

Unfortunately each controller can map their buttons and axes differently.  If you look at the PewPew sample app, it has a pretty simple way of letting the user decide what buttons/axes to use and you can capture it at that point.

Rob

I already have a calibration system that asks for inputs and everything. Here’s what I do:

  1. Ask for button inputs

  2. Store button inputs in adapted format (“I asked for the action button, and the user pressed button14. Now I can transform button14 events into action button events”)

  3. Ask for axis inputs

  4. Store axis inputs in adapted format (“I asked for the left stick’s axes, and the user moved axes 1 and 2. Now I can transform axes 1 and 2 into left stick input events”)

My problem is, in step #4, I was originally storing the axis inputs by axis.descriptor. For example, I’d save “left stick Y axis” as “Joystick 1: Axis 1” (whatever came back from the axis event when I calibrated). The problem is, I would then save the calibrated axis data and try reloading the game. Half the time the axes would work, and half the time they wouldn’t. I figured out that it was because each time I restarted the game, the controller’s axes were getting new axis.descriptor values. Sometimes they’d be what I measured (“Joystick 1: Axis 1”), but sometimes they’d switch around (so that the axis that once sent “Joystick 1: Axis 1” events now sent “Joystick 2: Axis 1” events). I’m asking if axis.number is the same way. Does it ever change, or will it remain constant for each controller? (Note: I’m not talking about remaining constant for every controller. I’m talking about, if a controller identifies an axis as axis #3, will axis #3 for that controller always be that axis? Or will it swap around like axis.descriptor?).

  • Caleb

Unfortunately each controller can map their buttons and axes differently.  If you look at the PewPew sample app, it has a pretty simple way of letting the user decide what buttons/axes to use and you can capture it at that point.

Rob

I already have a calibration system that asks for inputs and everything. Here’s what I do:

  1. Ask for button inputs

  2. Store button inputs in adapted format (“I asked for the action button, and the user pressed button14. Now I can transform button14 events into action button events”)

  3. Ask for axis inputs

  4. Store axis inputs in adapted format (“I asked for the left stick’s axes, and the user moved axes 1 and 2. Now I can transform axes 1 and 2 into left stick input events”)

My problem is, in step #4, I was originally storing the axis inputs by axis.descriptor. For example, I’d save “left stick Y axis” as “Joystick 1: Axis 1” (whatever came back from the axis event when I calibrated). The problem is, I would then save the calibrated axis data and try reloading the game. Half the time the axes would work, and half the time they wouldn’t. I figured out that it was because each time I restarted the game, the controller’s axes were getting new axis.descriptor values. Sometimes they’d be what I measured (“Joystick 1: Axis 1”), but sometimes they’d switch around (so that the axis that once sent “Joystick 1: Axis 1” events now sent “Joystick 2: Axis 1” events). I’m asking if axis.number is the same way. Does it ever change, or will it remain constant for each controller? (Note: I’m not talking about remaining constant for every controller. I’m talking about, if a controller identifies an axis as axis #3, will axis #3 for that controller always be that axis? Or will it swap around like axis.descriptor?).

  • Caleb