Files
ovrt_sys
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Raw bindings into the javascript API.
//!
//! For using those functions, prefer `events` instead.

use crate::{
    types::{self, Uid},
    wasm_bindgen,
};

/// Sends HMD and left/right controller position and rotation, also shows the active controller.
/// (Needs to be enabled per overlay, refer to API above).
// https://github.com/swfsql/ovrt-sys/issues/2
#[wasm_bindgen(js_name = DevicePositionUpdate)]
// TODO: check accordingly to reference.
// reference: function DevicePositionUpdate(deviceInfo) {
pub fn device_position_update(device_info: String) {
    let device_info = serde_json::from_str::<
        types::OVRDeviceUpdate,
    >(&device_info)
    .expect("failed to deserialize");
    super::device_position_update(device_info)
}

/// Receives messages from other browser instances.
#[wasm_bindgen(js_name = ReceiveMessage)]
// TODO: check accordingly to reference.
// reference: function ReceiveMessage(message) {
pub fn receive_message(message: String) {
    super::receive_message(message)
}

/// If the user is interacting with the current overlay.
/// (Mouse over).
#[wasm_bindgen(js_name = InteractionStateChanged)]
// TODO: check accordingly to reference.
// reference: function InteractionStateChanged(isInteracting) {
pub fn interaction_state_changed(is_interacting: bool) {
    super::interaction_state_changed(is_interacting)
}

/// Called when an overlay is spawned.
#[wasm_bindgen(js_name = OverlayOpened)]
// TODO: check accordingly to reference.
// reference: function OverlayOpened(uid) {
pub fn overlay_opened(uid: i32) {
    super::overlay_opened(Uid(uid))
}

/// Called when an overlay is closed.
#[wasm_bindgen(js_name = OverlayClosed)]
// TODO: check accordingly to reference.
// reference: function OverlayClosed(uid) {
pub fn overlay_closed(uid: i32) {
    super::overlay_closed(Uid(uid))
}

/// Called when an overlay is moved or its size changes.
/// (Needs to be enabled per overlay, refer to API above).
// https://github.com/swfsql/ovrt-sys/issues/2
#[wasm_bindgen(js_name = OverlayTransformChanged)]
// TODO: check accordingly to reference.
// reference: function OverlayTransformChanged(updateData) {
pub fn overlay_transform_changed(uid: i32, data: String) {
    let data =
        serde_json::from_str::<types::OVRTransformUpdate>(&data)
            .expect("failed to deserialize");
    super::overlay_transform_changed(Uid(uid), data)
}

/// Called when the API has finished injecting into the browser and the API can now be used.
#[wasm_bindgen(js_name = APIInit)]
// TODO: check accordingly to reference.
// reference: none
pub fn api_init() {
    super::api_init()
}