Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address contradiction on whether XRInputSource gamepads are exposed #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

msub2
Copy link

@msub2 msub2 commented Jul 18, 2024

While looking over this spec in preparation for eventually updating Servo's WebXR implementation, I noticed a very clear contradiction between the intro text to the Gamepad API integration and the Navigator section. The intro text states that user agents MAY expose XRInputSource gamepads via navigator.getGamepads(), but the following section states that they MUST NOT be exposed. Looking at the git blame, it seems like the intro text change was more recent, so I think it makes sense to treat that as the ground truth.


Preview | Diff

@toji
Copy link
Member

toji commented Jul 18, 2024

Hm... this is a bit more complex that it may appear at first.

For the record the text from the "Navigator" section has been in this repo since commit #1, so there's no obvious paper trail as to the discussion that led to it. The other text was merged in #49, which points to #19, which also is unfortunately light on discussion but at least provides some context: Browsers wanted to ability to use controllers as more traditional gamepads for non-XR content. The group agreed that this was a good idea and the text was added to support that use case.

The complication comes from this: Yes, you can show XR controllers as standard gamepads if the user agent wants to. But can you have them in the gamepads array AND as an XRInputSource on an active session at the same time? I'm inclined to say no, and I think that's what this (admittedly confusing) apparent text contradiction is trying to say.

When the text says "An XRInputSource's associated Gamepad MAY be exposed via navigator.getGamepads()" I think it's using "XRInputSource" not necessarily as an actual XRInputSource instance attached to an XRSession but as a more abstract "Input source for an XR device that may be exposed as an XRInputSource instance at some point." (Yes, that's confusing. I blame myself.) It would make sense to me to say that a controller can be exposed as a typical gamepad if the UA wants up until an XRSession is started. If the controller then shows up as an input source for that session it MUST NOT appear in the normal gamepad list until the session has ended. That way we avoid getting accidental double-processing of inputs and it's very clear which interfaces developers should be looking to in order to handle XR input.

That being said, this obviously needs some clearer text all around, and regardless of my speculating above I think the more important consideration at this point is what are implementations currently doing and how might existing content break if we make changes here. As such I think this is a great topic for our next meeting.

/agenda

@probot-label probot-label bot added the agenda label Jul 18, 2024
@msub2
Copy link
Author

msub2 commented Jul 20, 2024

After reading your explanation and looking over the spec again that definitely does make more sense. Perhaps a good way of making it more explicit at first glance would be to establish the input coming from the XR device as "raw input" or similar, which can then be used in the creation of a Gamepad object that can be returned either by navigator.getGamepads() or on an active XRInputSource

@Yonet Yonet removed the agenda label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants