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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
//! Raw bindings into the javascript API.
//!
//! For using those functions, prefer `api` instead.

use crate::wasm_bindgen;

#[wasm_bindgen]
extern "C" {

    /// Spawn a new overlay.
    ///
    /// This is private/hidden for safety. See `spawn_overlay` for more info.
    ///
    /// Returns an uid.
    // https://github.com/swfsql/ovrt-sys/issues/2
    #[wasm_bindgen(js_namespace = window, js_name = SpawnOverlay)]
    pub(crate) fn spawn_overlay_with_callback(
        transform_info: String,
        callback: String,
    ) -> i32;

    /// Spawn a new overlay.
    ///
    /// This is private/hidden for safety. See `spawn_overlay` for more info.
    ///
    /// Returns an uid.
    #[wasm_bindgen(js_namespace = window, js_name = SpawnOverlay)]
    pub(crate) fn spawn_overlay(transform_info: String) -> i32;

    /// Set contents of an overlay.
    ///
    /// This is private/hidden for safety. See `types::WindowTypeValue` for more info.
    // https://github.com/swfsql/ovrt-sys/issues/2
    // https://github.com/swfsql/ovrt-sys/issues/6
    #[wasm_bindgen(js_namespace = window, js_name = SetContents)]
    pub(crate) fn set_contents_website(
        uid: String,
        type_: i32,
        contents: String,
    );

    /// Set contents of an overlay.
    ///
    /// This is private/hidden for safety. See `types::WindowTypeValue` for more info.
    #[wasm_bindgen(js_namespace = window, js_name = SetContents)]
    // TODO: check accordingly to reference.
    // reference: window.SetContents(String(uid), Number(winData.type), normalizedContents);
    // https://github.com/swfsql/ovrt-sys/issues/6
    pub(crate) fn set_contents_desktop(
        uid: String,
        type_: i32,
        monitor_id: i32,
    );

    /// Set contents of an overlay.
    ///
    /// This is private/hidden for safety. See `types::WindowTypeValue` for more info.
    #[wasm_bindgen(js_namespace = window, js_name = SetContents)]
    // TODO: check accordingly to reference.
    // reference: window.SetContents(String(uid), Number(winData.type), normalizedContents);
    // https://github.com/swfsql/ovrt-sys/issues/6
    pub(crate) fn set_contents_window(
        uid: String,
        type_: i32,
        window_handle: i32,
    );

    /// Returns a list of open windows and their handles.
    /// (If user has this option enabled).
    ///
    /// Returns `windowTitles`.
    // https://github.com/swfsql/ovrt-sys/issues/2
    #[wasm_bindgen(js_namespace = window, js_name = GetWindowTitles)]
    // TODO: check accordingly to reference.
    // reference: window.GetWindowTitles("completeIntervalWinTitles");
    // window.GetWindowTitles("ovrtWinTitles");
    pub(crate) fn get_window_titles(callback: String) -> String;

    /// Returns a list of open windows and their handles.
    /// (If user has this option enabled).
    ///
    /// Returns `windowTitles`.
    #[wasm_bindgen(js_name = GetWindowTitlesCallback)]
    // TODO: check accordingly to reference.
    // reference: window.GetWindowTitles("completeIntervalWinTitles");
    // window.GetWindowTitles("ovrtWinTitles");
    pub(crate) fn get_window_titles_callback(
        callback: String,
    ) -> String;

    /// (Used for SetContents monitorId).
    ///
    /// Returns `monitorCount` (how many monitors are connected).
    #[wasm_bindgen(js_namespace = window, js_name = GetMonitorCount)]
    // TODO: check accordingly to reference.
    // reference: GetMonitorCount("ovrtMonitorTotal");
    // window.GetMonitorCount(callback, data);
    pub(crate) fn get_monitor_count(callback: String) -> i32;

    /// Refresh a browser page.
    #[wasm_bindgen(js_namespace = window, js_name = Refresh)]
    // TODO: check accordingly to reference.
    // reference: window.Refresh(uid);
    pub(crate) fn refresh(uid: i32);

    /// Get `OVROverlayTransform` of a specified overlay.
    ///
    /// Returns `transformInfo`.
    // https://github.com/swfsql/ovrt-sys/issues/2
    #[wasm_bindgen(js_namespace = window, js_name = GetOverlayTransform)]
    // TODO: check accordingly to reference.
    // reference: window.GetOverlayTransform(String(uid), "ovrtWinDetailed");
    pub(crate) fn get_overlay_transform(uid: i32) -> String;

    /// Get `OVROverlayTransform` of a specified overlay.
    ///
    /// Returns `transformInfo`.
    #[wasm_bindgen(js_namespace = window, js_name = GetOverlayTransform)]
    // TODO: check accordingly to reference.
    // reference: window.GetOverlayTransform(String(uid), "ovrtWinDetailed");
    pub(crate) fn get_overlay_transform_with_callback(
        uid: i32,
        callback: String,
    ) -> String;

    /// Get type of overlay.
    /// (Browser, window capture, desktop capture).
    ///
    /// Returns `type`.
    #[wasm_bindgen(js_namespace = window, js_name = GetOverlayType)]
    // TODO: check accordingly to reference.
    // reference: window.GetOverlayType(uid, callback);
    pub(crate) fn get_overlay_type(
        uid: i32,
        callback: String,
    ) -> i32;

    /// Get bounds of overlay bounding box.
    /// (Refer to Unity documentation 'Bounds' section).
    ///
    /// Returns `bounds`.
    // https://github.com/swfsql/ovrt-sys/issues/2
    #[wasm_bindgen(js_namespace = window, js_name = GetOverlayBounds)]
    // TODO: check accordingly to reference.
    // reference: window.GetOverlayBounds(uid, callback);
    pub(crate) fn get_overlay_bounds(
        uid: i32,
        callback: String,
    ) -> String;

    /// Get finger curl positions.
    ///
    /// Returns `curls`.
    /// (Returns 0 for all values if user is in Simulator Mode).
    // https://github.com/swfsql/ovrt-sys/issues/2
    #[wasm_bindgen(js_namespace = window, js_name = GetFingerCurls)]
    // TODO: check accordingly to reference.
    // reference: window.GetFingerCurls("completeFingerCurls");
    pub(crate) fn get_finger_curls(callback: String) -> String;

    /// Set position of an overlay.
    #[wasm_bindgen(js_namespace = window, js_name = SetOverlayPosition)]
    // TODO: check accordingly to reference.
    // reference: window.SetOverlayPosition(uid, pos.x, pos.y, pos.z);
    pub(crate) fn set_overlay_position(
        uid: i32,
        posX: f64,
        posY: f64,
        posZ: f64,
    );

    /// Set rotation of an overlay.
    /// (EulerAngles).
    #[wasm_bindgen(js_namespace = window, js_name = SetOverlayRotation)]
    // TODO: check accordingly to reference.
    // reference: window.SetOverlayRotation(uid, rot.x, rot.y, rot.z);
    pub(crate) fn set_overlay_rotation(
        uid: i32,
        rotX: f64,
        rotY: f64,
        rotZ: f64,
    );

    /// Set overlay setting.
    ///
    /// This is private/hidden for safety. See `types::SettingValue` for more info.
    #[wasm_bindgen(js_namespace = window, js_name = SetOverlaySetting)]
    // TODO: check accordingly to reference.
    // reference: window.SetOverlaySetting(uid, setting, value);
    pub(crate) fn set_overlay_setting_i32(
        uid: i32,
        setting: i32,
        new_value: i32,
    );

    /// Set overlay setting.
    ///
    /// This is private/hidden for safety. See `types::SettingValue` for more info.
    #[wasm_bindgen(js_namespace = window, js_name = SetOverlaySetting)]
    pub(crate) fn set_overlay_setting_f64(
        uid: i32,
        setting: i32,
        new_value: f64,
    );

    /// Set overlay setting.
    ///
    /// This is private/hidden for safety. See `types::SettingValue` for more info.
    #[wasm_bindgen(js_namespace = window, js_name = SetOverlaySetting)]
    pub(crate) fn set_overlay_setting_bool(
        uid: i32,
        setting: i32,
        new_value: bool,
    );

    // /// Close the specified overlay.
    // #[wasm_bindgen(js_namespace = window, js_name = CloseOverlay)]
    // // TODO: check accordingly to reference.
    // // reference: window.CloseOverlay(uid);
    // // https://github.com/swfsql/ovrt-sys/issues/6
    // pub(crate) fn close_overlay(uid: i32);

    /// Close the specified overlay.
    #[wasm_bindgen(js_namespace = window, js_name = CloseOverlay)]
    // TODO: check accordingly to reference.
    // reference: window.CloseOverlay(uid);
    // https://github.com/swfsql/ovrt-sys/issues/6
    // https://github.com/swfsql/ovrt-sys/issues/2
    pub(crate) fn close_overlay_str(uid: String);

    /// Send device position/rotation data to the calling overlay.
    /// (Refer to 'Events' below).
    #[wasm_bindgen(js_namespace = window, js_name = SendDeviceData)]
    // TODO: check accordingly to reference.
    // reference: window.SendDeviceData(enable);
    pub(crate) fn send_device_data(enabled: bool);

    /// Send overlay position/rotation data to the calling overlay.
    /// (Refer to 'Events' below).
    #[wasm_bindgen(js_namespace = window, js_name = SendOverlayPositions)]
    // TODO: check accordingly to reference.
    // reference: window.SendOverlayPositions(enable);
    pub(crate) fn send_overlay_positions(enabled: bool);

    /// Send message all other open browser instances.
    /// (Calls 'ReceiveMessage').
    #[wasm_bindgen(js_namespace = window, js_name = BroadcastMessage)]
    // TODO: check accordingly to reference.
    // reference: window.BroadcastMessage(JSON.stringify({broadcast: true,event: event,data: data,}));
    // window.BroadcastMessage(JSON.stringify({broadcast: false,event: event,data: data,senderId: senderId,targetId: targetId,}));
    //
    // check send_message below
    pub(crate) fn broadcast_message(message: String);

    /// Send message to specific browser instance.
    /// (Calls 'ReceiveMessage').
    #[wasm_bindgen(js_namespace = window, js_name = SendMessage)]
    // TODO: check accordingly to reference.
    // reference: none
    // TODO: actually, it appears that this was merged into broadcast_message
    // but now it has its own api call
    pub(crate) fn send_message(uid: i32, message: String);

    /// Set if this overlay should receive keyboard inputs.
    /// (This will block the keyboard working on OVR Toolkit windows!).
    #[wasm_bindgen(js_namespace = window, js_name = SetKeyboardFocus)]
    // TODO: check accordingly to reference.
    // reference: none
    pub(crate) fn set_keyboard_focus(enabled: bool);

    /// Sets the title of the browser that is visible in the Window List of OVR Toolkit.
    #[wasm_bindgen(js_namespace = window, js_name = SetBrowserTitle)]
    // TODO: check accordingly to reference.
    // reference: none
    pub(crate) fn set_browser_title(title: String);
}