Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XNA C# Controller Input Structures

Tags:

c#

xna

xbox360

I have looked all over the net and need some assistance. Is there a link somewhere to example code of all the buttons for the Xbox 360 controller. For example:

if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
    this.Exit();

I know this exits the game if you press back on the controller.

I just need examples of states for both joysticks, d-pad, and all the buttons.

like image 344
Crash_Override Avatar asked Jul 16 '26 06:07

Crash_Override


1 Answers

Have you checked out the MSDN XNA input documentation? It doesn't really have examples, but it appears you have the idea of what you do with the inputs.

The articles there have all the information on the inputs.

All the controller buttons which you can get to through GamePad.GetState(PlayerIndex.One).Buttons

The joystick which you can get through GamePad.GetState(PlayerIndex.One).Thumbsticks

And the D-Pad which you can get through GamePad.GetState(PlayerIndex.One).DPad

like image 125
fire.eagle Avatar answered Jul 18 '26 19:07

fire.eagle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!