mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Add XRInputSource.handedness
This commit is contained in:
parent
b693af6a54
commit
e5716624d4
2 changed files with 16 additions and 2 deletions
|
@ -18,7 +18,7 @@ enum XRTargetRayMode {
|
||||||
|
|
||||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||||
interface XRInputSource {
|
interface XRInputSource {
|
||||||
// [SameObject] readonly attribute XRHandedness handedness;
|
readonly attribute XRHandedness handedness;
|
||||||
// [SameObject] readonly attribute XRTargetRayMode targetRayMode;
|
// [SameObject] readonly attribute XRTargetRayMode targetRayMode;
|
||||||
// [SameObject] readonly attribute XRSpace targetRaySpace;
|
// [SameObject] readonly attribute XRSpace targetRaySpace;
|
||||||
// [SameObject] readonly attribute XRSpace? gripSpace;
|
// [SameObject] readonly attribute XRSpace? gripSpace;
|
||||||
|
|
|
@ -4,12 +4,15 @@
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding;
|
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding;
|
||||||
|
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
||||||
|
XRHandedness, XRInputSourceMethods,
|
||||||
|
};
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::xrsession::XRSession;
|
use crate::dom::xrsession::XRSession;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webvr_traits::{WebVRGamepadData, WebVRGamepadState};
|
use webvr_traits::{WebVRGamepadData, WebVRGamepadHand, WebVRGamepadState};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct XRInputSource {
|
pub struct XRInputSource {
|
||||||
|
@ -52,3 +55,14 @@ impl XRInputSource {
|
||||||
*self.state.borrow_mut() = state;
|
*self.state.borrow_mut() = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl XRInputSourceMethods for XRInputSource {
|
||||||
|
/// https://immersive-web.github.io/webxr/#dom-xrinputsource-handedness
|
||||||
|
fn Handedness(&self) -> XRHandedness {
|
||||||
|
match self.data.hand {
|
||||||
|
WebVRGamepadHand::Unknown => XRHandedness::None,
|
||||||
|
WebVRGamepadHand::Left => XRHandedness::Left,
|
||||||
|
WebVRGamepadHand::Right => XRHandedness::Right,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue