Gamepads

Gamepads, such as the Xbox Elite Wireless Controller and the PS4 DualShock, are popular input devices for consoles and desktop.

Note

Xenko is currently optimized for the Xbox Elite gamepad. Other controllers work, but might have unexpected button mappings. Gamepad-specific features like the PS4 DualShock touchpad aren't supported.

  • Digital buttons have two states: up and down. The D-pad, Start, Back, Thumbstick (press), A, B, X and Y buttons are digital buttons.

The Xbox Elite controller buttons have the following names in Xenko:

Before handling gamepad input:

To query the states and state changes of digital gamepad buttons, on the object, call:

Button (GamePadButton) is the gamepad button you want to check.

You can also get the state of digital buttons using .

Note

The GamePadState.Buttons field is a bitmask that uses binary system. Depending on the bitmask value, you can determine which buttons are up or down.

To query values of analog buttons, first get the current state of gamepad using , where index (Integer) is the index of the gamepad you want to check.

Warning

The value returned by IGamePadDevice.State is the state of the gamepad at the current update. You can't reuse this value for the next updates. You have to query it again in every update.

To get trigger and thumbstick positions, use these fields:

FieldDescription
GamePadState.LeftThumbLeft thumbstick X-axis/Y-axis value in the range [-1.0f, 1.0f] for both axes.
Right thumbstick X-axis/Y-axis value in the range [-1.0f, 1.0f] for both axes.
GamePadState.LeftTriggerLeft trigger analog control value in the range [0, 1.0f] for a single axes.
Right trigger analog control value in the range [0, 1.0f] for a single axis.

Thumbsticks move along the X and Y axes. Their positions read as follows:

Query thumb position

Triggers move along the X axis. Their positions read as follows:

Query trigger position

Note

Xenko currently only supports vibration for Xbox gamepads.