Y-axis on thumbsticks is inverted on my directXgamepads

Feb 6, 2011 at 2:43 PM

Hi,

Don't know if this is just an issue for me or not.
The Y-axis on the thumbsticks produces -1 when they are pressed upwards and +1 when they are pressed downwards.
I'm new at this... but I think it should be the opposite.

I've tried with two different kinds of gamepads with the same results. The gamepads have always work correctly in all games using directx.
Thanks for all the work you put into Nuclex.Input.

(I use Nuclex Framework R1323.)

BR
/Sam

Coordinator
Feb 6, 2011 at 4:35 PM

Just checked it with my Xbox 360 game pad and an old Thrustmaster PC game pad and I get the same behavior - Y axis in DirectInput seems to be Y down.

I couldn't find anything in the documentation that explicitly says this, but I think it's safe to assume that this is the case with all Y axes - I flipped the lot of them.

Fix is committed to SVN and should make it to the nightly builds in a minute.

Thanks!

Feb 7, 2011 at 1:20 PM

Excellent! Downloaded the new source. Works like a charm.

Thanks!
/Sam

Feb 11, 2012 at 5:34 PM

Hi,

 

I seem to have the same problem with the latest source.  How can I invert the axis just in my application?  I have the code so just point me to the right place if you don't mind.  Ideally a property would be great in the future though ;)

 

Thanks

F

Coordinator
Feb 21, 2012 at 10:01 AM

Hi!

Latest source means SVN or latest source download on CodePlex? SVN is fixed, source download on CodePlex is, thanks to lazy me, still not updated...

If you want to invert axes yourself, check Nuclex.Input\Source\Devices\DirectInputConverter.cs - there's method simply named Convert() which turns a DirectInput JoystickState into XNA's GamePadState.

The axis flipping can be done by simply inverting the value returned by the axis readers (they already return a value normalized to the -1.0 .. +1.0 range)

if (this.axisReaders[1] != null) {
  leftThumbstick.Y = -this.axisReaders[1].GetValue(ref joystickState);
} else {
  leftThumbstick.Y = 0.0f;
}