I am trying to support both mouse/keyboard and gamepad for a twin-stick-shooter style game. I’m scratching my head at gamepad axis events and how deceiving they are.
My axis events are mapped like so:
With my gamepads disconnected I receive gamepad axis events with a value of 0.0f every frame. With no gamepads connected, I’d expect this to either not get called or be NaN. I feel like I’m missing a key part of this story, do people dynamically bind/unbind axis based on gamepad connection polling?
Right. I’m doing some outright gamepad detection now:
if (UseGamepad)
{
LastAimX = Val;
}
I guess I’m more interested in why this is the case from an architectural point of view. 0.0f is a valid axis value for a gamepad but that’s if and only if your gamepad is connected.
I don’t know if this has any bearing on your case, but I think you are only supposed to make one map pr. axis. The positive one, that is. Now, I would imagine, that the inputs would report both 1 and -1 and -1 and 1, depending on which way you go on the axis…