DPad

Jul 30, 2011 at 4:01 PM
Edited Jul 31, 2011 at 12:04 PM

I can not get gamepad arrows state, i use this code in update method and put a breakpoint in DoSomething and it never gets called, I also use buttonPressed event to get buttons state which works, but I could not manage to get arrows state, what should I do:

if(input.GetGamePad(ExtendedPlayerIndex.Five).GetState().DPad.Up == ButtonState.Pressed)
	DoSomething();
Coordinator
Aug 9, 2011 at 9:43 AM

Does your game pad report its DPad as individual buttons or as a PoV hat?

The only DirectInput game pad I could test with was a Thrustmaster Dual Analog Pro, where I don't remember having any issues. I'll check again if that specified way of querying the DPad might be messed up or something.

Aug 9, 2011 at 10:42 PM
Edited Aug 9, 2011 at 10:44 PM

I manged to get it working like this, but I do not know why does it see its DPad as a ThumbStick, code and gamepad image below: 

if(input.GetGamePad(ExtendedPlayerIndex.Five).GetState().ThumbSticks.Left.Y > 0)
	GoUp();

 

Gamepad

Coordinator
Aug 10, 2011 at 7:29 AM

That would be DirectInput. There are 4 different kinds of input objects: buttons (on/off), sliders (analogous 0.0 .. 1.0), axes (analogous -1.0 .. +1.0) and PoV hats (direction in degrees). A game pad is free to report its hardware as any of those.

My guess is that this game pad reports the directional pad as two analogous axes in order to work with as many games as possible (since a PoV hat is typically used for looking around instead of moving the character).

Nuclex.Input could theoretically map analogous axes to the DPad for the DirectInput -> XNA GamePadState translation, but I think that would be counter-productive (lots of game pads with an actual analogous thumb stick ending up with a digital DPad instead).

Aug 10, 2011 at 7:44 AM

Thank you for the explanation.