GamePadState

struct GamePadState : System.ValueType

Represents specific information about the state of the controller, including the current state of buttons and sticks.

This is implemented as a partial struct to allow for individual platforms to offer additional data without separate state queries to GamePad.

GamePadState Default

The default initialized gamepad state.

readonly bool IsConnected

Gets a value indicating if the controller is connected.

Value:true if it is connected; otherwise, false.
readonly int PacketNumber

Gets the packet number associated with this state.

Value:The packet number.
readonly GamePadButtons Buttons

Gets a structure that identifies what buttons on the controller are pressed.

Value:The buttons structure.
readonly GamePadDPad DPad

Gets a structure that identifies what directions of the directional pad on the controller are pressed.

Value:The directional pad structure.
readonly GamePadThumbSticks ThumbSticks

Gets a structure that indicates the position of the controller sticks (thumbsticks).

Value:The thumbsticks position.
readonly GamePadTriggers Triggers

Gets a structure that identifies the position of triggers on the controller.

Value:Positions of the triggers.
void set_IsConnected(bool value)
Parameters:
  • value (bool) –
void set_PacketNumber(int value)
Parameters:
  • value (int) –
void set_Buttons(GamePadButtons value)
Parameters:
  • value (Microsoft.Xna.Framework.Input.GamePadButtons) –
void set_DPad(GamePadDPad value)
Parameters:
  • value (Microsoft.Xna.Framework.Input.GamePadDPad) –
void set_ThumbSticks(GamePadThumbSticks value)
Parameters:
  • value (Microsoft.Xna.Framework.Input.GamePadThumbSticks) –
void set_Triggers(GamePadTriggers value)
Parameters:
  • value (Microsoft.Xna.Framework.Input.GamePadTriggers) –
bool IsButtonDown(Buttons button)

Determines whether specified input device buttons are pressed in this GamePadState.

Parameters:
  • button (Microsoft.Xna.Framework.Input.Buttons) – Buttons to query. Specify a single button, or combine multiple buttons using a bitwise OR operation.
Returns:

true, if button was pressed, false otherwise.

bool IsButtonUp(Buttons button)

Determines whether specified input device buttons are released (not pressed) in this GamePadState.

Parameters:
  • button (Microsoft.Xna.Framework.Input.Buttons) – Buttons to query. Specify a single button, or combine multiple buttons using a bitwise OR operation.
Returns:

true, if button was released (not pressed), false otherwise.

bool op_Equality(GamePadState left, GamePadState right)

Determines whether a specified instance of T:Microsoft.Xna.Framework.Input.GamePadState is equal to another specified T:Microsoft.Xna.Framework.Input.GamePadState.

Parameters:
  • left (Microsoft.Xna.Framework.Input.GamePadState) – The first T:Microsoft.Xna.Framework.Input.GamePadState to compare.
  • right (Microsoft.Xna.Framework.Input.GamePadState) – The second T:Microsoft.Xna.Framework.Input.GamePadState to compare.
Returns:

true if left and right are equal; otherwise, false.

bool op_Inequality(GamePadState left, GamePadState right)

Determines whether a specified instance of T:Microsoft.Xna.Framework.Input.GamePadState is not equal to another specified T:Microsoft.Xna.Framework.Input.GamePadState.

Parameters:
  • left (Microsoft.Xna.Framework.Input.GamePadState) – The first T:Microsoft.Xna.Framework.Input.GamePadState to compare.
  • right (Microsoft.Xna.Framework.Input.GamePadState) – The second T:Microsoft.Xna.Framework.Input.GamePadState to compare.
Returns:

true if left and right are not equal; otherwise, false.

bool Equals(System.Object obj)

Determines whether the specified T:System.Object is equal to the current T:Microsoft.Xna.Framework.Input.GamePadState.

Parameters:
  • obj (System.Object) – The T:System.Object to compare with the current T:Microsoft.Xna.Framework.Input.GamePadState.
Returns:
true if the specified T:System.Object is equal to the current

T:Microsoft.Xna.Framework.Input.GamePadState; otherwise, false.

int GetHashCode()

Serves as a hash function for a T:Microsoft.Xna.Framework.Input.GamePadState object.

Returns:
A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a

hash table.

string ToString()

Returns a T:System.String that represents the current T:Microsoft.Xna.Framework.Input.GamePadState.

Returns:A T:System.String that represents the current T:Microsoft.Xna.Framework.Input.GamePadState.