summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_udp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-09-14 15:34:44 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-09-14 15:34:44 +0200
commitc58c0af311892929dbce4e5437c4035214552438 (patch)
tree2a6d78d740b2a83f7fe5822068bbb006a3e8a8a9 /ftnoir_tracker_udp
parente695bca32e6f34461dfa720a2b693835adbb9422 (diff)
Run dos2unix on the tree. No user-facing changes.
Diffstat (limited to 'ftnoir_tracker_udp')
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp.cpp346
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp.h194
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp364
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp146
4 files changed, 525 insertions, 525 deletions
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
index 83f518fa..1364ee1c 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
@@ -1,173 +1,173 @@
-/********************************************************************************
-* 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_udp.h"
-#include "facetracknoir/global-settings.h"
-
-FTNoIR_Tracker::FTNoIR_Tracker()
-{
- inSocket = 0;
- outSocket = 0;
-
- bEnableRoll = true;
- bEnablePitch = true;
- bEnableYaw = true;
- bEnableX = true;
- bEnableY = true;
- bEnableZ = true;
- portAddress = 5551;
- should_quit = false;
-
- for (int i = 0; i < 6; i++)
- newHeadPose[i] = 0;
-}
-
-FTNoIR_Tracker::~FTNoIR_Tracker()
-{
- if (inSocket) {
- inSocket->close();
- delete inSocket;
- }
-
- if (outSocket) {
- outSocket->close();
- delete outSocket;
- }
-}
-
-/** QThread run @override **/
-void FTNoIR_Tracker::run() {
-
-QHostAddress sender;
-quint16 senderPort;
-
- //
- // Read the data that was received.
- //
- forever {
- if (should_quit)
- break;
- if (inSocket != 0) {
- while (inSocket->hasPendingDatagrams()) {
-
- QByteArray datagram;
- datagram.resize(inSocket->pendingDatagramSize());
- mutex.lock();
- inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort);
- mutex.unlock();
- }
- }
- else {
- break;
- }
-
- usleep(10000);
- }
-}
-
-void FTNoIR_Tracker::StartTracker(QFrame* videoFrame)
-{
- loadSettings();
- //
- // Create UDP-sockets if they don't exist already.
- // They must be created here, because they must be in the new thread (FTNoIR_Tracker::run())
- //
- if (inSocket == 0) {
- qDebug() << "FTNoIR_Tracker::Initialize() creating insocket";
- inSocket = new QUdpSocket();
- // Connect the inSocket to the port, to receive messages
-
- if (!inSocket->bind(QHostAddress::Any, (int) portAddress, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) {
- QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton);
- delete inSocket;
- inSocket = 0;
- }
- }
- start();
- return;
-}
-
-bool FTNoIR_Tracker::GiveHeadPoseData(double *data)
-{
- mutex.lock();
- if (bEnableX) {
- data[TX] = newHeadPose[TX];
- }
- if (bEnableX) {
- data[TY] = newHeadPose[TY];
- }
- if (bEnableX) {
- data[TZ] = newHeadPose[TZ];
- }
- if (bEnableYaw) {
- data[Yaw] = newHeadPose[Yaw];
- }
- if (bEnablePitch) {
- data[Pitch] = newHeadPose[Pitch];
- }
- if (bEnableRoll) {
- data[Roll] = newHeadPose[Roll];
- }
- mutex.unlock();
- return true;
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTNoIR_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 ( "FTNClient" );
- 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();
- portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt();
- 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 FTNoIR_Tracker;
-}
+/********************************************************************************
+* 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_udp.h"
+#include "facetracknoir/global-settings.h"
+
+FTNoIR_Tracker::FTNoIR_Tracker()
+{
+ inSocket = 0;
+ outSocket = 0;
+
+ bEnableRoll = true;
+ bEnablePitch = true;
+ bEnableYaw = true;
+ bEnableX = true;
+ bEnableY = true;
+ bEnableZ = true;
+ portAddress = 5551;
+ should_quit = false;
+
+ for (int i = 0; i < 6; i++)
+ newHeadPose[i] = 0;
+}
+
+FTNoIR_Tracker::~FTNoIR_Tracker()
+{
+ if (inSocket) {
+ inSocket->close();
+ delete inSocket;
+ }
+
+ if (outSocket) {
+ outSocket->close();
+ delete outSocket;
+ }
+}
+
+/** QThread run @override **/
+void FTNoIR_Tracker::run() {
+
+QHostAddress sender;
+quint16 senderPort;
+
+ //
+ // Read the data that was received.
+ //
+ forever {
+ if (should_quit)
+ break;
+ if (inSocket != 0) {
+ while (inSocket->hasPendingDatagrams()) {
+
+ QByteArray datagram;
+ datagram.resize(inSocket->pendingDatagramSize());
+ mutex.lock();
+ inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort);
+ mutex.unlock();
+ }
+ }
+ else {
+ break;
+ }
+
+ usleep(10000);
+ }
+}
+
+void FTNoIR_Tracker::StartTracker(QFrame* videoFrame)
+{
+ loadSettings();
+ //
+ // Create UDP-sockets if they don't exist already.
+ // They must be created here, because they must be in the new thread (FTNoIR_Tracker::run())
+ //
+ if (inSocket == 0) {
+ qDebug() << "FTNoIR_Tracker::Initialize() creating insocket";
+ inSocket = new QUdpSocket();
+ // Connect the inSocket to the port, to receive messages
+
+ if (!inSocket->bind(QHostAddress::Any, (int) portAddress, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton);
+ delete inSocket;
+ inSocket = 0;
+ }
+ }
+ start();
+ return;
+}
+
+bool FTNoIR_Tracker::GiveHeadPoseData(double *data)
+{
+ mutex.lock();
+ if (bEnableX) {
+ data[TX] = newHeadPose[TX];
+ }
+ if (bEnableX) {
+ data[TY] = newHeadPose[TY];
+ }
+ if (bEnableX) {
+ data[TZ] = newHeadPose[TZ];
+ }
+ if (bEnableYaw) {
+ data[Yaw] = newHeadPose[Yaw];
+ }
+ if (bEnablePitch) {
+ data[Pitch] = newHeadPose[Pitch];
+ }
+ if (bEnableRoll) {
+ data[Roll] = newHeadPose[Roll];
+ }
+ mutex.unlock();
+ return true;
+}
+
+//
+// Load the current Settings from the currently 'active' INI-file.
+//
+void FTNoIR_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 ( "FTNClient" );
+ 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();
+ portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt();
+ 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 FTNoIR_Tracker;
+}
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h
index c4c85372..76fcacf2 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h
@@ -1,97 +1,97 @@
-#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
-#include "ui_ftnoir_ftnclientcontrols.h"
-#include <QThread>
-#include <QUdpSocket>
-#include <QMessageBox>
-#include <QSettings>
-#include <QMutex>
-#include <QWaitCondition>
-#include <math.h>
-#include "facetracknoir/global-settings.h"
-
-class FTNoIR_Tracker : public ITracker, public QThread
-{
-public:
- FTNoIR_Tracker();
- ~FTNoIR_Tracker();
-
- void StartTracker( QFrame *videoframe );
- bool GiveHeadPoseData(double *data);
- void loadSettings();
- volatile bool should_quit;
- void WaitForExit() {
- should_quit = true;
- wait();
- }
-
-protected:
- void run(); // qthread override run method
-
-private:
- // UDP socket-variables
- QUdpSocket *inSocket; // Receive from ...
- QUdpSocket *outSocket; // Send to ...
- QHostAddress destIP; // Destination IP-address
- QHostAddress srcIP; // Source IP-address
-
- double newHeadPose[6]; // Structure with new headpose
-
- float portAddress; // Port-number
- 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::UICFTNClientControls 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;
-};
-
+#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
+#include "ui_ftnoir_ftnclientcontrols.h"
+#include <QThread>
+#include <QUdpSocket>
+#include <QMessageBox>
+#include <QSettings>
+#include <QMutex>
+#include <QWaitCondition>
+#include <math.h>
+#include "facetracknoir/global-settings.h"
+
+class FTNoIR_Tracker : public ITracker, public QThread
+{
+public:
+ FTNoIR_Tracker();
+ ~FTNoIR_Tracker();
+
+ void StartTracker( QFrame *videoframe );
+ bool GiveHeadPoseData(double *data);
+ void loadSettings();
+ volatile bool should_quit;
+ void WaitForExit() {
+ should_quit = true;
+ wait();
+ }
+
+protected:
+ void run(); // qthread override run method
+
+private:
+ // UDP socket-variables
+ QUdpSocket *inSocket; // Receive from ...
+ QUdpSocket *outSocket; // Send to ...
+ QHostAddress destIP; // Destination IP-address
+ QHostAddress srcIP; // Source IP-address
+
+ double newHeadPose[6]; // Structure with new headpose
+
+ float portAddress; // Port-number
+ 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::UICFTNClientControls 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_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp
index 4fe0d8c8..5c0d7b1c 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp
@@ -1,182 +1,182 @@
-/********************************************************************************
-* 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_udp.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.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
-
- 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("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 ( "FTNClient" );
- 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());
-
- ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() );
- 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 ( "FTNClient" );
- 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.setValue ( "PortNumber", ui.spinPortNumber->value() );
- 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;
-}
+/********************************************************************************
+* 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_udp.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.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
+
+ 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("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 ( "FTNClient" );
+ 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());
+
+ ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() );
+ 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 ( "FTNClient" );
+ 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.setValue ( "PortNumber", ui.spinPortNumber->value() );
+ 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_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp
index d4afb410..dcdbe487 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp
@@ -1,73 +1,73 @@
-/********************************************************************************
-* 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 *
-* *
-* 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_udp.h"
-#include <QDebug>
-#include "facetracknoir/global-settings.h"
-
-FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
- //populate the description strings
- trackerFullName = "FaceTrackNoIR UDP";
- trackerShortName = "UDP";
- trackerDescription = "FaceTrackNoIR UDP";
-}
-
-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")
-
-extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
-{
- return new FTNoIR_TrackerDll;
-}
+/********************************************************************************
+* 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 *
+* *
+* 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_udp.h"
+#include <QDebug>
+#include "facetracknoir/global-settings.h"
+
+FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
+ //populate the description strings
+ trackerFullName = "FaceTrackNoIR UDP";
+ trackerShortName = "UDP";
+ trackerDescription = "FaceTrackNoIR UDP";
+}
+
+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")
+
+extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
+{
+ return new FTNoIR_TrackerDll;
+}