summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_udp
diff options
context:
space:
mode:
Diffstat (limited to 'ftnoir_tracker_udp')
-rw-r--r--ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui450
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp.cpp69
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp.h41
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp40
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp29
5 files changed, 98 insertions, 531 deletions
diff --git a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui
index 5c602792..4a5624cf 100644
--- a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui
+++ b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui
@@ -1,384 +1,66 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>UICFTNClientControls</class>
- <widget class="QWidget" name="UICFTNClientControls">
- <property name="windowModality">
- <enum>Qt::NonModal</enum>
- </property>
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>411</width>
- <height>232</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>UDP tracker settings</string>
- </property>
- <property name="windowIcon">
- <iconset>
- <normaloff>../facetracknoir/images/facetracknoir.png</normaloff>../facetracknoir/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>147</width>
- <height>68</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>
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UICFTNClientControls</class>
+ <widget class="QWidget" name="UICFTNClientControls">
+ <property name="windowModality">
+ <enum>Qt::NonModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>216</width>
+ <height>71</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>UDP tracker settings</string>
+ </property>
+ <property name="windowIcon">
+ <iconset>
+ <normaloff>../facetracknoir/images/facetracknoir.png</normaloff>../facetracknoir/images/facetracknoir.png</iconset>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Port</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="spinPortNumber">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>spinPortNumber</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+ <slots>
+ <slot>startEngineClicked()</slot>
+ <slot>stopEngineClicked()</slot>
+ <slot>cameraSettingsClicked()</slot>
+ </slots>
+</ui>
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
index 02ae21f0..136e075d 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
@@ -1,37 +1,7 @@
-/********************************************************************************
-* 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"
+#include "facetracknoir/plugin-support.h"
-FTNoIR_Tracker::FTNoIR_Tracker() : should_quit(false)
-{
- should_quit = false;
-
- for (int i = 0; i < 6; i++)
- newHeadPose[i] = 0;
-}
+FTNoIR_Tracker::FTNoIR_Tracker() : last_recv_pose { 0,0,0, 0,0,0 }, should_quit(false) {}
FTNoIR_Tracker::~FTNoIR_Tracker()
{
@@ -39,45 +9,34 @@ FTNoIR_Tracker::~FTNoIR_Tracker()
wait();
}
-/** QThread run @override **/
void FTNoIR_Tracker::run() {
- forever {
+ QByteArray datagram;
+ datagram.resize(sizeof(last_recv_pose));
+ for (;;) {
if (should_quit)
break;
- while (inSocket.hasPendingDatagrams()) {
- QMutexLocker foo(&mutex);
- QByteArray datagram;
- datagram.resize(sizeof(newHeadPose));
- inSocket.readDatagram((char * ) newHeadPose, sizeof(double[6]));
+ QMutexLocker foo(&mutex);
+ while (sock.hasPendingDatagrams()) {
+ sock.readDatagram((char * ) last_recv_pose, sizeof(double[6]));
}
- usleep(10000);
- }
+ msleep(1);
+ }
}
void FTNoIR_Tracker::StartTracker(QFrame*)
{
- (void) inSocket.bind(QHostAddress::Any, (int) s.port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
+ (void) sock.bind(QHostAddress::Any, (int) s.port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
start();
}
void FTNoIR_Tracker::GetHeadPoseData(double *data)
{
QMutexLocker foo(&mutex);
- if (s.enable_x)
- data[TX] = newHeadPose[TX];
- if (s.enable_y)
- data[TY] = newHeadPose[TY];
- if (s.enable_z)
- data[TZ] = newHeadPose[TZ];
- if (s.enable_yaw)
- data[Yaw] = newHeadPose[Yaw];
- if (s.enable_pitch)
- data[Pitch] = newHeadPose[Pitch];
- if (s.enable_roll)
- data[Roll] = newHeadPose[Roll];
+ for (int i = 0; i < 6; i++)
+ data[i] = last_recv_pose[i];
}
-extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor()
+extern "C" OPENTRACK_EXPORT ITracker* GetConstructor()
{
return new FTNoIR_Tracker;
}
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h
index 62eb67df..a6f2e6d3 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h
@@ -1,58 +1,43 @@
-#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
+#pragma once
#include "ui_ftnoir_ftnclientcontrols.h"
-#include <QThread>
#include <QUdpSocket>
-#include <QMessageBox>
-#include <QMutex>
-#include <QWaitCondition>
-#include <math.h>
-#include "facetracknoir/global-settings.h"
+#include <QThread>
+#include <cmath>
+#include "facetracknoir/plugin-api.hpp"
#include "facetracknoir/options.h"
using namespace options;
struct settings {
pbundle b;
value<int> port;
- value<bool> enable_roll, enable_pitch, enable_yaw,
- enable_x, enable_y, enable_z;
settings() :
b(bundle("udp-tracker")),
- port(b, "port", 4242),
- enable_roll(b, "enable-roll", true),
- enable_pitch(b, "enable-pitch", true),
- enable_yaw(b, "enable-yaw", true),
- enable_x(b, "enable-x", true),
- enable_y(b, "enable-y", true),
- enable_z(b, "enable-y", true)
+ port(b, "port", 4242)
{}
};
-class FTNoIR_Tracker : public ITracker, public QThread
+class FTNoIR_Tracker : public ITracker, protected QThread
{
public:
FTNoIR_Tracker();
~FTNoIR_Tracker();
void StartTracker(QFrame *);
void GetHeadPoseData(double *data);
- volatile bool should_quit;
protected:
- void run(); // qthread override run method
+ void run() override;
private:
- QUdpSocket inSocket;
- QHostAddress destIP;
- QHostAddress srcIP;
- double newHeadPose[6];
+ QUdpSocket sock;
+ double last_recv_pose[6];
QMutex mutex;
settings s;
+ volatile bool should_quit;
};
-// Widget that has controls for FTNoIR protocol client-settings.
class TrackerControls: public QWidget, public ITrackerDialog
{
Q_OBJECT
public:
-
- explicit TrackerControls();
+ TrackerControls();
void registerTracker(ITracker *) {}
void unRegisterTracker() {}
private:
@@ -63,9 +48,6 @@ private slots:
void doCancel();
};
-//*******************************************************************************************************
-// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker
-//*******************************************************************************************************
class FTNoIR_TrackerDll : public Metadata
{
public:
@@ -74,4 +56,3 @@ public:
void getDescription(QString *strToBeFilled);
void getIcon(QIcon *icon);
};
-
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp
index 8d1b99f2..062b1899 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp
@@ -1,44 +1,14 @@
-/********************************************************************************
-* 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"
+#include "facetracknoir/plugin-support.h"
TrackerControls::TrackerControls() :
QWidget()
{
ui.setupUi( this );
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- tie_setting(s.enable_x, ui.chkEnableX);
- tie_setting(s.enable_y, ui.chkEnableY);
- tie_setting(s.enable_z, ui.chkEnableZ);
- tie_setting(s.enable_yaw, ui.chkEnableYaw);
- tie_setting(s.enable_pitch, ui.chkEnablePitch);
- tie_setting(s.enable_roll, ui.chkEnableRoll);
tie_setting(s.port, ui.spinPortNumber);
}
@@ -48,11 +18,11 @@ void TrackerControls::doOK() {
}
void TrackerControls::doCancel() {
- s.b->revert();
+ s.b->reload();
this->close();
}
-extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
+extern "C" OPENTRACK_EXPORT ITrackerDialog* 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 22dc7daa..7cd23552 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp
@@ -1,30 +1,5 @@
-/********************************************************************************
-* 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"
+#include "facetracknoir/plugin-support.h"
void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled)
{
@@ -46,7 +21,7 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon)
*icon = QIcon(":/images/facetracknoir.png");
}
-extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
+extern "C" OPENTRACK_EXPORT Metadata* GetMetadata()
{
return new FTNoIR_TrackerDll;
}