From b3d3a1f1d4f9739a506990edefcd2d81502368d4 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Fri, 16 Nov 2012 12:00:53 +0000 Subject: Added registerProtocol and unRegisterProtocol to the Protocol classes. Now the Protocol Dialog can get data from the protocol, when the Tracker is running. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@192 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp | 20 ++++++++++---------- FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h | 13 ++++++++++--- .../ftnoir_protocol_MOUSE_dialog.cpp | 2 ++ 3 files changed, 22 insertions(+), 13 deletions(-) (limited to 'FTNoIR_Protocol_MOUSE') diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp index 7c75cd26..f81a38f7 100644 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp +++ b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp @@ -35,7 +35,7 @@ #include "ftnoir_protocol_mouse.h" /** constructor **/ -FTNoIR_Protocol_MOUSE::FTNoIR_Protocol_MOUSE() +FTNoIR_Protocol::FTNoIR_Protocol() { prev_fMouse_X = 0.0f; prev_fMouse_Y = 0.0f; @@ -46,17 +46,17 @@ FTNoIR_Protocol_MOUSE::FTNoIR_Protocol_MOUSE() } /** destructor **/ -FTNoIR_Protocol_MOUSE::~FTNoIR_Protocol_MOUSE() +FTNoIR_Protocol::~FTNoIR_Protocol() { } /** helper to Auto-destruct **/ -void FTNoIR_Protocol_MOUSE::Release() +void FTNoIR_Protocol::Release() { delete this; } -void FTNoIR_Protocol_MOUSE::Initialize() +void FTNoIR_Protocol::Initialize() { int ScreenX, ScreenY; @@ -71,7 +71,7 @@ int ScreenX, ScreenY; // // Scale the measured value to the Joystick values // -long FTNoIR_Protocol_MOUSE::scale2AnalogLimits( float x, float min_x, float max_x ) { +long FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { double y; y = ((MOUSE_AXIS_MAX - MOUSE_AXIS_MIN)/(max_x - min_x)) * x + ((MOUSE_AXIS_MAX - MOUSE_AXIS_MIN)/2) + MOUSE_AXIS_MIN; @@ -81,7 +81,7 @@ double y; // // Load the current Settings from the currently 'active' INI-file. // -void FTNoIR_Protocol_MOUSE::loadSettings() { +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(); @@ -105,7 +105,7 @@ void FTNoIR_Protocol_MOUSE::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol_MOUSE::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { float fMouse_X; // The actual value float fMouse_Y; float fMouse_Wheel; @@ -264,7 +264,7 @@ float fMouse_Wheel; // // Returns 'true' if all seems OK. // -bool FTNoIR_Protocol_MOUSE::checkServerInstallationOK( HANDLE handle ) +bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) { return true; @@ -273,7 +273,7 @@ bool FTNoIR_Protocol_MOUSE::checkServerInstallationOK( HANDLE handle ) // // Return a name, if present the name from the Game, that is connected... // -void FTNoIR_Protocol_MOUSE::getNameFromGame( char *dest ) +void FTNoIR_Protocol::getNameFromGame( char *dest ) { sprintf_s(dest, 99, "Mouse"); return; @@ -290,5 +290,5 @@ void FTNoIR_Protocol_MOUSE::getNameFromGame( char *dest ) FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() { - return new FTNoIR_Protocol_MOUSE; + return new FTNoIR_Protocol; } diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h index a7915780..b7765b96 100644 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h +++ b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h @@ -60,11 +60,11 @@ enum FTN_MouseStyle { }; -class FTNoIR_Protocol_MOUSE : public IProtocol +class FTNoIR_Protocol : public IProtocol { public: - FTNoIR_Protocol_MOUSE(); - ~FTNoIR_Protocol_MOUSE(); + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); void Release(); void Initialize(); @@ -108,6 +108,12 @@ public: void Release(); // Member functions which are accessible from outside the DLL 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; @@ -116,6 +122,7 @@ private: /** helper **/ bool settingsDirty; + FTNoIR_Protocol *theProtocol; private slots: void doOK(); diff --git a/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dialog.cpp b/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dialog.cpp index 75f96660..b8d7d7ee 100644 --- a/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dialog.cpp +++ b/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dialog.cpp @@ -88,6 +88,8 @@ QWidget() connect(ui.chkUseVirtualDesk, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + theProtocol = NULL; + // Load the settings from the current .INI-file loadSettings(); } -- cgit v1.2.3