summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-04-27 04:12:54 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-04-27 04:12:54 +0200
commitc557231b34a5c536a3fcb4f4a21c47d06b3a1ade (patch)
treea1e02e21e4dc693c2f0f36e998a5fa9f80bfa7b2
parent5ac90e772c62b7bef43ebd1bb1b2000626be1236 (diff)
Rift: from mm0zct with fixes
-rw-r--r--CMakeLists.txt31
-rw-r--r--facetracknoir/facetracknoir.ui2
-rw-r--r--ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui381
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.cpp137
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.h91
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp179
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp55
7 files changed, 875 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ea116ec..4f10b370 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,7 @@ endif()
IF(WIN32)
SET(SDK_SM_FACEAPI_PATH "" CACHE PATH "SeeingMachines FaceAPI SDK path")
+ SET(SDK_RIFT "" CACHE PATH "libOVR path")
ENDIF()
file(GLOB ftnoir-faceapi-wrapper-c "faceapi/*.cpp")
@@ -245,6 +246,14 @@ if(NOT SDK_FACEAPI_ONLY)
file(GLOB ftnoir-tracker-hillcrest-rc "ftnoir_tracker_hillcrest/*.qrc")
QT4_WRAP_UI(ftnoir-tracker-hillcrest-uih ${ftnoir-tracker-hillcrest-ui})
QT4_ADD_RESOURCES(ftnoir-tracker-hillcrest-rcc ${ftnoir-tracker-hillcrest-rc})
+
+ file(GLOB ftnoir-tracker-rift-c "ftnoir_tracker_rift/*.cpp")
+ file(GLOB ftnoir-tracker-rift-h "ftnoir_tracker_rift/*.h")
+ QT4_WRAP_CPP(ftnoir-tracker-rift-moc ${ftnoir-tracker-rift-h})
+ file(GLOB ftnoir-tracker-rift-ui "ftnoir_tracker_rift/*.ui")
+ file(GLOB ftnoir-tracker-rift-rc "ftnoir_tracker_rift/*.qrc")
+ QT4_WRAP_UI(ftnoir-tracker-rift-uih ${ftnoir-tracker-rift-ui})
+ QT4_ADD_RESOURCES(ftnoir-tracker-rift-rcc ${ftnoir-tracker-rift-rc})
file(GLOB ftnoir-tracker-faceapi-c "ftnoir_tracker_sm/*.cpp")
file(GLOB ftnoir-tracker-faceapi-h "ftnoir_tracker_sm/*.h")
@@ -427,6 +436,19 @@ endif()
SET_TARGET_PROPERTIES(ftnoir-tracker-udp
PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt")
endif()
+
+ if(SDK_RIFT)
+ include_directories("${SDK_RIFT}/include")
+ add_library(ftnoir-tracker-rift SHARED ${ftnoir-tracker-rift-c} ${ftnoir-tracker-rift-moc} ${ftnoir-tracker-rift-uih} ${ftnoir-tracker-rift-rcc})
+ target_link_libraries(ftnoir-tracker-rift ${MY_QT_LIBS})
+ if(WIN32)
+ target_link_libraries(ftnoir-tracker-rift "${SDK_RIFT}/lib/win32/libovr.lib" winmm.lib)
+ endif()
+ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
+ SET_TARGET_PROPERTIES(ftnoir-tracker-rift
+ PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt")
+ endif()
+ endif()
if(SDK_HILLCREST)
include_directories("${SDK_HILLCREST}/include")
@@ -537,6 +559,15 @@ if(NOT SDK_FACEAPI_ONLY)
NAMELINK_SKIP
)
endif()
+
+ if(SDK_RIFT)
+ install(
+ TARGETS ftnoir-tracker-rift
+ RUNTIME DESTINATION .
+ LIBRARY DESTINATION .
+ NAMELINK_SKIP
+ )
+ endif()
if(WIN32)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui
index 74245cf9..119ea4e2 100644
--- a/facetracknoir/facetracknoir.ui
+++ b/facetracknoir/facetracknoir.ui
@@ -489,7 +489,7 @@ QGroupBox {
<number>-1</number>
</property>
<property name="maxVisibleItems">
- <number>5</number>
+ <number>42</number>
</property>
</widget>
<widget class="QPushButton" name="btnShowEngineControls">
diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui
new file mode 100644
index 00000000..8bef36a7
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui
@@ -0,0 +1,381 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UIRiftControls</class>
+ <widget class="QWidget" name="UIRiftControls">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>411</width>
+ <height>210</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Oculus Rift tracker settings FaceTrackNoIR</string>
+ </property>
+ <property name="windowIcon">
+ <iconset>
+ <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <layout class="QVBoxLayout" name="_vertical_layout">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Port-number</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="spinPortNumber">
+ <property name="minimum">
+ <number>5550</number>
+ </property>
+ <property name="maximum">
+ <number>10000</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>85</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Enable Axis</string>
+ </property>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>143</width>
+ <height>60</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Roll:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>Pitch:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>Yaw:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="chkEnableRoll">
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="chkEnablePitch">
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="chkEnableYaw">
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="label_14">
+ <property name="text">
+ <string>X:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QCheckBox" name="chkEnableX">
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLabel" name="label_15">
+ <property name="text">
+ <string>Y:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QCheckBox" name="chkEnableY">
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QLabel" name="label_16">
+ <property name="text">
+ <string>Z:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="QCheckBox" name="chkEnableZ">
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Enter the port-number for the remote PC.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Remember: you may have to change firewall-settings too!</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <item>
+ <widget class="QPushButton" name="btnOK">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnCancel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>10</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>spinPortNumber</tabstop>
+ <tabstop>btnOK</tabstop>
+ <tabstop>btnCancel</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+ <slots>
+ <slot>startEngineClicked()</slot>
+ <slot>stopEngineClicked()</slot>
+ <slot>cameraSettingsClicked()</slot>
+ </slots>
+</ui>
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
new file mode 100644
index 00000000..ca290d0b
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
@@ -0,0 +1,137 @@
+/* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */
+#include "ftnoir_tracker_rift.h"
+#include "facetracknoir/global-settings.h"
+ #include "OVR.h"
+#include <cstdio>
+using namespace OVR;
+
+bool Rift_Tracker::isInitialised = false;
+
+Rift_Tracker::Rift_Tracker()
+{
+ pSensor.Clear();
+ pHMD.Clear();
+ pManager.Clear();
+ bEnableRoll = true;
+ bEnablePitch = true;
+ bEnableYaw = true;
+ bEnableX = true;
+ bEnableY = true;
+ bEnableZ = true;
+ should_quit = false;
+ for (int i = 0; i < 6; i++)
+ newHeadPose[i] = 0;
+}
+
+Rift_Tracker::~Rift_Tracker()
+{
+ pSensor.Clear();
+ pHMD.Clear();
+ pManager.Clear();
+}
+
+
+void Rift_Tracker::StartTracker(QFrame* videoFrame)
+{
+ //QMessageBox::warning(0,"FaceTrackNoIR Notification", "Tracking loading settings...",QMessageBox::Ok,QMessageBox::NoButton);
+ loadSettings();
+ //
+ // Startup the Oculus SDK device handling, use the first Rift sensor we find.
+ //
+ if(!isInitialised){
+ System::Init(Log::ConfigureDefaultLog(LogMask_All));
+ isInitialised = true;
+ }
+
+ pManager = *DeviceManager::Create();
+ DeviceEnumerator<HMDDevice>& enumerator = pManager->EnumerateDevices<HMDDevice>();
+ if (enumerator.IsAvailable())
+ {
+ pHMD = *enumerator.CreateDevice();
+
+ pSensor = *pHMD->GetSensor();
+
+ if (pSensor){
+ SFusion.AttachToSensor(pSensor);
+ }else{
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton);
+ }
+ SFusion.SetYawCorrectionEnabled(true);
+ SFusion.SetMagReference();
+ }
+
+ return;
+}
+
+bool Rift_Tracker::GiveHeadPoseData(double *data)
+{
+ if (pHMD.GetPtr() != NULL) {
+ Quatf hmdOrient = SFusion.GetOrientation();
+ float yaw = 0.0f;
+ float pitch = 0.0f;
+ float roll = 0.0f;
+ hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch , &roll);
+ newHeadPose[RY] =pitch;
+ newHeadPose[RZ] = roll;
+ newHeadPose[RX] = yaw;
+
+ if (bEnableX) {
+ data[TX] = newHeadPose[TX];
+ }
+ if (bEnableX) {
+ data[TY] = newHeadPose[TY];
+ }
+ if (bEnableX) {
+ data[TZ] = newHeadPose[TZ];
+ }
+ if (bEnableYaw) {
+ data[RX] = newHeadPose[RX];
+ }
+ if (bEnablePitch) {
+ data[RY] = newHeadPose[RY];
+ }
+ if (bEnableRoll) {
+ data[RZ] = newHeadPose[RZ];
+ }
+ }
+ return pHMD.GetPtr() != NULL;
+}
+
+
+//
+// Load the current Settings from the currently 'active' INI-file.
+//
+void Rift_Tracker::loadSettings() {
+
+ qDebug() << "FTNoIR_Tracker::loadSettings says: Starting ";
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+
+ qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile;
+
+ iniFile.beginGroup ( "Rift" );
+ bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool();
+ bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool();
+ bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool();
+ bEnableX = iniFile.value ( "EnableX", 1 ).toBool();
+ bEnableY = iniFile.value ( "EnableY", 1 ).toBool();
+ bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool();
+ iniFile.endGroup ();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Factory function that creates instances if the Tracker object.
+
+// Export both decorated and undecorated names.
+// GetTracker - Undecorated name, which can be easily used with GetProcAddress
+// Win32 API function.
+// _GetTracker@0 - Common name decoration for __stdcall functions in C language.
+//#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
+
+extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetConstructor()
+{
+ return (ITracker*) new Rift_Tracker;
+}
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h
new file mode 100644
index 00000000..b73f8b36
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h
@@ -0,0 +1,91 @@
+#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
+#include "ui_ftnoir_rift_clientcontrols.h"
+#include <QMessageBox>
+#include <QSettings>
+#include <QWaitCondition>
+#include <math.h>
+#include "facetracknoir/global-settings.h"
+#include "OVR.h"
+class Rift_Tracker : public ITracker
+{
+public:
+ Rift_Tracker();
+ ~Rift_Tracker();
+
+ void StartTracker( QFrame *videoframe );
+ bool GiveHeadPoseData(double *data);
+ void loadSettings();
+ volatile bool should_quit;
+ void WaitForExit() {
+ return;
+ }
+protected:
+ void run(); // qthread override run method
+
+private:
+ static bool isInitialised;
+ OVR::Ptr<OVR::DeviceManager> pManager;
+ OVR::Ptr<OVR::HMDDevice> pHMD;
+ OVR::Ptr<OVR::SensorDevice> pSensor;
+ OVR::SensorFusion SFusion;
+ double newHeadPose[6]; // Structure with new headpose
+ bool bEnableRoll;
+ bool bEnablePitch;
+ bool bEnableYaw;
+ bool bEnableX;
+ bool bEnableY;
+ bool bEnableZ;
+ QMutex mutex;
+};
+
+// Widget that has controls for FTNoIR protocol client-settings.
+class TrackerControls: public QWidget, public ITrackerDialog
+{
+ Q_OBJECT
+public:
+
+ explicit TrackerControls();
+ ~TrackerControls();
+ void showEvent ( QShowEvent * event );
+
+ void Initialize(QWidget *parent);
+ void registerTracker(ITracker *tracker) {};
+ void unRegisterTracker() {};
+
+private:
+ Ui::UIRiftControls ui;
+ void loadSettings();
+ void save();
+
+ /** helper **/
+ bool settingsDirty;
+
+private slots:
+ void doOK();
+ void doCancel();
+ void settingChanged() { settingsDirty = true; };
+ void settingChanged(int) { settingsDirty = true; };
+};
+
+//*******************************************************************************************************
+// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker
+//*******************************************************************************************************
+class FTNoIR_TrackerDll : public Metadata
+{
+public:
+ FTNoIR_TrackerDll();
+ ~FTNoIR_TrackerDll();
+
+ void Initialize();
+
+ void getFullName(QString *strToBeFilled);
+ void getShortName(QString *strToBeFilled);
+ void getDescription(QString *strToBeFilled);
+ void getIcon(QIcon *icon);
+
+private:
+ QString trackerFullName; // Trackers' name and description
+ QString trackerShortName;
+ QString trackerDescription;
+};
+
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp
new file mode 100644
index 00000000..e724e438
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp
@@ -0,0 +1,179 @@
+/********************************************************************************
+* FaceTrackNoIR This program is a private project of some enthusiastic *
+* gamers from Holland, who don't like to pay much for *
+* head-tracking. *
+* *
+* Copyright (C) 2012 Wim Vriend (Developing) *
+* Ron Hendriks (Researching and Testing) *
+* *
+* Homepage: http://facetracknoir.sourceforge.net/home/default.htm *
+* *
+* This program is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU General Public License as published by the *
+* Free Software Foundation; either version 3 of the License, or (at your *
+* option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but *
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
+* more details. *
+* *
+* You should have received a copy of the GNU General Public License along *
+* with this program; if not, see <http://www.gnu.org/licenses/>. *
+* *
+********************************************************************************/
+#include "ftnoir_tracker_rift.h"
+#include "facetracknoir/global-settings.h"
+
+//*******************************************************************************************************
+// FaceTrackNoIR Client Settings-dialog.
+//*******************************************************************************************************
+
+//
+// Constructor for server-settings-dialog
+//
+TrackerControls::TrackerControls() :
+QWidget()
+{
+ ui.setupUi( this );
+
+ // Connect Qt signals to member-functions
+ connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
+ connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
+
+ connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
+ connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
+ connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
+ connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
+ connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
+ connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
+
+ // Load the settings from the current .INI-file
+ loadSettings();
+}
+
+//
+// Destructor for server-dialog
+//
+TrackerControls::~TrackerControls() {
+ qDebug() << "~TrackerControls() says: started";
+}
+
+//
+// Initialize tracker-client-dialog
+//
+void TrackerControls::Initialize(QWidget *parent) {
+
+ QPoint offsetpos(100, 100);
+ if (parent) {
+ this->move(parent->pos() + offsetpos);
+ }
+ show();
+}
+
+//
+// OK clicked on server-dialog
+//
+void TrackerControls::doOK() {
+ save();
+ this->close();
+}
+
+// override show event
+void TrackerControls::showEvent ( QShowEvent * event ) {
+ loadSettings();
+}
+
+//
+// Cancel clicked on server-dialog
+//
+void TrackerControls::doCancel() {
+ //
+ // Ask if changed Settings should be saved
+ //
+ if (settingsDirty) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
+
+ qDebug() << "doCancel says: answer =" << ret;
+
+ switch (ret) {
+ case QMessageBox::Save:
+ save();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ this->close();
+ break;
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ default:
+ // should never be reached
+ break;
+ }
+ }
+ else {
+ this->close();
+ }
+}
+
+
+//
+// Load the current Settings from the currently 'active' INI-file.
+//
+void TrackerControls::loadSettings() {
+
+// qDebug() << "loadSettings says: Starting ";
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+
+// qDebug() << "loadSettings says: iniFile = " << currentFile;
+
+ iniFile.beginGroup ( "Rift" );
+ ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool());
+ ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool());
+ ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool());
+ ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool());
+ ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool());
+ ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool());
+
+ iniFile.endGroup ();
+
+ settingsDirty = false;
+}
+
+//
+// Save the current Settings to the currently 'active' INI-file.
+//
+void TrackerControls::save() {
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+
+ iniFile.beginGroup ( "Rift" );
+ iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() );
+ iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() );
+ iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() );
+ iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() );
+ iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() );
+ iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() );
+ iniFile.endGroup ();
+
+ settingsDirty = false;
+}
+////////////////////////////////////////////////////////////////////////////////
+// Factory function that creates instances if the Tracker-settings dialog object.
+
+// Export both decorated and undecorated names.
+// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
+// Win32 API function.
+// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
+//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
+
+extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetDialog( )
+{
+ return (ITrackerDialog*) new TrackerControls;
+}
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp
new file mode 100644
index 00000000..ccf9225f
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp
@@ -0,0 +1,55 @@
+/* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */
+#include "ftnoir_tracker_rift.h"
+#include <QDebug>
+#include "facetracknoir/global-settings.h"
+
+FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
+ //populate the description strings
+ trackerFullName = "Rift";
+ trackerShortName = "Rift";
+ trackerDescription = "Rift";
+}
+
+FTNoIR_TrackerDll::~FTNoIR_TrackerDll()
+{
+
+}
+
+void FTNoIR_TrackerDll::Initialize()
+{
+ return;
+}
+
+void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerFullName;
+};
+
+void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerShortName;
+};
+
+void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerDescription;
+};
+
+void FTNoIR_TrackerDll::getIcon(QIcon *icon)
+{
+ *icon = QIcon(":/images/facetracknoir.png");
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Factory function that creates instances if the Tracker object.
+
+// Export both decorated and undecorated names.
+// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress
+// Win32 API function.
+// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language.
+//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0")
+
+extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
+{
+ return new FTNoIR_TrackerDll;
+}