Skip to main content

Gamepad

type GamepadPayload = {
leftX: number
leftY: number
rightX: number
rightY: number
leftTrigger: number
rightTrigger: number
up: boolean
down: boolean
left: boolean
right: boolean
leftThumbstick: boolean
rightThumbstick: boolean
leftShoulder: boolean
rightShoulder: boolean
north: boolean
south: boolean
east: boolean
west: boolean
home: boolean
utilLeft: boolean
utilRight: boolean
}

This data is sent when the host moves a gamepad's thumbsticks, or presses a button or trigger.

Value

Any true value indicates the button is pressed. Any false value indicates the button is released.

All number/double values are in the range of 0 to 1.

Fields

The leftX and leftY fields coresspond to the left thumbstick movement. The rightX and rightY fields coresspond to the right thumbstick movement.

The leftTrigger and rightTrigger fields coresspond to the amount of pressure applied to the left and right triggers.

The leftThumbstick and rightThumbstick fields coresspond to the press of the left and right thumbsticks.

The leftShoulder and rightShoulder fields coresspond to the left and right shoulder buttons.

The up, down, left, and right fields coresspond to the D-pad.

The north, south, east, and west fields coresspond to the face buttons.

The utilLeft and utilRight fields coresspond to the two buttons locate in the center area of the gamepad.

The home field coressponds to the button at the center of the gamepad. On Xbox controllers, this is the Xbox button. On PlayStation controllers, this is the PS button. On Nintendo Switch controllers, this is the home button.