diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2019-07-10 13:46:23 -0700 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2019-07-11 11:12:59 -0700 |
commit | b654b6007a0673be6297443dbdf1d5d39e91a670 (patch) | |
tree | 33c3aeefb102a15c4dcee849ce33270196b2a68c /components/script/dom/xrinputsource.rs | |
parent | 0d5d1a3dc41abb6bef7c13c8ade4976c446c3feb (diff) | |
download | servo-b654b6007a0673be6297443dbdf1d5d39e91a670.tar.gz servo-b654b6007a0673be6297443dbdf1d5d39e91a670.zip |
Hook input code into new webxr crate
Diffstat (limited to 'components/script/dom/xrinputsource.rs')
-rw-r--r-- | components/script/dom/xrinputsource.rs | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/components/script/dom/xrinputsource.rs b/components/script/dom/xrinputsource.rs index 108ca16b9fc..061f746016a 100644 --- a/components/script/dom/xrinputsource.rs +++ b/components/script/dom/xrinputsource.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding; use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{ XRHandedness, XRInputSourceMethods, @@ -10,33 +9,27 @@ use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{ 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::{ApiPose, XRSession}; +use crate::dom::xrsession::XRSession; use crate::dom::xrspace::XRSpace; use dom_struct::dom_struct; -use webvr_traits::{WebVRGamepadData, WebVRGamepadHand, WebVRGamepadState}; +use webxr_api::{Handedness, InputId, InputSource}; #[dom_struct] pub struct XRInputSource { reflector: Reflector, session: Dom<XRSession>, #[ignore_malloc_size_of = "Defined in rust-webvr"] - data: WebVRGamepadData, + info: InputSource, #[ignore_malloc_size_of = "Defined in rust-webvr"] - state: DomRefCell<WebVRGamepadState>, target_ray_space: MutNullableDom<XRSpace>, } impl XRInputSource { - pub fn new_inherited( - session: &XRSession, - data: WebVRGamepadData, - state: WebVRGamepadState, - ) -> XRInputSource { + pub fn new_inherited(session: &XRSession, info: InputSource) -> XRInputSource { XRInputSource { reflector: Reflector::new(), session: Dom::from_ref(session), - data, - state: DomRefCell::new(state), + info, target_ray_space: Default::default(), } } @@ -44,32 +37,27 @@ impl XRInputSource { pub fn new( global: &GlobalScope, session: &XRSession, - data: WebVRGamepadData, - state: WebVRGamepadState, + info: InputSource, ) -> DomRoot<XRInputSource> { reflect_dom_object( - Box::new(XRInputSource::new_inherited(session, data, state)), + Box::new(XRInputSource::new_inherited(session, info)), global, XRInputSourceBinding::Wrap, ) } - pub fn update_state(&self, state: WebVRGamepadState) { - *self.state.borrow_mut() = state; - } - - pub fn pose(&self) -> ApiPose { - unimplemented!() + pub fn id(&self) -> InputId { + self.info.id } } 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, + match self.info.handedness { + Handedness::None => XRHandedness::None, + Handedness::Left => XRHandedness::Left, + Handedness::Right => XRHandedness::Right, } } |