w3c / gamepad

Gamepad
https://w3c.github.io/gamepad/
Other
141 stars 48 forks source link

Add -1 to the set of allowed indices #158

Closed Manishearth closed 1 month ago

Manishearth commented 2 years ago

Closes https://github.com/immersive-web/webxr-gamepads-module/issues/27

The WebXR module constructs Gamepads that are not exposed via navigator.getGamepads(), this adds a -1 value for index that can accomodate them.


Preview | Diff

nondebug commented 2 years ago

Gamepad API has been rewritten to use algorithms in the time since the WebXR issue was filed. Now there are algorithmic steps for selecting a gamepad index and constructing a Gamepad, but these steps assume we're connecting a "traditional gamepad" (as WebXR describes it) and should not be used to initialize XR gamepads. WebXR should define new steps for constructing a Gamepad from an XR input source.

Since the requirements in the "index attribute" description are already defined in the algorithm for initializing the attribute, let's remove the duplicate information so the description is correct regardless of how the attribute is initialized. Maybe just the first sentence is okay?

The index of the gamepad in the {{Navigator}}, if it is exposed via {{Navigator/getGamepads()}}.

Actually, this is incorrect since a Gamepad object retains its index after it's disconnected and no longer exposed by getGamepads(). Let's keep it simple and let the algorithms define what the behavior is. If we need to add more information, put it in a non-normative block.

The index of the gamepad.
Manishearth commented 2 years ago

@nondebug Thanks! How about now?

Manishearth commented 2 years ago

r? @nondebug

himorin commented 1 year ago

@nondebug hi, this issue remains as a sole blocker for WebXR gamepads API to CR. any update on this?

siusin commented 1 year ago

@nondebug ping?

marcoscaceres commented 8 months ago

We discussed this during the editor's meeting. We would prefer not to add this to our spec and it should just be part of WebXR.

Manishearth commented 8 months ago

We discussed this during the editor's meeting. We would prefer not to add this to our spec and it should just be part of WebXR.

"It should just be a part of WebXR" isn't quite clear: currently WebXR sets it to -1 which is not actually allowed by this spec. Should we say that we are modifying the Gamepads spec? Or should we do something else here?

The use case of "gamepads that are not in navigator.getGamepads() seems real and unhandled by this spec as written.

marcoscaceres commented 7 months ago

Ok, we will take another look at the editor's meeting and see if we can suggest figure out a path forward.

nondebug commented 7 months ago

We discussed this and decided to refactor the "A new gamepad" algorithm to take an index parameter, which can be undefined (in which case we will use the "selecting an unused gamepad index" algorithm). Then WebXR Gamepads module can create the Gamepad with index initialized to -1.

Manishearth commented 7 months ago

Thank you!

marcoscaceres commented 1 month ago

Closing as I think this already got addressed in a different way.