API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classGamepad

@codexo/exojs / input / stable

One of four stable gamepad slots. Lives for the entire `Application` lifetime even when no physical pad is attached - a "mailbox" that physical hardware moves into and out of. Subscribe to onConnect / onDisconnect for hardware lifecycle, onButtonDown / onButtonUp / onAxisChange for granular per-event notifications, or call onTrigger / onActive / onStart / onStop to register stateful InputBindings pinned to this slot. Listeners survive disconnect/reconnect cycles - a binding registered when the slot was empty will automatically activate when a pad connects.

8
props
11
methods
6
events
Import
import { Gamepad } from '@codexo/exojs'

One of four stable gamepad slots. Lives for the entire `Application` lifetime even when no physical pad is attached - a "mailbox" that physical hardware moves into and out of.

Subscribe to onConnect / onDisconnect for hardware lifecycle, onButtonDown / onButtonUp / onAxisChange for granular per-event notifications, or call onTrigger / onActive / onStart / onStop to register stateful InputBindings pinned to this slot.

Listeners survive disconnect/reconnect cycles - a binding registered when the slot was empty will automatically activate when a pad connects.

Constructors1
new(slot: 0 | 1 | 2 | 3, channels: Float32Array): Gamepad
Methods11
destroy(): void
Tear down this gamepad slot. Called on application shutdown.
Name this device prints on control - "A" on an Xbox pad, "Cross" on a PlayStation one, "B" on a Switch one - or undefined when the slot is empty or this family does not label that control. Resolved against the connected pad's own mapping, so a generation that deviates from its family default is honoured: the PlayStation Select control reads "Share" on a DualShock 4 and "Create" on a DualSense.
Returns true when this pad's mapping declares the requested channel. Use to gate listener registration on optional hardware (e.g. Joy-Con solo lacks a right stick - pad.hasChannel(GamepadAxis.RightStickX) returns false).
Register a callback fired every frame while any of channels is active. Receives the channel value (0..1 for buttons, -1..1 for bipolar axes). The callback is optional: with none, this just creates a binding, which is the idiomatic way to poll a stick or trigger per frame - read InputBinding.active / InputBinding.value in your own update() instead of tracking held-state in a callback.
stopVibration(): void
Stop any active rumble on this pad. Silent no-op when unsupported.
Trigger a rumble effect on this pad. Resolves when the effect finishes. Silent no-op when the pad is disconnected or the platform does not support haptic feedback. Use canVibrate to detect support.
Properties8
browserGamepad: Gamepad | null
The underlying browser gamepad object, or null when disconnected.
canVibrate: boolean
true when the connected pad supports rumble via the Web Gamepad API.
connected: boolean
true while a physical pad is attached to this slot.
Device family of the connected pad, or null when the slot is empty. The value to key a game's own button-glyph or controller artwork on; ExoJS ships no glyph assets of its own.
internalIndex: null | number
Browser-assigned hardware index from navigator.getGamepads() (i.e. Gamepad.index), or null when no pad is attached. Stable for the lifetime of a single physical connection but may change across disconnect/reconnect. Low-level escape hatch for advanced consumers that need to correlate slots with the raw browser API; prefer slot for stable per-application pad identity.
slot: 0 | 1 | 2 | 3
This pad's stable slot (0..3).
Events6
Fires when this slot's physical pad has been replaced by a previously higher-numbered slot's pad, after a 'compact'-strategy disconnect. Dispatched with the source slot index the pad came from. Listeners remain attached and the channel buffer is preserved across the move.
Source