v152 · gamepad button type
What the interfaces expose
Two small interfaces, and the whole feature is one property on the smaller one. Both are read out here from the browser rather than from documentation, with the property this feature adds marked whether or not it is there.
GamepadButton
Three properties describe a button today: whether it is down, whether it is being touched without being pressed, and how far it has travelled for an analogue control. None of them says what the button is — that comes entirely from its index.
Gamepad
| member | present? | what it gives you |
|---|
Anything connected?
Connect a controller and press a button — browsers do not report a gamepad until it is used, which is a privacy measure rather than a bug.
| index | id | mapping | buttons | axes | types available? |
|---|---|---|---|---|---|
| Nothing connected yet. | |||||
The id column is the string applications currently match against to guess what the extra buttons are. Read one and the problem is obvious: it is free text, it differs by operating system and browser for the same device, and nothing constrains its format.