Allow initializing the gamepad index to a specific value#193
Allow initializing the gamepad index to a specific value#193
Conversation
| </h3> | ||
| <p> | ||
| <dfn>A new `Gamepad`</dfn> representing a connected gamepad device is | ||
| constructed by performing the following steps: |
There was a problem hiding this comment.
Who provides the index originally? I guess it's the UA. I wonder if we should make this more consistent by making it mandatory to pass the index. Would that work across browsers?
There was a problem hiding this comment.
The UA shouldn't decide the index, it's decided by the "select an unused gamepad index" algorithm which is based on the sequence of previous gamepad connections/disconnections.
Let's make |index| mandatory by moving index selection into the "when a gamepad becomes available on the system" steps.
There was a problem hiding this comment.
Looking at this again I now remember why it's done this way. The "select an unused gamepad index" algorithm needs to access the Navigator object. Currently it does so by creating a Gamepad object and then finding the navigator via the Gamepad's relevant global object. If we want to pass the index into the "a new Gamepad with index" steps then we need to get the Navigator object from somewhere else, since the Gamepad doesn't exist yet. This would need to happen in the "When a gamepad becomes available on the system" steps.
Is there a way to find the relevant global object without referencing an existing object? The current method seems kind of magical, how did the Gamepad know what its relevant global object should be when it was created? We could abuse the same trick by creating a dummy object just to get its global object, but I assume there's a better way to specify this that doesn't involve creating a dummy object.
Closes #???
The following tasks have been completed:
Implementation commitment:
Preview | Diff