From 75360443eb879b49a72c11b2a3d2d299ca61f9d7 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Fri, 28 Sep 2012 13:40:18 +0000 Subject: Modified sendHeadposeToGame, so it also sends raw data. Unified the code by adding the Dll class to the protocols and moving the dialog to a separate source. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@173 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h | 15 +- FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp | 34 - FTNoIR_Filter_Base/ftnoir_filter_base.h | 1 - FTNoIR_Filter_DZ1/FTNoIR_FilterControls.ui | 772 --------------------- FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.h | 147 ---- FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.vcproj | 377 ---------- FTNoIR_Filter_DZ1/Filter.qrc | 5 - FTNoIR_Filter_DZ1/ftnoir_filter_dz1.cpp | 251 ------- FTNoIR_Filter_DZ1/ftnoir_filter_dz1_dialog.cpp | 228 ------ FTNoIR_Filter_DZ1/images/filter-16.png | Bin 642 -> 0 bytes FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h | 12 +- FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp | 34 - FTNoIR_Protocol_Base/ftnoir_protocol_base.h | 32 +- FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp | 190 +---- FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h | 28 +- FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.vcproj | 8 + FTNoIR_Protocol_FG/ftnoir_protocol_fg_dialog.cpp | 223 ++++++ FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp | 56 ++ FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp | 164 +---- FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h | 28 +- .../FTNoIR_Protocol_FSUIPC.vcproj | 8 + .../ftnoir_protocol_FSUIPC_dialog.cpp | 195 ++++++ .../ftnoir_protocol_FSUIPC_dll.cpp | 56 ++ FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp | 144 +--- FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h | 28 +- FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.vcproj | 8 + FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp | 176 +++++ FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp | 56 ++ FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp | 158 +---- FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h | 27 +- FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.vcproj | 8 + .../ftnoir_protocol_FTIR_dialog.cpp | 190 +++++ FTNoIR_Protocol_FTIR/ftnoir_protocol_FTIR_dll.cpp | 56 ++ FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp | 160 +---- FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h | 27 +- FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.vcproj | 8 + FTNoIR_Protocol_FTN/ftnoir_protocol_FTN_dll.cpp | 56 ++ FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp | 192 +++++ FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp | 201 +----- FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h | 28 +- FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.vcproj | 8 + .../ftnoir_protocol_MOUSE_dialog.cpp | 233 +++++++ .../ftnoir_protocol_MOUSE_dll.cpp | 56 ++ FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.cpp | 156 +---- FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.h | 28 +- FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.vcproj | 8 + .../ftnoir_protocol_PPJOY_dialog.cpp | 189 +++++ .../ftnoir_protocol_PPJOY_dll.cpp | 56 ++ FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp | 127 +--- FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h | 27 +- FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj | 8 + FTNoIR_Protocol_SC/ftnoir_protocol_SC_dialog.cpp | 159 +++++ FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp | 56 ++ FaceTrackNoIR.sln | 5 + FaceTrackNoIR/FaceTrackNoIR.cpp | 23 +- FaceTrackNoIR/FaceTrackNoIR.h | 4 +- FaceTrackNoIR/tracker.cpp | 37 +- bin/Settings/ArmA.ini | 4 +- bin/Settings/GlovePIE.ini | 10 +- bin/Settings/SimConnect.ini | 67 +- 60 files changed, 2334 insertions(+), 3314 deletions(-) delete mode 100644 FTNoIR_Filter_DZ1/FTNoIR_FilterControls.ui delete mode 100644 FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.h delete mode 100644 FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.vcproj delete mode 100644 FTNoIR_Filter_DZ1/Filter.qrc delete mode 100644 FTNoIR_Filter_DZ1/ftnoir_filter_dz1.cpp delete mode 100644 FTNoIR_Filter_DZ1/ftnoir_filter_dz1_dialog.cpp delete mode 100644 FTNoIR_Filter_DZ1/images/filter-16.png create mode 100644 FTNoIR_Protocol_FG/ftnoir_protocol_fg_dialog.cpp create mode 100644 FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp create mode 100644 FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dialog.cpp create mode 100644 FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dll.cpp create mode 100644 FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp create mode 100644 FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp create mode 100644 FTNoIR_Protocol_FTIR/ftnoir_protocol_FTIR_dialog.cpp create mode 100644 FTNoIR_Protocol_FTIR/ftnoir_protocol_FTIR_dll.cpp create mode 100644 FTNoIR_Protocol_FTN/ftnoir_protocol_FTN_dll.cpp create mode 100644 FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp create mode 100644 FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dialog.cpp create mode 100644 FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dll.cpp create mode 100644 FTNoIR_Protocol_PPJOY/ftnoir_protocol_PPJOY_dialog.cpp create mode 100644 FTNoIR_Protocol_PPJOY/ftnoir_protocol_PPJOY_dll.cpp create mode 100644 FTNoIR_Protocol_SC/ftnoir_protocol_SC_dialog.cpp create mode 100644 FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp diff --git a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h b/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h index 742b4d1e..0a57eb88 100644 --- a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h +++ b/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h @@ -135,18 +135,11 @@ public: FTNoIR_FilterDll(); ~FTNoIR_FilterDll(); - void Release(); - void Initialize(); + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk2"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk2"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk2"); }; - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); - -private: - QString filterFullName; // Filters' name and description - QString filterShortName; - QString filterDescription; + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); }; }; diff --git a/FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp b/FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp index ccd1aaae..e1452bf2 100644 --- a/FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp +++ b/FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp @@ -34,10 +34,6 @@ #include FTNoIR_FilterDll::FTNoIR_FilterDll() { - //populate the description strings - filterFullName = "Accela Filter Mk2"; - filterShortName = "Accela Mk2"; - filterDescription = "Accela filter Mk2"; } FTNoIR_FilterDll::~FTNoIR_FilterDll() @@ -45,36 +41,6 @@ FTNoIR_FilterDll::~FTNoIR_FilterDll() } -void FTNoIR_FilterDll::Release() -{ - delete this; -} - -void FTNoIR_FilterDll::Initialize() -{ - return; -} - -void FTNoIR_FilterDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = filterFullName; -}; - -void FTNoIR_FilterDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = filterShortName; -}; - -void FTNoIR_FilterDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = filterDescription; -}; - -void FTNoIR_FilterDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/filter-16.png"); -}; - //////////////////////////////////////////////////////////////////////////////// // Factory function that creates instances if the Filter object. diff --git a/FTNoIR_Filter_Base/ftnoir_filter_base.h b/FTNoIR_Filter_Base/ftnoir_filter_base.h index 71d2faf0..44ce3d72 100644 --- a/FTNoIR_Filter_Base/ftnoir_filter_base.h +++ b/FTNoIR_Filter_Base/ftnoir_filter_base.h @@ -71,7 +71,6 @@ GetFilterDialog(void); struct IFilterDll { virtual ~IFilterDll() {} - virtual void Initialize() = 0; virtual void getFullName(QString *strToBeFilled) = 0; virtual void getShortName(QString *strToBeFilled) = 0; diff --git a/FTNoIR_Filter_DZ1/FTNoIR_FilterControls.ui b/FTNoIR_Filter_DZ1/FTNoIR_FilterControls.ui deleted file mode 100644 index 7de21537..00000000 --- a/FTNoIR_Filter_DZ1/FTNoIR_FilterControls.ui +++ /dev/null @@ -1,772 +0,0 @@ - - - UICFilterControls - - - - 0 - 0 - 411 - 366 - - - - DZ1 Filter settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - - 0 - 45 - - - - General Settings - - - - - 10 - 10 - 371 - 31 - - - - - - - - 123 - 0 - - - - - 120 - 16777215 - - - - - - - Camera frequency - - - - - - - - 45 - 15 - - - - 5 - - - 200 - - - 5 - - - 10 - - - 30 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - - - - - - 50 - 22 - - - - background:none; - - - 5 - - - 200 - - - 5 - - - 30 - - - - - - - - 35 - 0 - - - - - 30 - 16777215 - - - - - - - Hz - - - - - - - - - - - - 0 - 90 - - - - High sensitivity settings - - - - - 10 - 10 - 371 - 61 - - - - - - - - 90 - 0 - - - - - 110 - 16777215 - - - - - - - Deadzone - - - - - - - - 35 - 0 - - - - - 100 - 16777215 - - - - - - - degrees - - - - - - - - 110 - 0 - - - - - 130 - 16777215 - - - - - - - Move toward last position - - - - - - - - 45 - 15 - - - - 1 - - - 100 - - - 5 - - - 10 - - - 24 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - - - - - - 40 - 22 - - - - background:none; - - - 1 - - - 100 - - - 5 - - - 24 - - - - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - - - - % - - - - - - - - 50 - 0 - - - - 10.000000000000000 - - - 0.100000000000000 - - - 0.240000000000000 - - - - - - - - - - - - 0 - 90 - - - - Low sensitivity settings - - - - - 10 - 10 - 371 - 61 - - - - - - - - 90 - 0 - - - - - 110 - 16777215 - - - - - - - Maximum difference - - - - - - - - 35 - 0 - - - - - 100 - 16777215 - - - - - - - degrees - - - - - - - - 123 - 0 - - - - - 130 - 16777215 - - - - - - - Move toward saved pos. - - - - - - - - 45 - 15 - - - - 1 - - - 100 - - - 5 - - - 10 - - - 35 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - - - - - - 40 - 22 - - - - background:none; - - - 1 - - - 100 - - - 5 - - - 35 - - - - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - - - - % - - - - - - - - 50 - 0 - - - - 10.000000000000000 - - - 0.100000000000000 - - - 1.750000000000000 - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - The filter-settings may need some explanation... - - - - - - - Maybe Stanislaw can make one in laymans terms? - - - true - - - - - - - ... - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 52 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 52 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - btnOK - btnCancel - - - - - slideHz - valueChanged(int) - spinHz - setValue(int) - - - 291 - 45 - - - 347 - 44 - - - - - spinHz - valueChanged(int) - slideHz - setValue(int) - - - 347 - 44 - - - 291 - 45 - - - - - slideMoveLast - valueChanged(int) - spinMoveLast - setValue(int) - - - 287 - 126 - - - 343 - 125 - - - - - spinMoveLast - valueChanged(int) - slideMoveLast - setValue(int) - - - 343 - 125 - - - 287 - 126 - - - - - slideMoveSaved - valueChanged(int) - spinMoveSaved - setValue(int) - - - 202 - 213 - - - 312 - 212 - - - - - spinMoveSaved - valueChanged(int) - slideMoveSaved - setValue(int) - - - 309 - 203 - - - 260 - 203 - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.h b/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.h deleted file mode 100644 index 35a5fcb6..00000000 --- a/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.h +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTN_FILTER_H -#define INCLUDED_FTN_FILTER_H - -#include "..\ftnoir_filter_base\ftnoir_filter_base.h" -#include "ui_FTNoIR_FilterControls.h" - -static int compare_double(const void *one, const void *two) { - double foo = (*((double*) one) - *((double*) two)); - if (foo > 0) - return 1; - if (foo < 0) - return -1; - return 0; -} - -//#define HZ 30 - -//#define DEADZONE 0.1 -//#define MOVE_LAST 0.24 -//#define MOVE_SAVED (0.35 / HZ) -#define SLOW_SPEED 0.1 - -//#define MAXDIFF 1.75 -#define INITIAL_SMOOTH_SPEED 0.00834 -#define SMOOTH_FACTOR 2.5 -#define REMEMBER_SMOOTHNESS 5 // Changed from HZ/5 - -#define MULT_Y_POS 1.7 -#define MULT_Y_NEG 0.8 -#define MULT_X 1.5 - -#define COCKPIT_PITCH 8.7 - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// DZ1 Filter: Stanislaw wrote a new filter, which makes the view more stable, when not moving your face. -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class FTNoIR_Filter : public IFilter -{ -public: - FTNoIR_Filter(); - ~FTNoIR_Filter(); - - void Release(); - void Initialize(); - void StartFilter(); - void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget); - - void getFilterFullName(QString *strToBeFilled); - void getFilterShortName(QString *strToBeFilled); - void getFilterDescription(QString *strToBeFilled); - -private: - void loadSettings(); // Load the settings from the INI-file - THeadPoseData newHeadPose; // Structure with new headpose - - bool first_run; - double last_positions[6]; - double saved_positions[6]; - double prev_positions[6]; - bool smoothing[6]; - double smooth_start[6]; - double smooth_speed[6]; - int smooth_remember[6]; - - float kCameraHz; // Hz - float kDeadZone; // degrees - float kMoveLast; // % - float kMaxDiff; // degrees - float kMoveSaved; // % - - QString filterFullName; // Filters' name and description - QString filterShortName; - QString filterDescription; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* - -// Widget that has controls for FTNoIR protocol filter-settings. -class FilterControls: public QWidget, Ui::UICFilterControls, public IFilterDialog -{ - Q_OBJECT -public: - - explicit FilterControls(); - virtual ~FilterControls(); - void showEvent ( QShowEvent * event ); - - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent, IFilterPtr ptr); - void getFilterFullName(QString *strToBeFilled); - void getFilterShortName(QString *strToBeFilled); - void getFilterDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); - -private: - Ui::UICFilterControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - - QString filterFullName; // Filters' name and description - QString filterShortName; - QString filterDescription; - IFilterPtr pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void settingChanged( int ) { settingsDirty = true; }; - void settingChanged( double ) { settingsDirty = true; }; -}; - -#endif //INCLUDED_FTN_FILTER_H -//END - diff --git a/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.vcproj b/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.vcproj deleted file mode 100644 index a09aa9bd..00000000 --- a/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.vcproj +++ /dev/null @@ -1,377 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Filter_DZ1/Filter.qrc b/FTNoIR_Filter_DZ1/Filter.qrc deleted file mode 100644 index e64ec35a..00000000 --- a/FTNoIR_Filter_DZ1/Filter.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/filter-16.png - - diff --git a/FTNoIR_Filter_DZ1/ftnoir_filter_dz1.cpp b/FTNoIR_Filter_DZ1/ftnoir_filter_dz1.cpp deleted file mode 100644 index ce1b4063..00000000 --- a/FTNoIR_Filter_DZ1/ftnoir_filter_dz1.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_filter_DZ1.h" -#include "math.h" -#include - -//#define LOG_OUTPUT - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -FTNoIR_Filter::FTNoIR_Filter() -{ - //populate the description strings - filterFullName = "Deadzone Filter Mk1"; - filterShortName = "DZ1"; - filterDescription = "Deadzone Filter"; - - first_run = true; - loadSettings(); // Load the Settings - -} - -FTNoIR_Filter::~FTNoIR_Filter() -{ - -} - -void FTNoIR_Filter::Release() -{ - delete this; -} - -void FTNoIR_Filter::Initialize() -{ - qDebug() << "FTNoIR_Filter::Initialize says: Starting "; - loadSettings(); - return; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Filter::loadSettings() { - qDebug() << "FTNoIR_Filter::loadSettings says: Starting "; - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - qDebug() << "FTNoIR_Filter::loadSettings says: iniFile = " << currentFile; - - // - // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR - // - iniFile.beginGroup ( "Filter_DZ1" ); - kCameraHz = iniFile.value ( "cameraHz", 30 ).toInt(); - kDeadZone = iniFile.value ( "DeadZone", 0.1f ).toFloat(); - kMoveLast = (iniFile.value ( "MoveLast", 24 ).toFloat()) / 100; // Convert from int to float percentage - kMaxDiff = iniFile.value ( "MaxDiff", 1.75f ).toFloat(); - kMoveSaved = ((iniFile.value ( "MoveSaved", 35 ).toFloat()) / 100) / kCameraHz; // Convert from int to float percentage and divide by Hz - iniFile.endGroup (); - -} - -void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) -{ - //non-optimised version for clarity - double target[6]; - double prev_output[6]; - double scale[]={3.0, 3.0, 3.0, 3.0, 3.0, 3.0}; -// static double deadzones[] = { DEADZONE, DEADZONE, DEADZONE, DEADZONE, DEADZONE, DEADZONE }; - float output[6]; - int i=0, j=0; - - //find out how far the head has moved - prev_output[0]=current_camera_position->x; - prev_output[1]=current_camera_position->y; - prev_output[2]=current_camera_position->z; - prev_output[3]=current_camera_position->yaw; - prev_output[4]=current_camera_position->pitch; - prev_output[5]=current_camera_position->roll; - - target[0]=target_camera_position->x; - target[1]=target_camera_position->y; - target[2]=target_camera_position->z; - target[3]=target_camera_position->yaw; - target[4]=target_camera_position->pitch; - target[5]=target_camera_position->roll; - - if (first_run) - { - //on the first run, output=target - for (i=0;i<6;i++) - { - last_positions[i] = target[i]; - saved_positions[i] = target[i]; - prev_positions[i] = target[i]; - smooth_remember[i] = 0; - smoothing[i] = false; - smooth_speed[i] = -1.0; - } - - new_camera_position->x=target[0]; - new_camera_position->y=target[1]; - new_camera_position->z=target[2]; - new_camera_position->yaw=target[3]; - new_camera_position->pitch=target[4]; - new_camera_position->roll=target[5]; - - first_run=false; - - //we can bail - return; - } else if (!newTarget) { - int i; - for (i = 0; i < 6; i++) { - output[i] = prev_positions[i]; - } - goto end; - } - - for (i=0;i<6;i++) - { - double e2 = target[i]; - bool slowp = fabs(last_positions[i] - e2) < kDeadZone && fabs(e2 - saved_positions[i]) < kMaxDiff; // DeadZone and MAXDIFF from INI-file - if (smoothing[i] || !slowp) { - double start = smooth_start[i]; - double vec = e2 - start; - int sign = vec < 0 ? -1 : 1; - int sign2 = e2 < 0 ? -1 : 1; - if (sign != sign2) - sign2 = -sign2; - double diff = (kCameraHz / REMEMBER_SMOOTHNESS) - smooth_remember[i]; - smooth_speed[i] *= -(diff * diff) / (double) ((kCameraHz / REMEMBER_SMOOTHNESS) * (kCameraHz / REMEMBER_SMOOTHNESS)) + 1.001; - if (smooth_speed[i] < INITIAL_SMOOTH_SPEED) - smooth_speed[i] = INITIAL_SMOOTH_SPEED; - vec = fabs(vec); - double iter = vec * SMOOTH_FACTOR / (double) kCameraHz; - smooth_speed[i] += iter; - double bleh = smooth_speed[i] * sign; - double foo = smooth_start[i] + bleh; - bool done = sign2 > 0 ? foo > e2 : foo < e2; - smooth_remember[i] = (kCameraHz / REMEMBER_SMOOTHNESS); - if (done) { - smoothing[i] = false; - output[i] = e2; - saved_positions[i] = e2; - last_positions[i] = e2; - prev_positions[i] = e2; - } else { - smoothing[i] = true; - prev_positions[i] = output[i] = foo; - } - } else { - if (smooth_remember[i] <= 0) { - smooth_speed[i] = -1.0; - } else { - smooth_remember[i]--; - } - last_positions[i] = last_positions[i] + (e2 - last_positions[i]) * kMoveLast; // MOVE_LAST from INI-file - saved_positions[i] = saved_positions[i] + (e2 - saved_positions[i]) * kMoveSaved; // MOVE_SAVED from INI-file - output[i] = prev_positions[i] = prev_positions[i] + (e2 - prev_positions[i]) * (SLOW_SPEED/kCameraHz); // Get CameraHz from INI - smooth_start[i] = output[i]; - smoothing[i] = false; -#if 0 - if (i == 3) { - FILE* dlog = fopen("debug-log.txt", "a"); - fprintf(dlog, "slowed=%f frames=%d diff=%f\n", output[i], slow_move_count[i], e1 - last_positions[i]); - fclose(dlog); - } -#endif - } - } - -end: - new_camera_position->x=output[0]; - new_camera_position->y=output[1]; - new_camera_position->z=output[2]; - new_camera_position->yaw=output[3] * MULT_X; - new_camera_position->pitch=output[4] * (output[4] < 0 ? MULT_Y_NEG : MULT_Y_POS) - COCKPIT_PITCH; - new_camera_position->roll=output[5]; - -#if 1 - // - // Also update the 'current' position, for the next iteration. - // - current_camera_position->x=output[0]; - current_camera_position->y=output[1]; - current_camera_position->z=output[2]; - current_camera_position->yaw=output[3] * MULT_X; - current_camera_position->pitch=output[4] * (output[4] < 0 ? MULT_Y_NEG : MULT_Y_POS) + COCKPIT_PITCH; - current_camera_position->roll=output[5]; -#endif -} - -void FTNoIR_Filter::getFilterFullName(QString *strToBeFilled) -{ - *strToBeFilled = filterFullName; -}; - - -void FTNoIR_Filter::getFilterShortName(QString *strToBeFilled) -{ - *strToBeFilled = filterShortName; -}; - - -void FTNoIR_Filter::getFilterDescription(QString *strToBeFilled) -{ - *strToBeFilled = filterDescription; -}; - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter object. - -// Export both decorated and undecorated names. -// GetFilter - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilter@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetFilter=_GetFilter@0") - -FTNOIR_FILTER_BASE_EXPORT FILTERHANDLE __stdcall GetFilter() -{ - return new FTNoIR_Filter; -} diff --git a/FTNoIR_Filter_DZ1/ftnoir_filter_dz1_dialog.cpp b/FTNoIR_Filter_DZ1/ftnoir_filter_dz1_dialog.cpp deleted file mode 100644 index 88b4b04b..00000000 --- a/FTNoIR_Filter_DZ1/ftnoir_filter_dz1_dialog.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_filter_DZ1.h" -#include "math.h" -#include - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* -// -// Constructor for server-settings-dialog -// -FilterControls::FilterControls() : -QWidget() -{ - ui.setupUi( this ); - - //populate the description strings - filterFullName = "Deadzone Filter Mk1"; - filterShortName = "DZ1"; - filterDescription = "Deadzone Filter"; - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - // Connect sliders for reduction factor - connect(ui.slideHz, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.spinDeadZone, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.slideMoveLast, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - - qDebug() << "FilterControls() says: started"; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FilterControls::~FilterControls() { - qDebug() << "~FilterControls() says: started"; -} - -void FilterControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FilterControls::Initialize(QWidget *parent, IFilterPtr ptr) { - - // - // The dialog can be opened, while the Tracker is running. - // In that case, ptr will point to the active Filter-instance. - // This can be used to update settings, while Tracking and may also be handy to display logging-data and such... - // - pFilter = ptr; - - // - // - // - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FilterControls::doOK() { - save(); - if (pFilter) { - pFilter->Initialize(); - } - this->close(); -} - -// override show event -void FilterControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FilterControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FilterControls::loadSettings() { - qDebug() << "FilterControls::loadSettings says: Starting "; - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - qDebug() << "FilterControls::loadSettings says: iniFile = " << currentFile; - - // - // The DZ1-filter-settings - // - iniFile.beginGroup ( "Filter_DZ1" ); - ui.slideHz->setValue (iniFile.value ( "cameraHz", 30 ).toInt()); - ui.spinDeadZone->setValue (iniFile.value ( "DeadZone", 0.1f ).toDouble()); - ui.slideMoveLast->setValue (iniFile.value ( "MoveLast", 24 ).toInt()); - ui.spinMaxDiff->setValue (iniFile.value ( "MaxDiff", 1.75f ).toDouble()); - ui.slideMoveSaved->setValue (iniFile.value ( "MoveSaved", 35 ).toFloat()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FilterControls::save() { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "Filter_DZ1" ); - iniFile.setValue ( "cameraHz", ui.slideHz->value() ); - iniFile.setValue ( "DeadZone", ui.spinDeadZone->value() ); - iniFile.setValue ( "MoveLast", ui.slideMoveLast->value() ); - iniFile.setValue ( "MaxDiff", ui.spinMaxDiff->value() ); - iniFile.setValue ( "MoveSaved", ui.slideMoveSaved->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -void FilterControls::getFilterFullName(QString *strToBeFilled) -{ - *strToBeFilled = filterFullName; -}; - - -void FilterControls::getFilterShortName(QString *strToBeFilled) -{ - *strToBeFilled = filterShortName; -}; - - -void FilterControls::getFilterDescription(QString *strToBeFilled) -{ - *strToBeFilled = filterDescription; -}; - -void FilterControls::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/filter-16.png"); -}; - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter-settings dialog object. - -// Export both decorated and undecorated names. -// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") - -FTNOIR_FILTER_BASE_EXPORT FILTERDIALOGHANDLE __stdcall GetFilterDialog( ) -{ - return new FilterControls; -} diff --git a/FTNoIR_Filter_DZ1/images/filter-16.png b/FTNoIR_Filter_DZ1/images/filter-16.png deleted file mode 100644 index ecde6a10..00000000 Binary files a/FTNoIR_Filter_DZ1/images/filter-16.png and /dev/null differ diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h index f313d154..18afe3bd 100644 --- a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h +++ b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h @@ -107,15 +107,11 @@ public: void Release(); void Initialize(); - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA Filter Mk2"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Exponentially Weighted Moving Average filter with dynamic smoothing parameter"); }; -private: - QString filterFullName; // Filters' name and description - QString filterShortName; - QString filterDescription; + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); }; }; #endif //INCLUDED_FTN_FILTER_H diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp index c9867f1b..4e644446 100644 --- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp +++ b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp @@ -34,10 +34,6 @@ #include FTNoIR_FilterDll::FTNoIR_FilterDll() { - //populate the description strings - filterFullName = "EWMA Filter Mk2"; - filterShortName = "EWMA"; - filterDescription = "Exponentially Weighted Moving Average filter with dynamic smoothing parameter"; } FTNoIR_FilterDll::~FTNoIR_FilterDll() @@ -45,36 +41,6 @@ FTNoIR_FilterDll::~FTNoIR_FilterDll() } -void FTNoIR_FilterDll::Release() -{ - delete this; -} - -void FTNoIR_FilterDll::Initialize() -{ - return; -} - -void FTNoIR_FilterDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = filterFullName; -}; - -void FTNoIR_FilterDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = filterShortName; -}; - -void FTNoIR_FilterDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = filterDescription; -}; - -void FTNoIR_FilterDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/filter-16.png"); -}; - //////////////////////////////////////////////////////////////////////////////// // Factory function that creates instances if the Filter object. diff --git a/FTNoIR_Protocol_Base/ftnoir_protocol_base.h b/FTNoIR_Protocol_Base/ftnoir_protocol_base.h index 76f5ecc7..214aae7f 100644 --- a/FTNoIR_Protocol_Base/ftnoir_protocol_base.h +++ b/FTNoIR_Protocol_Base/ftnoir_protocol_base.h @@ -58,12 +58,8 @@ struct IProtocol virtual ~IProtocol() {} virtual void Initialize() = 0; virtual bool checkServerInstallationOK ( HANDLE handle ) = 0; - virtual void sendHeadposeToGame( THeadPoseData *headpose ) = 0; + virtual void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) = 0; virtual void getNameFromGame( char *dest ) = 0; // Take care dest can handle up to 100 chars... - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; }; typedef IProtocol* IProtocolPtr; @@ -85,6 +81,26 @@ struct IProtocolDialog { virtual ~IProtocolDialog() {} virtual void Initialize(QWidget *parent) = 0; +}; + +typedef IProtocolDialog* IProtocolDialogPtr; + +// Factory function that creates instances of the Protocol object. +EXTERN_C +FTNOIR_PROTOCOL_BASE_EXPORT +IProtocolDialogPtr +__stdcall +GetProtocolDialog(void); + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct IProtocolDll +{ + virtual ~IProtocolDll() {} virtual void getFullName(QString *strToBeFilled) = 0; virtual void getShortName(QString *strToBeFilled) = 0; @@ -92,14 +108,14 @@ struct IProtocolDialog virtual void getIcon(QIcon *icon) = 0; }; -typedef IProtocolDialog* IProtocolDialogPtr; +typedef IProtocolDll* IProtocolDllPtr; // Factory function that creates instances of the Protocol object. EXTERN_C FTNOIR_PROTOCOL_BASE_EXPORT -IProtocolDialogPtr +IProtocolDllPtr __stdcall -GetProtocolDialog(void); +GetProtocolDll(void); #endif // FTNOIR_PROTOCOL_BASE_H diff --git a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp index 9234c4d4..0eba8333 100644 --- a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp +++ b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp @@ -97,7 +97,7 @@ void FTNoIR_Protocol_FG::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol_FG::sendHeadposeToGame( THeadPoseData *headpose ) { +void FTNoIR_Protocol_FG::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { int no_bytes; QHostAddress sender; quint16 senderPort; @@ -243,191 +243,3 @@ FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() { return new FTNoIR_Protocol_FG; } - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FGControls::FGControls() : -QWidget() -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.chkLocalPC, SIGNAL(stateChanged(int)), this, SLOT(chkLocalPCOnlyChanged())); - connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FGControls::~FGControls() { - qDebug() << "~FGControls() says: started"; -} - -void FGControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FGControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FGControls::doOK() { - save(); - this->close(); -} - -// override show event -void FGControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FGControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FGControls::loadSettings() { -// qDebug() << "loadSettings says: Starting "; - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - -// qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FG" ); - ui.chkLocalPC->setChecked (iniFile.value ( "LocalPCOnly", 1 ).toBool()); - - ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); - ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); - ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); - ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); - iniFile.endGroup (); - - chkLocalPCOnlyChanged(); - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FGControls::save() { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "FG" ); - iniFile.setValue ( "LocalPCOnly", ui.chkLocalPC->isChecked() ); - iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); - iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); - iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); - iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); - iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Handle change of the checkbox. -// -void FGControls::chkLocalPCOnlyChanged() { - - if ( ui.chkLocalPC->isChecked() ) { - ui.spinIPFirstNibble->setValue( 127 ); - ui.spinIPFirstNibble->setEnabled ( false ); - ui.spinIPSecondNibble->setValue( 0 ); - ui.spinIPSecondNibble->setEnabled ( false ); - ui.spinIPThirdNibble->setValue( 0 ); - ui.spinIPThirdNibble->setEnabled ( false ); - ui.spinIPFourthNibble->setValue( 1 ); - ui.spinIPFourthNibble->setEnabled ( false ); - } - else { - ui.spinIPFirstNibble->setEnabled ( true ); - ui.spinIPSecondNibble->setEnabled ( true ); - ui.spinIPThirdNibble->setEnabled ( true ); - ui.spinIPFourthNibble->setEnabled ( true ); - } - - settingsDirty = true; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new FGControls; -} diff --git a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h index ff3be6bd..b836d321 100644 --- a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h +++ b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h @@ -49,13 +49,9 @@ public: void Initialize(); bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear UDP protocol"); }; - private: // Tracker *headTracker; // For upstream messages... TFlightGearData FlightData; @@ -82,11 +78,6 @@ public: void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); - 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.ico"); }; - private: Ui::UICFGControls ui; void loadSettings(); @@ -102,5 +93,22 @@ private slots: void settingChanged() { settingsDirty = true; }; }; +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +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 getIcon(QIcon *icon) { *icon = QIcon(":/images/FlightGear.ico"); }; +}; + + #endif//INCLUDED_FGSERVER_H //END diff --git a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.vcproj b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.vcproj index 9e34aa64..c37903ad 100644 --- a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.vcproj +++ b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.vcproj @@ -171,6 +171,14 @@ RelativePath=".\ftnoir_Protocol_FG.cpp" > + + + + . * +* * +* FGServer FGServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +/* + Modifications (last one on top): + 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp +*/ +#include "ftnoir_protocol_fg.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FGControls::FGControls() : +QWidget() +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + //if (parent) { + // this->move(parent->pos() + offsetpos); + //} + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.chkLocalPC, SIGNAL(stateChanged(int)), this, SLOT(chkLocalPCOnlyChanged())); + connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FGControls::~FGControls() { + qDebug() << "~FGControls() says: started"; +} + +void FGControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FGControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FGControls::doOK() { + save(); + this->close(); +} + +// override show event +void FGControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FGControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FGControls::loadSettings() { +// qDebug() << "loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) + +// qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "FG" ); + ui.chkLocalPC->setChecked (iniFile.value ( "LocalPCOnly", 1 ).toBool()); + + ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); + ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); + ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); + ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); + + ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); + iniFile.endGroup (); + + chkLocalPCOnlyChanged(); + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FGControls::save() { + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "FG" ); + iniFile.setValue ( "LocalPCOnly", ui.chkLocalPC->isChecked() ); + iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); + iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); + iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); + iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); + iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Handle change of the checkbox. +// +void FGControls::chkLocalPCOnlyChanged() { + + if ( ui.chkLocalPC->isChecked() ) { + ui.spinIPFirstNibble->setValue( 127 ); + ui.spinIPFirstNibble->setEnabled ( false ); + ui.spinIPSecondNibble->setValue( 0 ); + ui.spinIPSecondNibble->setEnabled ( false ); + ui.spinIPThirdNibble->setValue( 0 ); + ui.spinIPThirdNibble->setEnabled ( false ); + ui.spinIPFourthNibble->setValue( 1 ); + ui.spinIPFourthNibble->setEnabled ( false ); + } + else { + ui.spinIPFirstNibble->setEnabled ( true ); + ui.spinIPSecondNibble->setEnabled ( true ); + ui.spinIPThirdNibble->setEnabled ( true ); + ui.spinIPFourthNibble->setEnabled ( true ); + } + + settingsDirty = true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new FGControls; +} \ No newline at end of file diff --git a/FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp b/FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp new file mode 100644 index 00000000..ca71063b --- /dev/null +++ b/FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_fg.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp index c88e7ec0..9bada9da 100644 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp +++ b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp @@ -103,7 +103,7 @@ void FTNoIR_Protocol_FSUIPC::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol_FSUIPC::sendHeadposeToGame( THeadPoseData *headpose ) { +void FTNoIR_Protocol_FSUIPC::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { DWORD result; TFSState pitch; TFSState yaw; @@ -228,165 +228,3 @@ FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() { return new FTNoIR_Protocol_FSUIPC; } - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -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())); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FSUIPCControls::~FSUIPCControls() { - qDebug() << "~FSUIPCControls() says: started"; -} - -void FSUIPCControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FSUIPCControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FSUIPCControls::doOK() { - save(); - this->close(); -} - -// override show event -void FSUIPCControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FSUIPCControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FSUIPCControls::loadSettings() { - - qDebug() << "loadSettings says: Starting "; - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FSUIPC" ); - ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FSUIPCControls::save() { - - qDebug() << "save() says: started"; - - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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" ); - iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Show the Dialog to set the DLL's location -// -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 (*)")); - if (!fileName.isEmpty()) { - ui.txtLocationOfDLL->setText( fileName ); - settingsDirty = true; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new FSUIPCControls; -} diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h index 15ef9209..d073c823 100644 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h +++ b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h @@ -65,13 +65,9 @@ public: void Initialize(); bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); }; - private: // Private properties QString ProgramName; @@ -96,11 +92,6 @@ public: void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); }; - void getIcon(QIcon *icon) { *icon = QIcon(":/images/FS9.ico"); }; - private: Ui::UICFSUIPCControls ui; void loadSettings(); @@ -116,5 +107,22 @@ private slots: void getLocationOfDLL(); }; +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/FS9.ico"); }; +}; + + #endif//INCLUDED_FSUIPCSERVER_H //END diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.vcproj b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.vcproj index 9722f354..57466728 100644 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.vcproj +++ b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.vcproj @@ -172,6 +172,14 @@ RelativePath=".\ftnoir_Protocol_FSUIPC.cpp" > + + + + . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_fsuipc.h" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +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())); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FSUIPCControls::~FSUIPCControls() { + qDebug() << "~FSUIPCControls() says: started"; +} + +void FSUIPCControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FSUIPCControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FSUIPCControls::doOK() { + save(); + this->close(); +} + +// override show event +void FSUIPCControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FSUIPCControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FSUIPCControls::loadSettings() { + + qDebug() << "loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) + + qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "FSUIPC" ); + ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FSUIPCControls::save() { + + qDebug() << "save() says: started"; + + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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" ); + iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Show the Dialog to set the DLL's location +// +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 (*)")); + if (!fileName.isEmpty()) { + ui.txtLocationOfDLL->setText( fileName ); + settingsDirty = true; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new FSUIPCControls; +} diff --git a/FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dll.cpp b/FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dll.cpp new file mode 100644 index 00000000..d61c2d83 --- /dev/null +++ b/FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_fsuipc.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp index f4018c2e..ad532120 100644 --- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp +++ b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp @@ -78,7 +78,7 @@ void FTNoIR_Protocol_FT::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol_FT::sendHeadposeToGame( THeadPoseData *headpose ) { +void FTNoIR_Protocol_FT::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { float virtPosX; float virtPosY; float virtPosZ; @@ -338,145 +338,3 @@ FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() { return new FTNoIR_Protocol_FT; } - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FTControls::FTControls() : -QWidget() -{ - QString aFileName; // File Path and Name - - 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.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(chkTIRViewsChanged())); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FTControls::~FTControls() { - qDebug() << "~FTControls() says: started"; -} - -void FTControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FTControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FTControls::doOK() { - save(); - this->close(); -} - -// override show event -void FTControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FTControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTControls::loadSettings() { - qDebug() << "loadSettings says: Starting "; - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FT" ); -// ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FTControls::save() { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "FT" ); -// iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new FTControls; -} diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h index 736b8600..f6daa226 100644 --- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h +++ b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h @@ -52,13 +52,9 @@ public: void Initialize(); bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack protocol"); }; - private: bool FTCreateMapping(HANDLE handle); void FTDestroyMapping(); @@ -92,11 +88,6 @@ public: void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack protocol"); }; - void getIcon(QIcon *icon) { *icon = QIcon(":/images/Freetrack.ico"); }; - private: Ui::UICFTControls ui; void loadSettings(); @@ -111,5 +102,22 @@ private slots: void settingChanged() { settingsDirty = true; }; }; +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/Freetrack.ico"); }; +}; + + #endif//INCLUDED_FTSERVER_H //END diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.vcproj b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.vcproj index 80fcdfed..9a11270a 100644 --- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.vcproj +++ b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.vcproj @@ -171,6 +171,14 @@ RelativePath=".\ftnoir_Protocol_FT.cpp" > + + + + . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ft.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FTControls::FTControls() : +QWidget() +{ + QString aFileName; // File Path and Name + + 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.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(chkTIRViewsChanged())); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FTControls::~FTControls() { + qDebug() << "~FTControls() says: started"; +} + +void FTControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FTControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FTControls::doOK() { + save(); + this->close(); +} + +// override show event +void FTControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FTControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTControls::loadSettings() { + qDebug() << "loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) + + qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "FT" ); +// ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FTControls::save() { + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "FT" ); +// iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new FTControls; +} diff --git a/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp b/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp new file mode 100644 index 00000000..4513c6ba --- /dev/null +++ b/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ft.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp index 0c8b2fbf..f3585b0e 100644 --- a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp +++ b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp @@ -124,7 +124,7 @@ void FTNoIR_Protocol_FTIR::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol_FTIR::sendHeadposeToGame( THeadPoseData *headpose ) { +void FTNoIR_Protocol_FTIR::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { float virtPosX; float virtPosY; float virtPosZ; @@ -399,159 +399,3 @@ FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() { return new FTNoIR_Protocol_FTIR; } - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FTIRControls::FTIRControls() : -QWidget() -{ - QString aFileName; // File Path and Name - - 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.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(chkTIRViewsChanged())); - connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); - - aFileName = QCoreApplication::applicationDirPath() + "/"; - aFileName.append(FTIR_VIEWS_FILENAME); - if ( !QFile::exists( aFileName ) ) { - ui.chkTIRViews->setChecked( false ); - ui.chkTIRViews->setEnabled ( false ); - } - else { - ui.chkTIRViews->setEnabled ( true ); - } - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FTIRControls::~FTIRControls() { - qDebug() << "~FTIRControls() says: started"; -} - -void FTIRControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FTIRControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FTIRControls::doOK() { - save(); - this->close(); -} - -// override show event -void FTIRControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FTIRControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTIRControls::loadSettings() { - qDebug() << "loadSettings says: Starting "; - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FTIR" ); - ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); - ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 1 ).toBool()); - - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FTIRControls::save() { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "FTIR" ); - iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() ); - iniFile.setValue ( "useDummyExe", ui.chkStartDummy->isChecked() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new FTIRControls; -} diff --git a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h index 7478f405..951a2fa8 100644 --- a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h +++ b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h @@ -56,13 +56,9 @@ public: void Initialize(); bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("fake TrackIR"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTIR"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("TrackIR V4 protocol"); }; - private: bool FTIRCreateMapping(HANDLE handle); void FTIRDestroyMapping(); @@ -102,11 +98,6 @@ public: void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("fake TrackIR"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTIR"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("TrackIR V4 protocol"); }; - void getIcon(QIcon *icon) { *icon = QIcon(":/images/TrackIR.ico"); }; - private: Ui::UICFTIRControls ui; void loadSettings(); @@ -122,5 +113,21 @@ private slots: void settingChanged() { settingsDirty = true; }; }; +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("fake TrackIR"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTIR"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("TrackIR V4 protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/TrackIR.ico"); }; +}; + #endif//INCLUDED_FTIRSERVER_H //END diff --git a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.vcproj b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.vcproj index d258f30e..19ba5c8f 100644 --- a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.vcproj +++ b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.vcproj @@ -171,6 +171,14 @@ RelativePath=".\ftnoir_Protocol_FTIR.cpp" > + + + + . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ftir.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FTIRControls::FTIRControls() : +QWidget() +{ + QString aFileName; // File Path and Name + + 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.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(chkTIRViewsChanged())); + connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); + + aFileName = QCoreApplication::applicationDirPath() + "/"; + aFileName.append(FTIR_VIEWS_FILENAME); + if ( !QFile::exists( aFileName ) ) { + ui.chkTIRViews->setChecked( false ); + ui.chkTIRViews->setEnabled ( false ); + } + else { + ui.chkTIRViews->setEnabled ( true ); + } + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FTIRControls::~FTIRControls() { + qDebug() << "~FTIRControls() says: started"; +} + +void FTIRControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FTIRControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FTIRControls::doOK() { + save(); + this->close(); +} + +// override show event +void FTIRControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FTIRControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTIRControls::loadSettings() { + qDebug() << "loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) + + qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "FTIR" ); + ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); + ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 1 ).toBool()); + + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FTIRControls::save() { + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "FTIR" ); + iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() ); + iniFile.setValue ( "useDummyExe", ui.chkStartDummy->isChecked() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new FTIRControls; +} diff --git a/FTNoIR_Protocol_FTIR/ftnoir_protocol_FTIR_dll.cpp b/FTNoIR_Protocol_FTIR/ftnoir_protocol_FTIR_dll.cpp new file mode 100644 index 00000000..9af0f7ab --- /dev/null +++ b/FTNoIR_Protocol_FTIR/ftnoir_protocol_FTIR_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ftir.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp index 55888484..bcda3dbc 100755 --- a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp +++ b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp @@ -86,7 +86,7 @@ void FTNoIR_Protocol_FTN::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol_FTN::sendHeadposeToGame( THeadPoseData *headpose ) { +void FTNoIR_Protocol_FTN::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { int no_bytes; QHostAddress sender; quint16 senderPort; @@ -198,161 +198,3 @@ FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() { return new FTNoIR_Protocol_FTN; } - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FTNControls::FTNControls() : -QWidget() -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FTNControls::~FTNControls() { - qDebug() << "~FTNControls() says: started"; -} - -void FTNControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FTNControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FTNControls::doOK() { - save(); - this->close(); -} - -// override show event -void FTNControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FTNControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNControls::loadSettings() { -// qDebug() << "loadSettings says: Starting "; - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - -// qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FTN" ); - ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); - ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); - ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); - ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FTNControls::save() { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "FTN" ); - iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); - iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); - iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); - iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); - iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new FTNControls; -} diff --git a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h index b460563c..3eb65f5f 100644 --- a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h +++ b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h @@ -49,13 +49,9 @@ public: void Initialize(); bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTN Client"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR Client protocol"); }; - private: THeadPoseData TestData; long frame_counter; @@ -82,11 +78,6 @@ public: void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTN Client"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR Client protocol"); }; - void getIcon(QIcon *icon) { *icon = QIcon(":/images/FaceTrackNoIR.ico"); }; - private: Ui::UICFTNControls ui; void loadSettings(); @@ -101,5 +92,21 @@ private slots: void settingChanged() { settingsDirty = true; }; }; +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTN Client"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR Client protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/FaceTrackNoIR.ico"); }; +}; + #endif//INCLUDED_FTNSERVER_H //END diff --git a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.vcproj b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.vcproj index 3a59a74b..ca8d8a16 100644 --- a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.vcproj +++ b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.vcproj @@ -171,6 +171,14 @@ RelativePath=".\ftnoir_Protocol_FTN.cpp" > + + + + . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ftn.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp b/FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp new file mode 100644 index 00000000..a2e7813b --- /dev/null +++ b/FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp @@ -0,0 +1,192 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ftn.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FTNControls::FTNControls() : +QWidget() +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + //if (parent) { + // this->move(parent->pos() + offsetpos); + //} + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FTNControls::~FTNControls() { + qDebug() << "~FTNControls() says: started"; +} + +void FTNControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FTNControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FTNControls::doOK() { + save(); + this->close(); +} + +// override show event +void FTNControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FTNControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNControls::loadSettings() { +// qDebug() << "loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) + +// qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "FTN" ); + ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); + ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); + ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); + ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); + + ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FTNControls::save() { + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "FTN" ); + iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); + iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); + iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); + iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); + iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new FTNControls; +} diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp index e431348d..7c75cd26 100644 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp +++ b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp @@ -105,7 +105,7 @@ void FTNoIR_Protocol_MOUSE::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol_MOUSE::sendHeadposeToGame( THeadPoseData *headpose ) { +void FTNoIR_Protocol_MOUSE::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { float fMouse_X; // The actual value float fMouse_Y; float fMouse_Wheel; @@ -292,202 +292,3 @@ FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() { return new FTNoIR_Protocol_MOUSE; } - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -MOUSEControls::MOUSEControls() : -QWidget() -{ - ui.setupUi( this ); - - // - // Setup the choices - // - ui.cbxSelectMouseStyle->addItem("Absolute"); - ui.cbxSelectMouseStyle->addItem("Relative"); - - ui.cbxSelectMouse_X->addItem("None"); - ui.cbxSelectMouse_X->addItem("Pitch"); - ui.cbxSelectMouse_X->addItem("Yaw"); - ui.cbxSelectMouse_X->addItem("Roll"); - ui.cbxSelectMouse_X->addItem("X"); - ui.cbxSelectMouse_X->addItem("Y"); - ui.cbxSelectMouse_X->addItem("Z"); - - ui.cbxSelectMouse_Y->addItem("None"); - ui.cbxSelectMouse_Y->addItem("Pitch"); - ui.cbxSelectMouse_Y->addItem("Yaw"); - ui.cbxSelectMouse_Y->addItem("Roll"); - ui.cbxSelectMouse_Y->addItem("X"); - ui.cbxSelectMouse_Y->addItem("Y"); - ui.cbxSelectMouse_Y->addItem("Z"); - - ui.cbxSelectMouse_Wheel->addItem("None"); - ui.cbxSelectMouse_Wheel->addItem("Pitch"); - ui.cbxSelectMouse_Wheel->addItem("Yaw"); - ui.cbxSelectMouse_Wheel->addItem("Roll"); - ui.cbxSelectMouse_Wheel->addItem("X"); - ui.cbxSelectMouse_Wheel->addItem("Y"); - ui.cbxSelectMouse_Wheel->addItem("Z"); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.cbxSelectMouse_X, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - connect(ui.cbxSelectMouse_Y, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - connect(ui.cbxSelectMouse_Wheel, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - - connect(ui.spinSensX, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.spinSensY, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.spinSensWheel, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - - connect(ui.chkUseVirtualDesk, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -MOUSEControls::~MOUSEControls() { - qDebug() << "~MOUSEControls() says: started"; -} - -void MOUSEControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void MOUSEControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void MOUSEControls::doOK() { - save(); - this->close(); -} - -// override show event -void MOUSEControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void MOUSEControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void MOUSEControls::loadSettings() { - qDebug() << "loadSettings says: Starting "; - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Mouse" ); - ui.cbxSelectMouseStyle->setCurrentIndex(iniFile.value ( "Style", 1 ).toInt() - 1); - ui.cbxSelectMouse_X->setCurrentIndex(iniFile.value ( "Mouse_X", 1 ).toInt() - 1); - ui.cbxSelectMouse_Y->setCurrentIndex(iniFile.value ( "Mouse_Y", 1 ).toInt() - 1); - ui.cbxSelectMouse_Wheel->setCurrentIndex(iniFile.value ( "Mouse_Wheel", 1 ).toInt() - 1); - - ui.slideSensX->setValue(iniFile.value("SensX", 10).toInt()); - ui.slideSensY->setValue(iniFile.value("SensY", 10).toInt()); - ui.slideSensWheel->setValue(iniFile.value("SensWheel", 10).toInt()); - - ui.chkUseVirtualDesk->setChecked( iniFile.value ( "useVirtualDesk", 0 ).toBool() ); - - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void MOUSEControls::save() { - qDebug() << "save() says: started"; - - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "Mouse" ); - iniFile.setValue ( "Style", ui.cbxSelectMouseStyle->currentIndex() + 1 ); - iniFile.setValue ( "Mouse_X", ui.cbxSelectMouse_X->currentIndex() + 1 ); - iniFile.setValue ( "Mouse_Y", ui.cbxSelectMouse_Y->currentIndex() + 1 ); - iniFile.setValue ( "Mouse_Wheel", ui.cbxSelectMouse_Wheel->currentIndex() + 1 ); - - iniFile.setValue ( "SensX", ui.slideSensX->value() ); - iniFile.setValue ( "SensY", ui.slideSensY->value() ); - iniFile.setValue ( "SensWheel", ui.slideSensWheel->value() ); - - iniFile.setValue( "useVirtualDesk", ui.chkUseVirtualDesk->isChecked() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new MOUSEControls; -} diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h index c2c16abb..a7915780 100644 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h +++ b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h @@ -70,13 +70,9 @@ public: void Initialize(); bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - 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"); }; - private: HANDLE h; INPUT MouseStruct; @@ -113,11 +109,6 @@ public: void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); - 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.ico"); }; - private: Ui::UICMOUSEControls ui; void loadSettings(); @@ -132,5 +123,22 @@ private slots: void settingChanged( int setting ) { settingsDirty = true; }; }; +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +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 getIcon(QIcon *icon) { *icon = QIcon(":/images/Mouse.ico"); }; +}; + + #endif//INCLUDED_MOUSESERVER_H //END diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.vcproj b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.vcproj index ec50f7ad..4fb03cda 100644 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.vcproj +++ b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.vcproj @@ -171,6 +171,14 @@ RelativePath=".\ftnoir_Protocol_MOUSE.cpp" > + + + + . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_MOUSE.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +MOUSEControls::MOUSEControls() : +QWidget() +{ + ui.setupUi( this ); + + // + // Setup the choices + // + ui.cbxSelectMouseStyle->addItem("Absolute"); + ui.cbxSelectMouseStyle->addItem("Relative"); + + ui.cbxSelectMouse_X->addItem("None"); + ui.cbxSelectMouse_X->addItem("Pitch"); + ui.cbxSelectMouse_X->addItem("Yaw"); + ui.cbxSelectMouse_X->addItem("Roll"); + ui.cbxSelectMouse_X->addItem("X"); + ui.cbxSelectMouse_X->addItem("Y"); + ui.cbxSelectMouse_X->addItem("Z"); + + ui.cbxSelectMouse_Y->addItem("None"); + ui.cbxSelectMouse_Y->addItem("Pitch"); + ui.cbxSelectMouse_Y->addItem("Yaw"); + ui.cbxSelectMouse_Y->addItem("Roll"); + ui.cbxSelectMouse_Y->addItem("X"); + ui.cbxSelectMouse_Y->addItem("Y"); + ui.cbxSelectMouse_Y->addItem("Z"); + + ui.cbxSelectMouse_Wheel->addItem("None"); + ui.cbxSelectMouse_Wheel->addItem("Pitch"); + ui.cbxSelectMouse_Wheel->addItem("Yaw"); + ui.cbxSelectMouse_Wheel->addItem("Roll"); + ui.cbxSelectMouse_Wheel->addItem("X"); + ui.cbxSelectMouse_Wheel->addItem("Y"); + ui.cbxSelectMouse_Wheel->addItem("Z"); + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.cbxSelectMouse_X, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + connect(ui.cbxSelectMouse_Y, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + connect(ui.cbxSelectMouse_Wheel, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + + connect(ui.spinSensX, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.spinSensY, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.spinSensWheel, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + + connect(ui.chkUseVirtualDesk, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +MOUSEControls::~MOUSEControls() { + qDebug() << "~MOUSEControls() says: started"; +} + +void MOUSEControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void MOUSEControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void MOUSEControls::doOK() { + save(); + this->close(); +} + +// override show event +void MOUSEControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void MOUSEControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void MOUSEControls::loadSettings() { + qDebug() << "loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) + + qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "Mouse" ); + ui.cbxSelectMouseStyle->setCurrentIndex(iniFile.value ( "Style", 1 ).toInt() - 1); + ui.cbxSelectMouse_X->setCurrentIndex(iniFile.value ( "Mouse_X", 1 ).toInt() - 1); + ui.cbxSelectMouse_Y->setCurrentIndex(iniFile.value ( "Mouse_Y", 1 ).toInt() - 1); + ui.cbxSelectMouse_Wheel->setCurrentIndex(iniFile.value ( "Mouse_Wheel", 1 ).toInt() - 1); + + ui.slideSensX->setValue(iniFile.value("SensX", 10).toInt()); + ui.slideSensY->setValue(iniFile.value("SensY", 10).toInt()); + ui.slideSensWheel->setValue(iniFile.value("SensWheel", 10).toInt()); + + ui.chkUseVirtualDesk->setChecked( iniFile.value ( "useVirtualDesk", 0 ).toBool() ); + + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void MOUSEControls::save() { + qDebug() << "save() says: started"; + + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "Mouse" ); + iniFile.setValue ( "Style", ui.cbxSelectMouseStyle->currentIndex() + 1 ); + iniFile.setValue ( "Mouse_X", ui.cbxSelectMouse_X->currentIndex() + 1 ); + iniFile.setValue ( "Mouse_Y", ui.cbxSelectMouse_Y->currentIndex() + 1 ); + iniFile.setValue ( "Mouse_Wheel", ui.cbxSelectMouse_Wheel->currentIndex() + 1 ); + + iniFile.setValue ( "SensX", ui.slideSensX->value() ); + iniFile.setValue ( "SensY", ui.slideSensY->value() ); + iniFile.setValue ( "SensWheel", ui.slideSensWheel->value() ); + + iniFile.setValue( "useVirtualDesk", ui.chkUseVirtualDesk->isChecked() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new MOUSEControls; +} diff --git a/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dll.cpp b/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dll.cpp new file mode 100644 index 00000000..cc6ddc17 --- /dev/null +++ b/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_MOUSE.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.cpp b/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.cpp index f533fdf3..4689c92f 100644 --- a/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.cpp +++ b/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.cpp @@ -128,7 +128,7 @@ void FTNoIR_Protocol_PPJOY::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol_PPJOY::sendHeadposeToGame( THeadPoseData *headpose ) { +void FTNoIR_Protocol_PPJOY::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { float virtPosX; float virtPosY; float virtPosZ; @@ -217,157 +217,3 @@ FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() { return new FTNoIR_Protocol_PPJOY; } - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -PPJOYControls::PPJOYControls() : -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.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); - - for (int i = 1 ; i < 17; i++) { - QString cbxText = QString("Virtual Joystick %1").arg(i); - ui.cbxSelectPPJoyNumber->addItem(QIcon("images/PPJoy.ico"), cbxText); - } - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -PPJOYControls::~PPJOYControls() { - qDebug() << "~PPJOYControls() says: started"; -} - -void PPJOYControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void PPJOYControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void PPJOYControls::doOK() { - save(); - this->close(); -} - -// override show event -void PPJOYControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void PPJOYControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void PPJOYControls::loadSettings() { - qDebug() << "loadSettings says: Starting "; - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "PPJoy" ); - ui.cbxSelectPPJoyNumber->setCurrentIndex(iniFile.value ( "Selection", 1 ).toInt() - 1); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void PPJOYControls::save() { - qDebug() << "save() says: started"; - - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "PPJoy" ); - iniFile.setValue ( "Selection", ui.cbxSelectPPJoyNumber->currentIndex() + 1 ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Handle changes of the Virtual Joystick selection -// -void PPJOYControls::virtualJoystickSelected( int index ) -{ - settingsDirty = true; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new PPJOYControls; -} diff --git a/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.h b/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.h index 266fd877..b9220916 100644 --- a/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.h +++ b/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.h @@ -69,13 +69,9 @@ public: void Initialize(); bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("PPJoy Virtual Joystick"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("PPJoy"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("PPJoy virtual joystick protocol"); }; - private: HANDLE h; JOYSTICK_STATE JoyState; @@ -107,11 +103,6 @@ public: void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("PPJoy Virtual Joystick"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("PPJoy"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("PPJoy virtual joystick protocol"); }; - void getIcon(QIcon *icon) { *icon = QIcon(":/images/PPJoy.ico"); }; - private: Ui::UICPPJOYControls ui; void loadSettings(); @@ -127,5 +118,22 @@ private slots: void settingChanged() { settingsDirty = true; }; }; +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("PPJoy Virtual Joystick"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("PPJoy"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("PPJoy virtual joystick protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/PPJoy.ico"); }; +}; + + #endif//INCLUDED_PPJOYSERVER_H //END diff --git a/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.vcproj b/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.vcproj index e8332f65..7a42d19f 100644 --- a/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.vcproj +++ b/FTNoIR_Protocol_PPJOY/FTNoIR_Protocol_PPJOY.vcproj @@ -171,6 +171,14 @@ RelativePath=".\ftnoir_Protocol_PPJOY.cpp" > + + + + . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_PPJOY.h" +#include + + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +PPJOYControls::PPJOYControls() : +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.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); + + for (int i = 1 ; i < 17; i++) { + QString cbxText = QString("Virtual Joystick %1").arg(i); + ui.cbxSelectPPJoyNumber->addItem(QIcon("images/PPJoy.ico"), cbxText); + } + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +PPJOYControls::~PPJOYControls() { + qDebug() << "~PPJOYControls() says: started"; +} + +void PPJOYControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void PPJOYControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void PPJOYControls::doOK() { + save(); + this->close(); +} + +// override show event +void PPJOYControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void PPJOYControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void PPJOYControls::loadSettings() { + qDebug() << "loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) + + qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "PPJoy" ); + ui.cbxSelectPPJoyNumber->setCurrentIndex(iniFile.value ( "Selection", 1 ).toInt() - 1); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void PPJOYControls::save() { + qDebug() << "save() says: started"; + + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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 ( "PPJoy" ); + iniFile.setValue ( "Selection", ui.cbxSelectPPJoyNumber->currentIndex() + 1 ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Handle changes of the Virtual Joystick selection +// +void PPJOYControls::virtualJoystickSelected( int index ) +{ + settingsDirty = true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new PPJOYControls; +} diff --git a/FTNoIR_Protocol_PPJOY/ftnoir_protocol_PPJOY_dll.cpp b/FTNoIR_Protocol_PPJOY/ftnoir_protocol_PPJOY_dll.cpp new file mode 100644 index 00000000..67536857 --- /dev/null +++ b/FTNoIR_Protocol_PPJOY/ftnoir_protocol_PPJOY_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_PPJOY.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp index 6c0cf42f..3399955a 100644 --- a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp +++ b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp @@ -96,7 +96,7 @@ void FTNoIR_Protocol_SC::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol_SC::sendHeadposeToGame( THeadPoseData *headpose ) { +void FTNoIR_Protocol_SC::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { virtSCRotX = -1.0f * headpose->pitch; // degrees @@ -385,128 +385,3 @@ FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() { return new FTNoIR_Protocol_SC; } - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -SCControls::SCControls() : -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.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); - - //for (int i = 1 ; i < 17; i++) { - // QString cbxText = QString("Virtual Joystick %1").arg(i); - // ui.cbxSelectPPJoyNumber->addItem(QIcon("images/PPJoy.ico"), cbxText); - //} - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -SCControls::~SCControls() { - qDebug() << "~SCControls() says: started"; -} - -void SCControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void SCControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void SCControls::doOK() { - save(); - this->close(); -} - -// override show event -void SCControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void SCControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void SCControls::loadSettings() { - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void SCControls::save() { - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new SCControls; -} diff --git a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h index cf8c3e5c..cfdde6a6 100644 --- a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h +++ b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h @@ -87,13 +87,9 @@ public: void Initialize(); bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); }; - private: // Private properties QString ProgramName; @@ -144,11 +140,6 @@ public: void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); }; - void getIcon(QIcon *icon) { *icon = QIcon(":/images/FSX.ico"); }; - private: Ui::UICSCControls ui; void loadSettings(); @@ -163,5 +154,21 @@ private slots: void settingChanged() { settingsDirty = true; }; }; +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/FSX.ico"); }; +}; + #endif//INCLUDED_SCSERVER_H //END diff --git a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj index c37c64e1..579c8bea 100644 --- a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj +++ b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj @@ -172,6 +172,14 @@ RelativePath=".\ftnoir_Protocol_SC.cpp" > + + + + . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_SC.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +SCControls::SCControls() : +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.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); + + //for (int i = 1 ; i < 17; i++) { + // QString cbxText = QString("Virtual Joystick %1").arg(i); + // ui.cbxSelectPPJoyNumber->addItem(QIcon("images/PPJoy.ico"), cbxText); + //} + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +SCControls::~SCControls() { + qDebug() << "~SCControls() says: started"; +} + +void SCControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void SCControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void SCControls::doOK() { + save(); + this->close(); +} + +// override show event +void SCControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void SCControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void SCControls::loadSettings() { + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void SCControls::save() { + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new SCControls; +} diff --git a/FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp b/FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp new file mode 100644 index 00000000..f67f95db --- /dev/null +++ b/FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_SC.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/FaceTrackNoIR.sln b/FaceTrackNoIR.sln index c4ac19ec..2cc1053e 100644 --- a/FaceTrackNoIR.sln +++ b/FaceTrackNoIR.sln @@ -45,6 +45,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_Toradex", "F EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_Arduino", "FTNoIR_Tracker_Arduino\FTNoIR_Tracker_Arduino.vcproj", "{26073935-6C44-49FD-A986-DD91FE727306}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_PT", "FTNoIR_Tracker_PT\FTNoIR_Tracker_PT.vcproj", "{7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -134,6 +136,9 @@ Global {26073935-6C44-49FD-A986-DD91FE727306}.Debug|Win32.Build.0 = Debug|Win32 {26073935-6C44-49FD-A986-DD91FE727306}.Release|Win32.ActiveCfg = Release|Win32 {26073935-6C44-49FD-A986-DD91FE727306}.Release|Win32.Build.0 = Release|Win32 + {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Debug|Win32.ActiveCfg = Debug|Win32 + {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Debug|Win32.Build.0 = Debug|Win32 + {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Release|Win32.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 00e3a87c..340b80d5 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -1143,11 +1143,12 @@ void FaceTrackNoIR::exit() { // void FaceTrackNoIR::createIconGroupBox() { -importGetProtocolDialog getProtocol; +importGetProtocolDll getProtocol; +IProtocolDllPtr pProtocolDll; // Pointer to Protocol info instance (in DLL) importGetFilterDll getFilter; IFilterDllPtr pFilterDll; // Pointer to Filter info instance (in DLL) importGetTrackerDll getTracker; -ITrackerDll *pTrackerDll; // Pointer to Filter info instance (in DLL) +ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) @@ -1173,27 +1174,19 @@ ITrackerDll *pTrackerDll; // Pointer to Filter info instance (in DLL) // qDebug() << "createIconGroupBox says: ProtocolName = " << protocolFileList.at(i); - // - // Delete the existing QDialog - // - if (pProtocolDialog) { - delete pProtocolDialog; - pProtocolDialog = NULL; - } - // Show the appropriate Protocol-server Settings QLibrary *protocolLib = new QLibrary(protocolFileList.at(i)); QString *protocolName = new QString(""); QIcon *protocolIcon = new QIcon(); - getProtocol = (importGetProtocolDialog) protocolLib->resolve("GetProtocolDialog"); + getProtocol = (importGetProtocolDll) protocolLib->resolve("GetProtocolDll"); if (getProtocol) { - IProtocolDialogPtr ptrXyz(getProtocol()); + IProtocolDllPtr ptrXyz(getProtocol()); if (ptrXyz) { - pProtocolDialog = ptrXyz; - pProtocolDialog->getFullName( protocolName ); - pProtocolDialog->getIcon( protocolIcon ); + pProtocolDll = ptrXyz; + pProtocolDll->getFullName( protocolName ); + pProtocolDll->getIcon( protocolIcon ); // qDebug() << "FaceTrackNoIR::showServerControls GetProtocolDialog Function Resolved!"; } else { diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index e3cf798e..a7992bbb 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -49,7 +49,7 @@ typedef ITrackerDialogPtr (WINAPI *importGetTrackerDialog)(void); typedef ITrackerDllPtr (WINAPI *importGetTrackerDll)(void); typedef IProtocolDialogPtr (WINAPI *importGetProtocolDialog)(void); -//typedef IProtocolDllPtr (WINAPI *importGetProtocolDll)(void); +typedef IProtocolDllPtr (WINAPI *importGetProtocolDll)(void); typedef IFilterDialogPtr (WINAPI *importGetFilterDialog)(void); typedef IFilterDllPtr (WINAPI *importGetFilterDll)(void); @@ -83,7 +83,7 @@ private: QStringList filterFileList; // List of Filter-DLL-files, that are present in the program-folder QStringList trackerFileList; // List of Tracker-DLL-files, that are present in the program-folder - ITrackerDialogPtr pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) + ITrackerDialogPtr pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) IProtocolDialogPtr pProtocolDialog; // Pointer to Protocol dialog instance (in DLL) IFilterDialogPtr pFilterDialog; // Pointer to Filter dialog instance (in DLL) diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index c78644c1..6153433f 100755 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -664,30 +664,13 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); if (InhibitKey.doZ) output_camera.z = 0.0f; } - // All Protocol server(s) + // + // Send the headpose to the game + // if (pProtocol) { gameoutput_camera = output_camera + gamezero_camera; - pProtocol->sendHeadposeToGame( &gameoutput_camera ); // degrees & centimeters + pProtocol->sendHeadposeToGame( &gameoutput_camera, &newpose ); // degrees & centimeters } - -# ifdef USE_DEBUG_CLIENT - debug_Client->setHeadRotX( Tracker::Pitch.headPos ); // degrees - debug_Client->setHeadRotY( Tracker::Yaw.headPos ); - debug_Client->setHeadRotZ( Tracker::Roll.headPos ); - - debug_Client->setHeadPosX( Tracker::X.headPos ); // centimeters - debug_Client->setHeadPosY( Tracker::Y.headPos ); - debug_Client->setHeadPosZ( Tracker::Z.headPos ); - - debug_Client->setVirtRotX ( new_camera.pitch ); // degrees - debug_Client->setVirtRotY ( new_camera.yaw ); - debug_Client->setVirtRotZ ( new_camera.roll ); - debug_Client->setVirtPosX ( new_camera.x ); // centimeters - debug_Client->setVirtPosY ( new_camera.y ); - debug_Client->setVirtPosZ ( new_camera.z ); -# endif - - } else { // @@ -701,7 +684,7 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); output_camera.y = 0.0f; output_camera.z = 0.0f; gameoutput_camera = output_camera + gamezero_camera; - pProtocol->sendHeadposeToGame( &gameoutput_camera ); // degrees & centimeters + pProtocol->sendHeadposeToGame( &gameoutput_camera, &newpose ); // degrees & centimeters } X.curvePtr->setTrackingActive( false ); Y.curvePtr->setTrackingActive( false ); @@ -713,17 +696,7 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); } } -# ifdef USE_DEBUG_CLIENT - debug_Client->confidence = Tracker::Pitch.confidence; - debug_Client->newSample = Tracker::Pitch.newSample; - debug_Client->smoothvalue = getSmoothFromList( &Pitch.rawList ); - debug_Client->prev_value = Tracker::Pitch.prevPos; - debug_Client->dT = dT; - debug_Client->sendHeadposeToGame(); // Log to Excel -# endif - Tracker::Pitch.newSample = false; - ReleaseMutex(Tracker::hTrackMutex); //for lower cpu load diff --git a/bin/Settings/ArmA.ini b/bin/Settings/ArmA.ini index 2fdcf98c..350c6ec7 100644 --- a/bin/Settings/ArmA.ini +++ b/bin/Settings/ArmA.ini @@ -13,7 +13,7 @@ invertRoll=true invertX=true invertY=false invertZ=false -useEWMA=true +useEWMA=false redYaw=60 redPitch=60 redRoll=60 @@ -89,7 +89,7 @@ Enable_ReverseAxis=false RA_Yaw=40 RA_ZPos=0 RA_ToZPos=100 -MouseKey_Center=0 +MouseKey_Center=3 MouseKey_GameZero=0 MouseKey_StartStop=0 MouseKey_Inhibit=0 diff --git a/bin/Settings/GlovePIE.ini b/bin/Settings/GlovePIE.ini index 39c0d818..317b030a 100644 --- a/bin/Settings/GlovePIE.ini +++ b/bin/Settings/GlovePIE.ini @@ -22,7 +22,8 @@ redY=75 redZ=75 [GameProtocol] -Selection=3 +Selection=6 +DLL=FTNoIR_Protocol_PPJOY.dll [PPJoy] Selection=1 @@ -46,3 +47,10 @@ Inhibit_Roll=false Inhibit_X=false Inhibit_Y=false Inhibit_Z=false + +[TrackerSource] +Selection=2 +DLL=FTNoIR_Tracker_SM.dll + +[Filter] +DLL=FTNoIR_Filter_Accela.dll diff --git a/bin/Settings/SimConnect.ini b/bin/Settings/SimConnect.ini index ae948471..6b2b3e79 100644 --- a/bin/Settings/SimConnect.ini +++ b/bin/Settings/SimConnect.ini @@ -1,5 +1,5 @@ [Tracking] -Smooth=5 +Smooth=1 invertYaw=false invertPitch=false invertRoll=false @@ -18,11 +18,11 @@ powCurve=12 maxSmooth=70 [GameProtocol] -Selection=5 +Selection=7 DLL=FTNoIR_Protocol_SC.dll [TrackerSource] -Selection=0 +Selection=2 DLL=FTNoIR_Tracker_SM.dll [Curves] @@ -72,6 +72,18 @@ Inhibit_X=false Inhibit_Y=false Inhibit_Z=false SetEngineStop=true +MouseKey_Center=3 +MouseKey_GameZero=0 +Keycode_GameZero=0 +Shift_GameZero=false +Ctrl_GameZero=false +Alt_GameZero=false +MouseKey_StartStop=0 +MouseKey_Inhibit=0 +Enable_ReverseAxis=false +RA_Yaw=40 +RA_ZPos=-20 +RA_ToZPos=50 [FTN] LocalPCOnly=true @@ -90,21 +102,25 @@ IP-4=1 PortNumber=5550 [Curves-Accela-Scaling-Rotation] -point-count=1 -point-0-x=4 -point-0-y=8 -point-1-x=3.03917525773196 -point-1-y=5.40377358490566 +point-count=4 +point-0-x=0.916230366492147 +point-0-y=2.73913043478261 +point-1-x=2.13089005235602 +point-1-y=3.26086956521739 +point-2-x=3.54450261780105 +point-2-y=4.21739130434783 +point-3-x=4 +point-3-y=5.17391304347826 [Curves-Accela-Scaling-Translation] point-count=2 -point-0-x=2 -point-0-y=4 +point-0-x=1.7434554973822 +point-0-y=3.73913043478261 point-1-x=4 point-1-y=8 [Filter] -DLL=FTNoIR_Filter_Accela.dll +DLL=FTNoIR_Filter_EWMA2.dll Selection=FTNoIR_Filter_Accela.dll [Curves-Yaw] @@ -122,13 +138,36 @@ point-1-x=50 point-1-y=180 [Curves-PitchDown] +point-count=3 +point-0-x=10 +point-0-y=18 +point-1-x=50 +point-1-y=28 +point-2-x=50 +point-2-y=180 + +[Curves-Roll] point-count=2 -point-0-x=49.75 -point-0-y=79 +point-0-x=25 +point-0-y=90 point-1-x=50 point-1-y=180 -[Curves-Roll] +[Curves-X] +point-count=2 +point-0-x=25 +point-0-y=90 +point-1-x=50 +point-1-y=180 + +[Curves-Y] +point-count=2 +point-0-x=25 +point-0-y=90 +point-1-x=50 +point-1-y=180 + +[Curves-Z] point-count=2 point-0-x=25 point-0-y=90 -- cgit v1.2.3