Skip to content

GamepadAPI

Types

gamepad

This Gamepad API interface defines an individual gamepad or other controller, allowing access to information such as button presses, axis positions, and id. See Gamepad on MDN

type gamepad = {
id: string,
index: int,
connected: bool,
timestamp: float,
mapping: gamepadMappingType,
axes: array<float>,
buttons: array<gamepadButton>,
vibrationActuator: gamepadHapticActuator,
}

Record fields

id
string
index
int
connected
bool
timestamp
float
axes
array< float >
buttons
array< gamepadButton >

gamepadButton

An individual button of a gamepad or other controller, allowing access to the current state of different types of buttons available on the control device. See GamepadButton on MDN

type gamepadButton = {
pressed: bool,
touched: bool,
value: float,
}

Record fields

pressed
bool
touched
bool
value
float

gamepadEffectParameters

type gamepadEffectParameters = {
mutable duration?: int,
mutable startDelay?: int,
mutable strongMagnitude?: float,
mutable weakMagnitude?: float,
mutable leftTrigger?: float,
mutable rightTrigger?: float,
}

Record fields

duration
option< int >
startDelay
option< int >
strongMagnitude
option< float >
weakMagnitude
option< float >
leftTrigger
option< float >
rightTrigger
option< float >

gamepadHapticActuator

This Gamepad API interface represents hardware in the controller designed to provide haptic feedback to the user (if available), most commonly vibration hardware. See GamepadHapticActuator on MDN

type gamepadHapticActuator = {}

Module

There are methods and helpers defined in GamepadHapticActuator .

gamepadHapticEffectType

type gamepadHapticEffectType =
| @as("dual-rumble") DualRumble
| @as("trigger-rumble") TriggerRumble

gamepadHapticsResult

type gamepadHapticsResult =
| @as("complete") Complete
| @as("preempted") Preempted

gamepadMappingType

type gamepadMappingType =
| @as("standard") Standard
| @as("xr-standard") XrStandard