From e437f501a6b7a6a9ac90eec6d91ebf022aa09ff8 Mon Sep 17 00:00:00 2001
From: Stanislaw Halik <sthalik@misaki.pl>
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')

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