[w3c/gamepad] Gamepad event timing (#83)

The spec describes gamepadconnected and gamepaddisconnected events but does not describe the timing of when these events should be dispatched or how they interact with the navigator.getGamepads polling method. I'd like to propose stricter guarantees on this timing.

To ensure there is no difference between accessing the gamepad state through event.gamepad or navigator.getGamepads() from an event listener:

> If a gamepad event is dispatched and there is an event listener for the event, the gamepad state returned by navigator.getGamepads() MUST match the gamepad state in event.gamepad. The gamepad state returned by navigator.getGamepads() MUST remain the same until all event listeners have completed.

(Possibly this should also specify that the Gamepad object is the same object as in the getGamepads array.)

To ensure a sane ordering of events so that event listeners can accurately track which gamepads are currently connected:

> gamepadconnected and gamepaddisconnected MUST NOT be dispatched twice in a row for the same gamepad. For instance, if a gamepad is determined to have been disconnected and connected in the same polling update then gamepaddisconnected MUST be dispatched first.

(Possibly also specify that gamepaddisconnected must not be dispatched before gamepadconnected for a particular gamepad, although this may already be implied by the spec.)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/gamepad/issues/83

Received on Thursday, 16 August 2018 18:06:33 UTC