Made the xr-standard gamepad mapping more rigid by toji · Pull Request #735 · immersive-web/webxr · GitHub
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

Made the xr-standard gamepad mapping more rigid #735

Merged
merged 7 commits into from
Jun 27, 2019
Merged

Made the xr-standard gamepad mapping more rigid #735

merged 7 commits into from
Jun 27, 2019

Conversation

toji
Copy link
Member

@toji toji commented Jun 25, 2019

Addresses concerns brought up in #695

This will make cross-platform implementations more compatible by
removing some level of platform option from the mapping process. It will
also make it more practical to expose the discussed "profiles" concept
by making it easier to have inter-compatible sets of profiles.

Also took the opportunity to normalized on the verbiage "thumbstick"
instead of joystick, since that appears to be the official verbiage used
by all the device vendors.

@toji toji added this to the June 2019 milestone Jun 25, 2019
@toji toji self-assigned this Jun 25, 2019
Copy link
Member

@NellWaliczek NellWaliczek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small nits, but otherwise looks good. I'd like to make sure @thetuvix is happy with the new button mappings before we merge though.

images/xr-standard-mapping.svg Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@toji
Copy link
Member Author

toji commented Jun 25, 2019

Feedback addressed aside from the "MUST" recommendation, which I left a comment for.

Copy link
Member

@NellWaliczek NellWaliczek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fast fixes!

@toji
Copy link
Member Author

toji commented Jun 25, 2019

@thetuvix: I'd appreciate your approval prior to merging as well.

index.bs Outdated
<td>Primary Touchpad/Joystick X</td>
<td>Yes</td>
<td>Touchpad X</td>
<td>If thumbstick is not present</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side question, since primary axes were already required before: Are we requiring that all xr-standard gamepads have either a touchpad or thumbstick? What about simpler "remote-style" controllers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thoughts when initially laying out the mapping were that we wanted to ensure that if something was advertised as xr-standard developers could depend on it having a certain baseline level of functionality. I still think that's a reasonable goal, though it's maybe less important if paired with the profiles concept. And yes, that would mean that some input devices (Like the Daydream controller) wouldn't qualify for xr-standard.

If we wanted to loosen up on that restriction and simply say that xr-standard only means that the inputs are mapped to a predictable place, and does not imply which of them are present then we could do so. I think we might want to look at expanding the proposed generic profile set to be a bit more descriptive in that case, with variants like:

  • button-controller
  • touchpad-controller // This is basically just the daydream controller and.... anything else?
  • touchpad-button-controller
  • thumbstick-controller // Never seen a thumbstick controller without a separate trigger
  • thumbstick-button-controller
  • touchpad-thumbstick-controller // Is this actually a thing anywhere?
  • touchpad-thumbstick-button-controller

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we wanted to loosen up on that restriction and simply say that xr-standard only means that the inputs are mapped to a predictable place, and does not imply which of them are present then we could do so.

This aligns with what I've been thinking here. Before, we only had one concept, xr-standard, overloaded to serve two purposes:

  • xr-standard defined which controller parts map to which buttons/axes IDs
  • xr-standard promised a minimum profile of controller parts that developers could assume were present

We've now split these into two distinct mapping and profile concepts in the API. It seems reasonable to embrace that, simplifying the meaning of the xr-standard mapping to a pure ID mapping, and allowing profiles to make more specific promises.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we continue this thread as part of #738?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support this direction. I'd kinda been feeling the same way as I looked over the actual spec text changes.

</tr>
</tbody>
</table>

Devices that lack one of the optional inputs listed in the tables above MUST preserve their place in the {{Gamepad/buttons}} or {{Gamepad/axes}} array, reporting a <dfn>placeholder button</dfn> or <dfn>placeholder axis</dfn>, respectively. A [=placeholder button=] MUST report <code>0</code> for {{GamepadButton/value}}, <code>false</code> for {{GamepadButton/pressed}}, and <code>false</code> for {{GamepadButton/touched}}. A [=placeholder axis=] MUST report <code>0</code>. [=Placeholder buttons=] and [=placeholder axis|axes=] MUST be omitted if they are the last element in the array or all following elements are also [=placeholder buttons=] or [=placeholder axis|axes=].

