-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathohmdAPI.cpp
110 lines (99 loc) · 3.01 KB
/
ohmdAPI.cpp
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
/**********************************************************\
Auto-generated ohmdAPI.cpp
\**********************************************************/
#include "JSObject.h"
#include "variant_list.h"
#include "DOM/Document.h"
#include "global/config.h"
#include <OVR.h>
#include "ohmdAPI.h"
///////////////////////////////////////////////////////////////////////////////
/// @fn ohmdPtr ohmdAPI::getPlugin()
///
/// @brief Gets a reference to the plugin that was passed in when the object
/// was created. If the plugin has already been released then this
/// will throw a FB::script_error that will be translated into a
/// javascript exception in the page.
///////////////////////////////////////////////////////////////////////////////
ohmdPtr ohmdAPI::getPlugin()
{
ohmdPtr plugin(m_plugin.lock());
if (!plugin) {
throw FB::script_error("The plugin is invalid");
}
return plugin;
}
std::string ohmdAPI::get_version()
{
return FBSTRING_PLUGIN_VERSION;
}
FB::VariantMap ohmdAPI::get_deviceInfo()
{
FB::VariantMap hmdMap;
ohmdPtr plugin = getPlugin();
if (!plugin->pHMD) {
hmdMap["error"] = true;
hmdMap["message"] = "HMD Device not found";
} else {
OVR::HMDInfo hmdInfo;
plugin->pHMD->GetDeviceInfo(&hmdInfo);
FB::VariantList DistortionK;
DistortionK.push_back(hmdInfo.DistortionK[0]);
DistortionK.push_back(hmdInfo.DistortionK[1]);
DistortionK.push_back(hmdInfo.DistortionK[2]);
DistortionK.push_back(hmdInfo.DistortionK[3]);
hmdMap["error"] = false;
hmdMap["displayDeviceName"] = hmdInfo.DisplayDeviceName;
hmdMap["interpupillaryDistance"] = hmdInfo.InterpupillaryDistance;
hmdMap["distortionK"] = DistortionK;
}
return hmdMap;
}
FB::VariantMap ohmdAPI::get_orientation()
{
FB::VariantMap hmdMap;
ohmdPtr plugin = getPlugin();
if (!plugin->pHMD || !plugin->pSensor){
hmdMap["error"] = true;
hmdMap["message"] = "HMD Device not found";
} else {
OVR::Quatf hmdOrient = plugin->SFusion.GetOrientation();
float yaw=0.0f, pitch=0.0f, roll=0.0f;
hmdOrient.GetEulerAngles<OVR::Axis_Y, OVR::Axis_X, OVR::Axis_Z>(&yaw, &pitch, &roll);
FB::VariantList OrientationK;
OrientationK.push_back(yaw);
OrientationK.push_back(pitch);
OrientationK.push_back(roll);
hmdMap["error"] = false;
hmdMap["orientation"] = OrientationK;
}
return hmdMap;
}
FB::VariantMap ohmdAPI::get_acceleration()
{
FB::VariantMap hmdMap;
ohmdPtr plugin = getPlugin();
if (!plugin->pHMD || !plugin->pSensor){
hmdMap["error"] = true;
hmdMap["message"] = "HMD Device not found";
} else {
// :TODO:
hmdMap["error"] = true;
hmdMap["message"] = "Property not yet implemented";
}
return hmdMap;
}
FB::VariantMap ohmdAPI::get_angularVelocity()
{
FB::VariantMap hmdMap;
ohmdPtr plugin = getPlugin();
if (!plugin->pHMD || !plugin->pSensor){
hmdMap["error"] = true;
hmdMap["message"] = "HMD Device not found";
} else {
// :TODO:
hmdMap["error"] = true;
hmdMap["message"] = "Property not yet implemented";
}
return hmdMap;
}