Re: [w3c/gamepad] Allow initializing the gamepad index to a specific value (PR #193)

@nondebug commented on this pull request.



> @@ -650,17 +650,24 @@ <h3>
           Constructing a `Gamepad`
         </h3>
         <p>
-          <dfn>A new `Gamepad`</dfn> representing a connected gamepad device is
-          constructed by performing the following steps:

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.

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

Message ID: <w3c/gamepad/pull/193/review/2078229451@github.com>

Received on Saturday, 25 May 2024 00:26:13 UTC