summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Protocol_FT
diff options
context:
space:
mode:
Diffstat (limited to 'FTNoIR_Protocol_FT')
-rw-r--r--FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui161
-rw-r--r--FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp133
-rw-r--r--FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h3
-rw-r--r--FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp29
4 files changed, 252 insertions, 74 deletions
diff --git a/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui b/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui
index 29cba42b..980b2943 100644
--- a/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui
+++ b/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui
@@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
- <width>411</width>
- <height>112</height>
+ <width>588</width>
+ <height>263</height>
</rect>
</property>
<property name="windowTitle">
- <string>FreeTrack settings FaceTrackNoIR</string>
+ <string>FreeTrack 2.0 settings FaceTrackNoIR</string>
</property>
<property name="windowIcon">
<iconset>
@@ -25,7 +25,149 @@
</property>
<layout class="QVBoxLayout" name="_vertical_layout">
<item>
- <layout class="QHBoxLayout">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>70</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>TIRViews</string>
+ </property>
+ <widget class="QCheckBox" name="chkTIRViews">
+ <property name="geometry">
+ <rect>
+ <x>70</x>
+ <y>20</y>
+ <width>88</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::RightToLeft</enum>
+ </property>
+ <property name="text">
+ <string>Use TIRViews</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_4">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>10</y>
+ <width>301</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>TIRViews is only required for some older games (like CFS3).</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_5">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>30</y>
+ <width>421</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>For it to work, TIRViews.dll must be placed in the FaceTrackNoIR program folder.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_6">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>50</y>
+ <width>251</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>If the checkbox is disabled, the DLL was not found.</string>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>70</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>TrackIR.exe</string>
+ </property>
+ <widget class="QCheckBox" name="chkStartDummy">
+ <property name="geometry">
+ <rect>
+ <x>13</x>
+ <y>20</y>
+ <width>145</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::RightToLeft</enum>
+ </property>
+ <property name="text">
+ <string>Start dummy TrackIR.exe</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_3">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>10</y>
+ <width>351</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Some programs check, to see if a process called TrackIR.exe is running,</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>30</y>
+ <width>261</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>before enabling head-tracking (EZCA is one of them).</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_7">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>50</y>
+ <width>231</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Check the checkbox, to overcome this problem.</string>
+ </property>
+ </widget>
+ </widget>
+ </item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
@@ -55,17 +197,6 @@
</spacer>
</item>
<item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>There are no settings necessary for the FreeTrack protocol.</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp
index 159d3c31..7a1d898e 100644
--- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp
+++ b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp
@@ -26,6 +26,7 @@
********************************************************************************/
/*
Modifications (last one on top):
+ 20130203 - WVR: Added Tirviews and dummy checkboxes to the Settings dialog. This is necessary for CFS3 etc.
20130125 - WVR: Upgraded to FT2.0: now the FreeTrack protocol supports all TIR-enabled games.
20110401 - WVR: Moved protocol to a DLL, convenient for installation etc.
20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame
@@ -42,6 +43,9 @@
FTNoIR_Protocol::FTNoIR_Protocol()
{
comhandle = 0;
+ useTIRViews = false;
+ useDummyExe = false;
+
loadSettings();
ProgramName = "";
intGameID = 0;
@@ -49,6 +53,7 @@ FTNoIR_Protocol::FTNoIR_Protocol()
dummyTrackIR = 0;
viewsStart = 0;
viewsStop = 0;
+
}
/** destructor **/
@@ -88,11 +93,11 @@ FTNoIR_Protocol::~FTNoIR_Protocol()
FTDestroyMapping();
}
-/** helper to Auto-destruct **/
-void FTNoIR_Protocol::Release()
-{
- delete this;
-}
+///** helper to Auto-destruct **/
+//void FTNoIR_Protocol::Release()
+//{
+// delete this;
+//}
void FTNoIR_Protocol::Initialize()
{
@@ -113,20 +118,28 @@ QStringList gameLine;
QFile file(QCoreApplication::applicationDirPath() + "/Settings/FaceTrackNoIR Supported Games.csv");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<< "cannot read file!";
- return false;
+
+ QString strError("Cannot load file: " + file.fileName());
+ sprintf_s(pMemData->ProgramName, 99, strError.toAscii());
+ file.close();
+
+ //
+ // Return true anyway, because maybe it's V160 compatible.
+ //
+ return true;
}
CSV csv(&file);
gameLine = csv.parseLine();
while (gameLine.count() > 2) {
- qDebug() << "Column 0: " << gameLine.at(0); // No.
- qDebug() << "Column 1: " << gameLine.at(1); // Game Name
- qDebug() << "Column 2: " << gameLine.at(2); // Game Protocol
- qDebug() << "Column 3: " << gameLine.at(3); // Supported since version
- qDebug() << "Column 4: " << gameLine.at(4); // Verified
- qDebug() << "Column 5: " << gameLine.at(5); // By
- qDebug() << "Column 6: " << gameLine.at(6); // International ID
- qDebug() << "Column 7: " << gameLine.at(7); // FaceTrackNoIR ID
+ //qDebug() << "Column 0: " << gameLine.at(0); // No.
+ //qDebug() << "Column 1: " << gameLine.at(1); // Game Name
+ //qDebug() << "Column 2: " << gameLine.at(2); // Game Protocol
+ //qDebug() << "Column 3: " << gameLine.at(3); // Supported since version
+ //qDebug() << "Column 4: " << gameLine.at(4); // Verified
+ //qDebug() << "Column 5: " << gameLine.at(5); // By
+ //qDebug() << "Column 6: " << gameLine.at(6); // International ID
+ //qDebug() << "Column 7: " << gameLine.at(7); // FaceTrackNoIR ID
//
// If the gameID was found, fill the shared memory
@@ -149,7 +162,8 @@ QStringList gameLine;
//
// If the gameID was NOT found, fill only the name "Unknown game connected"
//
- sprintf_s(pMemData->ProgramName, 99, gameLine.at(1).toAscii());
+ QString strUnknown("Unknown game connected (ID = " + gameID + ")");
+ sprintf_s(pMemData->ProgramName, 99, strUnknown.toAscii());
file.close();
return true;
}
@@ -158,6 +172,18 @@ QStringList gameLine;
// Load the current Settings from the currently 'active' INI-file.
//
void FTNoIR_Protocol::loadSettings() {
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+
+ //
+ // Use the settings-section from the deprecated fake-TIR protocol, as they are most likely to be found there.
+ //
+ iniFile.beginGroup ( "FTIR" );
+ useTIRViews = iniFile.value ( "useTIRViews", 0 ).toBool();
+ useDummyExe = iniFile.value ( "useDummyExe", 1 ).toBool();
+ iniFile.endGroup ();
}
//
@@ -254,46 +280,11 @@ PDWORD_PTR MsgResult = 0;
QString gameID = QString(pMemData->GameID);
// QString gameID = QString("2304");
- qDebug() << "sendHeadposeToGame: gameID = " << gameID;
+// qDebug() << "sendHeadposeToGame: gameID = " << gameID;
if (gameID.length() > 0) {
if ( gameID.toInt() != intGameID ) {
if (getGameData( gameID ) ) {
SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult);
-
- //
- // Check if TIRViews or dummy TrackIR.exe is required for this game
- //
- QString ftnID = QString(pMemData->FTNID);
- if (ftnID.length() >= 22) {
- if (ftnID.at(20) != '0') {
- FTIRViewsLib.setFileName(QCoreApplication::applicationDirPath() + "/TIRViews.dll");
- FTIRViewsLib.load();
-
- viewsStart = (importTIRViewsStart) FTIRViewsLib.resolve("TIRViewsStart");
- if (viewsStart == NULL) {
- qDebug() << "FTServer::run() says: TIRViewsStart function not found in DLL!";
- }
- else {
- qDebug() << "FTServer::run() says: TIRViewsStart executed!";
- viewsStart();
- }
-
- //
- // Load the Stop function from TIRViews.dll. Call it when terminating the thread.
- //
- viewsStop = (importTIRViewsStop) FTIRViewsLib.resolve("TIRViewsStop");
- if (viewsStop == NULL) {
- qDebug() << "FTServer::run() says: TIRViewsStop function not found in DLL!";
- }
- }
- if (ftnID.at(21) != '0') {
- QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe";
- dummyTrackIR = new QProcess();
- dummyTrackIR->start(program);
-
- qDebug() << "FTServer::run() says: TrackIR.exe executed!";
- }
- }
}
intGameID = gameID.toInt();
}
@@ -336,6 +327,46 @@ bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle )
settings.setValue( "Path" , aLocation );
settingsTIR.setValue( "Path" , aLocation );
+ //
+ // TIRViews must be started first, or the NPClient DLL will never be loaded.
+ //
+ if (useTIRViews) {
+
+ QString aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll";
+ if ( QFile::exists( aFileName ) ) {
+
+ FTIRViewsLib.setFileName(aFileName);
+ FTIRViewsLib.load();
+
+ viewsStart = (importTIRViewsStart) FTIRViewsLib.resolve("TIRViewsStart");
+ if (viewsStart == NULL) {
+ qDebug() << "FTServer::run() says: TIRViewsStart function not found in DLL!";
+ }
+ else {
+ qDebug() << "FTServer::run() says: TIRViewsStart executed!";
+ viewsStart();
+ }
+
+ //
+ // Load the Stop function from TIRViews.dll. Call it when terminating the thread.
+ //
+ viewsStop = (importTIRViewsStop) FTIRViewsLib.resolve("TIRViewsStop");
+ if (viewsStop == NULL) {
+ qDebug() << "FTServer::run() says: TIRViewsStop function not found in DLL!";
+ }
+ }
+ }
+
+ //
+ // Check if TIRViews or dummy TrackIR.exe is required for this game
+ //
+ if (useDummyExe) {
+ QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe";
+ dummyTrackIR = new QProcess();
+ dummyTrackIR->start(program);
+
+ qDebug() << "FTServer::run() says: TrackIR.exe executed!";
+ }
} catch(...) {
diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h
index 12a20ee8..00f124f6 100644
--- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h
+++ b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h
@@ -73,10 +73,11 @@ private:
// Private properties
QString ProgramName;
-// QLibrary FTClientLib;
QLibrary FTIRViewsLib;
QProcess *dummyTrackIR;
int intGameID;
+ bool useTIRViews; // Needs to be in the Settings dialog
+ bool useDummyExe;
float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); }
bool getGameData( QString gameID );
diff --git a/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp b/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp
index 62584b43..678b3a5f 100644
--- a/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp
+++ b/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp
@@ -50,7 +50,18 @@ QWidget()
// Connect Qt signals to member-functions
connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
-// connect(ui.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(chkTIRViewsChanged()));
+ connect(ui.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(chkTIRViewsChanged()));
+ connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged()));
+
+ aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll";
+ if ( !QFile::exists( aFileName ) ) {
+ ui.chkTIRViews->setChecked( false );
+ ui.chkTIRViews->setEnabled ( false );
+ save();
+ }
+ else {
+ ui.chkTIRViews->setEnabled ( true );
+ }
theProtocol = NULL;
@@ -65,11 +76,6 @@ FTControls::~FTControls() {
qDebug() << "~FTControls() says: started";
}
-void FTControls::Release()
-{
- delete this;
-}
-
//
// Initialize tracker-client-dialog
//
@@ -144,6 +150,11 @@ void FTControls::loadSettings() {
// ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool());
iniFile.endGroup ();
+ iniFile.beginGroup ( "FTIR" );
+ ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool());
+ ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 1 ).toBool());
+ iniFile.endGroup ();
+
settingsDirty = false;
}
@@ -157,7 +168,11 @@ void FTControls::save() {
QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
iniFile.beginGroup ( "FT" );
-// iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() );
+ iniFile.endGroup ();
+
+ iniFile.beginGroup ( "FTIR" );
+ iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() );
+ iniFile.setValue ( "useDummyExe", ui.chkStartDummy->isChecked() );
iniFile.endGroup ();
settingsDirty = false;