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

Add input mocking, input sources change event #25463

Merged
merged 15 commits into from Jan 9, 2020

Expose targetRayMode

  • Loading branch information
Manishearth committed Jan 9, 2020
commit 7046f543a1875ab419d30fad8cc33333e92e4373
@@ -19,7 +19,7 @@ enum XRTargetRayMode {
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
interface XRInputSource {
readonly attribute XRHandedness handedness;
// [SameObject] readonly attribute XRTargetRayMode targetRayMode;
readonly attribute XRTargetRayMode targetRayMode;

This comment has been minimized.

@asajeffrey

asajeffrey Jan 8, 2020

Member

Why no [SameObject]?

This comment has been minimized.

@Manishearth

Manishearth Jan 8, 2020

Author Member

Can't SameObject enums. I believe this was fixed upstream in the spec, we just never updated the commented webidl.

[SameObject] readonly attribute XRSpace targetRaySpace;
[SameObject] readonly attribute XRSpace? gripSpace;
// [SameObject] readonly attribute Gamepad? gamepad;
@@ -4,15 +4,15 @@

use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding;
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
XRHandedness, XRInputSourceMethods,
XRHandedness, XRInputSourceMethods, XRTargetRayMode,
};
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
use crate::dom::globalscope::GlobalScope;
use crate::dom::xrsession::XRSession;
use crate::dom::xrspace::XRSpace;
use dom_struct::dom_struct;
use webxr_api::{Handedness, InputId, InputSource};
use webxr_api::{Handedness, InputId, InputSource, TargetRayMode};

#[dom_struct]
pub struct XRInputSource {
@@ -64,6 +64,15 @@ impl XRInputSourceMethods for XRInputSource {
}
}

/// https://immersive-web.github.io/webxr/#dom-xrinputsource-targetraymode
fn TargetRayMode(&self) -> XRTargetRayMode {
match self.info.target_ray_mode {
TargetRayMode::Gaze => XRTargetRayMode::Gaze,
TargetRayMode::TrackedPointer => XRTargetRayMode::Tracked_pointer,
TargetRayMode::Screen => XRTargetRayMode::Screen,
}
}

/// https://immersive-web.github.io/webxr/#dom-xrinputsource-targetrayspace
fn TargetRaySpace(&self) -> DomRoot<XRSpace> {
self.target_ray_space.or_init(|| {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.