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 check how many gamepads are connected, use InputManager.GamePadCount.
To check if the current device has been disconnected, use the event.
To check if a device has been connected, use the InputManager.DeviceAdded event.
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 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 GetGamePadByIndex(index), 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:
Field | Description |
---|---|
GamePadState.LeftThumb | Left 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.LeftTrigger | Left 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:
Triggers move along the X axis. Their positions read as follows:
Note
Xenko currently only supports vibration for Xbox gamepads.