@fogrexon/glyph-arena-gamepad
Gamepad state snapshot reader. See also package README.
Exports
Generated from the package's source when the docs are built — do not edit this table by hand.
| Name | Kind |
|---|---|
CreateGamepadOptions | type |
GamepadReader | type |
GamepadState | type |
createGamepad | function |
createGamepad(options?)
const gamepad = createGamepad({ getGamepads? });
const pads = gamepad.snapshot();
gamepad.dispose();
Options
getGamepads?— inject gamepad enumeration. Defaults tonavigator.getGamepads()when available; otherwise returns an empty list.
Methods
snapshot()— return connected gamepads. Omitsnullslots and disconnected pads.dispose()— mark disposed. After dispose,snapshot()returns an empty array.
GamepadState
| Field | Type | Description |
|---|---|---|
index | number | gamepad index |
id | string | gamepad id string |
buttons | readonly boolean[] | pressed state per button |
axes | readonly number[] | raw axis values (no deadzone) |
Button and axis arrays are copied so caller mutation does not affect the next snapshot.
Errors
When getGamepads throws, snapshot() propagates the error.