From 36f82a4f0dc4f002123cc313eab7c845dcd13572 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Sat, 9 Feb 2013 15:29:53 +0000 Subject: Created a FaceTrackNoIR-version of FreeTrackClient.dll, because the existing one was crashing ArmA2. Made a 64-bit version too. The FTReportName function was a trouble-maker. In the repo of FreeTrack it expects a pointer to a name, in reality, it should receive an integer... Cost me a while to figure out why ArmA kept crashing :( Also added the option to enable/disable FreeTrack or TrackIR in the FreeTrack 2.0 settings-dialog. Even more, added a button so users can 'repair' the location of NPClient.dll. Some users complained that their SW didn't work with TrackIR any more, after running FaceTrackNoIR... git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@270 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui | 173 ++++++++++++++++++++--- FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp | 38 +++-- FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h | 3 + FTNoIR_Protocol_FT/FTTypes.h | 9 +- FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp | 37 ++++- 5 files changed, 233 insertions(+), 27 deletions(-) (limited to 'FTNoIR_Protocol_FT') diff --git a/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui b/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui index 980b2943..fc5abbcf 100644 --- a/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui +++ b/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui @@ -6,10 +6,16 @@ 0 0 - 588 - 263 + 645 + 416 + + + 645 + 0 + + FreeTrack 2.0 settings FaceTrackNoIR @@ -40,8 +46,8 @@ - 70 - 20 + 80 + 30 88 17 @@ -56,27 +62,27 @@ - 180 + 189 10 - 301 + 421 16 - TIRViews is only required for some older games (like CFS3). + TIRViews is only required for some older games (like CFS3). For it to work, TIRViews.dll - 180 + 189 30 421 16 - For it to work, TIRViews.dll must be placed in the FaceTrackNoIR program folder. + must be placed in the FaceTrackNoIR program folder. If the checkbox is disabled, the true @@ -85,14 +91,14 @@ - 180 + 189 50 - 251 + 411 16 - If the checkbox is disabled, the DLL was not found. + the DLL was not found. You can get it from NaturalPoint. @@ -111,8 +117,8 @@ - 13 - 20 + 20 + 30 145 17 @@ -127,7 +133,7 @@ - 180 + 189 10 351 16 @@ -140,7 +146,7 @@ - 180 + 189 30 261 16 @@ -156,7 +162,7 @@ - 180 + 189 50 231 16 @@ -168,6 +174,139 @@ + + + + + 0 + 70 + + + + Select interface + + + + + 189 + 10 + 351 + 16 + + + + Some games support both FreeTrack and TrackIR and may get confused, + + + + + + 189 + 30 + 261 + 16 + + + + when both interfaces are visible. + + + true + + + + + + 189 + 50 + 381 + 16 + + + + Try to disable one interface, if you experience problems. + + + + + + 6 + 30 + 168 + 22 + + + + + + + + + + 0 + 70 + + + + Repair NPClient location + + + + + 188 + 10 + 381 + 20 + + + + Users who use other software with an NPClient DLL (like TrackIR, FreeTrack or + + + + + + 184 + 30 + 411 + 20 + + + + GlovePIE) may need to repair the location of the DLL, after running FaceTrackNoIR. + + + true + + + + + + 187 + 50 + 391 + 20 + + + + Use this button to locate the desired NPClient DLL. + + + + + + 4 + 30 + 171 + 23 + + + + Locate DLL + + + + diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp index 0491b9fa..f33f92c5 100644 --- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp +++ b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp @@ -26,6 +26,8 @@ ********************************************************************************/ /* Modifications (last one on top): + 20130209 - WVR: Some games support both interfaces and cause trouble. Added ComboBox to fix this (hide one interface + by clearing the appropriate Registry-setting). 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. @@ -45,8 +47,13 @@ FTNoIR_Protocol::FTNoIR_Protocol() comhandle = 0; useTIRViews = false; useDummyExe = false; + intUsedInterface = 0; + // + // Load the INI-settings. + // loadSettings(); + ProgramName = ""; intGameID = 0; @@ -93,12 +100,6 @@ FTNoIR_Protocol::~FTNoIR_Protocol() FTDestroyMapping(); } -///** helper to Auto-destruct **/ -//void FTNoIR_Protocol::Release() -//{ -// delete this; -//} - void FTNoIR_Protocol::Initialize() { return; @@ -174,6 +175,10 @@ void FTNoIR_Protocol::loadSettings() { QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + iniFile.beginGroup ( "FT" ); + intUsedInterface = iniFile.value ( "UsedInterface", 0 ).toInt(); + iniFile.endGroup (); + // // Use the settings-section from the deprecated fake-TIR protocol, as they are most likely to be found there. // @@ -321,8 +326,25 @@ bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) // Write the path in the registry (for FreeTrack and FreeTrack20), for the game(s). // aLocation = QCoreApplication::applicationDirPath() + "/"; - settings.setValue( "Path" , aLocation ); - settingsTIR.setValue( "Path" , aLocation ); + + qDebug() << "checkServerInstallationOK says: used interface = " << intUsedInterface; + switch (intUsedInterface) { + case 0: // Use both interfaces + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , aLocation ); + break; + case 1: // Use FreeTrack, disable TrackIR + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , "" ); + break; + case 2: // Use TrackIR, disable FreeTrack + settings.setValue( "Path" , "" ); + settingsTIR.setValue( "Path" , aLocation ); + break; + default: + // should never be reached + break; + } // // TIRViews must be started first, or the NPClient DLL will never be loaded. diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h index 00f124f6..c82c3e79 100644 --- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h +++ b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h @@ -76,6 +76,7 @@ private: QLibrary FTIRViewsLib; QProcess *dummyTrackIR; int intGameID; + int intUsedInterface; // Determine which interface to use (or to hide from the game) bool useTIRViews; // Needs to be in the Settings dialog bool useDummyExe; @@ -114,9 +115,11 @@ private: FTNoIR_Protocol *theProtocol; private slots: + void selectDLL(); void doOK(); void doCancel(); void settingChanged() { settingsDirty = true; }; + void settingChanged(int) { settingsDirty = true; }; }; //******************************************************************************************************* diff --git a/FTNoIR_Protocol_FT/FTTypes.h b/FTNoIR_Protocol_FT/FTTypes.h index ece410ff..1f389711 100644 --- a/FTNoIR_Protocol_FT/FTTypes.h +++ b/FTNoIR_Protocol_FT/FTTypes.h @@ -92,6 +92,13 @@ struct FTMemMap { }; typedef FTMemMap * PFTMemMap; -extern bool (*FTGetData) (PFreetrackData data); +//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 diff --git a/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp b/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp index 678b3a5f..9f6fdcb1 100644 --- a/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp +++ b/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp @@ -32,6 +32,7 @@ */ #include "ftnoir_protocol_ft.h" #include +#include //******************************************************************************************************* // FaceTrackNoIR Client Settings-dialog. @@ -52,6 +53,12 @@ QWidget() connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); connect(ui.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(chkTIRViewsChanged())); connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); + connect(ui.cbxSelectInterface, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); + + ui.cbxSelectInterface->addItem("Enable both"); + ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); + ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; if ( !QFile::exists( aFileName ) ) { @@ -147,7 +154,7 @@ void FTControls::loadSettings() { qDebug() << "loadSettings says: iniFile = " << currentFile; iniFile.beginGroup ( "FT" ); -// ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); + ui.cbxSelectInterface->setCurrentIndex( iniFile.value ( "UsedInterface", 0 ).toInt() ); iniFile.endGroup (); iniFile.beginGroup ( "FTIR" ); @@ -168,6 +175,7 @@ void FTControls::save() { QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FT" ); + iniFile.setValue ( "UsedInterface", ui.cbxSelectInterface->currentIndex()); iniFile.endGroup (); iniFile.beginGroup ( "FTIR" ); @@ -178,6 +186,33 @@ void FTControls::save() { settingsDirty = false; } +// +// Select a NPClient.dll file, to repair the Location in the Registry. +// Several program distribute their own version of this file. +// +void FTControls::selectDLL() { + QFileDialog::Options options; + QFileDialog::FileMode mode; + + options |= QFileDialog::DontUseNativeDialog; + mode = QFileDialog::ExistingFile; + QString selectedFilter; + 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 + + settingsTIR.setValue( "Path" , aLocation ); + } + } +} + + //////////////////////////////////////////////////////////////////////////////// // Factory function that creates instances if the Protocol-settings dialog object. -- cgit v1.2.3