Skip to main content

Class: GamepadInputSource

Defined in: input/gamepad/input-sources/gamepad-input-source.ts:20

Represents a gamepad input source with associated bindings.

Unlike KeyboardInputSource and MouseInputSource, the Gamepad API has no change events, so this source must be polled every frame. It registers itself with the InputManager as an Updatable to do so.

Implements

Constructors

Constructor

new GamepadInputSource(inputManager, gamepadIndex?): GamepadInputSource

Defined in: input/gamepad/input-sources/gamepad-input-source.ts:37

Constructs a new GamepadInputSource.

Parameters

inputManager

InputManager

The input manager to register with.

gamepadIndex?

number = 0

The index of the gamepad to read from, as reported by navigator.getGamepads(). Defaults to 0, the first connected gamepad. -1 will select the last connected gamepad, which is useful for hot-plugging a single gamepad.

Returns

GamepadInputSource

Properties

axis1dBindings

readonly axis1dBindings: Set<GamepadAxis1dBinding>

Defined in: input/gamepad/input-sources/gamepad-input-source.ts:26

The set of 1D axis bindings associated with this input source.

Implementation of

Axis1dInputSource.axis1dBindings


name

readonly name: "gamepad" = 'gamepad'

Defined in: input/gamepad/input-sources/gamepad-input-source.ts:24

The name of this input source.

Implementation of

Axis1dInputSource.name

Methods

stop()

stop(): void

Defined in: input/gamepad/input-sources/gamepad-input-source.ts:107

Unregisters this source from the InputManager.

Returns

void

Implementation of

Stoppable.stop


update()

update(): void

Defined in: input/gamepad/input-sources/gamepad-input-source.ts:48

Polls the gamepad's current state and dispatches any bindings that read from it.

Returns

void

Implementation of

Updatable.update