summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_protocol_ft
diff options
context:
space:
mode:
Diffstat (limited to 'ftnoir_protocol_ft')
-rw-r--r--ftnoir_protocol_ft/ftnoir_protocol_ft.cpp80
-rw-r--r--ftnoir_protocol_ft/ftnoir_protocol_ft.h12
-rw-r--r--ftnoir_protocol_ft/fttypes.h68
3 files changed, 46 insertions, 114 deletions
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
index c0a186ff..312cf127 100644
--- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
+++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
@@ -1,35 +1,35 @@
-/********************************************************************************
-* FaceTrackNoIR This program is a private project of the some enthusiastic *
-* gamers from Holland, who don't like to pay much for *
-* head-tracking. *
-* *
-* Copyright (C) 2013 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/>. *
-* *
-* FTServer FTServer is the Class, that communicates headpose-data *
-* to games, using the FreeTrackClient.dll. *
+/*******************************************************************************
+* FaceTrackNoIR This program is a private project of the some enthusiastic
+* gamers from Holland, who don't like to pay much for
+* head-tracking.
+*
+* Copyright (C) 2013 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/>.
+*
+* FTServer FTServer is the Class, that communicates headpose-data
+* to games, using the FreeTrackClient.dll.
********************************************************************************/
#include "ftnoir_protocol_ft.h"
-#include "ftnoir_csv/csv.h"
+#include "csv/csv.h"
FTNoIR_Protocol::FTNoIR_Protocol() :
- pMemData((FTHeap*) shm.ptr()),
shm(FREETRACK_HEAP, FREETRACK_MUTEX, sizeof(FTHeap)),
+ pMemData((FTHeap*) shm.ptr()),
viewsStart(nullptr),
viewsStop(nullptr),
intGameID(0)
@@ -48,15 +48,15 @@ FTNoIR_Protocol::~FTNoIR_Protocol()
}
void FTNoIR_Protocol::pose(const double* headpose) {
- float yaw = getRadsFromDegrees(headpose[Yaw]);
- float pitch = getRadsFromDegrees(headpose[Pitch]);
+ float yaw = -getRadsFromDegrees(headpose[Yaw]);
+ float pitch = -getRadsFromDegrees(headpose[Pitch]);
float roll = getRadsFromDegrees(headpose[Roll]);
float tx = headpose[TX] * 10.f;
float ty = headpose[TY] * 10.f;
float tz = headpose[TZ] * 10.f;
shm.lock();
-
+
pMemData->data.RawX = 0;
pMemData->data.RawY = 0;
pMemData->data.RawZ = 0;
@@ -71,7 +71,7 @@ void FTNoIR_Protocol::pose(const double* headpose) {
pMemData->data.Pitch = pitch;
pMemData->data.Roll = roll;
- pMemData->data.X1 = ++pMemData->data.DataID;
+ pMemData->data.X1 = pMemData->data.DataID;
pMemData->data.X2 = 0;
pMemData->data.X3 = 0;
pMemData->data.X4 = 0;
@@ -90,7 +90,7 @@ void FTNoIR_Protocol::pose(const double* headpose) {
connected_game = gamename;
}
- pMemData->data.DataID += 1;
+ pMemData->data.DataID += 1;
shm.unlock();
}
@@ -128,9 +128,9 @@ void FTNoIR_Protocol::start_dummy() {
}
bool FTNoIR_Protocol::correct()
-{
- QSettings settings("Freetrack", "FreetrackClient"); // Registry settings (in HK_USER)
- QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER)
+{
+ QSettings settings("Freetrack", "FreetrackClient"); // Registry settings (in HK_USER)
+ QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER)
if (!shm.success())
return false;
@@ -138,15 +138,15 @@ bool FTNoIR_Protocol::correct()
QString aLocation = QCoreApplication::applicationDirPath() + "/";
switch (s.intUsedInterface) {
- case 0: // Use both interfaces
+ case 0: // Use both interfaces
settings.setValue( "Path" , aLocation );
settingsTIR.setValue( "Path" , aLocation );
break;
- case 1: // Use FreeTrack, disable TrackIR
+ case 1: // Use FreeTrack, disable TrackIR
settings.setValue( "Path" , aLocation );
settingsTIR.setValue( "Path" , "" );
break;
- case 2: // Use TrackIR, disable FreeTrack
+ case 2: // Use TrackIR, disable FreeTrack
settings.setValue( "Path" , "" );
settingsTIR.setValue( "Path" , aLocation );
break;
@@ -166,8 +166,8 @@ bool FTNoIR_Protocol::correct()
pMemData->data.CamHeight = 250;
pMemData->GameID2 = 0;
memset(pMemData->table, 0, 8);
-
- return true;
+
+ return true;
}
extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor()
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h
index 06992de5..6bbf1bd3 100644
--- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h
+++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h
@@ -38,7 +38,7 @@
#include <QMutexLocker>
#include "compat/compat.h"
#include "opentrack/options.hpp"
-#include "fttypes.h"
+#include "../freetrackclient/fttypes.h"
using namespace options;
struct settings {
@@ -60,7 +60,7 @@ class FTNoIR_Protocol : public IProtocol
public:
FTNoIR_Protocol();
~FTNoIR_Protocol() override;
- bool correct( );
+ bool correct();
void pose( const double *headpose );
QString game_name() override {
QMutexLocker foo(&game_name_mutex);
@@ -68,18 +68,18 @@ public:
}
private:
settings s;
- FTHeap *pMemData;
PortableLockedShm shm;
+ FTHeap *pMemData;
QLibrary FTIRViewsLib;
QProcess dummyTrackIR;
importTIRViewsStart viewsStart;
- importTIRViewsStop viewsStop;
-
+ importTIRViewsStop viewsStop;
+
int intGameID;
QString connected_game;
QMutex game_name_mutex;
-
+
static inline double getRadsFromDegrees(double degrees) { return degrees * 0.017453; }
void start_tirviews();
void start_dummy();
diff --git a/ftnoir_protocol_ft/fttypes.h b/ftnoir_protocol_ft/fttypes.h
deleted file mode 100644
index f41350c8..00000000
--- a/ftnoir_protocol_ft/fttypes.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/************************************************************************************
- * * FTTypes FTTypes contains the specific type definitions for the *
- * * FreeTrack protocol. *
- * * It was loosely translated from FTTypes.pas *
- * * which was created by the FreeTrack-team. *
- * * *
- * * Wim Vriend (Developing) *
- * * Ron Hendriks (Testing and Research) *
- * * *
- * * Homepage <http://facetracknoir.sourceforge.net/home/default.htm> *
- * * *
- * * 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. *
- * * *
- * * The FTTypes sources were translated from the original Delphi sources *
- * * created by the FreeTrack developers. *
- */
-
-#pragma once
-
-#ifndef _MSC_VER
-# include <inttypes.h>
-#else
-typedef unsigned __int32 uint32_t;
-#endif
-
-#define FREETRACK_HEAP "FT_SharedMem"
-#define FREETRACK_MUTEX "FT_Mutext"
-
-/* only 6 headpose floats and the data id are filled -sh */
-typedef struct __FTData {
- int DataID;
- int CamWidth;
- int CamHeight;
- /* virtual pose */
- float Yaw; /* positive yaw to the left */
- float Pitch; /* positive pitch up */
- float Roll; /* positive roll to the left */
- float X;
- float Y;
- float Z;
- /* raw pose with no smoothing, sensitivity, response curve etc. */
- float RawYaw;
- float RawPitch;
- float RawRoll;
- float RawX;
- float RawY;
- float RawZ;
- /* raw points, sorted by Y, origin top left corner */
- float X1;
- float Y1;
- float X2;
- float Y2;
- float X3;
- float Y3;
- float X4;
- float Y4;
-} FTData;
-
-/* we add some shit at the end for other legacy proto, sadly */
-
-typedef struct __FTHeap {
- FTData data;
- int32_t GameID;
- unsigned char table[8];
- int32_t GameID2;
-} FTHeap;