diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-09-17 12:54:58 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-09-17 12:54:58 +0200 |
commit | df84ea6740236bd377de7fefc90764831ce663b4 (patch) | |
tree | d2a6fa89e64fd090050988539d0afce713ad73d0 /ftnoir_protocol_ft | |
parent | 2b50200ca979cbf33d8e67503db341a6f62d1604 (diff) |
ft proto: cleanup
Diffstat (limited to 'ftnoir_protocol_ft')
-rw-r--r-- | ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 82 | ||||
-rw-r--r-- | ftnoir_protocol_ft/ftnoir_protocol_ft.h | 13 | ||||
-rw-r--r-- | ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 35 | ||||
-rw-r--r-- | ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp | 27 | ||||
-rw-r--r-- | ftnoir_protocol_ft/fttypes.h | 44 |
5 files changed, 52 insertions, 149 deletions
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 281af6a0..bb771c9d 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(FT_MM_DATA, FREETRACK_MUTEX, sizeof(FTHeap)) { - pMemData = (FTMemMap*) shm.mem; + pMemData = (FTHeap*) shm.mem; 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[Pitch]) * (s.useDummyExe ? 2.0 : 1.0); + float pitch = getRadsFromDegrees(headpose[Yaw]); + 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.Pitch = pitch; + pMemData->data.Yaw = yaw; + pMemData->data.Roll = roll; + + pMemData->data.X1 = ++pMemData->data.DataID; pMemData->data.X2 = 0; pMemData->data.X3 = 0; pMemData->data.X4 = 0; @@ -154,20 +134,14 @@ 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"; - - // - // Write the path in the registry (for FreeTrack and FreeTrack20), for the game(s). - // - aLocation = QCoreApplication::applicationDirPath() + "/"; + QString aLocation = QCoreApplication::applicationDirPath() + "/"; qDebug() << "checkServerInstallationOK says: used interface = " << s.intUsedInterface; + switch (s.intUsedInterface) { case 0: // Use both interfaces settings.setValue( "Path" , aLocation ); @@ -182,13 +156,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(); } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index 01682e69..b1d71f08 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -36,7 +36,6 @@ #include <QDebug> #include <QFile> #include <QString> -#include <windows.h> #include <QMutex> #include <QMutexLocker> #include "compat/compat.h" @@ -55,9 +54,8 @@ struct settings { {} }; -//typedef char *(WINAPI *importProvider)(void); -typedef void (WINAPI *importTIRViewsStart)(void); -typedef void (WINAPI *importTIRViewsStop)(void); +typedef void (__stdcall *importTIRViewsStart)(void); +typedef void (__stdcall *importTIRViewsStop)(void); class FTNoIR_Protocol : public IProtocol { @@ -71,14 +69,13 @@ public: return connected_game; } private: - importTIRViewsStart viewsStart; // Functions inside TIRViews.dll + importTIRViewsStart viewsStart; importTIRViewsStop viewsStop; - - FTMemMap *pMemData; + + FTHeap *pMemData; QString game_name; PortableLockedShm shm; - // Private properties QString ProgramName; QLibrary FTIRViewsLib; QProcess dummyTrackIR; diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index 5ce903b7..98d61675 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -26,21 +26,10 @@ #include <QDebug> #include <QFileDialog> -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FTControls::FTControls() : - QWidget() +FTControls::FTControls() { - QString aFileName; // File Path and Name - ui.setupUi( this ); - // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); @@ -54,8 +43,8 @@ FTControls::FTControls() : tie_setting(s.intUsedInterface, ui.cbxSelectInterface); - aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; - if ( !QFile::exists( aFileName ) ) { + QFile memhacks_pathname(QCoreApplication::applicationDirPath() + "/TIRViews.dll"); + if (!memhacks_pathname.exists()) { ui.chkTIRViews->setChecked( false ); ui.chkTIRViews->setEnabled ( false ); } @@ -75,22 +64,16 @@ void FTControls::doCancel() { } void FTControls::selectDLL() { - QString fileName = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)")); - - // - // Write the location of the file in the required Registry-key. - // - if (! fileName.isEmpty() ) { - if (fileName.endsWith("NPClient.dll", Qt::CaseInsensitive) ) { - QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) - QString aLocation = fileName.left(fileName.length() - 12); // Location of Client DLL + QString filename = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)")); - settingsTIR.setValue( "Path" , aLocation ); - } + if (! filename.isEmpty() ) { + QSettings node("NaturalPoint", "NATURALPOINT\\NPClient Location"); + QFileInfo dllname(filename); + node.setValue( "Path" , dllname.dir().path() ); } } -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog() { return new FTControls; } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp index 38f11211..d5a51457 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp @@ -1,28 +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_protocol_ft.h" +#include "facetracknoir/plugin-support.h" +#include "ftnoir_protocol_ft/ftnoir_protocol_ft.h" extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { diff --git a/ftnoir_protocol_ft/fttypes.h b/ftnoir_protocol_ft/fttypes.h index ced844dc..cc78a80a 100644 --- a/ftnoir_protocol_ft/fttypes.h +++ b/ftnoir_protocol_ft/fttypes.h @@ -16,27 +16,16 @@ * * The FTTypes sources were translated from the original Delphi sources * * * created by the FreeTrack developers. * */ -#ifndef INCLUDED_FTTYPES_H -#define INCLUDED_FTTYPES_H -#if !defined(_WIN32) -# include <inttypes.h> -typedef int32_t my_32bit_int; -# define WINAPI -#else -# include <windows.h> -typedef __int32 my_32bit_int; -#endif +#pragma once -//#include "Registry.h" +#include <inttypes.h> -// static const char* FT_CLIENT_LOCATION = "Software\\Freetrack\\FreetrackClient"; -//#define FT_CLIENT_FILENAME "FreeTrackClient.Dll" #define FT_MM_DATA "FT_SharedMem" -//#define FREETRACK "Freetrack" #define FREETRACK_MUTEX "FT_Mutext" -struct TFreeTrackData { +// only 6 headpose floats and the data id are filled -sh +typedef struct __FTData { int DataID; int CamWidth; int CamHeight; @@ -63,24 +52,11 @@ struct TFreeTrackData { float Y3; float X4; float Y4; -}; -typedef TFreeTrackData * PFreetrackData; +} FTData; -struct FTMemMap { - TFreeTrackData data; - my_32bit_int GameID; +typedef struct __FTAlloc { + FTData data; + int32_t GameID; unsigned char table[8]; - my_32bit_int GameID2; -}; -typedef FTMemMap * PFTMemMap; - -//extern bool (*FTGetData) (PFreetrackData data); -// DLL function signatures -// These match those given in FTTypes.pas -// WINAPI is macro for __stdcall defined somewhere in the depths of windows.h -typedef bool (WINAPI *importGetData)(TFreeTrackData * data); -typedef char *(WINAPI *importGetDllVersion)(void); -typedef void (WINAPI *importReportID)(int name); -typedef char *(WINAPI *importProvider)(void); - -#endif//INCLUDED_FTTYPES_H + int32_t GameID2; +} FTHeap; |