From 5ec8d2bb1b36510988b112cf1b830208ce6910a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 13:51:55 +0100 Subject: fsuipc: decruft, use settings framework --- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 88 ++++++----------------- 1 file changed, 22 insertions(+), 66 deletions(-) (limited to 'ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp') diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index 986ccc65..7ca990af 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -30,32 +30,22 @@ /** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() { - loadSettings(); - ProgramName = "Microsoft FS2004"; - - prevPosX = 0.0f; - prevPosY = 0.0f; - prevPosZ = 0.0f; - prevRotX = 0.0f; - prevRotY = 0.0f; - prevRotZ = 0.0f; + prevPosX = 0.0; + prevPosY = 0.0; + prevPosZ = 0.0; + prevRotX = 0.0; + prevRotY = 0.0; + prevRotZ = 0.0; } -/** destructor **/ FTNoIR_Protocol::~FTNoIR_Protocol() { - // - // Free the DLL - // - FSUIPCLib.unload(); + FSUIPCLib.unload(); } -// -// Scale the measured value to the Joystick values -// int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { -double y; -double local_x; + double y; + double local_x; local_x = x; if (local_x > max_x) { @@ -69,40 +59,20 @@ double local_x; return (int) y; } -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FSUIPC" ); - LocationOfDLL = iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString(); - qDebug() << "FSUIPCServer::loadSettings() says: Location of DLL = " << LocationOfDLL; - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { -DWORD result; -TFSState pitch; -TFSState yaw; -TFSState roll; -WORD FSZoom; + DWORD result; + TFSState pitch; + TFSState yaw; + TFSState roll; + WORD FSZoom; -float virtPosX; -float virtPosY; -float virtPosZ; + float virtPosX; + float virtPosY; + float virtPosZ; -float virtRotX; -float virtRotY; -float virtRotZ; - -// qDebug() << "FSUIPCServer::run() says: started!"; + float virtRotX; + float virtRotY; + float virtRotZ; virtRotX = -headpose[Pitch]; // degrees virtRotY = headpose[Yaw]; @@ -112,17 +82,11 @@ float virtRotZ; virtPosY = 0.0f; virtPosZ = headpose[TZ]; - // - // Init. the FSUIPC offsets (derived from Free-track...) - // pitch.Control = 66503; yaw.Control = 66504; roll.Control = 66505; - // - // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. - // - if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || + if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { // // Open the connection @@ -178,7 +142,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() // // Load the DLL. // - FSUIPCLib.setFileName( LocationOfDLL ); + FSUIPCLib.setFileName( s.LocationOfDLL ); if (FSUIPCLib.load() != true) { qDebug() << "checkServerInstallationOK says: Error loading FSUIPC DLL"; return false; @@ -190,14 +154,6 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } -/////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") extern "C" FTNOIR_PROTOCOL_BASE_EXPORT FTNoIR_Protocol* CALLING_CONVENTION GetConstructor(void) { -- cgit v1.2.3 From e437f501a6b7a6a9ac90eec6d91ebf022aa09ff8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 16:16:01 +0100 Subject: fsuipc: decruft more --- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 35 +++++++++++++--------- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 7 ++--- .../ftnoir_protocol_fsuipc_dialog.cpp | 9 ------ 3 files changed, 23 insertions(+), 28 deletions(-) (limited to 'ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp') diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index 7ca990af..632d502a 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -30,22 +30,25 @@ /** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() { - prevPosX = 0.0; - prevPosY = 0.0; - prevPosZ = 0.0; - prevRotX = 0.0; - prevRotY = 0.0; - prevRotZ = 0.0; + prevPosX = 0.0f; + prevPosY = 0.0f; + prevPosZ = 0.0f; + prevRotX = 0.0f; + prevRotY = 0.0f; + prevRotZ = 0.0f; } FTNoIR_Protocol::~FTNoIR_Protocol() { - FSUIPCLib.unload(); + FSUIPCLib.unload(); } +// +// Scale the measured value to the Joystick values +// int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { - double y; - double local_x; +double y; +double local_x; local_x = x; if (local_x > max_x) { @@ -74,6 +77,8 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { float virtRotY; float virtRotZ; +// qDebug() << "FSUIPCServer::run() says: started!"; + virtRotX = -headpose[Pitch]; // degrees virtRotY = headpose[Yaw]; virtRotZ = headpose[Roll]; @@ -82,11 +87,17 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { virtPosY = 0.0f; virtPosZ = headpose[TZ]; + // + // Init. the FSUIPC offsets (derived from Free-track...) + // pitch.Control = 66503; yaw.Control = 66504; roll.Control = 66505; - if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || + // + // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. + // + if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { // // Open the connection @@ -132,9 +143,6 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { prevRotZ = virtRotZ; } -// -// Returns 'true' if all seems OK. -// bool FTNoIR_Protocol::checkServerInstallationOK() { qDebug() << "checkServerInstallationOK says: Starting Function"; @@ -154,7 +162,6 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT FTNoIR_Protocol* CALLING_CONVENTION GetConstructor(void) { return new FTNoIR_Protocol; diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index a099df36..ff8d3b7f 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -76,8 +76,8 @@ public: private: QLibrary FSUIPCLib; double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; - settings s; static int scale2AnalogLimits( float x, float min_x, float max_x ); + settings s; }; class FSUIPCControls: public QWidget, public IProtocolDialog @@ -85,7 +85,7 @@ class FSUIPCControls: public QWidget, public IProtocolDialog Q_OBJECT public: FSUIPCControls(); - void registerProtocol(IProtocol *protocol) {} + void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} private: Ui::UICFSUIPCControls ui; @@ -96,9 +96,6 @@ private slots: void getLocationOfDLL(); }; -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* class FTNoIR_ProtocolDll : public Metadata { public: diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index 9ef4ad67..bae3d5df 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -29,8 +29,6 @@ FSUIPCControls::FSUIPCControls() : QWidget() { ui.setupUi( this ); - - // Connect Qt signals to member-functions connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); @@ -43,11 +41,7 @@ void FSUIPCControls::doOK() { this->close(); } - void FSUIPCControls::doCancel() { - // - // Ask if changed Settings should be saved - // if (s.b->modifiedp()) { int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); @@ -74,9 +68,6 @@ void FSUIPCControls::doCancel() { void FSUIPCControls::getLocationOfDLL() { - // - // Get the new filename of the INI-file. - // QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), ui.txtLocationOfDLL->text(), tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); -- cgit v1.2.3