Hook XRInputSourceArray into XRSession

This commit is contained in:
Manish Goregaokar 2019-10-08 15:34:04 -07:00
parent 868e5cbd62
commit 8ae1c2e0ad
3 changed files with 33 additions and 37 deletions

View file

@ -11,6 +11,7 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::xrinputsource::XRInputSource;
use crate::dom::xrsession::XRSession;
use dom_struct::dom_struct;
use webxr_api::InputId;
#[dom_struct]
pub struct XRInputSourceArray {
@ -46,6 +47,14 @@ impl XRInputSourceArray {
}
});
}
pub fn find(&self, id: InputId) -> Option<DomRoot<XRInputSource>> {
self.input_sources
.borrow()
.iter()
.find(|x| x.id() == id)
.map(|x| DomRoot::from_ref(&**x))
}
}
impl XRInputSourceArrayMethods for XRInputSourceArray {