summaryrefslogtreecommitdiffhomepage
path: root/tracker-rift-140
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-rift-140')
-rw-r--r--tracker-rift-140/CMakeLists.txt17
-rw-r--r--tracker-rift-140/dialog.cpp7
-rw-r--r--tracker-rift-140/dialog.ui124
-rw-r--r--tracker-rift-140/lang/nl_NL.ts35
-rw-r--r--tracker-rift-140/lang/ru_RU.ts35
-rw-r--r--tracker-rift-140/lang/stub.ts35
-rw-r--r--tracker-rift-140/lang/zh_CN.ts18
-rw-r--r--tracker-rift-140/rift-140.cpp60
-rw-r--r--tracker-rift-140/rift-140.hpp29
9 files changed, 74 insertions, 286 deletions
diff --git a/tracker-rift-140/CMakeLists.txt b/tracker-rift-140/CMakeLists.txt
index c0235142..278effe2 100644
--- a/tracker-rift-140/CMakeLists.txt
+++ b/tracker-rift-140/CMakeLists.txt
@@ -1,3 +1,14 @@
-include(opentrack-rift)
-otr_rift(tracker-rift-140 SDK_RIFT_140)
-SET(SDK_RIFT_140 "" CACHE PATH "libOVR 1.4.0 path for Oculus Rift")
+if(WIN32)
+ SET(SDK_RIFT_140 "" CACHE PATH "libOVR 1.4.0 path for Oculus Rift")
+ if(SDK_RIFT_140)
+ include_directories("${SDK_RIFT_140}/Include")
+ if(opentrack-64bit)
+ link_directories("${SDK_RIFT_140}/Lib/Windows/x64/Release/VS2017")
+ else()
+ link_directories("${SDK_RIFT_140}/Lib/Windows/Win32/Release/VS2017")
+ endif()
+ link_libraries(LibOVR winmm setupapi ws2_32 imagehlp wbemuuid)
+
+ otr_module(tracker-rift)
+ endif()
+endif()
diff --git a/tracker-rift-140/dialog.cpp b/tracker-rift-140/dialog.cpp
index bd6ac46c..53b4a1d2 100644
--- a/tracker-rift-140/dialog.cpp
+++ b/tracker-rift-140/dialog.cpp
@@ -3,15 +3,10 @@
dialog_rift_140::dialog_rift_140()
{
- ui.setupUi( this );
+ ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
-
- tie_setting(s.constant_drift, ui.constantDrift);
- tie_setting(s.deadzone, ui.deadzone);
- tie_setting(s.persistence, ui.persistence);
- tie_setting(s.useYawSpring, ui.yawSpring);
}
void dialog_rift_140::doOK() {
diff --git a/tracker-rift-140/dialog.ui b/tracker-rift-140/dialog.ui
index 6fe583c3..b2682529 100644
--- a/tracker-rift-140/dialog.ui
+++ b/tracker-rift-140/dialog.ui
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>218</width>
- <height>200</height>
+ <width>184</width>
+ <height>40</height>
</rect>
</property>
<property name="sizePolicy">
@@ -24,7 +24,7 @@
</property>
<property name="windowIcon">
<iconset>
- <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset>
+ <normaloff>images/opentrack.png</normaloff>images/opentrack.png</iconset>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
@@ -34,124 +34,6 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Yaw spring</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QCheckBox" name="yawSpring">
- <property name="text">
- <string>Enable</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Persistence</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QDoubleSpinBox" name="persistence">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>23</height>
- </size>
- </property>
- <property name="decimals">
- <number>5</number>
- </property>
- <property name="minimum">
- <double>0.900000000000000</double>
- </property>
- <property name="maximum">
- <double>1.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.001000000000000</double>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Constant drift</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QDoubleSpinBox" name="constantDrift">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>23</height>
- </size>
- </property>
- <property name="decimals">
- <number>5</number>
- </property>
- <property name="minimum">
- <double>0.000100000000000</double>
- </property>
- <property name="maximum">
- <double>0.100000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.001000000000000</double>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Deadzone</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QDoubleSpinBox" name="deadzone">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>23</height>
- </size>
- </property>
- <property name="decimals">
- <number>5</number>
- </property>
- <property name="maximum">
- <double>0.100000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.010000000000000</double>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
diff --git a/tracker-rift-140/lang/nl_NL.ts b/tracker-rift-140/lang/nl_NL.ts
index 68070720..d472b35c 100644
--- a/tracker-rift-140/lang/nl_NL.ts
+++ b/tracker-rift-140/lang/nl_NL.ts
@@ -4,50 +4,15 @@
<context>
<name>dialog_rift_140</name>
<message>
- <location filename="../dialog.ui" line="+23"/>
<source>Oculus Rift tracker settings FaceTrackNoIR</source>
<translation type="unfinished"></translation>
</message>
- <message>
- <location line="+16"/>
- <source>Yaw spring</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+6"/>
- <source>Enable</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+7"/>
- <source>Persistence</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+35"/>
- <source>Constant drift</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+35"/>
- <source>Deadzone</source>
- <translation type="unfinished"></translation>
- </message>
</context>
<context>
<name>rift_140Dll</name>
<message>
- <location filename="../rift-140.hpp" line="+57"/>
<source>Oculus Rift runtime 1.4.0 -- HMD</source>
<translation type="unfinished"></translation>
</message>
</context>
-<context>
- <name>rift_tracker_140</name>
- <message>
- <location filename="../impl.cpp" line="+61"/>
- <source>Unable to start Rift tracker: %1</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
</TS>
diff --git a/tracker-rift-140/lang/ru_RU.ts b/tracker-rift-140/lang/ru_RU.ts
index fe2cbea7..59099270 100644
--- a/tracker-rift-140/lang/ru_RU.ts
+++ b/tracker-rift-140/lang/ru_RU.ts
@@ -4,50 +4,15 @@
<context>
<name>dialog_rift_140</name>
<message>
- <location filename="../dialog.ui" line="+23"/>
<source>Oculus Rift tracker settings FaceTrackNoIR</source>
<translation type="unfinished"></translation>
</message>
- <message>
- <location line="+16"/>
- <source>Yaw spring</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+6"/>
- <source>Enable</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+7"/>
- <source>Persistence</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+35"/>
- <source>Constant drift</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+35"/>
- <source>Deadzone</source>
- <translation type="unfinished"></translation>
- </message>
</context>
<context>
<name>rift_140Dll</name>
<message>
- <location filename="../rift-140.hpp" line="+57"/>
<source>Oculus Rift runtime 1.4.0 -- HMD</source>
<translation type="unfinished"></translation>
</message>
</context>
-<context>
- <name>rift_tracker_140</name>
- <message>
- <location filename="../impl.cpp" line="+61"/>
- <source>Unable to start Rift tracker: %1</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
</TS>
diff --git a/tracker-rift-140/lang/stub.ts b/tracker-rift-140/lang/stub.ts
index 0a386ba1..26ab2040 100644
--- a/tracker-rift-140/lang/stub.ts
+++ b/tracker-rift-140/lang/stub.ts
@@ -4,50 +4,15 @@
<context>
<name>dialog_rift_140</name>
<message>
- <location filename="../dialog.ui" line="+23"/>
<source>Oculus Rift tracker settings FaceTrackNoIR</source>
<translation type="unfinished"></translation>
</message>
- <message>
- <location line="+16"/>
- <source>Yaw spring</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+6"/>
- <source>Enable</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+7"/>
- <source>Persistence</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+35"/>
- <source>Constant drift</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+35"/>
- <source>Deadzone</source>
- <translation type="unfinished"></translation>
- </message>
</context>
<context>
<name>rift_140Dll</name>
<message>
- <location filename="../rift-140.hpp" line="+57"/>
<source>Oculus Rift runtime 1.4.0 -- HMD</source>
<translation type="unfinished"></translation>
</message>
</context>
-<context>
- <name>rift_tracker_140</name>
- <message>
- <location filename="../impl.cpp" line="+61"/>
- <source>Unable to start Rift tracker: %1</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
</TS>
diff --git a/tracker-rift-140/lang/zh_CN.ts b/tracker-rift-140/lang/zh_CN.ts
new file mode 100644
index 00000000..ff552d19
--- /dev/null
+++ b/tracker-rift-140/lang/zh_CN.ts
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="zh_CN">
+<context>
+ <name>dialog_rift_140</name>
+ <message>
+ <source>Oculus Rift tracker settings FaceTrackNoIR</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>rift_140Dll</name>
+ <message>
+ <source>Oculus Rift runtime 1.4.0 -- HMD</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tracker-rift-140/rift-140.cpp b/tracker-rift-140/rift-140.cpp
index 45bfcc97..164b47f7 100644
--- a/tracker-rift-140/rift-140.cpp
+++ b/tracker-rift-140/rift-140.cpp
@@ -15,16 +15,13 @@
#include "rift-140.hpp"
#include "api/plugin-api.hpp"
-#include "compat/util.hpp"
#include <Extras/OVR_Math.h>
#include <QString>
using namespace OVR;
-rift_tracker_140::rift_tracker_140() : old_yaw(0), hmd(nullptr)
-{
-}
+rift_tracker_140::rift_tracker_140() = default;
rift_tracker_140::~rift_tracker_140()
{
@@ -35,32 +32,31 @@ rift_tracker_140::~rift_tracker_140()
}
}
-void rift_tracker_140::start_tracker(QFrame*)
+module_status rift_tracker_140::start_tracker(QFrame*)
{
if (OVR_FAILURE(ovr_Initialize(nullptr)))
goto error;
- if(OVR_FAILURE(ovr_Create(&hmd, &luid)))
+ if (OVR_FAILURE(ovr_Create(&hmd, &luid)))
+ goto error;
+
+ if (OVR_FAILURE(ovr_SetTrackingOriginType(hmd, ovrTrackingOrigin_EyeLevel)))
goto error;
- return;
+ return status_ok();
error:
hmd = nullptr;
ovrErrorInfo err;
ovr_GetLastErrorInfo(&err);
- QString strerror(err.ErrorString);
- if (strerror.size() == 0)
- strerror = QStringLiteral("Unknown reason #%1").arg(err.Result);
+ QString error_string(err.ErrorString);
+ if (error_string.size() == 0)
+ error_string = QStringLiteral("Unknown reason #%1").arg(err.Result);
ovr_Shutdown();
- QMessageBox::warning(nullptr,
- "Error",
- QCoreApplication::translate("rift_tracker_140", "Unable to start Rift tracker: %1").arg(strerror),
- QMessageBox::Ok,
- QMessageBox::NoButton);
+ return error(error_string);
}
void rift_tracker_140::data(double *data)
@@ -70,8 +66,8 @@ void rift_tracker_140::data(double *data)
ovrTrackingState ss = ovr_GetTrackingState(hmd, 0, false);
if (ss.StatusFlags & ovrStatus_OrientationTracked)
{
- static constexpr float c_mult = 8;
- static constexpr float c_div = 1/c_mult;
+ constexpr float c_mult = 8;
+ constexpr float c_div = 1/c_mult;
Vector3f axis;
float angle;
@@ -87,25 +83,21 @@ void rift_tracker_140::data(double *data)
pitch *= c_mult;
roll *= c_mult;
- double yaw_ = double(yaw);
- if (s.useYawSpring)
- {
- yaw_ = old_yaw*s.persistence + (yaw_-old_yaw);
- if(yaw_ > s.deadzone)
- yaw_ -= s.constant_drift;
- if(yaw_ < -s.deadzone)
- yaw_ += s.constant_drift;
- old_yaw = yaw_;
- }
- static constexpr double d2r = 180 / M_PI;
- data[Yaw] = yaw_ * -d2r;
- data[Pitch] = double(pitch) * d2r;
- data[Roll] = double(roll) * d2r;
- data[TX] = double(pose.Translation.x) * -1e2;
- data[TY] = double(pose.Translation.y) * 1e2;
- data[TZ] = double(pose.Translation.z) * 1e2;
+ constexpr double d2r = 180 / M_PI;
+ data[Yaw] = double(yaw) * -d2r;
+ data[Pitch] = double(pitch) * d2r;
+ data[Roll] = double(roll) * d2r;
+ data[TX] = double(pose.Translation.x) * -1e2;
+ data[TY] = double(pose.Translation.y) * 1e2;
+ data[TZ] = double(pose.Translation.z) * 1e2;
}
}
}
+bool rift_tracker_140::center()
+{
+ (void)ovr_RecenterTrackingOrigin(hmd);
+ return false;
+}
+
OPENTRACK_DECLARE_TRACKER(rift_tracker_140, dialog_rift_140, rift_140Dll)
diff --git a/tracker-rift-140/rift-140.hpp b/tracker-rift-140/rift-140.hpp
index 47eb7cd2..9cc34efa 100644
--- a/tracker-rift-140/rift-140.hpp
+++ b/tracker-rift-140/rift-140.hpp
@@ -9,14 +9,7 @@
using namespace options;
struct settings : opts {
- value<bool> useYawSpring;
- value<double> constant_drift, persistence, deadzone;
- settings() :
- opts("Rift-140"),
- useYawSpring(b, "yaw-spring", false),
- constant_drift(b, "constant-drift", 0.000005),
- persistence(b, "persistence", 0.99999),
- deadzone(b, "deadzone", 0.02)
+ settings() : opts("Rift-140")
{}
};
@@ -25,12 +18,13 @@ class rift_tracker_140 : public ITracker
public:
rift_tracker_140();
~rift_tracker_140() override;
- void start_tracker(QFrame *) override;
+ module_status start_tracker(QFrame *) override;
void data(double *data) override;
+ bool center() override;
+
private:
- double old_yaw;
- ovrSession hmd;
- ovrGraphicsLuid luid;
+ ovrSession hmd = nullptr;
+ ovrGraphicsLuid luid {};
settings s;
};
@@ -40,8 +34,8 @@ class dialog_rift_140: public ITrackerDialog
public:
dialog_rift_140();
- void register_tracker(ITracker *) {}
- void unregister_tracker() {}
+ void register_tracker(ITracker*) override {}
+ void unregister_tracker() override {}
private:
Ui::dialog_rift_140 ui;
@@ -53,8 +47,9 @@ private slots:
class rift_140Dll : public Metadata
{
-public:
- QString name() { return QString(QCoreApplication::translate("rift_140Dll", "Oculus Rift runtime 1.4.0 -- HMD")); }
- QIcon icon() { return QIcon(":/images/rift_tiny.png"); }
+ Q_OBJECT
+
+ QString name() override { return tr("Oculus Rift runtime 1.4.0 -- HMD"); }
+ QIcon icon() override { return QIcon(":/images/rift_tiny.png"); }
};