Skip to content

API Variable GamepadState

github-actions[bot] edited this page Nov 24, 2026 · 1 revision

Variable: GamepadState

const GamepadState: DataComponentDef<Record<string, 
  | ScalarType<"i32">
  | ScalarType<"u8">
| ScalarType<"f32">>>;

Defined in: src/engine/input/deviceEntities.ts:50

A gamepad's state this frame: buttons b0…b22 (0..1) and axes a0…a3 (-1..1, +Y down) by wire index (controls.ts), held/down/up bitmasks (bit i: button i), gyro (rad/s) and accelerometer (m/s²) where the device has them. Touchpad fingers (DualSense, DualShock 4): tpHeld/tpDown/tpUp bitmasks (bit 0 finger 0, bit 1 finger 1) and each finger's position tp0X/tp0Y, tp1X/tp1Y in 0..1 of the touchpad (origin top-left, +Y down; the last one after it lifts). battery 0..1, or -1 when unknown or wired without one; charging 1 while plugged in.

Clone this wiki locally