Table of Contents

Class GamePad

Namespace
Microsoft.Xna.Framework.Input
Assembly
MonoGame.Framework.dll

Supports querying the game controllers and setting the vibration motors.

public static class GamePad
Inheritance
GamePad
Inherited Members

Properties

MaximumGamePadCount

The maximum number of game pads supported on this system.

public static int MaximumGamePadCount { get; }

Property Value

int

Methods

GetCapabilities(PlayerIndex)

Returns the capabilities of the connected controller.

public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex)

Parameters

playerIndex PlayerIndex

Player index for the controller you want to query.

Returns

GamePadCapabilities

The capabilities of the controller.

GetCapabilities(int)

Returns the capabilities of the connected controller.

public static GamePadCapabilities GetCapabilities(int index)

Parameters

index int

Index for the controller you want to query.

Returns

GamePadCapabilities

The capabilities of the controller.

GetState(PlayerIndex)

Gets the current state of a game pad controller with an independent axes dead zone.

public static GamePadState GetState(PlayerIndex playerIndex)

Parameters

playerIndex PlayerIndex

Player index for the controller you want to query.

Returns

GamePadState

The state of the controller.

GetState(PlayerIndex, GamePadDeadZone)

Gets the current state of a game pad controller, using a specified dead zone on analog stick positions.

public static GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode)

Parameters

playerIndex PlayerIndex

Player index for the controller you want to query.

deadZoneMode GamePadDeadZone

Enumerated value that specifies what dead zone type to use.

Returns

GamePadState

The state of the controller.

GetState(PlayerIndex, GamePadDeadZone, GamePadDeadZone)

Gets the current state of a game pad controller, using a specified dead zone on analog stick positions.

public static GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone leftDeadZoneMode, GamePadDeadZone rightDeadZoneMode)

Parameters

playerIndex PlayerIndex

Player index for the controller you want to query.

leftDeadZoneMode GamePadDeadZone

Enumerated value that specifies what dead zone type to use for the left stick.

rightDeadZoneMode GamePadDeadZone

Enumerated value that specifies what dead zone type to use for the right stick.

Returns

GamePadState

The state of the controller.

GetState(int)

Gets the current state of a game pad controller with an independent axes dead zone.

public static GamePadState GetState(int index)

Parameters

index int

Index for the controller you want to query.

Returns

GamePadState

The state of the controller.

GetState(int, GamePadDeadZone)

Gets the current state of a game pad controller, using a specified dead zone on analog stick positions.

public static GamePadState GetState(int index, GamePadDeadZone deadZoneMode)

Parameters

index int

Index for the controller you want to query.

deadZoneMode GamePadDeadZone

Enumerated value that specifies what dead zone type to use.

Returns

GamePadState

The state of the controller.

GetState(int, GamePadDeadZone, GamePadDeadZone)

Gets the current state of a game pad controller, using a specified dead zone on analog stick positions.

public static GamePadState GetState(int index, GamePadDeadZone leftDeadZoneMode, GamePadDeadZone rightDeadZoneMode)

Parameters

index int

Index for the controller you want to query.

leftDeadZoneMode GamePadDeadZone

Enumerated value that specifies what dead zone type to use for the left stick.

rightDeadZoneMode GamePadDeadZone

Enumerated value that specifies what dead zone type to use for the right stick.

Returns

GamePadState

The state of the controller.

InitDatabase()

Initialies the internal database of gamepad mappings for an SDL context

public static void InitDatabase()

SetVibration(PlayerIndex, float, float)

Sets the vibration motor speeds on the controller device if supported.

public static bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor)

Parameters

playerIndex PlayerIndex

Player index that identifies the controller to set.

leftMotor float

The speed of the left motor, between 0.0 and 1.0. This motor is a low-frequency motor.

rightMotor float

The speed of the right motor, between 0.0 and 1.0. This motor is a high-frequency motor.

Returns

bool

Returns true if the vibration motors were set.

SetVibration(PlayerIndex, float, float, float, float)

Sets the vibration motor speeds on the controller device if supported.

public static bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor, float leftTrigger, float rightTrigger)

Parameters

playerIndex PlayerIndex

Player index that identifies the controller to set.

leftMotor float

The speed of the left motor, between 0.0 and 1.0. This motor is a low-frequency motor.

rightMotor float

The speed of the right motor, between 0.0 and 1.0. This motor is a high-frequency motor.

leftTrigger float

(Xbox One controller only) The speed of the left trigger motor, between 0.0 and 1.0. This motor is a high-frequency motor.

rightTrigger float

(Xbox One controller only) The speed of the right trigger motor, between 0.0 and 1.0. This motor is a high-frequency motor.

Returns

bool

Returns true if the vibration motors were set.

SetVibration(int, float, float)

Sets the vibration motor speeds on the controller device if supported.

public static bool SetVibration(int index, float leftMotor, float rightMotor)

Parameters

index int

Index for the controller you want to query.

leftMotor float

The speed of the left motor, between 0.0 and 1.0. This motor is a low-frequency motor.

rightMotor float

The speed of the right motor, between 0.0 and 1.0. This motor is a high-frequency motor.

Returns

bool

Returns true if the vibration motors were set.

SetVibration(int, float, float, float, float)

Sets the vibration motor speeds on the controller device if supported.

public static bool SetVibration(int index, float leftMotor, float rightMotor, float leftTrigger, float rightTrigger)

Parameters

index int

Index for the controller you want to query.

leftMotor float

The speed of the left motor, between 0.0 and 1.0. This motor is a low-frequency motor.

rightMotor float

The speed of the right motor, between 0.0 and 1.0. This motor is a high-frequency motor.

leftTrigger float

(Xbox One controller only) The speed of the left trigger motor, between 0.0 and 1.0. This motor is a high-frequency motor.

rightTrigger float

(Xbox One controller only) The speed of the right trigger motor, between 0.0 and 1.0. This motor is a high-frequency motor.

Returns

bool

Returns true if the vibration motors were set.