Class: Gamepad

html.Gamepad

Class representing a gamepad.

new html.Gamepad ()

Properties:
Name Type Description
connected bool

[readonly] Whether the gamepad is currently connected.

canRumble bool

[readonly] Whether the gamepad supports rumbling (force-feedback vibration).

index number

(default: 0) The device index of the gamepad to read.

name string

[readonly] The name of the gamepad.

axes Array.<number>

[readonly] Array of the axes' values.

buttons Array.<bool>

[readonly] Array of the states of the buttons.

triggers Array.<number>

[readonly] Array of the analog values of the buttons/triggers.

Extends

Methods

rumble (intensity, duration, callback)

Makes the gamepad rumble if supported.

Name Type Description
intensity number

A value between 0 and 1 describing the rumbling intensity.

duration number

The rumbling duration in milliseconds.

callback function

An optional callback that tells when the rumbling is over.