-
Notifications
You must be signed in to change notification settings - Fork 389
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
First pass at defining tracked sources #1361
Changes from 3 commits
1cc1abe
dc603b5
b1f3e57
96dc99a
daa8a66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -630,6 +630,7 @@ enum XRVisibilityState { | |||||||||
readonly attribute Float32Array? supportedFrameRates; | ||||||||||
[SameObject] readonly attribute XRRenderState renderState; | ||||||||||
[SameObject] readonly attribute XRInputSourceArray inputSources; | ||||||||||
[SameObject] readonly attribute XRInputSourceArray trackedSources; | ||||||||||
readonly attribute FrozenArray<DOMString> enabledFeatures; | ||||||||||
readonly attribute boolean isSystemKeyboardSupported; | ||||||||||
|
||||||||||
|
@@ -831,12 +832,14 @@ When this method is invoked, the user agent MUST run the following steps: | |||||||||
|
||||||||||
</div> | ||||||||||
|
||||||||||
Each {{XRSession}} has a <dfn>list of active XR input sources</dfn> (a [=/list=] of {{XRInputSource}}) which MUST be initially an empty [=/list=]. | ||||||||||
Each {{XRSession}} has a <dfn>list of active XR input sources</dfn> (a [=/list=] of {{XRInputSource}}) and a <dfn>list of active XR tracked sources</dfn> (a [=/list=] of {{XRInputSource}}) which MUST be initially an empty [=/list=]. | ||||||||||
|
||||||||||
Each {{XRSession}} has an <dfn for="XRSession">XR device</dfn>, which is an [=/XR device=] set at initialization. | ||||||||||
|
||||||||||
The <dfn attribute for="XRSession">inputSources</dfn> attribute returns the {{XRSession}}'s [=list of active XR input sources=]. | ||||||||||
|
||||||||||
The <dfn attribute for="XRSession">trackedSources</dfn> attribute returns the {{XRSession}}'s [=list of active XR tracked sources=]. | ||||||||||
|
||||||||||
The user agent MUST monitor any [=XR input source=]s associated with the [=XRSession/XR device=], including detecting when [=XR input source=]s are added, removed, or changed. | ||||||||||
|
||||||||||
Each {{XRSession}} has a <dfn for=XRSession>promise resolved</dfn> flag, initially `false`. | ||||||||||
|
@@ -848,13 +851,23 @@ NOTE: The purpose of this flag is to ensure that the [=XRSession/add input sourc | |||||||||
When <dfn for="XRSession" lt="add input source">new [=XR input source=]s become available</dfn> for {{XRSession}} |session|, the user agent MUST run the following steps: | ||||||||||
|
||||||||||
1. If |session|'s [=XRSession/promise resolved=] flag is not set, abort these steps. | ||||||||||
1. Let |added| be a new [=/list=]. | ||||||||||
1. Let |added primary sources| be a new [=/list=]. | ||||||||||
1. Let |added tracked sources| be a new [=/list=]. | ||||||||||
1. For each new [=XR input source=]: | ||||||||||
1. Let |inputSource| be a [=new=] {{XRInputSource}} in the [=relevant realm=] of this {{XRSession}}. | ||||||||||
1. Add |inputSource| to |added|. | ||||||||||
1. Let |inputSource| be a [=new=] {{XRInputSource}} in the [=relevant realm=] of this {{XRSession}}, then perform the following step: | ||||||||||
<dl class="switch"> | ||||||||||
: If |inputSource| is a [=primary input source=]: | ||||||||||
:: | ||||||||||
Add |inputSource| to |added primary sources|. | ||||||||||
: Otherwise: | ||||||||||
:: | ||||||||||
Add |inputSource| to |added tracked sources|. | ||||||||||
</dl> | ||||||||||
1. [=Queue a task=] to perform the following steps: | ||||||||||
1. [=list/Extend=] |session|'s [=list of active XR input sources=] with |added|. | ||||||||||
1. Fire an {{XRInputSourcesChangeEvent}} named {{inputsourceschange!!event}} on |session| with {{XRInputSourcesChangeEvent/added}} set to |added|. | ||||||||||
1. [=list/Extend=] |session|'s [=list of active XR input sources=] with |added primary sources|. | ||||||||||
1. If |added primary sources| is not empty, fire an {{XRInputSourcesChangeEvent}} named {{inputsourceschange!!event}} on |session| with {{XRInputSourcesChangeEvent/added}} set to |added primary sources|. | ||||||||||
1. [=list/Extend=] |session|'s [=list of active XR tracked sources=] with |added tracked sources|. | ||||||||||
1. If |added tracked sources| is not empty, fire an {{XRTrackedSourcesChangeEvent}} named {{trackedsourceschange!!event}} on |session| with {{XRTrackedSourcesChangeEvent/added}} set to |added tracked sources|. | ||||||||||
|
||||||||||
</div> | ||||||||||
|
||||||||||
|
@@ -863,34 +876,63 @@ When <dfn for="XRSession" lt="add input source">new [=XR input source=]s become | |||||||||
When any previously added <dfn for="XRSession" lt="remove input source">[=XR input source=]s are no longer available</dfn> for {{XRSession}} |session|, the user agent MUST run the following steps: | ||||||||||
|
||||||||||
1. If |session|'s [=XRSession/promise resolved=] flag is not set, abort these steps. | ||||||||||
1. Let |removed| be a new [=/list=]. | ||||||||||
1. Let |removed primary sources| be a new [=/list=]. | ||||||||||
1. Let |removed tracked sources| be a new [=/list=]. | ||||||||||
1. For each [=XR input source=] that is no longer available: | ||||||||||
1. Let |inputSource| be the {{XRInputSource}} in |session|'s [=list of active XR input sources=] associated with the [=XR input source=]. | ||||||||||
1. Add |inputSource| to |removed|. | ||||||||||
1. Let |inputSource| be the {{XRInputSource}} in |session|'s [=list of active XR input sources=] associated with the [=XR input source=], then perform the following step: | ||||||||||
<dl class="switch"> | ||||||||||
: If |inputSource| is a [=primary input source=]: | ||||||||||
:: | ||||||||||
Add |inputSource| to |removed primary sources|. | ||||||||||
: Otherwise: | ||||||||||
:: | ||||||||||
Add |inputSource| to |removed tracked sources|. | ||||||||||
</dl> | ||||||||||
1. [=Queue a task=] to perform the following steps: | ||||||||||
1. [=list/Remove=] each {{XRInputSource}} in |removed| from |session|'s [=list of active XR input sources=]. | ||||||||||
1. Fire an {{XRInputSourcesChangeEvent}} named {{inputsourceschange!!event}} on |session| with {{XRInputSourcesChangeEvent/removed}} set to |removed|. | ||||||||||
1. [=list/Remove=] each {{XRInputSource}} in |removed primary sources| from |session|'s [=list of active XR input sources=]. | ||||||||||
1. ire an {{XRInputSourcesChangeEvent}} named {{inputsourceschange!!event}} on |session| with {{XRInputSourcesChangeEvent/removed}} set to |removed primary sources|. | ||||||||||
1. [=list/Remove=] each {{XRInputSource}} in |removed tracked sources| from |session|'s [=list of active XR tracked sources=]. | ||||||||||
1. If |removed tracked sources| is not empty, fire an {{XRTrackedSourcesChangeEvent}} named {{trackedsourceschange!!event}} on |session| with {{XRTrackedSourcesChangeEvent/removed}} set to |removed tracked sources|. | ||||||||||
|
||||||||||
Note: The user agent MAY fire this event when an input source temporarily loses both position and orientation tracking. It is recommended that this only be done for physical handheld controller input sources. It is not recommended that this event be fired when this happens for tracked hand input sources, because this will happen often, nor is it recommended when this happens for tracker object input sources, since this makes it harder for the application to maintain a notion of identity. | ||||||||||
|
||||||||||
</div> | ||||||||||
|
||||||||||
<div class="algorithm" data-algorithm="on-input-source-change"> | ||||||||||
|
||||||||||
When the <dfn for="XRSession" export lt="change input source">{{XRInputSource/handedness}}, {{XRInputSource/targetRayMode}}, {{XRInputSource/profiles}}, or presence of a {{XRInputSource/gripSpace}} for any [=XR input source=]s change</dfn> for {{XRSession}} |session|, the user agent MUST run the following steps: | ||||||||||
When the <dfn for="XRSession" export lt="change input source">{{XRInputSource/handedness}}, {{XRInputSource/targetRayMode}}, {{XRInputSource/profiles}}, presence of a {{XRInputSource/gripSpace}} or the state of the [=primary input source=] or [=tracked input source=] for any [=XR input source=]s change</dfn> for {{XRSession}} |session|, the user agent MUST run the following steps: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reads somewhat confusingly to me. I believe you are trying to say that the algorithm should fire if an input source switched from primary to tracked or visa-versa, but "the state of the primary input source or tracked input source" makes it sound like any state change (like a button press) could trigger this. Not 100% confident in what a better phrasing would be, but perhaps something like this?
Suggested change
|
||||||||||
|
||||||||||
1. If |session|'s [=XRSession/promise resolved=] flag is not set, abort these steps. | ||||||||||
1. Let |added| be a new [=/list=]. | ||||||||||
1. Let |removed| be a new [=/list=]. | ||||||||||
1. Let |added primary sources| be a new [=/list=]. | ||||||||||
1. Let |removed primary sources| be a new [=/list=]. | ||||||||||
1. Let |added tracked sources| be a new [=/list=]. | ||||||||||
1. Let |removed tracked sources| be a new [=/list=]. | ||||||||||
1. For each changed [=XR input source=]: | ||||||||||
1. Let |oldInputSource| be the {{XRInputSource}} in |session|'s [=list of active XR input sources=] previously associated with the [=XR input source=]. | ||||||||||
1. Let |newInputSource| be a [=new=] {{XRInputSource}} in the [=relevant realm=] of |session|. | ||||||||||
1. Add |oldInputSource| to |removed|. | ||||||||||
1. Add |newInputSource| to |added|. | ||||||||||
1. Let |oldInputSource| be the {{XRInputSource}} in |session|'s [=list of active XR input sources=] previously associated with the [=XR input source=], then perform the following step: | ||||||||||
<dl class="switch"> | ||||||||||
: If |oldInputSource| is a [=primary input source=] or its state changed from a [=primary input source=] to [=tracked input source=] a: | ||||||||||
:: | ||||||||||
Add |oldInputSource| to |removed primary sources|. | ||||||||||
: Otherwise: | ||||||||||
:: | ||||||||||
Add |oldInputSource| to |removed tracked sources|. | ||||||||||
</dl> | ||||||||||
1. Let |newInputSource| be a [=new=] {{XRInputSource}} in the [=relevant realm=] of |session|, then perform the following step: | ||||||||||
<dl class="switch"> | ||||||||||
: If |newInputSource| is a [=primary input source=] or its state changed from a [=tracked input source=] to [=primary input source=] : | ||||||||||
:: | ||||||||||
Add |newInputSource| to |added primary sources|. | ||||||||||
: Otherwise: | ||||||||||
:: | ||||||||||
Add |newInputSource| to |added tracked sources|. | ||||||||||
</dl> | ||||||||||
1. [=Queue a task=] to perform the following steps: | ||||||||||
1. [=list/Remove=] each {{XRInputSource}} in |removed| from |session|'s [=list of active XR input sources=]. | ||||||||||
1. [=list/Extend=] |session|'s [=list of active XR input sources=] with |added|. | ||||||||||
1. Fire an {{XRInputSourcesChangeEvent}} named {{inputsourceschange!!event}} on |session| with{{XRInputSourcesChangeEvent/added}} set to |added| and {{XRInputSourcesChangeEvent/removed}} set to |removed|. | ||||||||||
1. [=list/Remove=] each {{XRInputSource}} in |removed primary sources| from |session|'s [=list of active XR input sources=]. | ||||||||||
1. [=list/Extend=] |session|'s [=list of active XR input sources=] with |added primary sources|. | ||||||||||
1. If |added primary sources| or |removed primary sources| are not empty, fire an {{XRInputSourcesChangeEvent}} named {{inputsourceschange!!event}} on |session| with{{XRInputSourcesChangeEvent/added}} set to |added primary sources| and {{XRInputSourcesChangeEvent/removed}} set to |removed primary sources|. | ||||||||||
1. [=list/Remove=] each {{XRInputSource}} in |removed tracked sources| from |session|'s [=list of active XR tracked sources=]. | ||||||||||
1. [=list/Extend=] |session|'s [=list of active XR input sources=] with |added tracked sources|. | ||||||||||
1. If |added tracked sources| or |removed tracked sources| are not empty, fire an {{XRTrackedSourcesChangeEvent}} named {{trackedsourceschange!!event}} on |session| with {{XRTrackedSourcesChangeEvent/added}} set to |added tracked sources| and {{XRTrackedSourcesChangeEvent/removed}} set to |removed tracked sources|. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See note below about the event type. |
||||||||||
|
||||||||||
</div> | ||||||||||
|
||||||||||
|
@@ -935,6 +977,8 @@ The <dfn attribute for="XRSession">onend</dfn> attribute is an [=Event handler I | |||||||||
|
||||||||||
The <dfn attribute for="XRSession">oninputsourceschange</dfn> attribute is an [=Event handler IDL attribute=] for the {{inputsourceschange}} event type. | ||||||||||
|
||||||||||
The <dfn attribute for="XRSession">ontrackedsourceschange</dfn> attribute is an [=Event handler IDL attribute=] for the {{trackedsourceschange}} event type. | ||||||||||
|
||||||||||
The <dfn attribute for="XRSession">onselectstart</dfn> attribute is an [=Event handler IDL attribute=] for the {{XRSession/selectstart}} event type. | ||||||||||
|
||||||||||
The <dfn attribute for="XRSession">onselectend</dfn> attribute is an [=Event handler IDL attribute=] for the {{selectend}} event type. | ||||||||||
|
@@ -1890,7 +1934,7 @@ Note: {{XRInputSource}}s in an {{XRSession}}'s {{XRSession/inputSources}} array | |||||||||
|
||||||||||
An [=XR input source=] is a <dfn>primary input source</dfn> if it supports a <dfn>primary action</dfn>. The [=primary action=] is a platform-specific action that, when engaged, produces {{XRSession/selectstart}}, {{XRSession/selectend}}, and {{XRSession/select}} events. Examples of possible [=primary action=]s are pressing a trigger, touchpad, or button, speaking a command, or making a hand gesture. If the platform guidelines define a recommended primary input then it should be used as the [=primary action=], otherwise the user agent is free to select one. The device MUST support at least one [=primary input source=]. | ||||||||||
|
||||||||||
An [=XR input source=] is an <dfn>auxiliary input source</dfn> if it does not support a [=primary action=], for example [=transient input sources=] associated with secondary screen touches on a multitouch device. | ||||||||||
An [=XR input source=] is an <dfn>tracked input source</dfn> if it does not support a [=primary action=], for example [=transient input sources=] associated with secondary screen touches on a multitouch device. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like the example used here is probably worth updating? The current one is a bit difficult to reason about. Also, the example should probably be non-normative. Maybe something like:
Suggested change
This probably also warrants a clarification in the WebXR Gamepads module that tracked input source MAY still expose gamepad data. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also have a discussion about what the various spaces on the tracked sources mean? For example, I'm comfortable with some cognitive dissonance in this area, since it's a relatively late addition, but I wouldn't mind it if we could provide some guidance for how future implementers should think about these spaces if we can. |
||||||||||
|
||||||||||
<div class="algorithm" data-algorithm="on-input-start"> | ||||||||||
|
||||||||||
|
@@ -1957,7 +2001,7 @@ When an [=XR input source=] |source| for {{XRSession}} |session| has its [=prima | |||||||||
Transient input {#transient-input} | ||||||||||
--------------- | ||||||||||
|
||||||||||
Some [=/XR device=]s may support <dfn>transient input sources</dfn>, where the [=XR input source=] is only meaningful while performing a <dfn>transient action</dfn>, either the [=primary action=] for a [=primary input source=], or a device-specific <dfn>auxiliary action</dfn> for an [=auxiliary input source=]. | ||||||||||
Some [=/XR device=]s may support <dfn>transient input sources</dfn>, where the [=XR input source=] is only meaningful while performing a <dfn>transient action</dfn>, either the [=primary action=] for a [=primary input source=], or a device-specific <dfn>auxiliary action</dfn> for an [=tracked input source=]. | ||||||||||
|
||||||||||
One example would be mouse, touch, or stylus input against an {{XRSessionMode/"inline"}} {{XRSession}}, which MUST produce a transient {{XRInputSource}} with a {{targetRayMode}} set to {{screen}}, treated as a [=primary action=] for the [=primary pointer=], and as a non-primary [=auxiliary action=] for a non-primary pointer. | ||||||||||
|
||||||||||
|
@@ -2457,7 +2501,7 @@ When the user agent has to <dfn>fire an input source event</dfn> with name |name | |||||||||
XRInputSourcesChangeEvent {#xrinputsourceschangeevent-interface} | ||||||||||
------------------------- | ||||||||||
|
||||||||||
{{XRInputSourcesChangeEvent}}s are fired to indicate changes to the {{XRInputSource}}s that are available to an {{XRSession}}. | ||||||||||
{{XRInputSourcesChangeEvent}}s are fired to indicate changes to the [=list of active XR input sources=] that are available to an {{XRSession}}. | ||||||||||
|
||||||||||
<pre class="idl"> | ||||||||||
[SecureContext, Exposed=Window] | ||||||||||
|
@@ -2482,6 +2526,34 @@ The <dfn attribute for="XRInputSourcesChangeEvent">added</dfn> attribute is a [= | |||||||||
|
||||||||||
The <dfn attribute for="XRInputSourcesChangeEvent">removed</dfn> attribute is a [=/list=] of {{XRInputSource}}s that were removed from the {{XRSession}} at the time of the event. | ||||||||||
|
||||||||||
XRTrackedSourcesChangeEvent {#xrtrackedsourceschangeevent-interface} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't need to be a different interface from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember if this was discussed at the face to face? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To clarify: We can how a different event but still have it use the same interface. The same way that we have a single There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This issue is still outstanding. If you removed the |
||||||||||
------------------------- | ||||||||||
|
||||||||||
{{XRTrackedSourcesChangeEvent}}s are fired to indicate changes to the [=list of active XR tracked sources=] that are available to an {{XRSession}}. | ||||||||||
|
||||||||||
<pre class="idl"> | ||||||||||
[SecureContext, Exposed=Window] | ||||||||||
interface XRTrackedSourcesChangeEvent : Event { | ||||||||||
constructor(DOMString type, XRTrackedSourcesChangeEventInit eventInitDict); | ||||||||||
[SameObject] readonly attribute XRSession session; | ||||||||||
[SameObject] readonly attribute FrozenArray<XRInputSource> added; | ||||||||||
[SameObject] readonly attribute FrozenArray<XRInputSource> removed; | ||||||||||
}; | ||||||||||
|
||||||||||
dictionary XRTrackedSourcesChangeEventInit : EventInit { | ||||||||||
required XRSession session; | ||||||||||
required FrozenArray<XRInputSource> added; | ||||||||||
required FrozenArray<XRInputSource> removed; | ||||||||||
|
||||||||||
}; | ||||||||||
</pre> | ||||||||||
|
||||||||||
The <dfn attribute for="XRTrackedSourcesChangeEvent">session</dfn> attribute indicates the {{XRSession}} that generated the event. | ||||||||||
|
||||||||||
The <dfn attribute for="XRTrackedSourcesChangeEvent">added</dfn> attribute is a [=/list=] of {{XRInputSource}}s that were added to the {{XRSession}} at the time of the event. | ||||||||||
|
||||||||||
The <dfn attribute for="XRTrackedSourcesChangeEvent">removed</dfn> attribute is a [=/list=] of {{XRInputSource}}s that were removed from the {{XRSession}} at the time of the event. | ||||||||||
|
||||||||||
|
||||||||||
XRReferenceSpaceEvent {#xrreferencespaceevent-interface} | ||||||||||
--------------------- | ||||||||||
|
@@ -2519,6 +2591,8 @@ A user agent MUST [=fire an event=] named <dfn event for="XRSession">end</dfn> u | |||||||||
|
||||||||||
A user agent MUST [=fire an event=] named <dfn event for="XRSession">inputsourceschange</dfn> using {{XRInputSourcesChangeEvent}} on an {{XRSession}} when the session's [=list of active XR input sources=] has changed. | ||||||||||
|
||||||||||
A user agent MUST [=fire an event=] named <dfn event for="XRSession">trackedsourceschange</dfn> using {{XRTrackedSourcesChangeEvent}} on an {{XRSession}} when the session's [=list of active XR tracked sources=] has changed. | ||||||||||
|
||||||||||
A user agent MUST [=fire an event=] named <dfn event for="XRSession">selectstart</dfn> using {{XRInputSourceEvent}} on an {{XRSession}} when one of its {{XRInputSource}}s begins its [=primary action=]. The event MUST be of type . | ||||||||||
|
||||||||||
A user agent MUST [=fire an event=] named <dfn event for="XRSession">selectend</dfn> using {{XRInputSourceEvent}} on an {{XRSession}} when one of its {{XRInputSource}}s ends its [=primary action=] or when an {{XRInputSource}} that has begun a [=primary action=] is disconnected. | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.