v152 · gamepad button type

The seventeen agreed positions

The standard mapping is a table of index-to-meaning that every browser and every controller driver agrees on. It is also the whole of what the platform tells you about a button — so a controller with more than seventeen has a tail of anonymous numbers.

The map, with anything connected laid over it

Connect a controller and press a button, then start watching.

Watching polls on every animation frame, because gamepads are not evented: navigator.getGamepads() returns a fresh snapshot each time and the objects from the previous frame stop updating. Any code that holds on to a Gamepad object is reading a still photograph.

The tail

Indices past 16 appear above with a dashed border. The standard mapping says nothing about them — not that they do not exist, but that no meaning is defined — so an application either ignores them or guesses.

see also