mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Use initialized input sources in getInputSources()
This commit is contained in:
parent
3a08e917e0
commit
5c8132c379
3 changed files with 19 additions and 1 deletions
|
@ -926,7 +926,7 @@ impl VRDisplay {
|
||||||
/// Initialize XRInputSources
|
/// Initialize XRInputSources
|
||||||
fn initialize_inputs(&self) {
|
fn initialize_inputs(&self) {
|
||||||
if self.initialized_inputs.get() {
|
if self.initialized_inputs.get() {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
self.initialized_inputs.set(true);
|
self.initialized_inputs.set(true);
|
||||||
|
|
||||||
|
@ -955,6 +955,15 @@ impl VRDisplay {
|
||||||
Err(_) => {},
|
Err(_) => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_input_sources(&self) -> Vec<DomRoot<XRInputSource>> {
|
||||||
|
self.initialize_inputs();
|
||||||
|
self.input_sources
|
||||||
|
.borrow()
|
||||||
|
.iter()
|
||||||
|
.map(|(_, x)| DomRoot::from_ref(&**x))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebVR Spec: If the number of values in the leftBounds/rightBounds arrays
|
// WebVR Spec: If the number of values in the leftBounds/rightBounds arrays
|
||||||
|
|
|
@ -25,7 +25,10 @@ interface XRSession : EventTarget {
|
||||||
// // Methods
|
// // Methods
|
||||||
Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceOptions options);
|
Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceOptions options);
|
||||||
|
|
||||||
|
// workaround until we have FrozenArray
|
||||||
|
// see https://github.com/servo/servo/issues/10427#issuecomment-449593626
|
||||||
// FrozenArray<XRInputSource> getInputSources();
|
// FrozenArray<XRInputSource> getInputSources();
|
||||||
|
sequence<XRInputSource> getInputSources();
|
||||||
|
|
||||||
Promise<void> updateRenderState(optional XRRenderStateInit state);
|
Promise<void> updateRenderState(optional XRRenderStateInit state);
|
||||||
long requestAnimationFrame(XRFrameRequestCallback callback);
|
long requestAnimationFrame(XRFrameRequestCallback callback);
|
||||||
|
|
|
@ -19,6 +19,7 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::vrdisplay::VRDisplay;
|
use crate::dom::vrdisplay::VRDisplay;
|
||||||
|
use crate::dom::xrinputsource::XRInputSource;
|
||||||
use crate::dom::xrlayer::XRLayer;
|
use crate::dom::xrlayer::XRLayer;
|
||||||
use crate::dom::xrreferencespace::XRReferenceSpace;
|
use crate::dom::xrreferencespace::XRReferenceSpace;
|
||||||
use crate::dom::xrrenderstate::XRRenderState;
|
use crate::dom::xrrenderstate::XRRenderState;
|
||||||
|
@ -153,4 +154,9 @@ impl XRSessionMethods for XRSession {
|
||||||
|
|
||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://immersive-web.github.io/webxr/#dom-xrsession-getinputsources
|
||||||
|
fn GetInputSources(&self) -> Vec<DomRoot<XRInputSource>> {
|
||||||
|
self.display.get_input_sources()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue