Re: [w3c/gamepad] Need to spec liveness of Gamepad objects (#8)

Sure, please take a look:

`getGamepads()` should return an array of `Gamepad` objects. The gamepad array is NOT a live array; the returned array will always hold the same `Gamepad` objects even if gamepads are connected and disconnected. The same gamepad array may be returned if no gamepads have been connected or disconnected. (But it's also fine to construct a new array for each call.)

Each non-null item in the array returned by `getGamepads()` corresponds to a single connected gamepad. As long as the gamepad remains connected, `getGamepads()` should return the same `Gamepad` object for that gamepad, at the same array index.

`Gamepad` objects are live. The `id` and `index` members should not be modified once the object is returned to script, but other members may be updated due to user interaction with the gamepad. (Should `mapping` or `hand` be allowed to change? This might be useful for devices that can be operated in multiple modes without a disconnection, eg Switch Joy-Cons.)

The `connected` member should return true as long as the gamepad remains connected, and false afterward.

The `axes` member is NOT a live array; it should hold the same array until any axis changes or the order of axes changes, after which it should return a new array with the updated axis state. (Should we continue to return the same array after disconnection?)

The `buttons` member is NOT a live array; it should hold the same array of `GamepadButton` objects as long as the gamepad remains connected and the order of buttons does not change. If the order of buttons changes, a new array should be returned. Each item in the array should hold the same `GamepadButton` object for the lifetime of the `buttons` array. (Should we continue to return the same array after disconnection?)

`GamepadButton` is live and its properties (`value`, `pressed`, `touched`) may change after the button has been returned to script.

The `timestamp` member should be updated whenever `connected`, `axes`, or `buttons` (also `pose`) is updated with new values. If there is no observable state change, the timestamp should not change. (This differs from the current spec language which describes the timestamp as "Last time the data for this gamepad was updated" which could include updates where the data received from the device matches the previous state. IMO this is not useful, API users should assume the browser is receiving updates continuously until the gamepad is disconnected.)

Live objects (`Gamepad`, `GamepadButton`) are updated when script is not running. If a change occurs while script is running, they will continue to hold the same values until the top of the event loop.

-- 
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/8#issuecomment-542871529

Received on Wednesday, 16 October 2019 20:11:26 UTC