API

Interface XrControllerComponents

Decoded xr-standard controller state for one input source. Every field is nullable because a given device may not expose that button/axis pair; callers should null-check before reading. Index conventions follow the WebXR xr-standard gamepad mapping.

interface XrControllerComponents {
    buttonA: XrButtonState | null;
    buttonB: XrButtonState | null;
    handedness: XrHandedness;
    squeeze: XrButtonState | null;
    thumbstick: XrButtonState | null;
    thumbstickAxes: readonly [number, number] | null;
    touchpad: XrButtonState | null;
    touchpadAxes: readonly [number, number] | null;
    trigger: XrButtonState | null;
}
Index
buttonA: XrButtonState | null

Primary face button (A / X) — buttons[4].

buttonB: XrButtonState | null

Secondary face button (B / Y) — buttons[5].

handedness: XrHandedness

"left", "right", or "none".

squeeze: XrButtonState | null

Grip / squeeze — buttons[1].

thumbstick: XrButtonState | null

Thumbstick press — buttons[3].

thumbstickAxes: readonly [number, number] | null

Thumbstick [x, y] in [-1, 1] — axes[2], axes[3].

touchpad: XrButtonState | null

Touchpad press — buttons[2].

touchpadAxes: readonly [number, number] | null

Touchpad [x, y] in [-1, 1] — axes[0], axes[1].

trigger: XrButtonState | null

Primary trigger — buttons[0].