diff options
Diffstat (limited to 'ftnoir_tracker_rift')
-rw-r--r-- | ftnoir_tracker_rift/ftnoir_rift.qrc | 7 | ||||
-rw-r--r-- | ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 473 | ||||
-rw-r--r-- | ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 181 | ||||
-rw-r--r-- | ftnoir_tracker_rift/ftnoir_tracker_rift.h | 76 | ||||
-rw-r--r-- | ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 171 | ||||
-rw-r--r-- | ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp | 19 | ||||
-rw-r--r-- | ftnoir_tracker_rift/images/medium.png | bin | 0 -> 5764 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift/images/rift_medium.png | bin | 0 -> 5764 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift/images/rift_small.png | bin | 0 -> 1212 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift/images/rift_tiny.png | bin | 0 -> 624 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift/images/small.png | bin | 0 -> 1212 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift/images/tiny.png | bin | 0 -> 624 bytes |
12 files changed, 361 insertions, 566 deletions
diff --git a/ftnoir_tracker_rift/ftnoir_rift.qrc b/ftnoir_tracker_rift/ftnoir_rift.qrc new file mode 100644 index 00000000..cd174fc4 --- /dev/null +++ b/ftnoir_tracker_rift/ftnoir_rift.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>images/rift_medium.png</file> + <file>images/rift_small.png</file> + <file>images/rift_tiny.png</file> + </qresource> +</RCC> diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index eaf5b9d6..a9168239 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -1,15 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>UIRiftControls</class> - <widget class="QWidget" name="UIHydraControls"> + <widget class="QWidget" name="UIRiftControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>411</width> - <height>142</height> + <width>209</width> + <height>288</height> </rect> </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="windowTitle"> <string>Oculus Rift tracker settings FaceTrackNoIR</string> </property> @@ -23,232 +32,260 @@ <property name="autoFillBackground"> <bool>false</bool> </property> - <layout class="QVBoxLayout" name="_vertical_layout"> - <item> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> <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>Pitch:</string> - </property> - </widget> - </item> - - <item row="0" 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="styleSheet"> - <string notr="true"/> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - - <item row="1" column="0"> - <widget class="QLabel" name="label_9"> - <property name="text"> - <string>Yaw:</string> - </property> - </widget> - </item> - - - <item row="1" 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="2" column="0"> - <widget class="QLabel" name="label_11"> - <property name="text"> - <string>Roll:</string> - </property> - </widget> - </item> - - <item row="2" 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="text"> - <string/> - </property> - </widget> - </item> - - - - - - - - - </layout> - </widget> + <property name="flat"> + <bool>false</bool> + </property> + <layout class="QFormLayout" name="formLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="label_6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Pitch:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QCheckBox" name="chkEnablePitch"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <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="0"> + <widget class="QLabel" name="label_9"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Yaw:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="chkEnableYaw"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <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="0"> + <widget class="QLabel" name="label_11"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Roll:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="chkEnableRoll"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <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> + </layout> </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> + <item row="1" column="0"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Yaw spring</string> </property> - </spacer> + <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> - <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 row="2" column="0"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> </item> </layout> </widget> - <tabstops> - <tabstop>btnOK</tabstop> - <tabstop>btnCancel</tabstop> - </tabstops> <resources/> <connections/> <slots> diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index eb05d5f9..b548db71 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -8,167 +8,84 @@ using namespace OVR; Rift_Tracker::Rift_Tracker() { - pSensor.Clear(); - pHMD.Clear(); - pManager.Clear(); - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; -#if 0 - bEnableX = true; - bEnableY = true; - bEnableZ = true; -#endif - isCalibrated = false; - should_quit = false; - for (int i = 0; i < 6; i++) - newHeadPose[i] = 0; + should_quit = false; + pManager = NULL; + pSensor = NULL; + pSFusion = NULL; + old_yaw = 0; } Rift_Tracker::~Rift_Tracker() { - pSensor.Clear(); - pHMD.Clear(); - pManager.Clear(); - System::Destroy(); + if (pSensor) + pSensor->Release(); + if (pSFusion) + delete pSFusion; + if (pManager) + pManager->Release(); + System::Destroy(); } -/* -void controller_manager_setup_callback( sixenseUtils::ControllerManager::setup_step step ) { - - QMessageBox::warning(0,"OpenTrack Info", "controller manager callback",QMessageBox::Ok,QMessageBox::NoButton); - if( sixenseUtils::getTheControllerManager()->isMenuVisible() ) { - // Ask the controller manager what the next instruction string should be. - std::string controller_manager_text_string = sixenseUtils::getTheControllerManager()->getStepString(); - QMessageBox::warning(0,"OpenTrack Info", controller_manager_text_string.c_str(),QMessageBox::Ok,QMessageBox::NoButton); - // We could also load the supplied controllermanager textures using the filename: sixenseUtils::getTheControllerManager()->getTextureFileName(); - - } -}*/ - -void Rift_Tracker::StartTracker(QFrame* videoFrame) +void Rift_Tracker::StartTracker(QFrame*) { - //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. - // System::Init(Log::ConfigureDefaultLog(LogMask_All)); - pManager = *DeviceManager::Create(); - DeviceEnumerator<HMDDevice>& enumerator = pManager->EnumerateDevices<HMDDevice>(); - if (enumerator.IsAvailable()) + pManager = DeviceManager::Create(); + if (pManager != NULL) { - pHMD = *enumerator.CreateDevice(); - - pSensor = *pHMD->GetSensor(); - - if (pSensor){ - SFusion.AttachToSensor(pSensor); + DeviceEnumerator<OVR::SensorDevice> enumerator = pManager->EnumerateDevices<OVR::SensorDevice>(); + if (enumerator.IsAvailable()) + { + pSensor = enumerator.CreateDevice(); + + if (pSensor){ + pSFusion = new OVR::SensorFusion(); + pSFusion->Reset(); + pSFusion->AttachToSensor(pSensor); + }else{ + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to create Rift sensor",QMessageBox::Ok,QMessageBox::NoButton); + } + }else{ - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to enumerate Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); } - isCalibrated = false; - MagCal.BeginAutoCalibration(SFusion); - - } + }else{ + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to start Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + } } -bool Rift_Tracker::GiveHeadPoseData(double *data) +void Rift_Tracker::GetHeadPoseData(double *data) { - if (pHMD.GetPtr() != NULL) { - - if (MagCal.IsAutoCalibrating()) - { - MagCal.UpdateAutoCalibration(SFusion); - if (MagCal.IsCalibrated()) - { - if(isCalibrated == false){ - //QMessageBox::warning(0,"OpenTrack Info", "Calibrated magnetic sensor",QMessageBox::Ok,QMessageBox::NoButton); - //fprintf(stderr,"magnetic calibration complete\n"); - isCalibrated = true; - } - //Vector3f mc = MagCal.GetMagCenter(); - //SetAdjustMessage("Magnetometer Calibration Complete\nCenter: %f %f %f",mc.x,mc.y,mc.z); - } - //SetAdjustMessage("Mag has been successfully calibrated"); - } - - Quatf hmdOrient = SFusion.GetOrientation(); - + if (pSFusion != NULL && pSensor != NULL) { + Quatf hmdOrient = pSFusion->GetOrientation(); + double newHeadPose[6]; + float yaw = 0.0f; float pitch = 0.0f; float roll = 0.0f; hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch , &roll); - newHeadPose[Yaw] = yaw; - newHeadPose[Pitch] =pitch; + newHeadPose[Pitch] = pitch; newHeadPose[Roll] = roll; - -#if 0 - - newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; - newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; - newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; - - //if (bEnableX) { - data[TX] = newHeadPose[TX]; - //} - //if (bEnableY) { - data[TY] = newHeadPose[TY]; - //} - //if (bEnableY) { - data[TZ] = newHeadPose[TZ]; - //} -#endif - if (bEnableYaw) { + newHeadPose[Yaw] = yaw; + if (s.useYawSpring) + { + newHeadPose[Yaw] = old_yaw*s.persistence + (yaw-old_yaw); + if(newHeadPose[Yaw]>s.deadzone)newHeadPose[Yaw]-= s.constant_drift; + if(newHeadPose[Yaw]<-s.deadzone)newHeadPose[Yaw]+= s.constant_drift; + old_yaw=yaw; + } + if (s.bEnableYaw) { data[Yaw] = newHeadPose[Yaw] * 57.295781f; } - if (bEnablePitch) { + if (s.bEnablePitch) { data[Pitch] = newHeadPose[Pitch] * 57.295781f; } - if (bEnableRoll) { + if (s.bEnableRoll) { data[Roll] = newHeadPose[Roll] * 57.295781f; } } - 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("opentrack"); // 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(); -#if 0 - bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); - bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); - bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); -#endif - 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 ITracker* CALLING_CONVENTION GetConstructor() { return new Rift_Tracker; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 7bacb91c..7162b7ca 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -1,80 +1,70 @@ +#pragma once #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ui_ftnoir_rift_clientcontrols.h" #include <QMessageBox> -#include <QSettings> #include <QWaitCondition> -#include <math.h> +#include <cmath> #include "facetracknoir/global-settings.h" #include "OVR.h" -#include "Util/Util_MagCalibration.h" +#include <memory> +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value<bool> bEnableYaw, bEnablePitch, bEnableRoll, useYawSpring; + value<double> constant_drift, persistence, deadzone; + settings() : + b(bundle("Rift")), + bEnableYaw(b, "EnableYaw", true), + bEnablePitch(b, "EnablePitch", true), + bEnableRoll(b, "EnableRoll", true), + useYawSpring(b, "yaw-spring", false), + constant_drift(b, "constant-drift", 0.000005), + persistence(b, "persistence", 0.99999), + deadzone(b, "deadzone", 0.02) + {} +}; + class Rift_Tracker : public ITracker { public: Rift_Tracker(); - ~Rift_Tracker(); + virtual ~Rift_Tracker() virt_override; - void StartTracker( QFrame *videoframe ); - bool GiveHeadPoseData(double *data); - void loadSettings(); + void StartTracker(QFrame *) virt_override; + void GetHeadPoseData(double *data) virt_override; + virtual int preferredHz() virt_override { return 250; } volatile bool should_quit; - void WaitForExit() {} 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; - // Magnetometer calibration and yaw correction - OVR::Util::MagCalibration MagCal; - bool isCalibrated; - - double newHeadPose[6]; // Structure with new headpose - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; -#if 0 - bool bEnableX; - bool bEnableY; - bool bEnableZ; -#endif - QMutex mutex; + OVR::DeviceManager* pManager; + OVR::SensorDevice* pSensor; + OVR::SensorFusion* pSFusion; + settings s; + double old_yaw; }; -// 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 registerTracker(ITracker *) {} void unRegisterTracker() {} private: Ui::UIRiftControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - + settings s; 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: diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 0b644723..ad532100 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -1,182 +1,35 @@ -/******************************************************************************** -* 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))); -#if 0 - 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))); -#endif - // Load the settings from the current .INI-file - loadSettings(); -} + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void TrackerControls::Initialize(QWidget *parent) { + tie_setting(s.bEnableYaw, ui.chkEnableYaw); + tie_setting(s.bEnablePitch, ui.chkEnablePitch); + tie_setting(s.bEnableRoll, ui.chkEnableRoll); - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); + 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); } -// -// OK clicked on server-dialog -// void TrackerControls::doOK() { - save(); + s.b->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(); - } + s.b->revert(); + close(); } - -// -// Load the current Settings from the currently 'active' INI-file. -// -void TrackerControls::loadSettings() { - -// qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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()); -#if 0 - ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); - ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); - ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); -#endif - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void TrackerControls::save() { - QSettings settings("opentrack"); // 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() ); -#if 0 - iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); - iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); - iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); -#endif - 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 ITrackerDialog* CALLING_CONVENTION GetDialog( ) { return new TrackerControls; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp index 775eedfc..2b24411c 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp @@ -18,31 +18,22 @@ FTNoIR_TrackerDll::~FTNoIR_TrackerDll() 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") + *icon = QIcon(":/images/rift_tiny.png"); +} extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { diff --git a/ftnoir_tracker_rift/images/medium.png b/ftnoir_tracker_rift/images/medium.png Binary files differnew file mode 100644 index 00000000..a5ba49e7 --- /dev/null +++ b/ftnoir_tracker_rift/images/medium.png diff --git a/ftnoir_tracker_rift/images/rift_medium.png b/ftnoir_tracker_rift/images/rift_medium.png Binary files differnew file mode 100644 index 00000000..a5ba49e7 --- /dev/null +++ b/ftnoir_tracker_rift/images/rift_medium.png diff --git a/ftnoir_tracker_rift/images/rift_small.png b/ftnoir_tracker_rift/images/rift_small.png Binary files differnew file mode 100644 index 00000000..3f18080c --- /dev/null +++ b/ftnoir_tracker_rift/images/rift_small.png diff --git a/ftnoir_tracker_rift/images/rift_tiny.png b/ftnoir_tracker_rift/images/rift_tiny.png Binary files differnew file mode 100644 index 00000000..76fe0f58 --- /dev/null +++ b/ftnoir_tracker_rift/images/rift_tiny.png diff --git a/ftnoir_tracker_rift/images/small.png b/ftnoir_tracker_rift/images/small.png Binary files differnew file mode 100644 index 00000000..3f18080c --- /dev/null +++ b/ftnoir_tracker_rift/images/small.png diff --git a/ftnoir_tracker_rift/images/tiny.png b/ftnoir_tracker_rift/images/tiny.png Binary files differnew file mode 100644 index 00000000..76fe0f58 --- /dev/null +++ b/ftnoir_tracker_rift/images/tiny.png |