summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-04-02 18:41:01 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-04-02 18:41:01 +0200
commit8303597a865400a363ae574ccde819302495f498 (patch)
treec83b383b3ec818f610cc6137f2b72ee7b4173b09 /ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp
parent8adf6b1650af6027f28db12ca2b4de92a3fac11d (diff)
Just put everything new in. Conflict resolution will be later
Diffstat (limited to 'ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp')
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp80
1 files changed, 10 insertions, 70 deletions
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;
}