summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_protocol_ftn
diff options
context:
space:
mode:
Diffstat (limited to 'ftnoir_protocol_ftn')
-rw-r--r--ftnoir_protocol_ftn/ftnoir_ftncontrols.ui2
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp80
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn.h40
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp9
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp5
-rw-r--r--ftnoir_protocol_ftn/images/facetracknoir.icobin0 -> 23558 bytes
6 files changed, 32 insertions, 104 deletions
diff --git a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui
index 56983fbe..d8efec61 100644
--- a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui
+++ b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui
@@ -15,7 +15,7 @@
</property>
<property name="windowIcon">
<iconset>
- <normaloff>images/FaceTrackNoIR.ico</normaloff>images/FaceTrackNoIR.ico</iconset>
+ <normaloff>images/FaceTrackNoIR.png</normaloff>images/facetracknoir.png</iconset>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp
index cfb6c618..26f331b3 100644
--- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp
+++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp
@@ -33,36 +33,27 @@
*/
#include "ftnoir_protocol_ftn.h"
#include <QFile>
+#include "facetracknoir/global-settings.h"
/** constructor **/
FTNoIR_Protocol::FTNoIR_Protocol()
{
loadSettings();
+ outSocket = 0;
}
/** destructor **/
FTNoIR_Protocol::~FTNoIR_Protocol()
{
- if (inSocket != 0) {
- inSocket->close();
- delete inSocket;
- }
-
if (outSocket != 0) {
outSocket->close();
delete outSocket;
}
}
-/** helper to Auto-destruct **/
-void FTNoIR_Protocol::Release()
-{
- delete this;
-}
-
void FTNoIR_Protocol::Initialize()
{
- return;
+ loadSettings();
}
//
@@ -88,15 +79,13 @@ void FTNoIR_Protocol::loadSettings() {
//
void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) {
int no_bytes;
-QHostAddress sender;
-quint16 senderPort;
+THeadPoseData TestData;
//
// Copy the Raw measurements directly to the client.
//
- frame_counter += 1;
TestData = *headpose;
- TestData.frame_number = frame_counter;
+ TestData.frame_number = 0;
//
// Try to send an UDP-message to the receiver
@@ -112,63 +101,14 @@ quint16 senderPort;
qDebug() << "FTNServer::writePendingDatagrams says: nothing sent!";
}
}
-
- //
- // Receiver may send data, so we must read that here.
- //
- if (inSocket != 0) {
- while (inSocket->hasPendingDatagrams()) {
-
- QByteArray datagram;
- datagram.resize(inSocket->pendingDatagramSize());
-
- inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort);
-
- fg_cmd = cmd; // Let's just accept that command for now...
- if ( cmd > 0 ) {
- qDebug() << "FTNServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd;
-// headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle
- }
- }
- }
}
//
// Check if the Client DLL exists and load it (to test it), if so.
// Returns 'true' if all seems OK.
//
-bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle )
+bool FTNoIR_Protocol::checkServerInstallationOK()
{
- // Init. the data
- TestData.x = 0.0f;
- TestData.y = 0.0f;
- TestData.z = 0.0f;
- TestData.yaw = 0.0f;
- TestData.pitch = 0.0f;
- TestData.roll = 0.0f;
- fg_cmd = 1;
-
- inSocket = 0;
- outSocket = 0;
-
- frame_counter = 0;
-
- //
- // Create UDP-sockets.
- //
- if (inSocket == 0) {
- qDebug() << "FGServer::sendHeadposeToGame creating insocket";
- inSocket = new QUdpSocket();
-
- // Connect the inSocket to the port, to receive messages
- if (!inSocket->bind(QHostAddress::Any, destPort+1, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) {
- QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton);
- delete inSocket;
- inSocket = 0;
- return false;
- }
- }
-
if (outSocket == 0) {
outSocket = new QUdpSocket();
}
@@ -181,7 +121,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle )
//
void FTNoIR_Protocol::getNameFromGame( char *dest )
{
- sprintf_s(dest, 99, "FaceTrackNoIR");
+ sprintf(dest, "FaceTrackNoIR UDP");
return;
}
@@ -192,9 +132,9 @@ void FTNoIR_Protocol::getNameFromGame( char *dest )
// GetProtocol - Undecorated name, which can be easily used with GetProcAddress
// Win32 API function.
// _GetProtocol@0 - Common name decoration for __stdcall functions in C language.
-#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
+//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
-FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol()
+extern "C" FTNOIR_PROTOCOL_BASE_EXPORT void* CALLING_CONVENTION GetConstructor()
{
- return new FTNoIR_Protocol;
+ return (IProtocol*) new FTNoIR_Protocol;
}
diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h
index 24f760c5..7dca6842 100644
--- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h
+++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h
@@ -29,15 +29,15 @@
#ifndef INCLUDED_FTNSERVER_H
#define INCLUDED_FTNSERVER_H
-#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h"
-#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h"
-#include "ui_FTNoIR_FTNcontrols.h"
+#include "ftnoir_protocol_base/ftnoir_protocol_base.h"
+#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
+#include "ui_ftnoir_ftncontrols.h"
#include <QThread>
#include <QUdpSocket>
#include <QMessageBox>
#include <QSettings>
-#include "Windows.h"
-#include "math.h"
+#include <math.h>
+#include "facetracknoir/global-settings.h"
class FTNoIR_Protocol : public IProtocol
{
@@ -45,24 +45,17 @@ public:
FTNoIR_Protocol();
~FTNoIR_Protocol();
- void Release();
void Initialize();
- bool checkServerInstallationOK( HANDLE handle );
+ bool checkServerInstallationOK();
void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose );
void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars...
private:
- THeadPoseData TestData;
- long frame_counter;
- QUdpSocket *inSocket; // Receive from FaceTrackNoIR
QUdpSocket *outSocket; // Send to FaceTrackNoIR
- qint32 cmd;
- qint32 fg_cmd; // Command from FlightGear
QHostAddress destIP; // Destination IP-address
int destPort; // Destination port-number
void loadSettings();
-
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -77,12 +70,8 @@ public:
void Release(); // Member functions which are accessible from outside the DLL
void Initialize(QWidget *parent);
- void registerProtocol(IProtocol *protocol) {
- theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- };
- void unRegisterProtocol() {
- theProtocol = NULL; // Reset the pointer
- };
+ void registerProtocol(IProtocol *protocol) {}
+ void unRegisterProtocol() {}
private:
Ui::UICFTNControls ui;
@@ -91,28 +80,27 @@ private:
/** helper **/
bool settingsDirty;
- FTNoIR_Protocol *theProtocol;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; };
+ void settingChanged() { settingsDirty = true; }
};
//*******************************************************************************************************
// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol
//*******************************************************************************************************
-class FTNoIR_ProtocolDll : public IProtocolDll
+class FTNoIR_ProtocolDll : public Metadata
{
public:
FTNoIR_ProtocolDll();
~FTNoIR_ProtocolDll();
- void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR"); };
- void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTN Client"); };
- void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR Client protocol"); };
+ void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR"); }
+ void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTN Client"); }
+ void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR Client protocol"); }
- void getIcon(QIcon *icon) { *icon = QIcon(":/images/FaceTrackNoIR.ico"); };
+ void getIcon(QIcon *icon) { *icon = QIcon(":/images/facetracknoir.png"); }
};
#endif//INCLUDED_FTNSERVER_H
diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp
index 58dbfbad..24ccc8b9 100644
--- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp
+++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp
@@ -32,6 +32,7 @@
*/
#include "ftnoir_protocol_ftn.h"
#include <QDebug>
+#include "facetracknoir/global-settings.h"
//*******************************************************************************************************
// FaceTrackNoIR Client Settings-dialog.
@@ -59,8 +60,6 @@ QWidget()
connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
- theProtocol = NULL;
-
// Load the settings from the current .INI-file
loadSettings();
}
@@ -186,9 +185,9 @@ void FTNControls::save() {
// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress
// Win32 API function.
// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language.
-#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0")
+//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0")
-FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( )
+extern "C" FTNOIR_PROTOCOL_BASE_EXPORT void* CALLING_CONVENTION GetDialog( )
{
- return new FTNControls;
+ return (IProtocolDialog*) new FTNControls;
}
diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp
index 00badedf..61f06914 100644
--- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp
+++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp
@@ -32,6 +32,7 @@
*/
#include "ftnoir_protocol_ftn.h"
#include <QDebug>
+#include "facetracknoir/global-settings.h"
FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() {
}
@@ -48,9 +49,9 @@ FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()
// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress
// Win32 API function.
// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language.
-#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0")
+//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0")
-FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll()
+extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_ProtocolDll;
}
diff --git a/ftnoir_protocol_ftn/images/facetracknoir.ico b/ftnoir_protocol_ftn/images/facetracknoir.ico
new file mode 100644
index 00000000..5115066c
--- /dev/null
+++ b/ftnoir_protocol_ftn/images/facetracknoir.ico
Binary files differ