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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.