summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_hydra
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-01-03 11:22:06 +0100
committerStanislaw Halik <sthalik@misaki.pl>2014-01-03 11:22:06 +0100
commita3df0c8a8d19655040c7d21812414d7a335def61 (patch)
tree6739401d8e59800731b2faf26e49b8df63664573 /ftnoir_tracker_hydra
parent7307adbc3b8ec2213bc90a91deb1beb9198e7ff2 (diff)
parent519434cd1abb8991635487c6d84bc0d85367fc42 (diff)
Merge branch 'feature/settings-template'
Conflicts: README.md
Diffstat (limited to 'ftnoir_tracker_hydra')
-rw-r--r--ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp95
-rw-r--r--ftnoir_tracker_hydra/ftnoir_tracker_hydra.h59
-rw-r--r--ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp186
-rw-r--r--ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp18
4 files changed, 61 insertions, 297 deletions
diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
index 31e3f319..70af2893 100644
--- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
+++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
@@ -9,22 +9,9 @@
#endif
#include <sixense.h>
#include <sixense_math.hpp>
-#if 0
-#include <sixense_utils/derivatives.hpp>
-#include <sixense_utils/button_states.hpp>
-#include <sixense_utils/event_triggers.hpp>
-#include <sixense_utils/controller_manager/controller_manager.hpp>
-#endif
-Hydra_Tracker::Hydra_Tracker()
+Hydra_Tracker::Hydra_Tracker() : should_quit(false)
{
- 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;
}
@@ -35,48 +22,18 @@ Hydra_Tracker::~Hydra_Tracker()
sixenseExit();
}
-/*
-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 Hydra_Tracker::StartTracker(QFrame*)
{
- //QMessageBox::warning(0,"FaceTrackNoIR Notification", "Tracking loading settings...",QMessageBox::Ok,QMessageBox::NoButton);
- loadSettings();
-
- // Init sixense
- //QMessageBox::warning(0,"OpenTrack Info", "sixense init",QMessageBox::Ok,QMessageBox::NoButton);
sixenseInit();
- //QMessageBox::warning(0,"OpenTrack Info", "sixense init complete, setting controller manager",QMessageBox::Ok,QMessageBox::NoButton);
- // Init the controller manager. This makes sure the controllers are present, assigned to left and right hands, and that
- // the hemisphere calibration is complete.
- //sixenseUtils::getTheControllerManager()->setGameType( sixenseUtils::ControllerManager::ONE_PLAYER_TWO_CONTROLLER );
- //sixenseUtils::getTheControllerManager()->registerSetupCallback( controller_manager_setup_callback );
- //QMessageBox::warning(0,"OpenTrack Info", "controller manager callback registered",QMessageBox::Ok,QMessageBox::NoButton);
- return;
}
-
void Hydra_Tracker::GetHeadPoseData(double *data)
{
sixenseSetActiveBase(0);
sixenseAllControllerData acd;
sixenseGetAllNewestData( &acd );
- //sixenseUtils::getTheControllerManager()->update( &acd );
-
- //sixenseControllerData cd;
- //Rotation quat = Rotation(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]);
- sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat);// sixenseMath::Quat(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]);
+ sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat);
float ypr[3];
@@ -90,62 +47,26 @@ void Hydra_Tracker::GetHeadPoseData(double *data)
newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f;
newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f;
- if (bEnableX) {
+ if (s.bEnableX) {
data[TX] = newHeadPose[TX];
}
- if (bEnableY) {
+ if (s.bEnableY) {
data[TY] = newHeadPose[TY];
}
- if (bEnableY) {
+ if (s.bEnableY) {
data[TZ] = newHeadPose[TZ];
}
-
- if (bEnableYaw) {
+ 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;
}
}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void Hydra_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 ( "Hydra" );
- 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 ITracker* CALLING_CONVENTION GetConstructor()
{
return new Hydra_Tracker;
diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h
index 240f0687..05a8b076 100644
--- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h
+++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h
@@ -1,86 +1,65 @@
#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
#include "ui_ftnoir_hydra_clientcontrols.h"
#include <QMessageBox>
-#include <QSettings>
#include <QWaitCondition>
#include <math.h>
#include "facetracknoir/global-settings.h"
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<bool> bEnableRoll, bEnablePitch, bEnableYaw, bEnableX, bEnableY, bEnableZ;
+ settings() :
+ b(bundle("tracker-hydra")),
+ bEnableRoll(b, "enable-rz", true),
+ bEnablePitch(b, "enable-ry", true),
+ bEnableYaw(b, "enable-rx", true),
+ bEnableX(b, "enable-tx", true),
+ bEnableY(b, "enable-ty", true),
+ bEnableZ(b, "enable-tz", true)
+ {}
+};
+
class Hydra_Tracker : public ITracker
{
public:
Hydra_Tracker();
~Hydra_Tracker();
-
void StartTracker(QFrame *) virt_override;
void GetHeadPoseData(double *data) virt_override;
- void loadSettings();
volatile bool should_quit;
protected:
void run(); // qthread override run method
-
private:
+ settings s;
bool isCalibrated;
-
double newHeadPose[6]; // Structure with new headpose
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
-
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
-
QMutex mutex;
-
virtual int preferredHz() virt_override { return 250; }
};
-// Widget that has controls for FTNoIR protocol client-settings.
class TrackerControls: public QWidget, public ITrackerDialog
{
Q_OBJECT
public:
-
explicit TrackerControls();
- ~TrackerControls();
- void showEvent (QShowEvent *);
-
- void Initialize(QWidget *parent);
void registerTracker(ITracker *) {}
void unRegisterTracker() {}
-
private:
+ settings s;
Ui::UIHydraControls 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 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_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp
index fa674662..4a2deb9f 100644
--- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp
+++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp
@@ -1,37 +1,6 @@
-/********************************************************************************
-* 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_hydra.h"
#include "facetracknoir/global-settings.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
TrackerControls::TrackerControls() :
QWidget()
{
@@ -41,139 +10,46 @@ QWidget()
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), 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();
-}
-
-//
-// Destructor for server-dialog
-//
-TrackerControls::~TrackerControls() {
- qDebug() << "~TrackerControls() says: started";
+ tie_setting(s.bEnableYaw, ui.chkEnableYaw);
+ tie_setting(s.bEnablePitch, ui.chkEnablePitch);
+ tie_setting(s.bEnableRoll, ui.chkEnableRoll);
+ tie_setting(s.bEnableX, ui.chkEnableX);
+ tie_setting(s.bEnableY, ui.chkEnableY);
+ tie_setting(s.bEnableZ, ui.chkEnableZ);
}
-//
-// 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();
+ s.b->save();
this->close();
}
-// override show event
-void TrackerControls::showEvent ( QShowEvent * ) {
- 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();
- }
+ if (!s.b->modifiedp())
+ {
+ close();
+ return;
+ }
+ int ret = QMessageBox::question (this,
+ "Settings have changed",
+ "Do you want to save the settings?",
+ QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+
+ switch (ret) {
+ case QMessageBox::Save:
+ s.b->save();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ s.b->revert();
+ this->close();
+ break;
+ default:
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ }
}
-
-//
-// 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 ( "Hydra" );
- 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("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 ( "Hydra" );
- 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 ITrackerDialog* CALLING_CONVENTION GetDialog( )
{
return new TrackerControls;
diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp
index db6f658c..a2cc7c01 100644
--- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp
+++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp
@@ -3,31 +3,19 @@
#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
- //populate the description strings
- trackerFullName = "Hydra";
- trackerShortName = "Hydra";
- trackerDescription = "Hydra";
-}
-
-FTNoIR_TrackerDll::~FTNoIR_TrackerDll()
-{
-
-}
-
void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled)
{
- *strToBeFilled = trackerFullName;
+ *strToBeFilled = "Hydra";
}
void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled)
{
- *strToBeFilled = trackerShortName;
+ *strToBeFilled = "Hydra";
}
void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled)
{
- *strToBeFilled = trackerDescription;
+ *strToBeFilled = "Hydra";
}
void FTNoIR_TrackerDll::getIcon(QIcon *icon)