Re: [w3c/gamepad] Spec liveness of Gamepad and GamepadButton objects (#8) (#123)

nondebug commented on this pull request.



> -          MUST be returned until the <a>user agent</a> needs to return
-          different values (or values in a different order).
+          <p>
+          Array of {{GamepadButton}} objects representing the current state of
+          all buttons of the gamepad. It is RECOMMENDED that buttons appear in
+          decreasing importance such that the primary button, secondary
+          button, tertiary button, and so on appear as elements 0, 1, 2, ...
+          in the buttons array.
+          </p>
+          <p>
+          When the system receives new data from a connected gamepad, a
+          microtask MUST be queued with the user interaction task source to
+          update the gamepad state. If the gamepad has the same buttons in the
+          same order as the previous update, the buttons attribute MUST return
+          the same array object. If the number of buttons or the ordering of
+          buttons has changed, the buttons attribute MUST return a new array

This would work for the buttons attribute but I'm not sure how to resolve it for axes. The axes attribute is FrozenArray<double> so we can't change the values in-place like we can for the buttons array.

I tested the current behavior in Firefox. `pad.axes === pad.axes` always returns true, but if you save the axes array before and after interacting with the joystick then you'll get different arrays:

```
let pad = navigator.getGamepads()[0];
let axes = pad.axes;
axes === pad.axes; // true
// wiggle the thumbstick
axes === pad.axes; // false
```

-- 
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/pull/123#discussion_r348856426

Received on Thursday, 21 November 2019 01:23:24 UTC