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,
): GamepadVisualizerParameters
helper(GamepadHelper) — GamepadHelper instance used for mappings and pathscontainer(Element) — DOM element that will contain the visualoptions(Object, optional) — Renderer optionsoptions.assetBasePath(string, optional, default: "'/assets/img/gamepads/'") — Base asset pathoptions.colorScheme(string, optional, default: "'White'") — Controller and button image coloroptions.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
GamepadVisualizer— This visualizer
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
GamepadVisualizer— This visualizer
setColorScheme(colorScheme: string): GamepadVisualizer
Change image colors and remount the current gamepad.
Parameters
colorScheme(string) — Image color scheme ('Black' or 'White')
Returns
GamepadVisualizer— This visualizer
destroy(): GamepadVisualizer
Remove the rendered visual and release references to the mounted gamepad.
Returns
GamepadVisualizer— This visualizer