Gamepadobjects, and only for gamepads that are actually connected.
- When handling a
gamepadconnectedevent, the event's
gamepadproperty is a live reference to the gamepad in question. It can be saved and used to check for future changes to the gamepad state.
- While handling a
gamepaddisconnectedevent, the array obtained from
navigator.getGamepads()will still include the gamepad being disconnected, but will report it as having 0 buttons and 0 axes.
- I have only ever seen index 0 be assigned to the first-connected gamepad.
navigator.getGamepads()contains four items, which are
nulluntil a gamepad is actually connected. (I expect this is a minimum and the array will expand if you connect five or more gamepads, but I haven't tested it.)