YouKnowMyName
YouKnowMyName

Reputation: 17

XNA game studio Xbox controller


I have a question about XNA. Is it possible in XNA to read input from an Xbox controller pluged into my PC? (I'm a beginner)

I would appreciate a reply.

Upvotes: 1

Views: 375

Answers (2)

Nahuel Ianni
Nahuel Ianni

Reputation: 3185

Yes. In the same fashion as Keyboard state and mouse state, XNA provides you with the Gamepad class which exposes the GetState method to control whatever you want in the game. One of the main differences is that the GetState method here asks you to provide the player index value (values 1 to 4) representing the player you want to read the info from.

Also, if you check the default code provided in the Update method, you will see that it is already been used to control a way to exit the game (by pressing the Back button if my memory doesn't lie to me).

Keep in mind that if you want to use a wireless gamepad, you'll need a wireless receiver connected on your PC to connect to it.

Upvotes: 3

thegentlecat
thegentlecat

Reputation: 498

According to this, you can use the GamePad class to read input from a XBox360 controller just like for every other type of game pad.

Upvotes: 0

Related Questions