summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-04-27 12:48:22 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-04-27 12:48:22 +0200
commit1edb87b13a58cbb87cbf99ee30cc5ee7eb15003a (patch)
tree2a50a92f0b206fc5eee43830606cded1c6eed68f
parente70bef88fdb5ffdf1c2dcf99ac9e22181d18f5ac (diff)
Implement game name in the UI, lost previously due to refactoring.
-rw-r--r--facetracknoir/facetracknoir.cpp8
-rw-r--r--facetracknoir/facetracknoir.ui19
-rw-r--r--facetracknoir/tracker.cpp15
-rw-r--r--facetracknoir/tracker.h1
-rw-r--r--ftnoir_protocol_base/ftnoir_protocol_base.h2
-rw-r--r--ftnoir_protocol_fg/ftnoir_protocol_fg.h18
-rw-r--r--ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp11
-rw-r--r--ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h9
-rw-r--r--ftnoir_protocol_ft/ftnoir_protocol_ft.cpp13
-rw-r--r--ftnoir_protocol_ft/ftnoir_protocol_ft.h26
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn.h3
-rw-r--r--ftnoir_protocol_mouse/ftnoir_protocol_mouse.h18
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc.cpp9
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc.h8
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine.cpp2
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine.h7
16 files changed, 87 insertions, 82 deletions
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp
index c031f2a8..59efeb60 100644
--- a/facetracknoir/facetracknoir.cpp
+++ b/facetracknoir/facetracknoir.cpp
@@ -857,7 +857,7 @@ void FaceTrackNoIR::startTracker( ) {
/** stop tracking the face **/
void FaceTrackNoIR::stopTracker( ) {
-
+ ui.game_name->setText("Not connected");
#if defined(_WIN32) || defined(__WIN32)
if (keybindingWorker)
{
@@ -1002,7 +1002,11 @@ void FaceTrackNoIR::showHeadPose() {
if (_curve_config) {
_curve_config->update();
}
-
+ if (Libraries->pProtocol)
+ {
+ QString name = Libraries->pProtocol->getGameName();
+ ui.game_name->setText(name);
+ }
}
/** toggles Video Widget **/
diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui
index d91a6a92..63107a80 100644
--- a/facetracknoir/facetracknoir.ui
+++ b/facetracknoir/facetracknoir.ui
@@ -848,7 +848,7 @@ QGroupBox {
<property name="geometry">
<rect>
<x>20</x>
- <y>20</y>
+ <y>10</y>
<width>400</width>
<height>25</height>
</rect>
@@ -1339,6 +1339,23 @@ background:none;</string>
<string>Roll</string>
</property>
</widget>
+ <widget class="QLabel" name="game_name">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>40</y>
+ <width>411</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">color:#ccc;
+background:none;</string>
+ </property>
+ <property name="text">
+ <string>Not connected</string>
+ </property>
+ </widget>
</widget>
<widget class="QFrame" name="video_frame">
<property name="geometry">
diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp
index ca7d71fb..7320abaf 100644
--- a/facetracknoir/tracker.cpp
+++ b/facetracknoir/tracker.cpp
@@ -263,21 +263,6 @@ void Tracker::run() {
}
//
-// Get the ProgramName from the Game and return it.
-//
-QString Tracker::getGameProgramName() {
-QString str;
-char dest[100];
-
- str = QString("No protocol active?");
- if (Libraries->pProtocol) {
- Libraries->pProtocol->getNameFromGame( dest );
- str = QString( dest );
- }
- return str;
-}
-
-//
// Handle the command, send upstream by the game.
// Valid values are:
// 1 = reset Headpose
diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h
index 59e0f19c..035a88ed 100644
--- a/facetracknoir/tracker.h
+++ b/facetracknoir/tracker.h
@@ -156,7 +156,6 @@ public:
// void registerHeadPoseCallback();
bool handleGameCommand ( int command );
- QString getGameProgramName(); // Get the ProgramName from the game and display it.
void loadSettings(); // Load settings from the INI-file
//bool isShortKeyPressed( TShortKey *key, BYTE *keystate );
//bool isMouseKeyPressed( int *key, DIMOUSESTATE *mousestate );
diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h
index f1985677..6980cb51 100644
--- a/ftnoir_protocol_base/ftnoir_protocol_base.h
+++ b/ftnoir_protocol_base/ftnoir_protocol_base.h
@@ -60,7 +60,7 @@ struct IProtocol
virtual void Initialize() = 0;
virtual bool checkServerInstallationOK() = 0;
virtual void sendHeadposeToGame( double *headpose, double *rawheadpose ) = 0;
- virtual void getNameFromGame( char *dest ) = 0; // Take care dest can handle up to 100 chars...
+ virtual QString getGameName() = 0;
};
////////////////////////////////////////////////////////////////////////////////
diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h
index 10fb1ea8..45d4c67d 100644
--- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h
+++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h
@@ -67,7 +67,9 @@ private:
QHostAddress destIP; // Destination IP-address
int destPort; // Destination port-number
void loadSettings();
-
+ QString getGameName() {
+ return "FlightGear";
+ }
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -83,10 +85,10 @@ public:
void Initialize(QWidget *parent);
void registerProtocol(IProtocol *protocol) {
theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- };
+ }
void unRegisterProtocol() {
theProtocol = NULL; // Reset the pointer
- };
+ }
private:
Ui::UICFGControls ui;
@@ -101,7 +103,7 @@ private slots:
void doOK();
void doCancel();
void chkLocalPCOnlyChanged();
- void settingChanged() { settingsDirty = true; };
+ void settingChanged() { settingsDirty = true; }
};
//*******************************************************************************************************
@@ -113,11 +115,11 @@ public:
FTNoIR_ProtocolDll();
~FTNoIR_ProtocolDll();
- void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); };
- void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); };
- void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear UDP protocol"); };
+ void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }
+ void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }
+ void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear UDP protocol"); }
- void getIcon(QIcon *icon) { *icon = QIcon(":/images/flightgear.png"); };
+ void getIcon(QIcon *icon) { *icon = QIcon(":/images/flightgear.png"); }
};
diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp
index 0c25e77e..b3d7acaa 100644
--- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp
+++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp
@@ -207,16 +207,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK()
return true;
}
-//
-// Return a name, if present the name from the Game, that is connected...
-//
-void FTNoIR_Protocol::getNameFromGame( char *dest )
-{
- sprintf_s(dest, 99, "FS2002/2004");
- return;
-}
-
-////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
// Factory function that creates instances if the Protocol object.
// Export both decorated and undecorated names.
diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h
index f23f45c2..d8f9e624 100644
--- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h
+++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h
@@ -67,8 +67,9 @@ public:
bool checkServerInstallationOK();
void sendHeadposeToGame( double *headpose, double *rawheadpose );
- void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars...
-
+ QString getGameName() {
+ return "Microsoft Flight Simulator X";
+ }
private:
// Private properties
QString ProgramName;
@@ -94,10 +95,10 @@ public:
void Initialize(QWidget *parent);
void registerProtocol(IProtocol *protocol) {
theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- };
+ }
void unRegisterProtocol() {
theProtocol = NULL; // Reset the pointer
- };
+ }
private:
Ui::UICFSUIPCControls ui;
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
index a3deba7a..9c3c8461 100644
--- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
+++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
@@ -211,6 +211,8 @@ float headRotZ;
start_dummy();
pMemData->GameID2 = pMemData->GameID;
intGameID = pMemData->GameID;
+ QMutexLocker((QMutex*)&this->game_name_mutex);
+ connected_game = gamename;
}
ReleaseMutex(hFTMutex);
@@ -395,17 +397,6 @@ void FTNoIR_Protocol::FTDestroyMapping()
}
-//
-// Return a name, if present the name from the Game, that is connected...
-//
-void FTNoIR_Protocol::getNameFromGame( char *dest )
-{
- QByteArray foo = game_name.toUtf8();
- memcpy(dest, foo.constData(), std::min<int>(foo.size(), 98));
- dest[foo.size()] = 0;
-}
-
-
////////////////////////////////////////////////////////////////////////////////
// Factory function that creates instances if the Protocol object.
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h
index c02dfc03..e1e46876 100644
--- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h
+++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h
@@ -40,6 +40,8 @@
#include <QFile>
#include <QString>
#include <windows.h>
+#include <QMutex>
+#include <QMutexLocker>
//#include "math.h"
//typedef char *(WINAPI *importProvider)(void);
@@ -57,7 +59,10 @@ public:
bool checkServerInstallationOK( );
void sendHeadposeToGame( double *headpose, double *rawheadpose );
- void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars...
+ QString getGameName() {
+ QMutexLocker((QMutex*)&game_name_mutex);
+ return connected_game;
+ }
private:
bool FTCreateMapping();
@@ -86,6 +91,9 @@ private:
void loadSettings();
void start_tirviews();
void start_dummy();
+
+ QString connected_game;
+ QMutex game_name_mutex;
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -102,10 +110,10 @@ public:
void Initialize(QWidget *parent);
void registerProtocol(IProtocol *protocol) {
theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- };
+ }
void unRegisterProtocol() {
theProtocol = NULL; // Reset the pointer
- };
+ }
private:
Ui::UICFTControls ui;
@@ -120,8 +128,8 @@ private slots:
void selectDLL();
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; };
- void settingChanged(int) { settingsDirty = true; };
+ void settingChanged() { settingsDirty = true; }
+ void settingChanged(int) { settingsDirty = true; }
};
//*******************************************************************************************************
@@ -133,11 +141,11 @@ public:
FTNoIR_ProtocolDll();
~FTNoIR_ProtocolDll();
- void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); };
- void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); };
- void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); };
+ void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }
+ void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }
+ void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); }
- void getIcon(QIcon *icon) { *icon = QIcon(":/images/freetrack.png"); };
+ void getIcon(QIcon *icon) { *icon = QIcon(":/images/freetrack.png"); }
};
diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h
index e2e33c73..6b4f3978 100644
--- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h
+++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h
@@ -50,6 +50,9 @@ public:
bool checkServerInstallationOK();
void sendHeadposeToGame( double *headpose, double *rawheadpose );
void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars...
+ QString getGameName() {
+ return "UDP Tracker";
+ }
private:
QUdpSocket *outSocket; // Send to FaceTrackNoIR
diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h
index d4ad94d5..c33865ef 100644
--- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h
+++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h
@@ -93,7 +93,9 @@ private:
long scale2AnalogLimits( float x, float min_x, float max_x );
void loadSettings();
-
+ QString getGameName() {
+ return "Mouse tracker";
+ }
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -110,10 +112,10 @@ public:
void Initialize(QWidget *parent);
void registerProtocol(IProtocol *protocol) {
theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- };
+ }
void unRegisterProtocol() {
theProtocol = NULL; // Reset the pointer
- };
+ }
private:
Ui::UICMOUSEControls ui;
@@ -127,7 +129,7 @@ private:
private slots:
void doOK();
void doCancel();
- void settingChanged( int setting ) { settingsDirty = true; };
+ void settingChanged( int setting ) { settingsDirty = true; }
};
//*******************************************************************************************************
@@ -139,11 +141,11 @@ public:
FTNoIR_ProtocolDll();
~FTNoIR_ProtocolDll();
- void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); };
- void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); };
- void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); };
+ void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }
+ void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }
+ void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); }
- void getIcon(QIcon *icon) { *icon = QIcon(":/images/mouse.png"); };
+ void getIcon(QIcon *icon) { *icon = QIcon(":/images/mouse.png"); }
};
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
index 39c98ea7..9d2fb498 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
@@ -359,15 +359,6 @@ void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData
}
}
-//
-// Return a name, if present the name from the Game, that is connected...
-//
-void FTNoIR_Protocol::getNameFromGame( char *dest )
-{
- sprintf(dest, "Microsoft FSX");
- return;
-}
-
////////////////////////////////////////////////////////////////////////////////
// Factory function that creates instances if the Protocol object.
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h
index e9dcfbb2..f069aa9c 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h
@@ -86,7 +86,9 @@ public:
void Initialize() {}
bool checkServerInstallationOK();
void sendHeadposeToGame( double *headpose, double *rawheadpose );
- void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars...
+ QString getGameName() {
+ return "FS2004/FSX";
+ }
private:
// Private properties
@@ -139,10 +141,10 @@ public:
void Initialize(QWidget *parent);
void registerProtocol(IProtocol *protocol) {
theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- };
+ }
void unRegisterProtocol() {
theProtocol = NULL; // Reset the pointer
- };
+ }
private:
Ui::UICSCControls ui;
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
index 2f4e64e7..27b36c33 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
@@ -82,6 +82,8 @@ void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose
bool tmp1, tmp2;
CSV::getGameData(id_str, tmp1, tmp2, shm->table, gamename);
gameid = shm->gameid2 = shm->gameid;
+ QMutexLocker(&game_name_mutex);
+ connected_game = gamename;
}
lck_shm.unlock();
}
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h
index 8b3ea739..d9c37e27 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h
@@ -37,6 +37,7 @@
#include <QLibrary>
#include <QProcess>
#include <QDebug>
+#include <QMutexLocker>
#include <QFile>
#include "facetracknoir/global-settings.h"
#include "compat/compat.h"
@@ -59,6 +60,12 @@ private:
WineSHM* shm;
QProcess wrapper;
int gameid;
+ QString game_name;
+ QMutex game_name_mutex;
+ QString getGameName() {
+ QMutexLocker(&game_name_mutex);
+ return game_name;
+ }
};
// Widget that has controls for FTNoIR protocol client-settings.