diff options
Diffstat (limited to 'tracker-rift-140')
-rw-r--r-- | tracker-rift-140/CMakeLists.txt | 17 | ||||
-rw-r--r-- | tracker-rift-140/dialog.cpp | 7 | ||||
-rw-r--r-- | tracker-rift-140/dialog.ui | 122 | ||||
-rw-r--r-- | tracker-rift-140/lang/nl_NL.ts | 21 | ||||
-rw-r--r-- | tracker-rift-140/lang/ru_RU.ts | 21 | ||||
-rw-r--r-- | tracker-rift-140/lang/stub.ts | 21 | ||||
-rw-r--r-- | tracker-rift-140/lang/zh_CN.ts | 23 | ||||
-rw-r--r-- | tracker-rift-140/rift-140.cpp | 45 | ||||
-rw-r--r-- | tracker-rift-140/rift-140.hpp | 27 |
9 files changed, 66 insertions, 238 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 a440db58..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"> @@ -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 04ed2ba1..d472b35c 100644 --- a/tracker-rift-140/lang/nl_NL.ts +++ b/tracker-rift-140/lang/nl_NL.ts @@ -7,24 +7,11 @@ <source>Oculus Rift tracker settings FaceTrackNoIR</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>rift_140Dll</name> <message> - <source>Yaw spring</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Enable</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Persistence</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Constant drift</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Deadzone</source> + <source>Oculus Rift runtime 1.4.0 -- HMD</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tracker-rift-140/lang/ru_RU.ts b/tracker-rift-140/lang/ru_RU.ts index a49a9017..59099270 100644 --- a/tracker-rift-140/lang/ru_RU.ts +++ b/tracker-rift-140/lang/ru_RU.ts @@ -7,24 +7,11 @@ <source>Oculus Rift tracker settings FaceTrackNoIR</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>rift_140Dll</name> <message> - <source>Yaw spring</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Enable</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Persistence</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Constant drift</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Deadzone</source> + <source>Oculus Rift runtime 1.4.0 -- HMD</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tracker-rift-140/lang/stub.ts b/tracker-rift-140/lang/stub.ts index d0b352bb..26ab2040 100644 --- a/tracker-rift-140/lang/stub.ts +++ b/tracker-rift-140/lang/stub.ts @@ -7,24 +7,11 @@ <source>Oculus Rift tracker settings FaceTrackNoIR</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>rift_140Dll</name> <message> - <source>Yaw spring</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Enable</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Persistence</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Constant drift</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Deadzone</source> + <source>Oculus Rift runtime 1.4.0 -- HMD</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tracker-rift-140/lang/zh_CN.ts b/tracker-rift-140/lang/zh_CN.ts index d0b352bb..ff552d19 100644 --- a/tracker-rift-140/lang/zh_CN.ts +++ b/tracker-rift-140/lang/zh_CN.ts @@ -1,30 +1,17 @@ <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> -<TS version="2.1"> +<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>Yaw spring</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Enable</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Persistence</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Constant drift</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Deadzone</source> + <source>Oculus Rift runtime 1.4.0 -- HMD</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tracker-rift-140/rift-140.cpp b/tracker-rift-140/rift-140.cpp index bf02191a..164b47f7 100644 --- a/tracker-rift-140/rift-140.cpp +++ b/tracker-rift-140/rift-140.cpp @@ -21,9 +21,7 @@ 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() { @@ -39,7 +37,10 @@ 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 status_ok(); @@ -49,13 +50,13 @@ error: 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(); - return error(strerror); + return error(error_string); } void rift_tracker_140::data(double *data) @@ -82,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_; - } 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; + 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 1a6714d5..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") {} }; @@ -27,10 +20,11 @@ public: ~rift_tracker_140() 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 otr_tr("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"); } }; |