v143 · device
Gamepad ongamepadconnected and ongamepaddisconnected event handler attributes
Add ongamepadconnected and ongamepaddisconnected event handlers to the WindowEventHandlers interface mixin. This would enable support for window.ongamepad[dis]connected or document.body.ongamepad[dis]connected event handler attributes.
concepts
-
Handler Attributes
Live: the page sets
window.ongamepadconnectedand polls every connected pad's buttons and axes. Connect a real gamepad and press any button to activate the browser event. -
Onerror-style handoff
Why this exists: handler attributes are a single slot (last-write-wins), addEventListener is multi-handler. Both styles fire in one log so you can see the semantics directly.
-
Multi-controller router
A real local-multiplayer router: connect up to four pads, see each player slot light up with the gamepad ID, axes, and button state live. Connect / disconnect is wired through the new handler attribute. Includes a rumble test.
-
Gamepad Event Logger
A live event log showing timestamp, gamepad id, index, mapping, and which handler fired. Side-by-side
addEventListenervsongamepadconnectedattribute code panels with enable/disable checkboxes and realnavigator.getGamepads()polling.
why it shipped
The gamepad[dis]connected events can be subscribed to using window.addEventListener() currently. This adds the ability to use window.ongamepad[dis]connected event handler attributes as well.