GamePad.GetState Method (PlayerIndex)
Gets the current state of a game pad controller.
Syntax
'Declaration
Public Shared Function GetState ( _
playerIndex As PlayerIndex _
) As GamePadState
public static GamePadState GetState (
PlayerIndex playerIndex
)
public:
static GamePadState GetState(
PlayerIndex playerIndex
)
Parameters
- playerIndex
Type: PlayerIndex
Player index for the controller you want to query.
Return Value
Type: GamePadState
The current state of the controller.
Exceptions
Exception type | Condition |
---|---|
InvalidOperationException | An unknown error has occurred. Verify that the correct playerIndex is being requested. |
Remarks
Best Practice |
---|
|
When you call GetState, check the returned structure's IsConnected property value. If the controller has been disconnected, this value will be false. When a controller is disconnected, values for its state will not be valid. Also, the controller will not receive any new vibration settings.
This method uses the GamePadDeadZone.IndependentAxes dead zone to smooth the values of the analog sticks. To specify a different dead zone type, or to specify no-dead-zone processing, pass a GamePadDeadZone value to this method.
Requirements
Namespace: Microsoft.Xna.Framework.Input
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)
See Also
Concepts
Overview of User Input and Input Devices
Reference
SignedInGamer.PlayerIndex Property
SignedInGamer.GameDefaults
GamePad Class
GamePad Members
Microsoft.Xna.Framework.Input Namespace
Platforms
Windows Phone