I’m working on my first multiplayer XNA game, and I need to be able to check input from each active GamePad on an Xbox360 or PC so that I don’t have to copy and paste the same code for four different controllers.
I’ve looked at the SignedInGamer, and SignedInGamerCollection , but none of them have a reference to the specific GamePad.
I’d like to do something like the snippet below, but modified so that it can be used in a loop for all current players so that I can get input for each of them. PlayerIndex has “One”, “Two”, “Three”, and “Four”.
GamePadState gS = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One);
When you call
GetState, the state structure will contain the propertyIsConnected. If it is false, the controller is disconnected. You can iterate over states of all active controllers using code like this: