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

  1. Handler Attributes

    Live: the page sets window.ongamepadconnected and polls every connected pad's buttons and axes. Connect a real gamepad and press any button to activate the browser event.

  2. 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.

  3. 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.

  4. Gamepad Event Logger

    A live event log showing timestamp, gamepad id, index, mapping, and which handler fired. Side-by-side addEventListener vs ongamepadconnected attribute code panels with enable/disable checkboxes and real navigator.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.

references