forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvr.h
More file actions
103 lines (80 loc) · 2.79 KB
/
vr.h
File metadata and controls
103 lines (80 loc) · 2.79 KB
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
/* -*- Mode: c++; indent-tabs-mode: nil; tab-width: 40; c-basic-offset: 4 -*- */
#ifndef __emscripten_vr_h__
#define __emscripten_vr_h__
#include <stdint.h>
#include <stdbool.h>
/*
* This file provides some basic interfaces for interacting with WebVR from Emscripten.
*
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef int32_t WebVRDeviceId;
typedef int32_t WebVRHardwareUnitId;
typedef enum {
WebVREyeLeft = 0,
WebVREyeRight = 1
} WebVREye;
typedef enum {
WebVRUnknownDevice = 0,
WebVRHMDDevice = 1,
WebVRPositionSensorDevice = 2
} WebVRDeviceType;
typedef struct WebVRFieldOfView {
double upDegrees;
double rightDegrees;
double downDegrees;
double leftDegrees;
} WebVRFieldOfView;
typedef struct WebVRPoint {
double x, y, z, w;
} WebVRPoint;
typedef struct WebVRIntRect {
int32_t x, y;
uint32_t width, height;
} WebVRIntRect;
typedef struct WebVRPositionState {
double timeStamp;
int hasPosition;
WebVRPoint position;
WebVRPoint linearVelocity;
WebVRPoint linearAcceleration;
int hasOrientation;
WebVRPoint orientation;
WebVRPoint angularVelocity;
WebVRPoint angularAcceleration;
} WebVRPositionState;
typedef struct WebVREyeParameters {
WebVRFieldOfView minimumFieldOfView;
WebVRFieldOfView maximumFieldOfView;
WebVRFieldOfView recommendedFieldOfView;
WebVRPoint eyeTranslation;
WebVRFieldOfView currentFieldOfView;
WebVRIntRect renderRect;
} WebVREyeParameters;
extern void emscripten_vr_init();
extern int emscripten_vr_ready();
extern int emscripten_vr_count_devices();
extern WebVRDeviceId emscripten_vr_get_device_id(int deviceIndex);
extern WebVRDeviceType emscripten_vr_get_device_type(WebVRDeviceId deviceId);
extern WebVRHardwareUnitId emscripten_vr_get_device_hwid(WebVRDeviceId deviceId);
extern char *emscripten_vr_get_device_name(WebVRDeviceId deviceId);
// select the given device as the fullscreen HMD device
extern int emscripten_vr_select_hmd_device(WebVRDeviceId deviceId);
extern WebVRDeviceId emscripten_vr_get_selected_hmd_device();
// For HMD devices.
// All of these return 1 on success, <= 0 on failure.
extern int emscripten_vr_hmd_get_eye_parameters(WebVRDeviceId deviceId, WebVREye whichEye, WebVREyeParameters *eyeParams);
extern int emscripten_vr_hmd_set_fov(WebVRDeviceId deviceId,
const WebVRFieldOfView *leftFov,
const WebVRFieldOfView *rightFov,
double zNear, double zFar);
// for Position devices
// All of these return 1 on success, <= 0 on failure.
extern int emscripten_vr_sensor_get_state(WebVRDeviceId deviceId, bool immediate, WebVRPositionState *state);
extern int emscripten_vr_sensor_zero(WebVRDeviceId deviceId);
#ifdef __cplusplus
} // ~extern "C"
#endif
#endif