Skip to content
Permalink
Browse files

Add blank FakeXRInputController interface

  • Loading branch information
Manishearth committed Jan 8, 2020
1 parent 9ecb13d commit bf30bf26a4754e21d4ae14ec0699cb3ca713c98c
@@ -534,7 +534,8 @@ unsafe_no_jsmanaged_fields!(
webxr_api::Registry,
webxr_api::Session,
webxr_api::Frame,
webxr_api::InputSource
webxr_api::InputSource,
webxr_api::InputId
);
unsafe_no_jsmanaged_fields!(ScriptToConstellationChan);
unsafe_no_jsmanaged_fields!(InteractiveMetrics);
@@ -0,0 +1,42 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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::codegen::Bindings::FakeXRInputControllerBinding::{self};
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use ipc_channel::ipc::IpcSender;
use webxr_api::{InputId, MockDeviceMsg};

#[dom_struct]
pub struct FakeXRInputController {
reflector: Reflector,
#[ignore_malloc_size_of = "defined in ipc-channel"]
sender: IpcSender<MockDeviceMsg>,
#[ignore_malloc_size_of = "defined in webxr-api"]
id: InputId,
}

impl FakeXRInputController {
pub fn new_inherited(sender: IpcSender<MockDeviceMsg>, id: InputId) -> FakeXRInputController {
FakeXRInputController {
reflector: Reflector::new(),
sender,
id,
}
}

pub fn new(
global: &GlobalScope,
sender: IpcSender<MockDeviceMsg>,
id: InputId,
) -> DomRoot<FakeXRInputController> {
reflect_dom_object(
Box::new(FakeXRInputController::new_inherited(sender, id)),
global,
FakeXRInputControllerBinding::Wrap,
)
}
}
@@ -301,6 +301,7 @@ pub mod eventtarget;
pub mod extendableevent;
pub mod extendablemessageevent;
pub mod fakexrdevice;
pub mod fakexrinputcontroller;
pub mod file;
pub mod filelist;
pub mod filereader;
@@ -0,0 +1,53 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */

// https://immersive-web.github.io/webxr-test-api/#fakexrinputcontroller

[Exposed=Window, Pref="dom.webxr.test"]
interface FakeXRInputController {
// void setHandedness(XRHandedness handedness);
// void setTargetRayMode(XRTargetRayMode targetRayMode);
// void setProfiles(sequence<DOMString> profiles);
// void setGripOrigin(FakeXRRigidTransformInit gripOrigin, optional boolean emulatedPosition = false);
// void clearGripOrigin();
// void setPointerOrigin(FakeXRRigidTransformInit pointerOrigin, optional boolean emulatedPosition = false);

// void disconnect();
// void reconnect();

// void startSelection();
// void endSelection();
// void simulateSelect();

// void setSupportedButtons(sequence<FakeXRButtonStateInit> supportedButtons);
// void updateButtonState(FakeXRButtonStateInit buttonState);
};

dictionary FakeXRInputSourceInit {
required XRHandedness handedness;
required XRTargetRayMode targetRayMode;
required FakeXRRigidTransformInit pointerOrigin;
required sequence<DOMString> profiles;
boolean selectionStarted = false;
boolean selectionClicked = false;
sequence<FakeXRButtonStateInit> supportedButtons;
FakeXRRigidTransformInit gripOrigin;
};

enum FakeXRButtonType {
"grip",
"touchpad",
"thumbstick",
"optional-button",
"optional-thumbstick"
};

dictionary FakeXRButtonStateInit {
required FakeXRButtonType buttonType;
required boolean pressed;
required boolean touched;
required float pressedValue;
float xValue = 0.0;
float yValue = 0.0;
};

0 comments on commit bf30bf2

Please sign in to comment.
You can’t perform that action at this time.