From c58c0af311892929dbce4e5437c4035214552438 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 15:34:44 +0200 Subject: Run dos2unix on the tree. No user-facing changes. --- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 256 +++++++++++++------------- 1 file changed, 128 insertions(+), 128 deletions(-) (limited to 'ftnoir_protocol_mouse/ftnoir_protocol_mouse.h') diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index fd0058ea..b537fc4e 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -1,128 +1,128 @@ -/******************************************************************************** -* 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) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* http://facetracknoir.sourceforge.net/home/default.htm * -* * -* 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 . * -* * -* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * -* generating Mouse commands. * -* Many games (like FPS's) support Mouse-look features, * -* but no face-tracking. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_MOUSESERVER_H -#define INCLUDED_MOUSESERVER_H - -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ui_ftnoir_mousecontrols.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "facetracknoir/global-settings.h" - -#define MOUSE_AXIS_MIN 0 -#define MOUSE_AXIS_MAX 65535 - -enum FTN_AngleName { - FTN_YAW = Yaw, - FTN_PITCH = Pitch, - FTN_ROLL = Roll, - FTN_X = TX, - FTN_Y = TY, - FTN_Z = TZ -}; - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); - -private: - HANDLE h; - INPUT MouseStruct; - - FTN_AngleName Mouse_X; // Map one of the 6DOF's to this Mouse direction - FTN_AngleName Mouse_Y; - FTN_AngleName Mouse_Wheel; - void loadSettings(); - QString getGameName() { - return "Mouse tracker"; - } -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class MOUSEControls: public QWidget, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit MOUSEControls(); - virtual ~MOUSEControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - -private: - Ui::UICMOUSEControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void settingChanged( int setting ) { settingsDirty = true; } -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public Metadata -{ -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.png"); } -}; - - -#endif//INCLUDED_MOUSESERVER_H -//END +/******************************************************************************** +* 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) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* http://facetracknoir.sourceforge.net/home/default.htm * +* * +* 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 . * +* * +* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * +* generating Mouse commands. * +* Many games (like FPS's) support Mouse-look features, * +* but no face-tracking. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_MOUSESERVER_H +#define INCLUDED_MOUSESERVER_H + +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ui_ftnoir_mousecontrols.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "facetracknoir/global-settings.h" + +#define MOUSE_AXIS_MIN 0 +#define MOUSE_AXIS_MAX 65535 + +enum FTN_AngleName { + FTN_YAW = Yaw, + FTN_PITCH = Pitch, + FTN_ROLL = Roll, + FTN_X = TX, + FTN_Y = TY, + FTN_Z = TZ +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + bool checkServerInstallationOK(); + void sendHeadposeToGame( double *headpose, double *rawheadpose ); + +private: + HANDLE h; + INPUT MouseStruct; + + FTN_AngleName Mouse_X; // Map one of the 6DOF's to this Mouse direction + FTN_AngleName Mouse_Y; + FTN_AngleName Mouse_Wheel; + void loadSettings(); + QString getGameName() { + return "Mouse tracker"; + } +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class MOUSEControls: public QWidget, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit MOUSEControls(); + virtual ~MOUSEControls(); + void showEvent ( QShowEvent * event ); + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + } + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + } + +private: + Ui::UICMOUSEControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void settingChanged( int setting ) { settingsDirty = true; } +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public Metadata +{ +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.png"); } +}; + + +#endif//INCLUDED_MOUSESERVER_H +//END -- cgit v1.2.3 From 49d6de31c4ba587d73fac8204cf92569bfaa7e6a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 12:56:39 +0200 Subject: proto: Correct visibility --- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 6 +++--- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'ftnoir_protocol_mouse/ftnoir_protocol_mouse.h') diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 5c2531be..40a83384 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -48,6 +48,9 @@ public: ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame( double *headpose, double *rawheadpose ); + QString getGameName() { + return "FlightGear"; + } private: bool blnConnectionActive; @@ -61,9 +64,6 @@ private: QHostAddress destIP; // Destination IP-address int destPort; // Destination port-number void loadSettings(); - QString getGameName() { - return "FlightGear"; - } }; // Widget that has controls for FTNoIR protocol client-settings. diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index b537fc4e..5aad9c01 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -61,7 +61,9 @@ public: ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame( double *headpose, double *rawheadpose ); - + QString getGameName() { + return "Mouse tracker"; + } private: HANDLE h; INPUT MouseStruct; @@ -70,9 +72,6 @@ private: FTN_AngleName Mouse_Y; FTN_AngleName Mouse_Wheel; void loadSettings(); - QString getGameName() { - return "Mouse tracker"; - } }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From b15ec9f185e600e45213b5727e9b2a28c104940f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 08:04:59 +0200 Subject: fix win32 build breakage Signed-off-by: Stanislaw Halik --- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 2 +- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 55 +++++++++-------------- ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 2 +- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 2 +- 9 files changed, 30 insertions(+), 41 deletions(-) (limited to 'ftnoir_protocol_mouse/ftnoir_protocol_mouse.h') diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index df25e9ed..986ccc65 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -87,7 +87,7 @@ void FTNoIR_Protocol::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { DWORD result; TFSState pitch; TFSState yaw; diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index d901b63e..52b2cd98 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -61,7 +61,7 @@ public: FTNoIR_Protocol(); ~FTNoIR_Protocol(); bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame(const double* headpose); QString getGameName() { return "Microsoft Flight Simulator X"; } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 47e99d31..186562cf 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -92,39 +92,28 @@ void FTNoIR_Protocol::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { -float virtPosX; -float virtPosY; -float virtPosZ; - -float virtRotX; -float virtRotY; -float virtRotZ; - -float headPosX; -float headPosY; -float headPosZ; - -float headRotX; -float headRotY; -float headRotZ; - - // - // Scale the Raw measurements to the client measurements. - // - headRotX = getRadsFromDegrees(rawheadpose[Pitch]); - headRotY = getRadsFromDegrees(rawheadpose[Yaw]); - headRotZ = getRadsFromDegrees(rawheadpose[Roll]); - headPosX = rawheadpose[TX] * 10; - headPosY = rawheadpose[TY] * 10; - headPosZ = rawheadpose[TZ] * 10; - - virtRotX = getRadsFromDegrees(headpose[Pitch]); - virtRotY = getRadsFromDegrees(headpose[Yaw]); - virtRotZ = getRadsFromDegrees(headpose[Roll]); - virtPosX = headpose[TX] * 10; - virtPosY = headpose[TY] * 10; - virtPosZ = headpose[TZ] * 10; +void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { + float virtPosX; + float virtPosY; + float virtPosZ; + + float virtRotX; + float virtRotY; + float virtRotZ; + + float headPosX; + float headPosY; + float headPosZ; + + float headRotX; + float headRotY; + float headRotZ; + headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]); + headRotY = virtRotY = getRadsFromDegrees(headpose[Yaw]); + headRotZ = virtRotZ = getRadsFromDegrees(headpose[Roll]); + headPosX = virtPosX = headpose[TX] * 10; + headPosY = virtPosY = headpose[TY] * 10; + headPosZ = virtPosZ = headpose[TZ] * 10; shm.lock(); diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index 8601bdfd..64e010a8 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -58,7 +58,7 @@ void FTNoIR_Protocol::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { float fMouse_X = 0; float fMouse_Y = 0; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index 5aad9c01..1eb80b12 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -60,7 +60,7 @@ public: FTNoIR_Protocol(); ~FTNoIR_Protocol(); bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame( const double *headpose); QString getGameName() { return "Mouse tracker"; } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index ca07fbf6..8a60f8fb 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -82,7 +82,7 @@ void FTNoIR_Protocol::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { PDWORD_PTR MsgResult = 0; diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index b24eb0cf..9ac56b30 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -83,7 +83,7 @@ public: FTNoIR_Protocol(); ~FTNoIR_Protocol(); bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame(const double* headpose); QString getGameName() { return "FS2004/FSX"; } diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp index 50a7bf97..76767c3b 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp @@ -14,7 +14,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() VJoy_Shutdown(); } -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { JOYSTICK_STATE state[2] = { 0 }; state[0].XAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Yaw] * VJOY_AXIS_MAX / 180.0)); diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 5a1d30fb..2fe53669 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -46,7 +46,7 @@ public: bool checkServerInstallationOK() { return true; } - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame( const double *headpose ); QString getGameName() { return "Virtual joystick"; } -- cgit v1.2.3 From 79697936ef3ce7f0bbd1965931cdfb4b2c4c9f5b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 17:06:23 +0200 Subject: Fix proto/filter dtor not being called Signed-off-by: Stanislaw Halik Reported-by: mm0zct --- ftnoir_filter_accela/ftnoir_filter_accela.h | 2 +- ftnoir_filter_base/ftnoir_filter_base.h | 4 +++- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 2 +- ftnoir_protocol_base/ftnoir_protocol_base.h | 4 +++- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 2 +- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 1 + ftnoir_protocol_ft/ftnoir_protocol_ft.h | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 2 +- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h | 2 +- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 2 +- ftnoir_protocol_wine/ftnoir_protocol_wine.h | 2 +- 14 files changed, 18 insertions(+), 13 deletions(-) (limited to 'ftnoir_protocol_mouse/ftnoir_protocol_mouse.h') diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 4afe127b..f1807fd0 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -42,7 +42,7 @@ class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - ~FTNoIR_Filter(); + virtual ~FTNoIR_Filter(); void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position, const double* last_post_filter_values); void Initialize() { first_run = true; diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index fe1ad19a..48a4a6b9 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -12,11 +12,13 @@ struct IFilter { - virtual ~IFilter() {} + virtual ~IFilter() = 0; virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, const double *last_post_filter) = 0; virtual void Initialize() = 0; }; +inline IFilter::~IFilter() { } + struct IFilterDialog { virtual ~IFilterDialog() {} diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 656b2895..7f2f21e6 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -41,7 +41,7 @@ class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - ~FTNoIR_Filter(); + virtual ~FTNoIR_Filter(); void Initialize() {} void FilterHeadPoseData(const double *target_camera_position, diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h index 5db49f01..e4ca1977 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -39,12 +39,14 @@ struct IProtocol { - virtual ~IProtocol() {} + virtual ~IProtocol() = 0; virtual bool checkServerInstallationOK() = 0; virtual void sendHeadposeToGame( const double* headpose ) = 0; virtual QString getGameName() = 0; }; +inline IProtocol::~IProtocol() { } + struct IProtocolDialog { virtual ~IProtocolDialog() {} diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 43d1b05a..9a4f304c 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -44,7 +44,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double *headpose); QString getGameName() { diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index 52b2cd98..87c6a3a4 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -59,7 +59,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double* headpose); QString getGameName() { diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 27e88136..65d877a7 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -61,6 +61,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() FTIRViewsLib.unload(); } dummyTrackIR.kill(); + dummyTrackIR.waitForFinished(5); } // diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index cd77bbe4..e13d260f 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -53,7 +53,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK( ); void sendHeadposeToGame( const double *headpose ); QString getGameName() { diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index 4e814ddf..9aee73ac 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -43,7 +43,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double *headpose); QString getGameName() { diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index 3c6f591c..aabd3e51 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -21,7 +21,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK() { return dev != NULL; } diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index 1eb80b12..1ce72f69 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -58,7 +58,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame( const double *headpose); QString getGameName() { diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index 9ac56b30..e17cabb5 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -81,7 +81,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double* headpose); QString getGameName() { diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 2fe53669..c4db29e4 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -42,7 +42,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK() { return true; } diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index 01bfc93d..d7276b8e 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -48,7 +48,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double* headpose); -- cgit v1.2.3 From 4a9c157caa350f0e333cba8444793ddae840bf12 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 10:33:12 +0100 Subject: settings for mouse --- ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 56 ++----- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 78 ++++----- .../ftnoir_protocol_mouse_dialog.cpp | 180 ++++++--------------- .../ftnoir_protocol_mouse_dll.cpp | 18 --- 4 files changed, 86 insertions(+), 246 deletions(-) (limited to 'ftnoir_protocol_mouse/ftnoir_protocol_mouse.h') diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index 64e010a8..cc8aa11e 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -29,38 +29,12 @@ #include "ftnoir_protocol_mouse.h" #include "facetracknoir/global-settings.h" -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - loadSettings(); -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - QSettings settings("opentrack"); // Registry settings (in HK_USER) - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup ( "Mouse" ); - Mouse_X = (FTN_AngleName) (iniFile.value ( "Mouse_X", 0 ).toInt()); - Mouse_Y = (FTN_AngleName) (iniFile.value ( "Mouse_Y", 0 ).toInt()); - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { - float fMouse_X = 0; - float fMouse_Y = 0; + double fMouse_X = 0; + double fMouse_Y = 0; + + int Mouse_X = s.Mouse_X; + int Mouse_Y = s.Mouse_Y; if (Mouse_X > 0 && Mouse_X <= 6) fMouse_X = headpose[Mouse_X-1] / (Mouse_X < 3 ? 100 : 180); @@ -77,24 +51,16 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { } } -// -// Returns 'true' if all seems OK. -// +void FTNoIR_Protocol::reload() +{ + s.b->reload(); +} + bool FTNoIR_Protocol::checkServerInstallationOK() { - - return true; + return true; } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() { return new FTNoIR_Protocol; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index 1ce72f69..01f283d3 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -41,37 +41,34 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value Mouse_X, Mouse_Y; + settings() : + b(bundle("mouse-proto")), + Mouse_X(b, "mouse-x", 0), + Mouse_Y(b, "mouse-y", 0) + {} +}; #define MOUSE_AXIS_MIN 0 #define MOUSE_AXIS_MAX 65535 -enum FTN_AngleName { - FTN_YAW = Yaw, - FTN_PITCH = Pitch, - FTN_ROLL = Roll, - FTN_X = TX, - FTN_Y = TY, - FTN_Z = TZ -}; - class FTNoIR_Protocol : public IProtocol { public: - FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol(); + FTNoIR_Protocol() {} bool checkServerInstallationOK(); void sendHeadposeToGame( const double *headpose); QString getGameName() { return "Mouse tracker"; } + void reload(); private: - HANDLE h; - INPUT MouseStruct; - - FTN_AngleName Mouse_X; // Map one of the 6DOF's to this Mouse direction - FTN_AngleName Mouse_Y; - FTN_AngleName Mouse_Wheel; - void loadSettings(); + struct settings s; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -79,31 +76,20 @@ class MOUSEControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit MOUSEControls(); - virtual ~MOUSEControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - + MOUSEControls(); + void registerProtocol(IProtocol *protocol) { + _proto = (FTNoIR_Protocol *) protocol; + } + void unRegisterProtocol() { + _proto = NULL; + } private: - Ui::UICMOUSEControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - + Ui::UICMOUSEControls ui; + settings s; + FTNoIR_Protocol* _proto; private slots: - void doOK(); - void doCancel(); - void settingChanged( int setting ) { settingsDirty = true; } + void doOK(); + void doCancel(); }; //******************************************************************************************************* @@ -112,13 +98,9 @@ private slots: class FTNoIR_ProtocolDll : public Metadata { public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); } - + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); } void getIcon(QIcon *icon) { *icon = QIcon(":/images/mouse.png"); } }; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index c8d62a58..cc62b004 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -23,158 +23,68 @@ * * ********************************************************************************/ #include "ftnoir_protocol_mouse.h" -#include #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -MOUSEControls::MOUSEControls() : -QWidget() +MOUSEControls::MOUSEControls() : _proto(nullptr) { - ui.setupUi( this ); - ui.cbxSelectMouse_X->addItem("None"); + ui.setupUi( this ); + ui.cbxSelectMouse_X->addItem("None"); ui.cbxSelectMouse_X->addItem("X"); - ui.cbxSelectMouse_X->addItem("Y"); - ui.cbxSelectMouse_X->addItem("Z"); - ui.cbxSelectMouse_X->addItem("Yaw"); + ui.cbxSelectMouse_X->addItem("Y"); + ui.cbxSelectMouse_X->addItem("Z"); + ui.cbxSelectMouse_X->addItem("Yaw"); ui.cbxSelectMouse_X->addItem("Pitch"); - ui.cbxSelectMouse_X->addItem("Roll"); + ui.cbxSelectMouse_X->addItem("Roll"); - ui.cbxSelectMouse_Y->addItem("None"); - ui.cbxSelectMouse_Y->addItem("X"); - ui.cbxSelectMouse_Y->addItem("Y"); - ui.cbxSelectMouse_Y->addItem("Z"); + ui.cbxSelectMouse_Y->addItem("None"); + ui.cbxSelectMouse_Y->addItem("X"); + ui.cbxSelectMouse_Y->addItem("Y"); + ui.cbxSelectMouse_Y->addItem("Z"); ui.cbxSelectMouse_Y->addItem("Yaw"); - ui.cbxSelectMouse_Y->addItem("Pitch"); - ui.cbxSelectMouse_Y->addItem("Roll"); - // 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 ))); - theProtocol = NULL; - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -MOUSEControls::~MOUSEControls() { - qDebug() << "~MOUSEControls() says: started"; -} + ui.cbxSelectMouse_Y->addItem("Pitch"); + ui.cbxSelectMouse_Y->addItem("Roll"); -// -// Initialize tracker-client-dialog -// -void MOUSEControls::Initialize(QWidget *parent) { + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); + tie_setting(s.Mouse_X, ui.cbxSelectMouse_X); + tie_setting(s.Mouse_Y, ui.cbxSelectMouse_Y); } -// -// OK clicked on server-dialog -// void MOUSEControls::doOK() { - save(); - this->close(); -} - -// override show event -void MOUSEControls::showEvent ( QShowEvent * event ) { - loadSettings(); + s.b->save(); + if (_proto) + _proto->reload(); + this->close(); } -// -// 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("opentrack"); // Registry settings (in HK_USER) - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Mouse" ); - ui.cbxSelectMouse_X->setCurrentIndex(iniFile.value ( "Mouse_X", 0 ).toInt() ); - ui.cbxSelectMouse_Y->setCurrentIndex(iniFile.value ( "Mouse_Y", 0 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; + if (s.b->modifiedp()) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + s.b->save(); + this->close(); + if (_proto) + _proto->reload(); + break; + case QMessageBox::Discard: + s.b->revert(); + this->close(); + break; + case QMessageBox::Cancel: + default: + break; + } + } + else { + this->close(); + } } -// -// Save the current Settings to the currently 'active' INI-file. -// -void MOUSEControls::save() { - qDebug() << "save() says: started"; - - QSettings settings("opentrack"); // Registry settings (in HK_USER) - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup ( "Mouse" ); - iniFile.setValue ( "Mouse_X", ui.cbxSelectMouse_X->currentIndex() ); - iniFile.setValue ( "Mouse_Y", ui.cbxSelectMouse_Y->currentIndex() ); - 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") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) { return new MOUSEControls; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp index d142934d..54f6b307 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp @@ -23,26 +23,8 @@ * * ********************************************************************************/ #include "ftnoir_protocol_mouse.h" -#include #include "facetracknoir/global-settings.h" -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") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_ProtocolDll; -- cgit v1.2.3