diff options
Diffstat (limited to 'ftnoir_protocol_ft/ftnoir_protocol_ft.cpp')
-rw-r--r-- | ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 86 |
1 files changed, 26 insertions, 60 deletions
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 281af6a0..ae23be3c 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -28,9 +28,9 @@ #include "ftnoir_csv/csv.h" FTNoIR_Protocol::FTNoIR_Protocol() : - shm(FT_MM_DATA, FREETRACK_MUTEX, sizeof(FTMemMap)) + shm(FREETRACK_HEAP, FREETRACK_MUTEX, sizeof(FTHeap)) { - pMemData = (FTMemMap*) shm.mem; + pMemData = (FTHeap*) shm.ptr(); ProgramName = ""; intGameID = 0; viewsStart = 0; @@ -49,50 +49,30 @@ FTNoIR_Protocol::~FTNoIR_Protocol() } void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { - float virtPosX; - float virtPosY; - float virtPosZ; - - float virtRotX; - float virtRotY; - float virtRotZ; - - float headPosX; - float headPosY; - float headPosZ; - - float headRotX; - float headRotY; - float headRotZ; - headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]) * (s.useDummyExe ? 2.0 : 1.0); - headRotY = virtRotY = getRadsFromDegrees(headpose[Yaw]); - headRotZ = virtRotZ = getRadsFromDegrees(headpose[Roll]); - headPosX = virtPosX = headpose[TX] * 10; - headPosY = virtPosY = headpose[TY] * 10; - headPosZ = virtPosZ = headpose[TZ] * 10; + 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 = headPosX; - pMemData->data.RawY = headPosY; - pMemData->data.RawZ = headPosZ; - pMemData->data.RawPitch = headRotX; - pMemData->data.RawYaw = headRotY; - pMemData->data.RawRoll = headRotZ; - - // - // - pMemData->data.X = virtPosX; - pMemData->data.Y = virtPosY; - pMemData->data.Z = virtPosZ; - pMemData->data.Pitch = virtRotX; - pMemData->data.Yaw = virtRotY; - pMemData->data.Roll = virtRotZ; - - // - // Leave some values 0 yet... - // - pMemData->data.X1 = pMemData->data.DataID + 10; + pMemData->data.RawX = 0; + pMemData->data.RawY = 0; + pMemData->data.RawZ = 0; + pMemData->data.RawPitch = 0; + pMemData->data.RawYaw = 0; + pMemData->data.RawRoll = 0; + + pMemData->data.X = tx; + pMemData->data.Y = ty; + pMemData->data.Z = tz; + pMemData->data.Yaw = yaw; + pMemData->data.Pitch = pitch; + pMemData->data.Roll = roll; + + pMemData->data.X1 = ++pMemData->data.DataID; pMemData->data.X2 = 0; pMemData->data.X3 = 0; pMemData->data.X4 = 0; @@ -146,28 +126,18 @@ void FTNoIR_Protocol::start_dummy() { QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe"; dummyTrackIR.setProgram("\"" + program + "\""); dummyTrackIR.start(); - - qDebug() << "FTServer::run() says: TrackIR.exe executed!" << program; } bool FTNoIR_Protocol::checkServerInstallationOK() { QSettings settings("Freetrack", "FreetrackClient"); // Registry settings (in HK_USER) QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) - QString aLocation; // Location of Client DLL - if (!shm.success()) return false; - qDebug() << "checkServerInstallationOK says: Starting Function"; + QString aLocation = QCoreApplication::applicationDirPath() + "/"; - // - // Write the path in the registry (for FreeTrack and FreeTrack20), for the game(s). - // - aLocation = QCoreApplication::applicationDirPath() + "/"; - - qDebug() << "checkServerInstallationOK says: used interface = " << s.intUsedInterface; switch (s.intUsedInterface) { case 0: // Use both interfaces settings.setValue( "Path" , aLocation ); @@ -182,13 +152,9 @@ bool FTNoIR_Protocol::checkServerInstallationOK() settingsTIR.setValue( "Path" , aLocation ); break; default: - // should never be reached - break; + break; } - // - // TIRViews must be started first, or the NPClient DLL will never be loaded. - // if (s.useTIRViews) { start_tirviews(); } @@ -205,7 +171,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() { return new FTNoIR_Protocol; } |