Additional buttons or axes may be exposed after these reserved indices, and SHOULD appear in order of decreasing importance. Related axes (such both axes of a joystick) SHOULD be grouped and, if applicable, SHOULD appear in X, Y, Z order. If a device has both a touchpad and a joystick the UA MAY designate whichever it chooses to be the primary axis-based input. Buttons reserved by the UA or platform MUST NOT be exposed.
Additional buttons or axes may be exposed after these reserved indices, and SHOULD appear in order of decreasing importance. Related axes (such as both axes of a thumbstick) MUST be grouped and, if applicable, MUST appear in X, Y, Z order. Buttons reserved by the UA or platform MUST NOT be exposed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to introduce further reserved indices in the future, we'd need some way to reconcile the additional indices. (I suppose this is true before this change as well)

Perhaps apps need to be explicit that they want an xr-standard mapping for their Gamepad - that way, we can later introduce an xr-standard-2 mapping or such that pushes out into button/axis 5, 6, etc.

Should the gamepad attribute perhaps be getGamepad(mapping)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty strongly against making that large of a change to this chunk of the API this late. (Though I don't object to introducing a xr-standard-2 at some point if needed.)

I do think we'll likely outgrow the current shape of the gamepad API at some point, but when that time comes I have a hunch that we'll be better served by introducing something along the lines of an action mapping API rather than continue to hack more robust concepts onto an API that obviously never expected to deal with them. (And hopefully at that point we have a few years of insight into how developers are using OpenXR to help inform our direction.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

Even if we later do need to support what I said in the gamepad API, there are slightly less clean ways to do it later without changes now - for example, when requesting your XRSession, you could centrally set xr-standard-2 as your preferring mapping for receiving xr-standard* gamepad buttons/axes.

input-explainer.md Outdated Show resolved Hide resolved
@toji
Copy link
Member Author

toji commented Jun 26, 2019

Okay, pushed an update that swaps the grip and touchpad button indices. (And they did a quick panicked recovery of a prior commit that I accidentally stomped on when pushing, which is why they're out-of-order now. 🙄)

index.bs Outdated Show resolved Hide resolved
toji and others added 5 commits June 26, 2019 15:00
This will make cross-platform implementations more compatible by
removing some level of platform option from the mapping process. It will
also make it more practical to expose the discussed "profiles" concept
by making it easier to have inter-compatible sets of profiles.

Also took the opportunity to normalized on the verbiage "thumbstick"
instead of joystick, since that appears to be the official verbiage used
by all the device vendors.
@toji
Copy link
Member Author

toji commented Jun 26, 2019

@thetuvix: I've got approval from Nell, but I'm going to hold off from merging until I hear that you're OK with the latest changes as well.

input-explainer.md Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
input-explainer.md Outdated Show resolved Hide resolved

Additional device-specific inputs may be exposed after these reserved indices, but devices that lack one of the canonical inputs must still preserve their place in the array. If a device has both a touchpad and a joystick the UA should designate one of them to be the primary axis-based input and expose the other at axes[2] and axes[3] with an associated button at button[3].
Additional device-specific inputs may be exposed after these reserved indices, but devices that lack one of the canonical inputs must still preserve their place in the array.

In order to make use of the `xr-standard` mapping, a device must meet **at least** the following criteria:

- Is a `tracked-pointer` device.
- Has a trigger or similarly accessed button
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems fine to require at least a primary button/trigger for buttons[0].

Should we more strongly state then that this button MUST also trigger onselect for this XRInputSource?

Copy link
Contributor

@thetuvix thetuvix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I left some nits to fix up, as well as some comments in the active discussions. I'm happy if you want to continue some of these discussions in a further PR.

Copy link
Member

@NellWaliczek NellWaliczek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a lot better to me. Thanks!

@toji
Copy link
Member Author

toji commented Jun 27, 2019

Thanks for the feedback! I agree that the xr-standard mapping no longer needs to stand in for profiles. I ran with Alex's suggestion of requiring a primary button (which I still specify should be separate from a touchpad/thumbstick press) but otherwise xr-standard in specified here to really just be an indication of which elements are surfaced where, and not which ones are actually present.

Would appreciate one more brief review from @NellWaliczek or @thetuvix before landing, but otherwise I'm going to plan on merging this by EOD.

@toji toji merged commit 3e3beef into master Jun 27, 2019
@toji toji deleted the xr-standard-2 branch June 27, 2019 16:42
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