GamepadVisualizer

Source: gamepad-visualizer.js:191

Render and update a controller visual in a caller-provided DOM container.


Constructor

new GamepadVisualizer( helper: GamepadHelper, container: Element, options?: Object, ): GamepadVisualizer

Parameters

  • helper (GamepadHelper) — GamepadHelper instance used for mappings and paths
  • container (Element) — DOM element that will contain the visual
  • options (Object, optional) — Renderer options
    • options.assetBasePath (string, optional, default: "'/assets/img/gamepads/'") — Base asset path
    • options.colorScheme (string, optional, default: "'White'") — Controller and button image color
    • options.unavailableText (string, optional) — Fallback text for unsupported visuals

Instance Methods

mount(gamepad: Gamepad | null): GamepadVisualizer

Mount a visual for a gamepad and apply its current input state.

Parameters

  • gamepad (Gamepad | null) — Gamepad to render

Returns

update(gamepad?: Gamepad): GamepadVisualizer

Update the mounted visual with the latest Gamepad API state.

Parameters

  • gamepad (Gamepad, optional) — Latest gamepad state; defaults to the mounted gamepad

Returns

setColorScheme(colorScheme: string): GamepadVisualizer

Change image colors and remount the current gamepad.

Parameters

  • colorScheme (string) — Image color scheme ('Black' or 'White')

Returns

destroy(): GamepadVisualizer

Remove the rendered visual and release references to the mounted gamepad.

Returns