From fa48b03e334e4f70a8f8bac7c7df2513c1cba0b8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 16 Jun 2014 03:00:26 +0200 Subject: Revert "lerp: didn't work at all, now does" This reverts commit a21435cb6fe163d6579f3fd3d42ad11c54037036. --- facetracknoir/lerp.hpp | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/lerp.hpp b/facetracknoir/lerp.hpp index 0123832ab..70d5995c2 100644 --- a/facetracknoir/lerp.hpp +++ b/facetracknoir/lerp.hpp @@ -2,52 +2,37 @@ #include "facetracknoir/timer.hpp" #include -#include class lerp { private: - static const constexpr double eps = 1e-2; - double last[2][6], cam[6], dt; + double last[2][6], dt; Timer t; public: lerp() : - last { {0,0,0,0,0,0}, {0,0,0,0,0,0} }, cam {0,0,0,0,0,0}, dt(1) + last { {0,0,0,0,0,0}, {0,0,0,0,0,0} }, dt(1) { } bool idempotentp(const double* input) { for (int i = 0; i < 6; i++) - { - double diff = fabs(cam[i] - input[i]); - if (diff > eps) + if (last[0][i] != input[i]) return false; - } return true; } - void write(const double* cam_, const double* input, double* output) + void write(const double* input, double* output) { - const double q = t.elapsed(); - const double d = q/dt; + const double q = dt; + dt = std::max(1, t.start()); - bool idem = idempotentp(cam_); + const double c = std::max(std::min(1.0, q/(double)dt), 0.0); - if (!idem) + for (int i = 0; i < 6; i++) { - dt = q; - t.start(); + last[1][i] = last[0][i]; + last[0][i] = input[i]; } - const double c = std::max(std::min(1.0, d), 0.0); - - if (!idem) - for (int i = 0; i < 6; i++) - { - last[1][i] = last[0][i]; - last[0][i] = input[i]; - cam[i] = cam_[i]; - } - for (int i = 0; i < 6; i++) output[i] = last[1][i] + (last[0][i] - last[1][i]) * c; } -- cgit v1.2.3 From 4d3df8df632d9230389fa2ffec6c4b28fa2985ff Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 16 Jun 2014 03:00:27 +0200 Subject: Revert "lerp class to simplify filter flow" This reverts commit 5409f26675a444170b3a68fc9750742cc68aaa1d. --- facetracknoir/lerp.hpp | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 facetracknoir/lerp.hpp (limited to 'facetracknoir') diff --git a/facetracknoir/lerp.hpp b/facetracknoir/lerp.hpp deleted file mode 100644 index 70d5995c2..000000000 --- a/facetracknoir/lerp.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include "facetracknoir/timer.hpp" -#include - -class lerp { -private: - double last[2][6], dt; - Timer t; -public: - lerp() : - last { {0,0,0,0,0,0}, {0,0,0,0,0,0} }, dt(1) - { - } - bool idempotentp(const double* input) - { - for (int i = 0; i < 6; i++) - if (last[0][i] != input[i]) - return false; - return true; - } - - void write(const double* input, double* output) - { - const double q = dt; - dt = std::max(1, t.start()); - - const double c = std::max(std::min(1.0, q/(double)dt), 0.0); - - for (int i = 0; i < 6; i++) - { - last[1][i] = last[0][i]; - last[0][i] = input[i]; - } - - for (int i = 0; i < 6; i++) - output[i] = last[1][i] + (last[0][i] - last[1][i]) * c; - } - - void get_state(double* state) - { - for (int i = 0; i < 6; i++) - state[i] = last[0][i]; - } -}; -- cgit v1.2.3 From 1f4751d5fc47dc469500854e9763d9796c847b57 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 11 Jul 2014 11:32:28 +0200 Subject: print some debug on win32 as well --- facetracknoir/global-settings.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index 3b6278604..36c14f092 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -87,9 +87,13 @@ DynamicLibrary::DynamicLibrary(const QString& filename) #if defined(_WIN32) QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; handle = new QLibrary(fullPath); + qDebug() << handle->errorString(); Dialog = (SETTINGS_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + qDebug() << handle->errorString(); Constructor = (NULLARY_DYNAMIC_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + qDebug() << handle->errorString(); Metadata = (METADATA_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + qDebug() << handle->errorString(); #else QByteArray latin1 = QFile::encodeName(filename); handle = dlopen(latin1.constData(), RTLD_NOW | -- cgit v1.2.3 From b87a7d0a25821e439e06a439eb4518395afbf7ed Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 11 Jul 2014 12:06:54 +0200 Subject: main ui: change profile cbx content when dir switch --- facetracknoir/facetracknoir.cpp | 17 +++++++---------- facetracknoir/facetracknoir.h | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 893e79cd1..00a7b95e2 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -104,7 +104,7 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : pProtocolDialog(NULL), pFilterDialog(NULL), kbd_quit(QKeySequence("Ctrl+Q"), this), - looping(false) + looping(0) { ui.setupUi(this); setFixedSize(size()); @@ -256,10 +256,8 @@ void FaceTrackNoIR::open() { QSettings settings("opentrack"); settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); } - looping = true; fill_profile_cbx(); loadSettings(); - looping = false; } } @@ -286,7 +284,7 @@ void FaceTrackNoIR::save() { void FaceTrackNoIR::saveAs() { - looping = true; + looping++; QSettings settings("opentrack"); QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); @@ -311,7 +309,7 @@ void FaceTrackNoIR::saveAs() save(); } - looping = false; + looping--; fill_profile_cbx(); } @@ -584,6 +582,7 @@ void FaceTrackNoIR::fill_profile_cbx() { if (looping) return; + looping++; QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); qDebug() << "Config file now" << currentFile; @@ -594,12 +593,10 @@ void FaceTrackNoIR::fill_profile_cbx() filters << "*.ini"; auto iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); ui.iconcomboProfile->clear(); - for ( int i = 0; i < iniFileList.size(); i++) { + for ( int i = 0; i < iniFileList.size(); i++) ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); - if (iniFileList.at(i) == pathInfo.fileName()) { - ui.iconcomboProfile->setCurrentIndex( i ); - } - } + ui.iconcomboProfile->setCurrentText(pathInfo.fileName()); + looping--; } void FaceTrackNoIR::profileSelected(int index) diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 50a6e0ec2..192b00b64 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -139,7 +139,7 @@ private: void bind_keyboard_shortcut(QxtGlobalShortcut&, key_opts& k); #endif void fill_profile_cbx(); - bool looping; + int looping; private slots: void open(); -- cgit v1.2.3 From fff9b880283f26d226eb1aa1a3bebf8a06d7d21b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 11 Jul 2014 12:12:35 +0200 Subject: some java-ism dirt nap --- facetracknoir/tracker.cpp | 1 - ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 094264ffe..dfe9bc1de 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -87,7 +87,6 @@ static void t_compensate(double* input, double* output, bool rz) output[i] = ret.at(i); } -/** QThread run method @override **/ void Tracker::run() { T6DOF offset_camera; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index 02ae21f02..97b2448b5 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -39,7 +39,6 @@ FTNoIR_Tracker::~FTNoIR_Tracker() wait(); } -/** QThread run @override **/ void FTNoIR_Tracker::run() { forever { if (should_quit) -- cgit v1.2.3 From b68868247aea33b2e26b80058fc5a48df69ba53a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Jul 2014 15:48:12 +0200 Subject: nix nonsensical typedef naming --- facetracknoir/global-settings.cpp | 16 ++++++++-------- facetracknoir/global-settings.h | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index 36c14f092..9c84945be 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -31,34 +31,34 @@ SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : correct = false; if (!mainApp) return; - NULLARY_DYNAMIC_FUNCTION ptr; + CTOR_FUNPTR ptr; DynamicLibrary* lib; lib = mainApp->current_tracker1(); if (lib && lib->Constructor) { - ptr = (NULLARY_DYNAMIC_FUNCTION) lib->Constructor; + ptr = (CTOR_FUNPTR) lib->Constructor; pTracker = (ITracker*) ptr(); } lib = mainApp->current_tracker2(); if (lib && lib->Constructor) { - ptr = (NULLARY_DYNAMIC_FUNCTION) lib->Constructor; + ptr = (CTOR_FUNPTR) lib->Constructor; pSecondTracker = (ITracker*) ptr(); } lib = mainApp->current_protocol(); if (lib && lib->Constructor) { - ptr = (NULLARY_DYNAMIC_FUNCTION) lib->Constructor; + ptr = (CTOR_FUNPTR) lib->Constructor; pProtocol = (IProtocol*) ptr(); } lib = mainApp->current_filter(); if (lib && lib->Constructor) { - ptr = (NULLARY_DYNAMIC_FUNCTION) lib->Constructor; + ptr = (CTOR_FUNPTR) lib->Constructor; pFilter = (IFilter*) ptr(); } @@ -109,13 +109,13 @@ DynamicLibrary::DynamicLibrary(const QString& filename) { fprintf(stderr, "Error, if any: %s\n", dlerror()); fflush(stderr); - Dialog = (SETTINGS_FUNCTION) dlsym(handle, "GetDialog"); + Dialog = (DIALOG_FUNPTR) dlsym(handle, "GetDialog"); fprintf(stderr, "Error, if any: %s\n", dlerror()); fflush(stderr); - Constructor = (NULLARY_DYNAMIC_FUNCTION) dlsym(handle, "GetConstructor"); + Constructor = (CTOR_FUNPTR) dlsym(handle, "GetConstructor"); fprintf(stderr, "Error, if any: %s\n", dlerror()); fflush(stderr); - Metadata = (METADATA_FUNCTION) dlsym(handle, "GetMetadata"); + Metadata = (METADATA_FUNPTR) dlsym(handle, "GetMetadata"); fprintf(stderr, "Error, if any: %s\n", dlerror()); fflush(stderr); } else { diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h index 6b04b73bc..4394d1a08 100644 --- a/facetracknoir/global-settings.h +++ b/facetracknoir/global-settings.h @@ -52,17 +52,17 @@ extern SelectedLibraries* Libraries; struct Metadata; -extern "C" typedef void* (CALLING_CONVENTION * NULLARY_DYNAMIC_FUNCTION)(void); -extern "C" typedef Metadata* (CALLING_CONVENTION* METADATA_FUNCTION)(void); -extern "C" typedef void* (CALLING_CONVENTION* SETTINGS_FUNCTION)(void); +extern "C" typedef void* (CALLING_CONVENTION * CTOR_FUNPTR)(void); +extern "C" typedef Metadata* (CALLING_CONVENTION* METADATA_FUNPTR)(void); +extern "C" typedef void* (CALLING_CONVENTION* DIALOG_FUNPTR)(void); class DynamicLibrary { public: DynamicLibrary(const QString& filename); virtual ~DynamicLibrary(); - SETTINGS_FUNCTION Dialog; - NULLARY_DYNAMIC_FUNCTION Constructor; - METADATA_FUNCTION Metadata; + DIALOG_FUNPTR Dialog; + CTOR_FUNPTR Constructor; + METADATA_FUNPTR Metadata; QString filename; private: #if defined(_WIN32) -- cgit v1.2.3 From 41c2933a5ab2a2592a8d4dffb91b6db3a02f3c9b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Jul 2014 16:21:31 +0200 Subject: rename file so that name makes any sense --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 2 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp | 2 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h | 2 +- facetracknoir/facetracknoir.h | 2 +- facetracknoir/global-settings.cpp | 136 --------------------- facetracknoir/global-settings.h | 93 -------------- facetracknoir/plugin-support.cpp | 136 +++++++++++++++++++++ facetracknoir/plugin-support.h | 93 ++++++++++++++ facetracknoir/tracker.h | 2 +- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 2 +- .../ftnoir_filter_accela_dialog.cpp | 2 +- ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp | 2 +- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 2 +- ftnoir_filter_kalman/kalman.cpp | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp | 2 +- .../ftnoir_protocol_libevdev.cpp | 2 +- .../ftnoir_protocol_libevdev.h | 2 +- .../ftnoir_protocol_libevdev_dialog.cpp | 2 +- .../ftnoir_protocol_libevdev_dll.cpp | 2 +- ftnoir_protocol_wine/ftnoir_protocol_wine.h | 2 +- .../ftnoir_protocol_wine_dialog.cpp | 2 +- ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 +- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 2 +- .../ftnoir_tracker_hydra_dialog.cpp | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 2 +- opentrack-api/opentrack-guts.h | 2 +- 46 files changed, 272 insertions(+), 272 deletions(-) delete mode 100644 facetracknoir/global-settings.cpp delete mode 100644 facetracknoir/global-settings.h create mode 100644 facetracknoir/plugin-support.cpp create mode 100644 facetracknoir/plugin-support.h (limited to 'facetracknoir') diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 190ed76ad..79f16629b 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -10,7 +10,7 @@ #ifdef OPENTRACK_API # include "ftnoir_tracker_base/ftnoir_tracker_base.h" -# include "facetracknoir/global-settings.h" +# include "facetracknoir/plugin-support.h" #endif #include "ftnoir_tracker_pt_settings.h" #include "frame_observer.h" diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp index f3fbbef70..15e830a4d 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp @@ -31,7 +31,7 @@ void TrackerDll::getIcon(QIcon *icon) #ifdef OPENTRACK_API -# include "facetracknoir/global-settings.h" +# include "facetracknoir/plugin-support.h" extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() #else # pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h index 1d30e7e50..22e1ff292 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h @@ -7,7 +7,7 @@ #if defined(OPENTRACK_API) # include "ftnoir_tracker_base/ftnoir_tracker_base.h" -# include "facetracknoir/global-settings.h" +# include "facetracknoir/plugin-support.h" #else # include "../ftnoir_tracker_base/ftnoir_tracker_base.h" #endif diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 192b00b64..ca8084c21 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -55,7 +55,7 @@ using namespace options; #include "facetracknoir/main-settings.hpp" -#include "global-settings.h" +#include "facetracknoir/plugin-support.h" #include "tracker.h" #include "facetracknoir/shortcuts.h" diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp deleted file mode 100644 index 9c84945be..000000000 --- a/facetracknoir/global-settings.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "global-settings.h" - -#if !(defined(_WIN32)) -# include -#endif - -SelectedLibraries* Libraries = NULL; - -SelectedLibraries::~SelectedLibraries() -{ - if (pTracker) { - delete pTracker; - pTracker = NULL; - } - - if (pSecondTracker) { - delete pSecondTracker; - pSecondTracker = NULL; - } - - if (pFilter) - delete pFilter; - - if (pProtocol) - delete pProtocol; -} - -SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : - pTracker(NULL), pSecondTracker(NULL), pFilter(NULL), pProtocol(NULL) -{ - correct = false; - if (!mainApp) - return; - CTOR_FUNPTR ptr; - DynamicLibrary* lib; - - lib = mainApp->current_tracker1(); - - if (lib && lib->Constructor) { - ptr = (CTOR_FUNPTR) lib->Constructor; - pTracker = (ITracker*) ptr(); - } - - lib = mainApp->current_tracker2(); - - if (lib && lib->Constructor) { - ptr = (CTOR_FUNPTR) lib->Constructor; - pSecondTracker = (ITracker*) ptr(); - } - - lib = mainApp->current_protocol(); - - if (lib && lib->Constructor) { - ptr = (CTOR_FUNPTR) lib->Constructor; - pProtocol = (IProtocol*) ptr(); - } - - lib = mainApp->current_filter(); - - if (lib && lib->Constructor) { - ptr = (CTOR_FUNPTR) lib->Constructor; - pFilter = (IFilter*) ptr(); - } - - // Check if the Protocol-server files were installed OK. - // Some servers also create a memory-mapping, for Inter Process Communication. - // The handle of the MainWindow is sent to 'The Game', so it can send a message back. - - if (pProtocol) - if(!pProtocol->checkServerInstallationOK()) - return; - - // retrieve pointers to the User Interface and the main Application - if (pTracker) { - pTracker->StartTracker( mainApp->get_video_widget() ); - } - if (pSecondTracker) { - pSecondTracker->StartTracker( mainApp->get_video_widget() ); - } - - correct = true; -} - -DynamicLibrary::DynamicLibrary(const QString& filename) -{ - this->filename = filename; -#if defined(_WIN32) - QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; - handle = new QLibrary(fullPath); - qDebug() << handle->errorString(); - Dialog = (SETTINGS_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); - qDebug() << handle->errorString(); - Constructor = (NULLARY_DYNAMIC_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); - qDebug() << handle->errorString(); - Metadata = (METADATA_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); - qDebug() << handle->errorString(); -#else - QByteArray latin1 = QFile::encodeName(filename); - handle = dlopen(latin1.constData(), RTLD_NOW | -# ifdef __linux - RTLD_DEEPBIND -# elif defined(__APPLE__) - RTLD_LOCAL|RTLD_FIRST|RTLD_NOW -# else - 0 -# endif - ); - if (handle) - { - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - Dialog = (DIALOG_FUNPTR) dlsym(handle, "GetDialog"); - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - Constructor = (CTOR_FUNPTR) dlsym(handle, "GetConstructor"); - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - Metadata = (METADATA_FUNPTR) dlsym(handle, "GetMetadata"); - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - } else { - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - } -#endif -} - -DynamicLibrary::~DynamicLibrary() -{ -#if defined(_WIN32) - handle->unload(); -#else - if (handle) - (void) dlclose(handle); -#endif -} diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h deleted file mode 100644 index 4394d1a08..000000000 --- a/facetracknoir/global-settings.h +++ /dev/null @@ -1,93 +0,0 @@ -#pragma once - -#if defined(_WIN32) -# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "@0" -# ifdef _MSC_VER -# define MAYBE_STDCALL_UNDERSCORE "_" -#else -# define MAYBE_STDCALL_UNDERSCORE "" -# endif -#else -# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "" -# define MAYBE_STDCALL_UNDERSCORE "" -#endif - -#ifdef _MSC_VER -# define virt_override -#else -# define virt_override override -#endif - -#include - -#include -#include -#include -#include -#include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_filter_base/ftnoir_filter_base.h" -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" - -#if defined(_WIN32) -# define CALLING_CONVENTION __stdcall -#else -# define CALLING_CONVENTION -#endif - -class IDynamicLibraryProvider; - -struct SelectedLibraries { -public: - ITracker* pTracker; - ITracker* pSecondTracker; - IFilter* pFilter; - IProtocol* pProtocol; - SelectedLibraries(IDynamicLibraryProvider* main = NULL); - ~SelectedLibraries(); - bool correct; -}; - -extern SelectedLibraries* Libraries; - -struct Metadata; - -extern "C" typedef void* (CALLING_CONVENTION * CTOR_FUNPTR)(void); -extern "C" typedef Metadata* (CALLING_CONVENTION* METADATA_FUNPTR)(void); -extern "C" typedef void* (CALLING_CONVENTION* DIALOG_FUNPTR)(void); - -class DynamicLibrary { -public: - DynamicLibrary(const QString& filename); - virtual ~DynamicLibrary(); - DIALOG_FUNPTR Dialog; - CTOR_FUNPTR Constructor; - METADATA_FUNPTR Metadata; - QString filename; -private: -#if defined(_WIN32) - QLibrary* handle; -#else - void* handle; -#endif -}; - -struct Metadata -{ - Metadata() {} - virtual ~Metadata() {} - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; - virtual void getIcon(QIcon *icon) = 0; -}; - -class IDynamicLibraryProvider { -public: - virtual DynamicLibrary* current_tracker1() = 0; - virtual DynamicLibrary* current_tracker2() = 0; - virtual DynamicLibrary* current_protocol() = 0; - virtual DynamicLibrary* current_filter() = 0; - virtual QFrame* get_video_widget() = 0; -}; diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp new file mode 100644 index 000000000..09e1c200d --- /dev/null +++ b/facetracknoir/plugin-support.cpp @@ -0,0 +1,136 @@ +#include "plugin-support.h" + +#if !(defined(_WIN32)) +# include +#endif + +SelectedLibraries* Libraries = NULL; + +SelectedLibraries::~SelectedLibraries() +{ + if (pTracker) { + delete pTracker; + pTracker = NULL; + } + + if (pSecondTracker) { + delete pSecondTracker; + pSecondTracker = NULL; + } + + if (pFilter) + delete pFilter; + + if (pProtocol) + delete pProtocol; +} + +SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : + pTracker(NULL), pSecondTracker(NULL), pFilter(NULL), pProtocol(NULL) +{ + correct = false; + if (!mainApp) + return; + CTOR_FUNPTR ptr; + DynamicLibrary* lib; + + lib = mainApp->current_tracker1(); + + if (lib && lib->Constructor) { + ptr = (CTOR_FUNPTR) lib->Constructor; + pTracker = (ITracker*) ptr(); + } + + lib = mainApp->current_tracker2(); + + if (lib && lib->Constructor) { + ptr = (CTOR_FUNPTR) lib->Constructor; + pSecondTracker = (ITracker*) ptr(); + } + + lib = mainApp->current_protocol(); + + if (lib && lib->Constructor) { + ptr = (CTOR_FUNPTR) lib->Constructor; + pProtocol = (IProtocol*) ptr(); + } + + lib = mainApp->current_filter(); + + if (lib && lib->Constructor) { + ptr = (CTOR_FUNPTR) lib->Constructor; + pFilter = (IFilter*) ptr(); + } + + // Check if the Protocol-server files were installed OK. + // Some servers also create a memory-mapping, for Inter Process Communication. + // The handle of the MainWindow is sent to 'The Game', so it can send a message back. + + if (pProtocol) + if(!pProtocol->checkServerInstallationOK()) + return; + + // retrieve pointers to the User Interface and the main Application + if (pTracker) { + pTracker->StartTracker( mainApp->get_video_widget() ); + } + if (pSecondTracker) { + pSecondTracker->StartTracker( mainApp->get_video_widget() ); + } + + correct = true; +} + +DynamicLibrary::DynamicLibrary(const QString& filename) +{ + this->filename = filename; +#if defined(_WIN32) + QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; + handle = new QLibrary(fullPath); + qDebug() << handle->errorString(); + Dialog = (SETTINGS_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + qDebug() << handle->errorString(); + Constructor = (NULLARY_DYNAMIC_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + qDebug() << handle->errorString(); + Metadata = (METADATA_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + qDebug() << handle->errorString(); +#else + QByteArray latin1 = QFile::encodeName(filename); + handle = dlopen(latin1.constData(), RTLD_NOW | +# ifdef __linux + RTLD_DEEPBIND +# elif defined(__APPLE__) + RTLD_LOCAL|RTLD_FIRST|RTLD_NOW +# else + 0 +# endif + ); + if (handle) + { + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + Dialog = (DIALOG_FUNPTR) dlsym(handle, "GetDialog"); + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + Constructor = (CTOR_FUNPTR) dlsym(handle, "GetConstructor"); + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + Metadata = (METADATA_FUNPTR) dlsym(handle, "GetMetadata"); + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + } else { + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + } +#endif +} + +DynamicLibrary::~DynamicLibrary() +{ +#if defined(_WIN32) + handle->unload(); +#else + if (handle) + (void) dlclose(handle); +#endif +} diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h new file mode 100644 index 000000000..4394d1a08 --- /dev/null +++ b/facetracknoir/plugin-support.h @@ -0,0 +1,93 @@ +#pragma once + +#if defined(_WIN32) +# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "@0" +# ifdef _MSC_VER +# define MAYBE_STDCALL_UNDERSCORE "_" +#else +# define MAYBE_STDCALL_UNDERSCORE "" +# endif +#else +# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "" +# define MAYBE_STDCALL_UNDERSCORE "" +#endif + +#ifdef _MSC_VER +# define virt_override +#else +# define virt_override override +#endif + +#include + +#include +#include +#include +#include +#include +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ftnoir_filter_base/ftnoir_filter_base.h" +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" + +#if defined(_WIN32) +# define CALLING_CONVENTION __stdcall +#else +# define CALLING_CONVENTION +#endif + +class IDynamicLibraryProvider; + +struct SelectedLibraries { +public: + ITracker* pTracker; + ITracker* pSecondTracker; + IFilter* pFilter; + IProtocol* pProtocol; + SelectedLibraries(IDynamicLibraryProvider* main = NULL); + ~SelectedLibraries(); + bool correct; +}; + +extern SelectedLibraries* Libraries; + +struct Metadata; + +extern "C" typedef void* (CALLING_CONVENTION * CTOR_FUNPTR)(void); +extern "C" typedef Metadata* (CALLING_CONVENTION* METADATA_FUNPTR)(void); +extern "C" typedef void* (CALLING_CONVENTION* DIALOG_FUNPTR)(void); + +class DynamicLibrary { +public: + DynamicLibrary(const QString& filename); + virtual ~DynamicLibrary(); + DIALOG_FUNPTR Dialog; + CTOR_FUNPTR Constructor; + METADATA_FUNPTR Metadata; + QString filename; +private: +#if defined(_WIN32) + QLibrary* handle; +#else + void* handle; +#endif +}; + +struct Metadata +{ + Metadata() {} + virtual ~Metadata() {} + + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; + virtual void getIcon(QIcon *icon) = 0; +}; + +class IDynamicLibraryProvider { +public: + virtual DynamicLibrary* current_tracker1() = 0; + virtual DynamicLibrary* current_tracker2() = 0; + virtual DynamicLibrary* current_protocol() = 0; + virtual DynamicLibrary* current_filter() = 0; + virtual QFrame* get_video_widget() = 0; +}; diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 46440c32c..49e7f3021 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -10,7 +10,7 @@ #include #include #include -#include "global-settings.h" +#include "plugin-support.h" #include #include diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index c9965f2d3..08e64667b 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -9,7 +9,7 @@ #include #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" using namespace std; FTNoIR_Filter::FTNoIR_Filter() : first_run(true) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 125c1a392..4a9136b57 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -1,7 +1,7 @@ #pragma once #include "ftnoir_filter_base/ftnoir_filter_base.h" #include "ui_ftnoir_accela_filtercontrols.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include #define ACCELA_SMOOTHING_ROTATION 60.0 diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index ca321891e..41b6022b7 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" FilterControls::FilterControls() : accela_filter(nullptr) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp index a024e7898..d42baef7d 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp @@ -1,5 +1,5 @@ #include "ftnoir_filter_accela.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index c073bfa4d..1001514d9 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -26,7 +26,7 @@ #include "math.h" #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include #include diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index bde3e79c3..c08b0dd94 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -27,7 +27,7 @@ #define INCLUDED_FTN_FILTER_H #include "ftnoir_filter_base/ftnoir_filter_base.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include "ui_ftnoir_ewma_filtercontrols.h" #include #include diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index fb02354ec..c042d12c8 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -25,7 +25,7 @@ #include "ftnoir_filter_ewma2.h" #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include "ui_ftnoir_ewma_filtercontrols.h" FilterControls::FilterControls() : diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp index 6ef7768ee..106bf4c65 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp @@ -23,7 +23,7 @@ * * ********************************************************************************/ #include "ftnoir_filter_ewma2.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index 6c737b4b1..e4b27d1fa 100755 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -10,7 +10,7 @@ #include "ftnoir_filter_base/ftnoir_filter_base.h" #include "ui_ftnoir_kalman_filtercontrols.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include #include #include diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp index bef6ddad6..81ee1df25 100644 --- a/ftnoir_filter_kalman/kalman.cpp +++ b/ftnoir_filter_kalman/kalman.cpp @@ -5,7 +5,7 @@ * copyright notice and this permission notice appear in all copies. */ #include "ftnoir_filter_kalman.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include #include diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index 0ef6b50fe..15a79131f 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -26,7 +26,7 @@ * It is based on the (Linux) example made by Melchior FRANZ. * ********************************************************************************/ #include "ftnoir_protocol_fg.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include // For Todd and Arda Kutlu diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index dca1f2453..f24331d9d 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -32,7 +32,7 @@ #include #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include "facetracknoir/options.h" using namespace options; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index 1c3e5ef8c..d9c596b7b 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -28,7 +28,7 @@ #include "ftnoir_protocol_fg.h" #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" //******************************************************************************************************* // FaceTrackNoIR Client Settings-dialog. diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp index 3125f1362..b7e286fdd 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp @@ -24,7 +24,7 @@ ********************************************************************************/ #include "ftnoir_protocol_fg.h" #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp index e93a751e3..4f71eb898 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp @@ -27,7 +27,7 @@ ********************************************************************************/ #include "ftnoir_protocol_ftn.h" #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" /** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index 99e6c6a1a..2e3c270ac 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -34,7 +34,7 @@ #include #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include "facetracknoir/options.h" using namespace options; diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index 37db314f9..6afe20f28 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -23,7 +23,7 @@ * * ********************************************************************************/ #include "ftnoir_protocol_ftn.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" FTNControls::FTNControls() : QWidget() diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp index 996894322..fdc2f4ca5 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp @@ -23,7 +23,7 @@ * * ********************************************************************************/ #include "ftnoir_protocol_ftn.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index 70fde395f..d2a8e5bfe 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -1,5 +1,5 @@ #include "ftnoir_protocol_libevdev.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" //#include "ftnoir_tracker_base/ftnoir_tracker_types.h" #include #include diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index 66f535473..c9c80c5f9 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -9,7 +9,7 @@ #include "ui_ftnoir_libevdev_controls.h" #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" extern "C" { # include diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp index bb54c354d..b63cc0c76 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp @@ -1,5 +1,5 @@ #include "ftnoir_protocol_libevdev.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" LibevdevControls::LibevdevControls() : QWidget() { diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp index 79a22d5e4..639b93d73 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp @@ -1,6 +1,6 @@ #include "ftnoir_protocol_libevdev.h" #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { } diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index 50d2bc0c8..70a2b0d0b 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -39,7 +39,7 @@ #include #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include "compat/compat.h" #include "ftnoir_protocol_wine/wine-shm.h" diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp index ecbc21374..29d462199 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp @@ -1,6 +1,6 @@ #include "ftnoir_protocol_wine.h" #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" //******************************************************************************************************* // FaceTrackNoIR Client Settings-dialog. diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp index dd7f17a6c..4b00d7dc5 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp @@ -1,6 +1,6 @@ #include "ftnoir_protocol_wine.h" #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { } diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index c3c8170ca..5e983f4f0 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -8,7 +8,7 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ftnoir_tracker_aruco.h" #include "ui_aruco-trackercontrols.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include #include #include @@ -457,7 +457,7 @@ extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDial TrackerControls::TrackerControls() { tracker = nullptr; - calib_timer.setInterval(100); + calib_timer.setInterval(200); ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); tie_setting(s.camera_index, ui.cameraName); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 76a6ba710..3f67953e9 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -4,7 +4,7 @@ #include "ftnoir_tracker_ht.h" #include "ftnoir_tracker_ht_dll.h" #include "ui_ht-trackercontrols.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include #if defined(_WIN32) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h b/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h index ffdc52629..af2ec00c4 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h @@ -6,7 +6,7 @@ */ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" //----------------------------------------------------------------------------- class TrackerDll : public Metadata diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 70af28938..6345ac573 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -1,6 +1,6 @@ /* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */ #include "ftnoir_tracker_hydra.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include "facetracknoir/rotation.h" #include #ifdef _WIN32 diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 05a8b0761..90574a4b4 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -3,7 +3,7 @@ #include #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include "facetracknoir/options.h" using namespace options; diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index 14be2c376..6c98a0a1d 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -1,5 +1,5 @@ #include "ftnoir_tracker_hydra.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" TrackerControls::TrackerControls() : QWidget() diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp index a2cc7c012..f0939081f 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp @@ -1,7 +1,7 @@ /* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */ #include "ftnoir_tracker_hydra.h" #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index 97b2448b5..1b6d9ddd5 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -23,7 +23,7 @@ * * ********************************************************************************/ #include "ftnoir_tracker_udp.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" FTNoIR_Tracker::FTNoIR_Tracker() : should_quit(false) { diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 62eb67df6..2854e9422 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -6,7 +6,7 @@ #include #include #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include "facetracknoir/options.h" using namespace options; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index 8d1b99f2e..17b174e84 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -23,7 +23,7 @@ * * ********************************************************************************/ #include "ftnoir_tracker_udp.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" TrackerControls::TrackerControls() : QWidget() diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp index 22dc7daa0..3d6fbc281 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -24,7 +24,7 @@ ********************************************************************************/ #include "ftnoir_tracker_udp.h" #include -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index c8e3309a0..c7134a6a9 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -12,7 +12,7 @@ #include #include #include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "facetracknoir/global-settings.h" +#include "facetracknoir/plugin-support.h" #include typedef ITracker* opentrack_tracker; -- cgit v1.2.3 From 7bf7e2af2f6f62251eafc5ddd08db6effd3df751 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Jul 2014 19:48:13 +0200 Subject: further rename fixes --- CMakeLists.txt | 2 +- facetracknoir/plugin-support.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index cbab479ba..e12f1c846 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,7 +217,7 @@ macro(opentrack_library n) install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) endmacro() -file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp" "opentrack-api/*.h" "facetracknoir/global-settings.h") +file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp" "opentrack-api/*.h" "facetracknoir/plugin-support.cpp") opentrack_module(opentrack-bin facetracknoir) opentrack_module(opentrack-pose-widget ftnoir_posewidget) diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp index 09e1c200d..5d810ed1e 100644 --- a/facetracknoir/plugin-support.cpp +++ b/facetracknoir/plugin-support.cpp @@ -88,11 +88,11 @@ DynamicLibrary::DynamicLibrary(const QString& filename) QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; handle = new QLibrary(fullPath); qDebug() << handle->errorString(); - Dialog = (SETTINGS_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + Dialog = (DIALOG_FUNPTR) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); qDebug() << handle->errorString(); - Constructor = (NULLARY_DYNAMIC_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + Constructor = (CTOR_FUNPTR) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); qDebug() << handle->errorString(); - Metadata = (METADATA_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + Metadata = (METADATA_FUNPTR) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); qDebug() << handle->errorString(); #else QByteArray latin1 = QFile::encodeName(filename); -- cgit v1.2.3 From ed33bf91fc5999eb55442524458585be3fc608e4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 28 Jul 2014 13:22:30 +0200 Subject: build system bug not relevant anymore --- compat/qt-bug-appeasement.cpp | 1 - facetracknoir/qt-moc.h | 10 ---------- 2 files changed, 11 deletions(-) delete mode 100644 compat/qt-bug-appeasement.cpp delete mode 100644 facetracknoir/qt-moc.h (limited to 'facetracknoir') diff --git a/compat/qt-bug-appeasement.cpp b/compat/qt-bug-appeasement.cpp deleted file mode 100644 index 9a86ac0a2..000000000 --- a/compat/qt-bug-appeasement.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "facetracknoir/qt-moc.h" diff --git a/facetracknoir/qt-moc.h b/facetracknoir/qt-moc.h deleted file mode 100644 index 8ccfffe89..000000000 --- a/facetracknoir/qt-moc.h +++ /dev/null @@ -1,10 +0,0 @@ -#include - -// this file exists only such that cmake qt automoc is appeased - -class AutomocMe : public QObject { - Q_OBJECT -private: - virtual void foo() = 0; - AutomocMe() {} -}; -- cgit v1.2.3 From ac0e2cce53c078235331f00dc79b65d333c90e76 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Aug 2014 09:18:23 +0200 Subject: use our own clock_gettime on win32 --- facetracknoir/timer.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp index e3fa38dee..24d62e37a 100644 --- a/facetracknoir/timer.hpp +++ b/facetracknoir/timer.hpp @@ -2,8 +2,7 @@ #include #if defined (_WIN32) # include -# define CLOCK_MONOTONIC 0 -static inline void clock_gettime(int, struct timespec* ts) +static inline void opentrack_clock_gettime(int, struct timespec* ts) { static LARGE_INTEGER freq; @@ -20,7 +19,7 @@ static inline void clock_gettime(int, struct timespec* ts) ts->tv_sec = d.QuadPart / 1000000000L; ts->tv_nsec = d.QuadPart % 1000000000L; } - +# define clock_gettime opentrack_clock_gettime #else # if defined(__MACH__) # define CLOCK_MONOTONIC 0 -- cgit v1.2.3 From 0027139d8348e07e6a2d9734489964961294fe22 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Aug 2014 10:19:10 +0200 Subject: remove MSVC support Leave as-is to avoid unconditionally assuming GNU extensions and ABI --- CMakeLists.txt | 99 +++--------------------- facetracknoir/facetracknoir.cpp | 2 +- facetracknoir/main.cpp | 26 ------- facetracknoir/plugin-support.h | 8 +- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 8 +- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 11 --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- ftnoir_tracker_base/ftnoir_tracker_base_global.h | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 6 +- opentrack-api/context.cpp | 2 +- 12 files changed, 26 insertions(+), 144 deletions(-) (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index f0e401aa4..647a34495 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ project(opentrack) cmake_minimum_required(VERSION 2.8.11) cmake_policy(SET CMP0020 NEW) +if(MSVC) + message(FATAL_ERROR "Support for MSVC removed due to incomplete C++11 support") +endif() + include(CMakeParseArguments) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/") @@ -47,43 +51,10 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_definitions(-DOPENTRACK_API -DIN_OPENTRACK) -if(MSVC) - add_definitions(-DNOMINMAX) -endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) add_definitions(-std=c++11) endif() -if(WIN32 AND MSVC) - set(SDK_GOOGLE_BREAKPAD "" CACHE PATH "google-breakpad for crash reporting") -endif() - -if(SDK_GOOGLE_BREAKPAD AND WIN32) - add_definitions(-DOPENTRACK_BREAKPAD) - include_directories("${SDK_GOOGLE_BREAKPAD}/src/client/windows/handler") - include_directories("${SDK_GOOGLE_BREAKPAD}/src/") -endif() - -if(WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) - find_path (WIN8_SDK_ROOT_DIR - Include/um/windows.h - PATHS - "$ENV{ProgramFiles}/Windows Kits/8.0" - "$ENV{ProgramFiles(x86)}/Windows Kits/8.0" - DOC "Windows 8 SDK root directory" - ) - - if(WIN8_SDK_ROOT_DIR) - SET(CMAKE_LIBRARY_PATH "${WIN8_SDK_ROOT_DIR}/Lib/win8/um/x86") - endif() -endif() - -if(WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") - SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") - SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") -endif() if(UNIX) set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") @@ -162,15 +133,7 @@ set(EXTRA-MOCS "${CMAKE_SOURCE_DIR}/facetracknoir/options.h") function(link_with_dinput8 n) if(WIN32) - if(MSVC) - target_link_libraries(${n} - "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) - else() - target_link_libraries(${n} dinput8 dxguid strmiids) - endif() + target_link_libraries(${n} dinput8 dxguid strmiids) endif() endfunction() @@ -306,11 +269,7 @@ opentrack_library(opentrack-proto-fgfs) if(SDK_VJOY) include_directories(${SDK_VJOY}) opentrack_library(opentrack-proto-vjoy) - if(MSVC) - target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib") - else() - target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") - endif() + target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") endif() if(SDK_ENABLE_LIBEVDEV) @@ -321,9 +280,6 @@ if(SDK_ENABLE_LIBEVDEV) endif() if(SDK_FSUIPC) - if(MSVC) - set(link-flags "/NODEFAULTLIB:libc") - endif() opentrack_library(opentrack-proto-fsuipc LINK "${link-flags}") target_link_libraries(opentrack-proto-fsuipc "${SDK_FSUIPC}/FSUIPC_User.lib") endif() @@ -384,12 +340,6 @@ if(SDK_ARUCO_LIBPATH) include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) opentrack_library(opentrack-tracker-aruco) target_link_libraries(opentrack-tracker-aruco ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) - if(WIN32 AND MSVC) - target_link_libraries(opentrack-tracker-aruco - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) - endif() endif() link_with_dinput8(opentrack-tracker-ht) @@ -411,24 +361,16 @@ if(SDK_RIFT) set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") set(c-flags "-fno-strict-aliasing") else() - if(MSVC) - set(link-flags "/NODEFAULTLIB:LIBCMT") - else() - set(c-flags "-fno-strict-aliasing") - endif() + set(c-flags "-fno-strict-aliasing") endif() opentrack_library(opentrack-tracker-rift LINK "${link-flags}" COMPILE "${c-flags}") - if(MSVC) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) + if(WIN32) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm setupapi ws2_32 imagehlp wbemuuid) else() - if(WIN32) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm setupapi) + if(NOT APPLE) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) else() - if(NOT APPLE) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) - else() - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") - endif() + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") endif() endif() endif() @@ -516,22 +458,11 @@ if(CMAKE_SYSTEM STREQUAL LINUX) link_libraries(rt) endif() -if(MSVC) - SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") -endif() target_link_libraries(opentrack opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTWIDGETS_LIB_RELEASE}) if(NOT WIN32) target_link_libraries(opentrack dl) target_link_libraries(opentrack-api dl) endif() -if(SDK_GOOGLE_BREAKPAD) - if(MSVC) - target_link_libraries(opentrack - "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/crash_generation_client.lib" - "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/exception_handler.lib" - "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/common.lib") - endif() -endif() # make install @@ -573,9 +504,3 @@ endif() if(WIN32) install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) endif() - -if(MSVC) - file(GLOB pdbs1 "${CMAKE_BINARY_DIR}/Release/*.pdb") - file(GLOB pdbs2 "${CMAKE_BINARY_DIR}/*.pdb") - install(FILES ${pdbs1} ${pdbs2} DESTINATION .) -endif() diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 00a7b95e2..d717b3bee 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -44,7 +44,7 @@ #include #ifdef _MSC_VER -# define LIB_PREFIX "" +# error "No support for MSVC anymore" #else # define LIB_PREFIX "lib" #endif diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 3143a0930..9bf11b322 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -32,34 +32,8 @@ #include #include -#if defined(_WIN32) && defined(_MSC_VER) -# include -# ifdef OPENTRACK_BREAKPAD -# include -using namespace google_breakpad; -bool dumpCallback(const wchar_t* dump_path, - const wchar_t* minidump_id, - void* context, - EXCEPTION_POINTERS* exinfo, - MDRawAssertionInfo* assertion, - bool succeeded) -{ - MessageBoxA(GetDesktopWindow(), - "Generating crash dump!\r\n" - "Please send the .dmp file to to help us improve the code.", - "opentrack crashed :(", - MB_OK | MB_ICONERROR); - return succeeded; -} - -# endif -#endif - int main(int argc, char** argv) { -#if defined(OPENTRACK_BREAKPAD) && defined(_MSC_VER) - auto handler = new ExceptionHandler(L".", nullptr, dumpCallback, nullptr, -1); -#endif QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); auto w = std::make_shared(); diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h index 4394d1a08..1c63151a7 100644 --- a/facetracknoir/plugin-support.h +++ b/facetracknoir/plugin-support.h @@ -3,7 +3,7 @@ #if defined(_WIN32) # define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "@0" # ifdef _MSC_VER -# define MAYBE_STDCALL_UNDERSCORE "_" +# error "No support for MSVC anymore" #else # define MAYBE_STDCALL_UNDERSCORE "" # endif @@ -12,12 +12,6 @@ # define MAYBE_STDCALL_UNDERSCORE "" #endif -#ifdef _MSC_VER -# define virt_override -#else -# define virt_override override -#endif - #include #include diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index e4b27d1fa..9964d6f23 100755 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -25,9 +25,9 @@ class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - void reset() virt_override; + void reset() override; void FilterHeadPoseData(const double *target_camera_position, - double *new_camera_position) virt_override; + double *new_camera_position) override; cv::KalmanFilter kalman; double prev_position[6]; double prev2_filter_pos[6]; @@ -56,8 +56,8 @@ public: show(); } Ui::KalmanUICFilterControls ui; - virtual void registerFilter(IFilter*) virt_override {} - virtual void unregisterFilter() virt_override {} + virtual void registerFilter(IFilter*) override {} + virtual void unregisterFilter() override {} public slots: void doOK(); void doCancel(); diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index dcdd8098c..6e0db58c1 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -67,7 +67,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol() virt_override; + virtual ~FTNoIR_Protocol() override; bool checkServerInstallationOK(); void sendHeadposeToGame(const double* headpose); QString getGameName() { diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 7de762ac2..c53aa49c2 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -103,7 +103,7 @@ public: actx.lpResourceName = MAKEINTRESOURCEA(resid); actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; #ifdef _MSC_VER -# define PREFIX "" +# error "MSVC support removed" #else # define PREFIX "lib" #endif diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 6ef828d4a..c36b15f30 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -106,17 +106,6 @@ typedef struct _JOYSTICK_STATE UINT32 Buttons; // 32 Buttons } JOYSTICK_STATE, * PJOYSTICK_STATE; -#include - -#undef EXTERN_C -#if _MSC_VER -# define EXTERN_C -#else -# define EXTERN_C extern "C" -#endif -#if _MSC_VER -# pragma comment(linker, "/implib:vjoy.def") -#endif EXTERN_C BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); EXTERN_C VOID __stdcall VJoy_Shutdown(); EXTERN_C BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 84b7eed30..18301b6a4 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -325,7 +325,7 @@ void Tracker::run() last_roi.height = std::min(grayscale.rows - last_roi.y, last_roi.height); } - cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, !first, cv::ITERATIVE); + cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, !first, cv::SOLVEPNP_ITERATIVE); first = false; cv::Mat rotation_matrix = cv::Mat::zeros(3, 3, CV_64FC1); cv::Mat junk1(3, 3, CV_64FC1), junk2(3, 3, CV_64FC1); diff --git a/ftnoir_tracker_base/ftnoir_tracker_base_global.h b/ftnoir_tracker_base/ftnoir_tracker_base_global.h index 6d6a1918a..5b53ba82f 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base_global.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base_global.h @@ -8,7 +8,7 @@ # if !defined(_MSC_VER) # define FTNOIR_TRACKER_BASE_EXPORT __attribute__ ((visibility ("default"))) Q_DECL_EXPORT # else -# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT +# error "MSVC support removed" # endif # else # define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 90574a4b4..7819dd67f 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -26,8 +26,8 @@ class Hydra_Tracker : public ITracker public: Hydra_Tracker(); ~Hydra_Tracker(); - void StartTracker(QFrame *) virt_override; - void GetHeadPoseData(double *data) virt_override; + void StartTracker(QFrame *) override; + void GetHeadPoseData(double *data) override; volatile bool should_quit; protected: void run(); // qthread override run method @@ -36,7 +36,7 @@ private: bool isCalibrated; double newHeadPose[6]; // Structure with new headpose QMutex mutex; - virtual int preferredHz() virt_override { return 250; } + virtual int preferredHz() override { return 250; } }; class TrackerControls: public QWidget, public ITrackerDialog diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 04fa5ac22..b706ad3a6 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -12,7 +12,7 @@ #include #ifdef _MSC_VER -# define LIB_PREFIX "" +# error "MSVC support removed" #else # define LIB_PREFIX "lib" #endif -- cgit v1.2.3 From 565c330eeece2edf93e9fa53d4fab27045ca9b3d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 31 Aug 2014 14:08:57 +0200 Subject: remove dead code --- facetracknoir/options.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 3fd0e7671..474d4ec23 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -26,12 +26,6 @@ #include #include -#ifdef __GNUC__ -# define ov override -#else -# define ov -#endif - #include namespace options { -- cgit v1.2.3 From be9901c4cc21597bcd28aebcc95ed488a5a7c172 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 13 Sep 2014 13:27:11 +0200 Subject: Remove incorrect ownership --- facetracknoir/main.cpp | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 9bf11b322..7462f8c21 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -1,35 +1,5 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 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 "facetracknoir.h" -#include "tracker.h" #include -#include -#include -#include -#include -#include #include int main(int argc, char** argv) @@ -41,6 +11,5 @@ int main(int argc, char** argv) w->show(); app.exec(); - return 0; + return 0; } - -- cgit v1.2.3 From d4dd9675276093817756187c04d89f10da2df02e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 13 Sep 2014 14:09:08 +0200 Subject: nix comment cancer --- facetracknoir/curve-config.cpp | 5 --- facetracknoir/facetracknoir.cpp | 4 +- facetracknoir/facetracknoir.h | 24 ++++------- facetracknoir/plugin-support.cpp | 7 +--- facetracknoir/plugin-support.h | 1 + facetracknoir/rotation.h | 11 ++--- facetracknoir/shortcuts.cpp | 12 +----- facetracknoir/tracker.cpp | 2 +- facetracknoir/tracker_types.cpp | 4 +- ftnoir_csv/csv.cpp | 18 +------- ftnoir_csv/csv.h | 11 +---- .../ftnoir_protocol_wine_dialog.cpp | 16 -------- ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp | 5 +-- .../ftnoir_tracker_joystick.cpp | 6 +-- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 5 +-- qfunctionconfigurator/functionconfig.cpp | 48 ++-------------------- qfunctionconfigurator/functionconfig.h | 14 +------ qfunctionconfigurator/qfunctionconfigurator.cpp | 6 +-- qfunctionconfigurator/qfunctionconfigurator.h | 31 +++++--------- 19 files changed, 44 insertions(+), 186 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 2bff009a5..ef63607d0 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -11,7 +11,6 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge QPoint offsetpos(120, 30); this->move(parent->pos() + offsetpos); - // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); @@ -39,7 +38,6 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge tie_setting(mainApp->s.a_y.invert, ui.chkInvertY); tie_setting(mainApp->s.a_z.invert, ui.chkInvertZ); - // Load the settings from the current .INI-file loadSettings(); } @@ -54,9 +52,6 @@ void CurveConfigurationDialog::doCancel() { close(); } -// -// Load the current Settings from the currently 'active' INI-file. -// void CurveConfigurationDialog::loadSettings() { QFunctionConfigurator* configs[6] = { ui.txconfig, diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index d717b3bee..8df368cd5 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -26,7 +26,7 @@ #include "tracker.h" #include "curve-config.h" #include "opentrack-version.h" -#include +#include #if defined(_WIN32) # include @@ -185,7 +185,6 @@ void FaceTrackNoIR::GetCameraNameDX() { #if defined(_WIN32) ui.cameraName->setText("No video-capturing device was found in your system: check if it's connected!"); - // Create the System Device Enumerator. HRESULT hr; ICreateDevEnum *pSysDevEnum = NULL; hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); @@ -197,7 +196,6 @@ void FaceTrackNoIR::GetCameraNameDX() { qDebug() << "GetWDM says: CoCreateInstance succeeded!"; - // Obtain a class enumerator for the video compressor category. IEnumMoniker *pEnumCat = NULL; hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index ca8084c21..1da2d6b87 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -22,24 +22,16 @@ * with this program; if not, see . * *********************************************************************************/ -#ifndef FaceTrackNoIR_H -#define FaceTrackNoIR_H +#pragma once #include #include -#include -#include -#include #include #include #include #include #include -#include -#include -#include #include -#include #if !defined(_WIN32) # include "qxt-mini/QxtGlobalShortcut" #else @@ -78,7 +70,7 @@ public: FaceTrackNoIR(QWidget *parent = 0); ~FaceTrackNoIR(); - QFrame *get_video_widget(); // Get a pointer to the video-widget, to use in the DLL + QFrame *get_video_widget(); Tracker *tracker; void bindKeyboardShortcuts(); DynamicLibrary* current_tracker1() { @@ -114,12 +106,12 @@ public slots: private: HeadPoseData pose; Ui::OpentrackUI ui; - QTimer timUpdateHeadPose; // Timer to display headpose + QTimer timUpdateHeadPose; - ITrackerDialog* pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) - ITrackerDialog* pSecondTrackerDialog; // Pointer to the second Tracker dialog instance (in DLL) - IProtocolDialog* pProtocolDialog; // Pointer to Protocol dialog instance (in DLL) - IFilterDialog* pFilterDialog; // Pointer to Filter dialog instance (in DLL) + ITrackerDialog* pTrackerDialog; + ITrackerDialog* pSecondTrackerDialog; + IProtocolDialog* pProtocolDialog; + IFilterDialog* pFilterDialog; QWidget *_keyboard_shortcuts; QWidget *_curve_config; @@ -161,5 +153,3 @@ private slots: void startTracker(); void stopTracker(); }; - -#endif // FaceTrackNoIR_H diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp index 5d810ed1e..2e80c5e44 100644 --- a/facetracknoir/plugin-support.cpp +++ b/facetracknoir/plugin-support.cpp @@ -1,4 +1,5 @@ #include "plugin-support.h" +#include #if !(defined(_WIN32)) # include @@ -62,15 +63,9 @@ SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : pFilter = (IFilter*) ptr(); } - // Check if the Protocol-server files were installed OK. - // Some servers also create a memory-mapping, for Inter Process Communication. - // The handle of the MainWindow is sent to 'The Game', so it can send a message back. - if (pProtocol) if(!pProtocol->checkServerInstallationOK()) return; - - // retrieve pointers to the User Interface and the main Application if (pTracker) { pTracker->StartTracker( mainApp->get_video_widget() ); } diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h index 1c63151a7..931f0fa1c 100644 --- a/facetracknoir/plugin-support.h +++ b/facetracknoir/plugin-support.h @@ -77,6 +77,7 @@ struct Metadata virtual void getIcon(QIcon *icon) = 0; }; +// merely to break a circular header dependency -sh class IDynamicLibraryProvider { public: virtual DynamicLibrary* current_tracker1() = 0; diff --git a/facetracknoir/rotation.h b/facetracknoir/rotation.h index 22f35abbe..d40fb6cf3 100644 --- a/facetracknoir/rotation.h +++ b/facetracknoir/rotation.h @@ -5,10 +5,9 @@ * copyright notice and this permission notice appear in all copies. */ -#ifndef ROTATION_H -#define ROTATION_H +#pragma once #include -// ---------------------------------------------------------------------------- + class RotationType { public: @@ -16,7 +15,7 @@ public: RotationType(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } RotationType(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} - RotationType inv(){ // inverse + RotationType inv(){ return RotationType(a,-b,-c, -d); } @@ -58,7 +57,3 @@ public: protected: double a,b,c,d; // quaternion coefficients }; - - - -#endif //ROTATION_H diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 601bbcc68..758617caa 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -9,9 +9,8 @@ KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget * QPoint offsetpos(100, 100); this->move(parent->pos() + offsetpos); - mainApp = ftnoir; // Preserve a pointer to FTNoIR + mainApp = ftnoir; - // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); @@ -33,9 +32,6 @@ KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget * tie_setting(mainApp->s.dingp, ui.ding); } -// -// OK clicked on server-dialog -// void KeyboardShortcutDialog::doOK() { mainApp->b->save(); this->close(); @@ -112,16 +108,10 @@ static bool isKeyPressed( const Key *key, const BYTE *keystate ) { ctrl = ( (keystate[DIK_LCONTROL] & 0x80) || (keystate[DIK_RCONTROL] & 0x80) ); alt = ( (keystate[DIK_LALT] & 0x80) || (keystate[DIK_RALT] & 0x80) ); - // - // If one of the modifiers is needed and not pressed, return false. - // if (key->shift && !shift) return false; if (key->ctrl && !ctrl) return false; if (key->alt && !alt) return false; - // - // All is well! - // return true; } return false; diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index dfe9bc1de..01fd0b4c0 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -160,7 +160,7 @@ void Tracker::run() { t_compensate(output_camera.axes, output_camera.axes, mainApp->s.tcomp_tz); if (Libraries->pProtocol) { - Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); // degrees & centimeters + Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); } } diff --git a/facetracknoir/tracker_types.cpp b/facetracknoir/tracker_types.cpp index dec4ff817..ba3ac552d 100644 --- a/facetracknoir/tracker_types.cpp +++ b/facetracknoir/tracker_types.cpp @@ -20,8 +20,7 @@ T6DOF operator-(const T6DOF& A, const T6DOF& B) C.axes[TX] = A.axes[TX] - B.axes[TX]; C.axes[TY] = A.axes[TY] - B.axes[TY]; C.axes[TZ] = A.axes[TZ] - B.axes[TZ]; - //C.frame_number? - return C; + return C; } T6DOF operator+(const T6DOF& A, const T6DOF& B) @@ -39,6 +38,5 @@ T6DOF operator+(const T6DOF& A, const T6DOF& B) C.axes[TX] = A.axes[TX] + B.axes[TX]; C.axes[TY] = A.axes[TY] + B.axes[TY]; C.axes[TZ] = A.axes[TZ] + B.axes[TZ]; - //C.frame_number? return C; } diff --git a/ftnoir_csv/csv.cpp b/ftnoir_csv/csv.cpp index 66823d248..b59b5083b 100644 --- a/ftnoir_csv/csv.cpp +++ b/ftnoir_csv/csv.cpp @@ -25,9 +25,9 @@ #define INSIDE_CSV #include "csv.h" #include -#include #include #include +#include CSV::CSV(QIODevice * device) { @@ -46,12 +46,10 @@ CSV::CSV(QString &string){ CSV::~CSV() { - //delete m_codec; } void CSV::setCodec(const char* codecName){ - //delete m_codec; m_codec = QTextCodec::codecForName(codecName); } @@ -59,7 +57,6 @@ QString CSV::readLine(){ QString line; if(m_string.isNull()){ - //READ DATA FROM DEVICE if(m_device && m_device->isReadable()){ QTextDecoder dec(m_codec); m_string = dec.toUnicode(m_device->readAll()); @@ -67,8 +64,6 @@ QString CSV::readLine(){ return QString(); } } - - //PARSE if((m_pos = m_rx.indexIn(m_string,m_pos)) != -1) { line = m_rx.cap(1); m_pos += m_rx.matchedLength(); @@ -111,12 +106,9 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) QStringList gameLine; qDebug() << "getGameData, ID = " << gameID; - // - // Open the supported games list, to get the Name. - // QFile file(QCoreApplication::applicationDirPath() + "/settings/facetracknoir supported games.csv"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - return; + return; } CSV csv(&file); gameLine = csv.parseLine(); @@ -131,9 +123,6 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) //qDebug() << "Column 6: " << gameLine.at(6); // International ID //qDebug() << "Column 7: " << gameLine.at(7); // FaceTrackNoIR ID - // - // If the gameID was found, fill the shared memory - // if (gameLine.count() > 6) { if (gameLine.at(6).compare( gameID, Qt::CaseInsensitive ) == 0) { QByteArray id = gameLine.at(7).toLatin1(); @@ -172,9 +161,6 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) gameLine = csv.parseLine(); } - // - // If the gameID was NOT found, fill only the name "Unknown game connected" - // qDebug() << "Unknown game connected" << gameID; file.close(); } diff --git a/ftnoir_csv/csv.h b/ftnoir_csv/csv.h index bfbece58c..79e1351e3 100644 --- a/ftnoir_csv/csv.h +++ b/ftnoir_csv/csv.h @@ -1,11 +1,4 @@ -/*dummy CSV reader for QT4*/ -/*version 0.1*/ -/*11.1.2009*/ -#ifndef CSV_H -#define CSV_H - -//#include "myclass_api.h" - +#pragma once #include #include #include @@ -41,5 +34,3 @@ private: CSV(QIODevice * device); CSV(QString &string); }; - -#endif // CSV_H diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp index 29d462199..a6fae479f 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp @@ -2,13 +2,6 @@ #include #include "facetracknoir/plugin-support.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// FTControls::FTControls() : QWidget() { ui.setupUi( this ); @@ -16,19 +9,10 @@ FTControls::FTControls() : QWidget() connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); } -// -// Destructor for server-dialog - -// -// OK clicked on server-dialog -// void FTControls::doOK() { this->close(); } -// -// Cancel clicked on server-dialog -// void FTControls::doCancel() { this->close(); } diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp index 7bab16518..7d7fb247c 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp @@ -1,13 +1,12 @@ #include "ftnoir_protocol_wine.h" -#include #include "facetracknoir/plugin-support.h" -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() +{ } FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() { - } extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index bf596f515..e1d92b783 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -54,10 +54,8 @@ static BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, diprg.diph.dwHeaderSize = sizeof( DIPROPHEADER ); diprg.diph.dwHow = DIPH_BYID; diprg.diph.dwObj = pdidoi->dwType; - diprg.lMax = AXIS_MAX; - diprg.lMin = -AXIS_MAX; - - // Set the range for the axis + diprg.lMax = FTNoIR_Tracker::AXIS_MAX; + diprg.lMin = -FTNoIR_Tracker::AXIS_MAX; if( FAILED( self->g_pJoystick->SetProperty( DIPROP_RANGE, &diprg.diph ) ) ) return DIENUM_STOP; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index b7ec9784a..cc8079bf7 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -4,9 +4,8 @@ TrackerControls::TrackerControls() : QWidget() { - ui.setupUi( this ); + ui.setupUi( this ); - // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); @@ -34,7 +33,7 @@ void TrackerControls::doCancel() { close(); } -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog() { return new TrackerControls; } diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 97a6db242..85d058fb9 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -17,9 +17,6 @@ #include #include -// -// Constructor with List of Points in argument. -// FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) : _mutex(QMutex::Recursive) { @@ -29,9 +26,9 @@ FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) _size = 0; lastValueTracked = QPointF(0,0); _tracking_active = false; - _max_Input = intMaxInput; // Added WVR 20120805 + _max_Input = intMaxInput; _max_Output = intMaxOutput; - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); loadSettings(iniFile); @@ -53,11 +50,6 @@ FunctionConfig::FunctionConfig() : { } -// -// Calculate the value of the function, given the input 'x'. -// Used to draw the curve and, most importantly, to translate input to output. -// The return-value is also stored internally, so the Widget can show the current value, when the Tracker is running. -// float FunctionConfig::getValue(float x) { QMutexLocker foo(&_mutex); int x2 = (int) (std::min(std::max(x, -360), 360) * MEMOIZE_PRECISION); @@ -67,9 +59,6 @@ float FunctionConfig::getValue(float x) { return ret; } -// -// The return-value is also stored internally, so the Widget can show the current value, when the Tracker is running. -// bool FunctionConfig::getLastPoint(QPointF& point ) { QMutexLocker foo(&_mutex); point = lastValueTracked; @@ -172,10 +161,6 @@ FunctionConfig::~FunctionConfig() { delete[] _data; } -// -// Remove a Point from the Function. -// Used by the Widget. -// void FunctionConfig::removePoint(int i) { QMutexLocker foo(&_mutex); if (i >= 0 && i < _points.size()) @@ -185,20 +170,12 @@ void FunctionConfig::removePoint(int i) { } } -// -// Add a Point to the Function. -// Used by the Widget and by loadSettings. -// void FunctionConfig::addPoint(QPointF pt) { QMutexLocker foo(&_mutex); _points.append(pt); reload(); } -// -// Move a Function Point. -// Used by the Widget. -// void FunctionConfig::movePoint(int idx, QPointF pt) { QMutexLocker foo(&_mutex); if (idx >= 0 && idx < _points.size()) @@ -208,10 +185,6 @@ void FunctionConfig::movePoint(int idx, QPointF pt) { } } -// -// Return the List of Points. -// Used by the Widget. -// QList FunctionConfig::getPoints() { QList ret; QMutexLocker foo(&_mutex); @@ -221,10 +194,6 @@ QList FunctionConfig::getPoints() { return ret; } -// -// Load the Points for the Function from the INI-file designated by settings. -// Settings for a specific Curve are loaded from their own Group in the INI-file. -// void FunctionConfig::loadSettings(QSettings& settings) { QMutexLocker foo(&_mutex); QPointF newPoint; @@ -235,12 +204,8 @@ void FunctionConfig::loadSettings(QSettings& settings) { int max = settings.value("point-count", 0).toInt(); for (int i = 0; i < max; i++) { - newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), 0).toFloat(), - settings.value(QString("point-%1-y").arg(i), 0).toFloat()); - // - // Make sure the new Point fits in the Function Range. - // Maybe this can be improved? - // + newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), 0).toFloat(), + settings.value(QString("point-%1-y").arg(i), 0).toFloat()); if (newPoint.x() > _max_Input) { newPoint.setX(_max_Input); } @@ -254,11 +219,6 @@ void FunctionConfig::loadSettings(QSettings& settings) { reload(); } -// -// Save the Points for the Function to the INI-file designated by settings. -// Settings for a specific Curve are saved in their own Group in the INI-file. -// The number of Points is also saved, to make loading more convenient. -// void FunctionConfig::saveSettings(QSettings& settings) { QMutexLocker foo(&_mutex); settings.beginGroup(QString("Curves-%1").arg(_title)); diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 4d771dfd0..9b43f0bd9 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -26,7 +26,7 @@ private: int _size; QString _title; float getValueInternal(int x); - QPointF lastValueTracked; // The last input value requested by the Tracker, with it's output-value. + QPointF lastValueTracked; volatile bool _tracking_active; int _max_Input; int _max_Output; @@ -34,19 +34,12 @@ private: public: int maxInput() const { return _max_Input; } int maxOutput() const { return _max_Output; } - // - // Contructor(s) and destructor - // FunctionConfig(); FunctionConfig(QString title, int intMaxInput, int intMaxOutput); ~FunctionConfig(); float getValue(float x); - bool getLastPoint(QPointF& point); // Get the last Point that was requested. - - // - // Functions to manipulate the Function - // + bool getLastPoint(QPointF& point); void removePoint(int i); void removeAllPoints() { QMutexLocker foo(&_mutex); @@ -64,9 +57,6 @@ public: _max_Output = MaxOutput; } - // - // Functions to load/save the Function-Points to an INI-file - // void saveSettings(QSettings& settings); void loadSettings(QSettings& settings); diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 55d1e1bcc..e94eded48 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -28,7 +28,7 @@ static const int pointSize = 5; QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) : QWidget(parent) { - movingPoint = -1; // Index of that same point + movingPoint = -1; _config = 0; _draw_background = true; _draw_function = true; @@ -37,9 +37,9 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) } void QFunctionConfigurator::setConfig(FunctionConfig* config) { - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + QSettings iniFile( currentFile, QSettings::IniFormat ); config->loadSettings(iniFile); _config = config; diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 1f6b4f788..d3a8741fe 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -4,8 +4,7 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. */ -#ifndef QFUNCTIONCONFIGURATOR_H -#define QFUNCTIONCONFIGURATOR_H +#pragma once #include #include @@ -14,14 +13,6 @@ #include "qfunctionconfigurator/functionconfig.h" #include "ftnoir_tracker_base/ftnoir_tracker_base.h" -// -// The FunctionConfigurator Widget is used to display and configure a function (curve). -// The Function is used by FaceTrackNoIR to 'translate' the actual head-pose to the virtual headpose. Every axis is configured by a separate Function. -// -// The Function is coded in a separate Class and can exists, without the Widget. When the widget is displayed (therefore 'created'), the Function can be attached to the -// Widget and the Widget used to change the Function. -// - class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget { Q_OBJECT @@ -70,23 +61,21 @@ private: _draw_function = _draw_background = true; } - QRectF range; // The actual rectangle for the Bezier-curve - QPointF lastPoint; // The right-most point of the Function - QPointF pixel_coord_to_point (QPointF point) const; // Convert the graphical Point to a real-life Point - QPointF point_to_pixel (QPointF point) const; // Convert the Point to a graphical Point + QRectF range; + QPointF lastPoint; + QPointF pixel_coord_to_point (QPointF point) const; + QPointF point_to_pixel (QPointF point) const; int movingPoint; QElapsedTimer timer; QPointF c; - QColor colBezier; // Color of Bezier curve + QColor colBezier; - bool _draw_background; // Flag to determine if the background should be (re-)drawn on the QPixmap - QPixmap _background; // Image of the static parts (axis, lines, etc.) - bool _draw_function; // Flag to determine if the function should be (re-)drawn on the QPixmap - QPixmap _function; // Image of the function (static unless edited by the user) + bool _draw_background; + QPixmap _background; + bool _draw_function; + QPixmap _function; FunctionConfig* _config; }; - -#endif // QFUNCTIONCONFIGURATOR_H -- cgit v1.2.3 From 46401fcd2e4e5437e74ca9fca04c7521432566aa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Sep 2014 03:10:31 +0200 Subject: ctor brevity --- facetracknoir/tracker_types.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker_types.h b/facetracknoir/tracker_types.h index a367371e5..043c04201 100644 --- a/facetracknoir/tracker_types.h +++ b/facetracknoir/tracker_types.h @@ -7,10 +7,7 @@ struct T6DOF { public: double axes[6]; - T6DOF() { - for (int i = 0; i < 6; i++) - axes[i] = 0; - } + T6DOF() : axes {0,0,0, 0,0,0 } {} }; T6DOF operator-(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B -- cgit v1.2.3 From 59d6976ebef702627b2676eecd3ad5c397072074 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Sep 2014 03:11:05 +0200 Subject: hook up axis source options Issue: #52 --- facetracknoir/curve-config.cpp | 22 ++- facetracknoir/ftnoir_curves.ui | 424 ++++++++++++++++++++++++++++------------ facetracknoir/main-settings.hpp | 19 +- 3 files changed, 326 insertions(+), 139 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index ef63607d0..e1f39d031 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -31,12 +31,19 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge tie_setting(mainApp->s.a_pitch.zero, ui.pos_ry); tie_setting(mainApp->s.a_roll.zero, ui.pos_rz); - tie_setting(mainApp->s.a_yaw.invert, ui.chkInvertYaw); - tie_setting(mainApp->s.a_pitch.invert, ui.chkInvertPitch); - tie_setting(mainApp->s.a_roll.invert, ui.chkInvertRoll); - tie_setting(mainApp->s.a_x.invert, ui.chkInvertX); - tie_setting(mainApp->s.a_y.invert, ui.chkInvertY); - tie_setting(mainApp->s.a_z.invert, ui.chkInvertZ); + tie_setting(mainApp->s.a_yaw.invert, ui.invert_yaw); + tie_setting(mainApp->s.a_pitch.invert, ui.invert_pitch); + tie_setting(mainApp->s.a_roll.invert, ui.invert_roll); + tie_setting(mainApp->s.a_x.invert, ui.invert_x); + tie_setting(mainApp->s.a_y.invert, ui.invert_y); + tie_setting(mainApp->s.a_z.invert, ui.invert_z); + + tie_setting(mainApp->s.a_yaw.src, ui.src_yaw); + tie_setting(mainApp->s.a_pitch.src, ui.src_pitch); + tie_setting(mainApp->s.a_roll.src, ui.src_roll); + tie_setting(mainApp->s.a_x.src, ui.src_x); + tie_setting(mainApp->s.a_y.src, ui.src_y); + tie_setting(mainApp->s.a_z.src, ui.src_z); loadSettings(); } @@ -83,9 +90,6 @@ void CurveConfigurationDialog::loadSettings() { } } -// -// Save the current Settings to the currently 'active' INI-file. -// void CurveConfigurationDialog::save() { qDebug() << "save() says: started"; diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 33421b40e..951d37a75 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -580,6 +580,9 @@ Options + + QFormLayout::AllNonFixedFieldsGrow + @@ -737,47 +740,6 @@ - - - - - - Translation compensation - - - true - - - - - - - 0 - 0 - - - - - - - Enable - - - - - - - - - - Disable Z axis compensation - - - - - - - @@ -791,7 +753,7 @@ - Axis inversion + Output source Qt::AlignCenter @@ -802,127 +764,345 @@ false - + QLayout::SetMinAndMaxSize 6 - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; + + + + X + + + + Yaw - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - + + - TX + Pitch - - - - - 65536 - 65536 - - - - Qt::RightToLeft + + + + Y - - false + + + + + + Z - - background:none; + + + + + + Roll + + + + - Pitch + - - - - - 65536 - 65536 - + + + + - - Qt::RightToLeft + + + + + + - - background:none; + + + + + + + + + + - TY + - - - - - 65536 - 65536 - + + + + - - Qt::RightToLeft + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + + + + 0 + 0 + + + + + + + Translation compensation + + + true + + + + + + + 0 + 0 + - background:none; + - Roll + Enable - - - - - 65536 - 65536 - - - - Qt::RightToLeft - + + - background:none; + - TZ + Disable Z axis compensation diff --git a/facetracknoir/main-settings.hpp b/facetracknoir/main-settings.hpp index 8e93bd24d..b45c5d9c8 100644 --- a/facetracknoir/main-settings.hpp +++ b/facetracknoir/main-settings.hpp @@ -2,6 +2,7 @@ #include #include "facetracknoir/options.h" +#include "ftnoir_tracker_base/ftnoir_tracker_types.h" using namespace options; struct key_opts { @@ -18,10 +19,12 @@ struct key_opts { struct axis_opts { value zero; value invert, altp; - axis_opts(pbundle b, QString pfx) : + value src; + axis_opts(pbundle b, QString pfx, int idx) : zero(b, n(pfx, "zero-pos"), 0), invert(b, n(pfx, "invert-axis"), false), - altp(b, n(pfx, "alt-axis-sign"), false) + altp(b, n(pfx, "alt-axis-sign"), false), + src(b, n(pfx, "source-index"), idx) {} private: static inline QString n(QString pfx, QString name) { @@ -44,12 +47,12 @@ struct main_settings { tracker2_dll(b, "tracker2-dll", ""), filter_dll(b, "filter-dll", ""), protocol_dll(b, "protocol-dll", ""), - a_x(b, "x"), - a_y(b, "y"), - a_z(b, "z"), - a_yaw(b, "yaw"), - a_pitch(b, "pitch"), - a_roll(b, "roll"), + a_x(b, "x", TX), + a_y(b, "y", TY), + a_z(b, "z", TZ), + a_yaw(b, "yaw", Yaw), + a_pitch(b, "pitch", Pitch), + a_roll(b, "roll", Roll), tcomp_p(b, "compensate-translation", true), tcomp_tz(b, "compensate-translation-disable-z-axis", false), dingp(b, "ding", true) -- cgit v1.2.3 From b81d4ac044e2e61a69f02ddecd8aedeb780c1a7b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Sep 2014 04:23:54 +0200 Subject: simplify alt axis logic --- facetracknoir/tracker.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 01fd0b4c0..ca5053158 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -39,16 +39,11 @@ Tracker::~Tracker() static void get_curve(double pos, double& out, THeadPoseDOF& axis) { bool altp = (pos < 0) && axis.opts.altp; - if (altp) { - out = (axis.opts.invert ? -1 : 1) * axis.curveAlt.getValue(pos); - axis.curve.setTrackingActive( false ); - axis.curveAlt.setTrackingActive( true ); - } - else { - out = (axis.opts.invert ? -1 : 1) * axis.curve.getValue(pos); - axis.curve.setTrackingActive( true ); - axis.curveAlt.setTrackingActive( false ); - } + axis.curve.setTrackingActive( !altp ); + axis.curveAlt.setTrackingActive( altp ); + auto& fc = altp ? axis.curveAlt : axis.curve; + out = (axis.opts.invert ? -1 : 1) * fc.getValue(pos); + out += axis.opts.zero; } -- cgit v1.2.3 From d0d3be7f3895df5997647394853986096f889a1a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Sep 2014 04:24:12 +0200 Subject: hook up axis src logic Issue: #52 --- facetracknoir/tracker.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index ca5053158..29855b311 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -119,7 +119,13 @@ void Tracker::run() { QMutexLocker foo(&mtx); for (int i = 0; i < 6; i++) - mainApp->axis(i).headPos = newpose[i]; + { + auto& axis = mainApp->axis(i); + int k = axis.opts.src; + if (k < 0 || k >= 6) + continue; + axis.headPos = newpose[k]; + } if (do_center) { for (int i = 0; i < 6; i++) -- cgit v1.2.3 From f8b65030eefbb8bf7ce09d5c0adbfd3192f1cf24 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Sep 2014 05:21:55 +0200 Subject: keep using raw headpose in ui Issue: #52 --- facetracknoir/tracker.cpp | 3 ++- facetracknoir/tracker.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 29855b311..db2a7af31 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -121,6 +121,7 @@ void Tracker::run() { for (int i = 0; i < 6; i++) { auto& axis = mainApp->axis(i); + raw_6dof.axes[i] = newpose[i]; int k = axis.opts.src; if (k < 0 || k >= 6) continue; @@ -184,7 +185,7 @@ void Tracker::getHeadPose( double *data ) { QMutexLocker foo(&mtx); for (int i = 0; i < 6; i++) { - data[i] = mainApp->axis(i).headPos; + data[i] = raw_6dof.axes[i]; } } diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 49e7f3021..152551d41 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -73,7 +73,7 @@ public: volatile bool do_center; volatile bool enabled; - T6DOF output_camera; + T6DOF output_camera, raw_6dof; void start() { QThread::start(); } }; -- cgit v1.2.3 From 4fdc2d9b3733f2b8d3edd4e10fdba0b7a525ae22 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Sep 2014 08:07:09 +0200 Subject: initialize COM on _WIN32 as per Win32 API For API correctness only. It worked without issues since ever. --- facetracknoir/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 7462f8c21..694715d14 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -2,8 +2,16 @@ #include #include +#ifdef _WIN32 +# include +#endif + int main(int argc, char** argv) { +#ifdef _WIN32 + CoInitializeEx(NULL, COINIT_MULTITHREADED); +#endif + QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); auto w = std::make_shared(); -- cgit v1.2.3 From 679f424c250a38473c82bf1f997b75fbea4d3758 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Sep 2014 12:40:39 +0200 Subject: nix explicit malloc simplifies, allows for copy operator --- facetracknoir/facetracknoir.cpp | 4 +- facetracknoir/facetracknoir.h | 2 +- facetracknoir/tracker.h | 46 ++++---- qfunctionconfigurator/functionconfig.cpp | 143 ++++++++++-------------- qfunctionconfigurator/functionconfig.h | 79 +++++++++---- qfunctionconfigurator/qfunctionconfigurator.cpp | 13 +-- qfunctionconfigurator/qfunctionconfigurator.h | 23 ++-- 7 files changed, 154 insertions(+), 156 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 8df368cd5..da8fae615 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -366,8 +366,8 @@ void FaceTrackNoIR::startTracker( ) { for (int i = 0; i < 6; i++) { - axis(i).curve.loadSettings(iniFile); - axis(i).curveAlt.loadSettings(iniFile); + axis(i).curve.loadSettings(iniFile, axis(i).name1); + axis(i).curveAlt.loadSettings(iniFile, axis(i).name2); } } diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 1da2d6b87..dc37ad377 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -86,7 +86,7 @@ public: return dlopen_filters.value(ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); } THeadPoseDOF& axis(int idx) { - return *pose.axes[idx]; + return pose.axes[idx]; } #if defined(_WIN32) diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 152551d41..d06ac9d27 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -21,12 +21,7 @@ #include "facetracknoir/timer.hpp" using namespace options; -class FaceTrackNoIR; // pre-define parent-class to avoid circular includes - class THeadPoseDOF { -private: - THeadPoseDOF(const THeadPoseDOF &) = delete; - THeadPoseDOF& operator=(const THeadPoseDOF&) = delete; public: THeadPoseDOF(QString primary, QString secondary, @@ -36,22 +31,27 @@ public: int maxOutput2, axis_opts* opts) : headPos(0), - curve(primary, maxInput1, maxOutput1), - curveAlt(secondary, maxInput2, maxOutput2), - opts(*opts) + curve(maxInput1, maxOutput1), + curveAlt(maxInput2, maxOutput2), + opts(*opts), + name1(primary), + name2(secondary) { QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); - curve.loadSettings(iniFile); - curveAlt.loadSettings(iniFile); + curve.loadSettings(iniFile, primary); + curveAlt.loadSettings(iniFile, secondary); } volatile double headPos; FunctionConfig curve; FunctionConfig curveAlt; axis_opts& opts; + QString name1, name2; }; +class FaceTrackNoIR; + class Tracker : protected QThread { Q_OBJECT @@ -80,23 +80,17 @@ public: class HeadPoseData { public: - THeadPoseDOF* axes[6]; - HeadPoseData(std::vector opts) - { - axes[TX] = new THeadPoseDOF("tx","tx_alt", 100, 100, 100, 100, opts[TX]); - axes[TY] = new THeadPoseDOF("ty","ty_alt", 100, 100, 100, 100, opts[TY]); - axes[TZ] = new THeadPoseDOF("tz","tz_alt", 100, 100, 100, 100, opts[TZ]); - axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180, opts[Yaw]); - axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90, opts[Pitch]); - axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180, opts[Roll]); - } - ~HeadPoseData() - { - for (int i = 0; i < 6; i++) - { - delete axes[i]; + THeadPoseDOF axes[6]; + HeadPoseData(std::vector opts) : + axes { + THeadPoseDOF("tx","tx_alt", 100, 100, 100, 100, opts[TX]), + THeadPoseDOF("ty","ty_alt", 100, 100, 100, 100, opts[TY]), + THeadPoseDOF("tz","tz_alt", 100, 100, 100, 100, opts[TZ]), + THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180, opts[Yaw]), + THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90, opts[Pitch]), + THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180, opts[Roll]) } - } + {} }; #endif diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 85d058fb9..640db1ef4 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -17,36 +17,17 @@ #include #include -FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) : - _mutex(QMutex::Recursive) -{ - _title = title; - _points = QList(); - _data = 0; - _size = 0; - lastValueTracked = QPointF(0,0); - _tracking_active = false; - _max_Input = intMaxInput; - _max_Output = intMaxOutput; - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - loadSettings(iniFile); - reload(); -} - void FunctionConfig::setTrackingActive(bool blnActive) { - _tracking_active = blnActive; + activep = blnActive; } FunctionConfig::FunctionConfig() : _mutex(QMutex::Recursive), - _data(0), - _size(0), - _tracking_active(false), - _max_Input(0), - _max_Output(0) + data(0), + activep(false), + max_x(0), + max_y(0) { } @@ -54,31 +35,30 @@ float FunctionConfig::getValue(float x) { QMutexLocker foo(&_mutex); int x2 = (int) (std::min(std::max(x, -360), 360) * MEMOIZE_PRECISION); float ret = getValueInternal(x2); - lastValueTracked.setX(x); - lastValueTracked.setY(ret); + last_input_value.setX(x); + last_input_value.setY(ret); return ret; } bool FunctionConfig::getLastPoint(QPointF& point ) { QMutexLocker foo(&_mutex); - point = lastValueTracked; - return _tracking_active; + point = last_input_value; + return activep; } float FunctionConfig::getValueInternal(int x) { float sign = x < 0 ? -1 : 1; x = x < 0 ? -x : x; float ret; - if (!_data) - ret = 0; - else if (_size == 0) + int sz = data.size(); + if (sz == 0) ret = 0; else if (x < 0) ret = 0; - else if (x < _size && x >= 0) - ret = _data[x]; + else if (x < sz && x >= 0) + ret = data[x]; else - ret = _data[_size - 1]; + ret = data[sz - 1]; return ret * sign; } @@ -96,35 +76,32 @@ static bool sortFn(const QPointF& one, const QPointF& two) { } void FunctionConfig::reload() { - _size = 0; + if (input.size()) + qStableSort(input.begin(), input.end(), sortFn); - if (_points.size()) - qStableSort(_points.begin(), _points.end(), sortFn); + if (input.size()) { + data = std::vector(MEMOIZE_PRECISION * input[input.size() - 1].x()); + + const int sz = data.size(); - if (_data) - delete[] _data; - _data = NULL; - if (_points.size()) { - _data = new float[_size = MEMOIZE_PRECISION * _points[_points.size() - 1].x()]; + for (int i = 0; i < sz; i++) + data[i] = -1; - for (int i = 0; i < _size; i++) - _data[i] = -1e6; - - for (int k = 0; k < _points[0].x() * MEMOIZE_PRECISION; k++) { - if (k < _size) - _data[k] = _points[0].y() * k / (_points[0].x() * MEMOIZE_PRECISION); + for (int k = 0; k < input[0].x() * MEMOIZE_PRECISION; k++) { + if (k < sz) + data[k] = input[0].y() * k / (input[0].x() * MEMOIZE_PRECISION); } - for (int i = 0; i < _points.size(); i++) { - QPointF p0 = ensureInBounds(_points, i - 1); - QPointF p1 = ensureInBounds(_points, i); - QPointF p2 = ensureInBounds(_points, i + 1); - QPointF p3 = ensureInBounds(_points, i + 2); + for (int i = 0; i < sz; i++) { + QPointF p0 = ensureInBounds(input, i - 1); + QPointF p1 = ensureInBounds(input, i); + QPointF p2 = ensureInBounds(input, i + 1); + QPointF p3 = ensureInBounds(input, i + 2); - int end = p2.x() * MEMOIZE_PRECISION; + int end = std::min(sz, p2.x() * MEMOIZE_PRECISION); int start = p1.x() * MEMOIZE_PRECISION; - for (int j = start; j < end && j < _size; j++) { + for (int j = start; j < end; j++) { double t = (j - start) / (double) (end - start); double t2 = t*t; double t3 = t*t*t; @@ -140,47 +117,41 @@ void FunctionConfig::reload() { (2. * p0.y() - 5. * p1.y() + 4. * p2.y() - p3.y()) * t2 + (-p0.y() + 3. * p1.y() - 3. * p2.y() + p3.y()) * t3); - if (x >= 0 && x < _size) - _data[x] = y; + if (x >= 0 && x < sz) + data[x] = y; } } float last = 0; - - for (int i = 0; i < _size; i++) + for (int i = 0; i < sz; i++) { - if (_data[i] == -1e6) - _data[i] = last; - last = _data[i]; + if (data[i] <= 0) + data[i] = last; + last = data[i]; } } } -FunctionConfig::~FunctionConfig() { - if (_data) - delete[] _data; -} - void FunctionConfig::removePoint(int i) { QMutexLocker foo(&_mutex); - if (i >= 0 && i < _points.size()) + if (i >= 0 && i < input.size()) { - _points.removeAt(i); + input.removeAt(i); reload(); } } void FunctionConfig::addPoint(QPointF pt) { QMutexLocker foo(&_mutex); - _points.append(pt); + input.append(pt); reload(); } void FunctionConfig::movePoint(int idx, QPointF pt) { QMutexLocker foo(&_mutex); - if (idx >= 0 && idx < _points.size()) + if (idx >= 0 && idx < input.size()) { - _points[idx] = pt; + input[idx] = pt; reload(); } } @@ -188,45 +159,45 @@ void FunctionConfig::movePoint(int idx, QPointF pt) { QList FunctionConfig::getPoints() { QList ret; QMutexLocker foo(&_mutex); - for (int i = 0; i < _points.size(); i++) { - ret.append(_points[i]); + for (int i = 0; i < input.size(); i++) { + ret.append(input[i]); } return ret; } -void FunctionConfig::loadSettings(QSettings& settings) { +void FunctionConfig::loadSettings(QSettings& settings, const QString& title) { QMutexLocker foo(&_mutex); QPointF newPoint; QList points; - settings.beginGroup(QString("Curves-%1").arg(_title)); + settings.beginGroup(QString("Curves-%1").arg(title)); int max = settings.value("point-count", 0).toInt(); for (int i = 0; i < max; i++) { newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), 0).toFloat(), settings.value(QString("point-%1-y").arg(i), 0).toFloat()); - if (newPoint.x() > _max_Input) { - newPoint.setX(_max_Input); + if (newPoint.x() > max_x) { + newPoint.setX(max_x); } - if (newPoint.y() > _max_Output) { - newPoint.setY(_max_Output); + if (newPoint.y() > max_y) { + newPoint.setY(max_y); } points.append(newPoint); } settings.endGroup(); - _points = points; + input = points; reload(); } -void FunctionConfig::saveSettings(QSettings& settings) { +void FunctionConfig::saveSettings(QSettings& settings, const QString& title) { QMutexLocker foo(&_mutex); - settings.beginGroup(QString("Curves-%1").arg(_title)); - int max = _points.size(); + settings.beginGroup(QString("Curves-%1").arg(title)); + int max = input.size(); settings.setValue("point-count", max); for (int i = 0; i < max; i++) { - settings.setValue(QString("point-%1-x").arg(i), _points[i].x()); - settings.setValue(QString("point-%1-y").arg(i), _points[i].y()); + settings.setValue(QString("point-%1-x").arg(i), input[i].x()); + settings.setValue(QString("point-%1-y").arg(i), input[i].y()); } for (int i = max; true; i++) diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 9b43f0bd9..22bfc406f 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, Stanislaw Halik +/* Copyright (c) 2011-2014, Stanislaw Halik * Permission to use, copy, modify, and/or distribute this * software for any purpose with or without fee is hereby granted, @@ -14,36 +14,72 @@ #include #include #include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include #define MEMOIZE_PRECISION 100 +class MyMutex { +private: + QMutex inner; + +public: + QMutex* operator->() { return &inner; } + QMutex* operator->() const { return &const_cast(this)->inner; } + + MyMutex operator=(const MyMutex& datum) + { + auto mode = + datum->isRecursive() + ? QMutex::Recursive + : QMutex::NonRecursive; + + return MyMutex(mode); + } + + MyMutex(const MyMutex& datum) + { + *this = datum; + } + + MyMutex(QMutex::RecursionMode mode = QMutex::NonRecursive) : + inner(mode) + { + } + + QMutex* operator&() + { + return &inner; + } +}; + class FTNOIR_TRACKER_BASE_EXPORT FunctionConfig { private: - QMutex _mutex; - QList _points; - void reload(); - float* _data; - int _size; - QString _title; + void reload(); float getValueInternal(int x); - QPointF lastValueTracked; - volatile bool _tracking_active; - int _max_Input; - int _max_Output; - FunctionConfig(const FunctionConfig&) = delete; + + MyMutex _mutex; + QList input; + std::vector data; + QPointF last_input_value; + volatile bool activep; + int max_x; + int max_y; public: - int maxInput() const { return _max_Input; } - int maxOutput() const { return _max_Output; } + int maxInput() const { return max_x; } + int maxOutput() const { return max_y; } FunctionConfig(); - FunctionConfig(QString title, int intMaxInput, int intMaxOutput); - ~FunctionConfig(); + FunctionConfig(int maxx, int maxy) + { + setMaxInput(maxx); + setMaxOutput(maxy); + } float getValue(float x); bool getLastPoint(QPointF& point); void removePoint(int i); void removeAllPoints() { QMutexLocker foo(&_mutex); - _points.clear(); + input.clear(); reload(); } @@ -51,15 +87,14 @@ public: void movePoint(int idx, QPointF pt); QList getPoints(); void setMaxInput(int MaxInput) { - _max_Input = MaxInput; + max_x = MaxInput; } void setMaxOutput(int MaxOutput) { - _max_Output = MaxOutput; + max_y = MaxOutput; } - void saveSettings(QSettings& settings); - void loadSettings(QSettings& settings); + void saveSettings(QSettings& settings, const QString& title); + void loadSettings(QSettings& settings, const QString& title); void setTrackingActive(bool blnActive); - QString getTitle() { return _title; } }; diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index e94eded48..a197dadb0 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -41,7 +41,7 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config) { QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); - config->loadSettings(iniFile); + config->loadSettings(iniFile, name); _config = config; _draw_function = _draw_background = true; update_range(); @@ -52,7 +52,7 @@ void QFunctionConfigurator::saveSettings(QString settingsFile) { QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) if (_config) { - _config->saveSettings(iniFile); + _config->saveSettings(iniFile, name); } } @@ -279,7 +279,6 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) } if (!bTouchingPoint) { _config->addPoint(pixel_coord_to_point(e->pos())); - emit CurveChanged( true ); } } } @@ -296,7 +295,6 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) if (found_pt != -1) { _config->removePoint(found_pt); - emit CurveChanged( true ); } movingPoint = -1; } @@ -353,7 +351,6 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) if (e->button() == Qt::LeftButton) { timer.invalidate(); if (movingPoint >= 0 && movingPoint < points.size()) { - emit CurveChanged( true ); if (_config) { _config->movePoint(movingPoint, pixel_coord_to_point(e->pos())); } @@ -400,12 +397,6 @@ QPointF QFunctionConfigurator::point_to_pixel(QPointF point) const range.y() + range.height() - point.y() * c.y()); } -void QFunctionConfigurator::setColorBezier(QColor color) -{ - colBezier = color; - update(); -} - void QFunctionConfigurator::resizeEvent(QResizeEvent *) { update_range(); diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index d3a8741fe..e4af0062f 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -16,40 +16,47 @@ class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget { Q_OBJECT - Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier) + Q_PROPERTY(QString Name READ get_name WRITE set_name) + QColor colorBezier() const { return colBezier; } + void setColorBezier(QColor color) + { + colBezier = color; + update(); + } + QString get_name() const { + return name; + } + void set_name(QString name) + { + this->name = name; + } public: QFunctionConfigurator(QWidget *parent = 0); FunctionConfig* config(); void setConfig(FunctionConfig* config); void saveSettings(QString settingsFile); - -signals: - void CurveChanged(bool); - public slots: - void setColorBezier(QColor); protected slots: void paintEvent(QPaintEvent *e); void mousePressEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); - protected: void drawBackground(); void drawFunction(); void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen); bool point_within_pixel(QPointF pt, QPointF pixel) const; - protected: virtual void resizeEvent(QResizeEvent *); private: + QString name; void update_range() { if (!_config) return; -- cgit v1.2.3 From d4dc0006fba2ce43fb09c47f1124df9c82836ddd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Sep 2014 14:19:04 +0200 Subject: add remap labels Issue: #52 --- facetracknoir/ftnoir_curves.ui | 107 ++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 43 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 951d37a75..f98bf8849 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -33,7 +33,7 @@ - background-color: #ccc; + QTabWidget::North @@ -598,15 +598,8 @@ false - - - - RX - - - - - + + deg. @@ -621,6 +614,22 @@ + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + @@ -651,22 +660,6 @@ - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - @@ -674,19 +667,19 @@ - - + + - cm + deg. 3 - -100.000000000000000 + -180.000000000000000 - 100.000000000000000 + 180.000000000000000 @@ -704,35 +697,42 @@ - - + + - deg. + cm 3 - -180.000000000000000 + -100.000000000000000 - 180.000000000000000 + 100.000000000000000 - - + + + + RX + + + + + - cm + deg. 3 - -100.000000000000000 + -180.000000000000000 - 100.000000000000000 + 180.000000000000000 @@ -753,7 +753,7 @@ - Output source + Output remap Qt::AlignCenter @@ -764,7 +764,7 @@ false - + QLayout::SetMinAndMaxSize @@ -1059,6 +1059,27 @@ + + + + Source + + + + + + + Invert + + + + + + + Destination + + + -- cgit v1.2.3 From 73a6c374bd9233b2f1fd9696a69983bb3b7d5563 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 18 Sep 2014 04:20:20 +0200 Subject: Revert "initialize COM on _WIN32 as per Win32 API" This reverts commit 03e4d58bbbbfb5d841354a34a2e2dc317b189deb. Issue: #53 Ironically breaks Windows open/save dialogs --- facetracknoir/main.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 694715d14..7462f8c21 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -2,16 +2,8 @@ #include #include -#ifdef _WIN32 -# include -#endif - int main(int argc, char** argv) { -#ifdef _WIN32 - CoInitializeEx(NULL, COINIT_MULTITHREADED); -#endif - QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); auto w = std::make_shared(); -- cgit v1.2.3 From cf5ab7886e8228d1622566cc59277bcf089199a9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 18 Sep 2014 07:24:52 +0200 Subject: cleanup qfc Issue: #44 Remove confusing logic and retarded comments by the usual offender. Change prototypes a bit for clarity's sake again. --- facetracknoir/curve-config.cpp | 56 +++---- qfunctionconfigurator/functionconfig.cpp | 11 +- qfunctionconfigurator/functionconfig.h | 2 +- qfunctionconfigurator/qfunctionconfigurator.cpp | 188 +++++++++++------------- qfunctionconfigurator/qfunctionconfigurator.h | 72 +++++---- 5 files changed, 158 insertions(+), 171 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index e1f39d031..535655c22 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -1,7 +1,5 @@ #include "facetracknoir/facetracknoir.h" #include "facetracknoir/curve-config.h" -#include -#include CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidget *parent) : QWidget( parent, Qt::Dialog ), mainApp(ftnoir) { @@ -78,39 +76,45 @@ void CurveConfigurationDialog::loadSettings() { ui.rzconfig_alt }; - QSettings settings("opentrack"); - QString currentFile = settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ) - .toString(); - for (int i = 0; i < 6; i++) { - configs[i]->setConfig(&mainApp->axis(i).curve); - alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt); + configs[i]->setConfig(&mainApp->axis(i).curve, mainApp->axis(i).name1); + alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, mainApp->axis(i).name2); } } void CurveConfigurationDialog::save() { - - qDebug() << "save() says: started"; - QSettings settings("opentrack"); QString currentFile = settings.value("SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ) .toString(); - - ui.rxconfig->saveSettings(currentFile); - ui.ryconfig->saveSettings(currentFile); - ui.rzconfig->saveSettings(currentFile); - ui.txconfig->saveSettings(currentFile); - ui.tyconfig->saveSettings(currentFile); - ui.tzconfig->saveSettings(currentFile); - - ui.txconfig_alt->saveSettings(currentFile); - ui.tyconfig_alt->saveSettings(currentFile); - ui.tzconfig_alt->saveSettings(currentFile); - ui.rxconfig_alt->saveSettings(currentFile); - ui.ryconfig_alt->saveSettings(currentFile); - ui.rzconfig_alt->saveSettings(currentFile); + + struct { + QFunctionConfigurator* qfc; + Axis axis; + bool altp; + } qfcs[] = + { + { ui.rxconfig, Yaw, false }, + { ui.ryconfig, Pitch, false}, + { ui.rzconfig, Roll, false }, + { ui.txconfig, TX, false }, + { ui.tyconfig, TY, false }, + { ui.tzconfig, TZ, false }, + + { ui.rxconfig_alt, Yaw, true }, + { ui.ryconfig_alt, Pitch, true}, + { ui.rzconfig_alt, Roll, true }, + { ui.txconfig_alt, TX, true }, + { ui.tyconfig_alt, TY, true }, + { ui.tzconfig_alt, TZ, true }, + { nullptr, Yaw, false } + }; + + for (int i = 0; qfcs[i].qfc; i++) + { + THeadPoseDOF& axis = mainApp->axis(qfcs[i].axis); + qfcs[i].qfc->saveSettings(currentFile, qfcs[i].altp ? axis.name2 : axis.name1); + } } diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 640db1ef4..159f350e5 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include void FunctionConfig::setTrackingActive(bool blnActive) @@ -156,13 +156,10 @@ void FunctionConfig::movePoint(int idx, QPointF pt) { } } -QList FunctionConfig::getPoints() { - QList ret; +const QList FunctionConfig::getPoints() { QMutexLocker foo(&_mutex); - for (int i = 0; i < input.size(); i++) { - ret.append(input[i]); - } - return ret; + // NB can't pass by reference + return input; } void FunctionConfig::loadSettings(QSettings& settings, const QString& title) { diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 22bfc406f..ee2087a05 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -85,7 +85,7 @@ public: void addPoint(QPointF pt); void movePoint(int idx, QPointF pt); - QList getPoints(); + const QList getPoints(); void setMaxInput(int MaxInput) { max_x = MaxInput; } diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index a197dadb0..17431986f 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -1,10 +1,12 @@ -/* Copyright (c) 2011-2012 Stanislaw Halik - * Adapted to FaceTrackNoIR by Wim Vriend. +/* Copyright (c) 2011-2014 Stanislaw Halik + * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. */ +// Adapted to FaceTrackNoIR by Wim Vriend. + #include "qfunctionconfigurator/qfunctionconfigurator.h" #include #include @@ -25,35 +27,33 @@ static const int pointSize = 5; -QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) - : QWidget(parent) +QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) : + QWidget(parent), + _config(nullptr), + moving_control_point_idx(-1), + _draw_function(true) { - movingPoint = -1; - _config = 0; - _draw_background = true; - _draw_function = true; update_range(); setMouseTracking(true); } -void QFunctionConfigurator::setConfig(FunctionConfig* config) { +void QFunctionConfigurator::setConfig(FunctionConfig* config, const QString& name) { QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); config->loadSettings(iniFile, name); _config = config; - _draw_function = _draw_background = true; + _draw_function = true; update_range(); update(); } -void QFunctionConfigurator::saveSettings(QString settingsFile) { - QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) +void QFunctionConfigurator::saveSettings(QString settingsFile, const QString& name) { + QSettings iniFile(settingsFile, QSettings::IniFormat); - if (_config) { + if (_config) _config->saveSettings(iniFile, name); - } } void QFunctionConfigurator::drawBackground() @@ -61,11 +61,13 @@ void QFunctionConfigurator::drawBackground() if (!_config) return; _background = QPixmap(width(), height()); + QPainter painter(&_background); painter.fillRect(rect(), QColor::fromRgb(204, 204, 204)); painter.setRenderHint(QPainter::Antialiasing); + QColor bg_color(112, 154, 209); - painter.fillRect(range, bg_color); + painter.fillRect(pixel_bounds, bg_color); QFont font; font.setPointSize(8); @@ -79,61 +81,59 @@ void QFunctionConfigurator::drawBackground() const int maxy = _config->maxOutput(); // horizontal grid - for (int i = 0; i < maxy; i += xstep) { - double y = range.height() - i * c.y() + range.y(); + double y = pixel_bounds.height() - i * c.y() + pixel_bounds.y(); drawLine(&painter, - QPointF(range.x(), y), - QPointF(range.x() + range.width(), y), + QPointF(pixel_bounds.x(), y), + QPointF(pixel_bounds.x() + pixel_bounds.width(), y), pen); painter.drawText(QRectF(10, y - metrics.height()/2, - range.left(), + pixel_bounds.left(), metrics.height()), QString::number(i)); } { const int i = maxy; - double y = range.height() - i * c.y() + range.y(); + double y = pixel_bounds.height() - i * c.y() + pixel_bounds.y(); drawLine(&painter, - QPointF(range.x(), y), - QPointF(range.x() + range.width(), y), + QPointF(pixel_bounds.x(), y), + QPointF(pixel_bounds.x() + pixel_bounds.width(), y), pen); painter.drawText(QRectF(10, y - metrics.height()/2, - range.x() - 10, + pixel_bounds.x() - 10, metrics.height()), QString::number(i)); } // vertical grid - for (int i = 0; i < maxx; i += ystep) { - double x = range.x() + i * c.x(); + double x = pixel_bounds.x() + i * c.x(); drawLine(&painter, - QPointF(x, range.y()), - QPointF(x, range.y() + range.height()), + QPointF(x, pixel_bounds.y()), + QPointF(x, pixel_bounds.y() + pixel_bounds.height()), pen); const QString text = QString::number(i); painter.drawText(QRectF(x - metrics.width(text)/2, - range.height() + 10 + metrics.height(), + pixel_bounds.height() + 10 + metrics.height(), metrics.width(text), metrics.height()), text); } { const int i = maxx; - double x = range.x() + i * c.x(); + double x = pixel_bounds.x() + i * c.x(); drawLine(&painter, - QPointF(x, range.y()), - QPointF(x, range.y() + range.height()), + QPointF(x, pixel_bounds.y()), + QPointF(x, pixel_bounds.y() + pixel_bounds.height()), pen); const QString text = QString::number(i); painter.drawText(QRectF(x - metrics.width(text)/2, - range.height() + 10 + metrics.height(), + pixel_bounds.height() + 10 + metrics.height(), metrics.width(text), metrics.height()), text); @@ -144,9 +144,6 @@ void QFunctionConfigurator::drawFunction() { if (!_config) return; - int i; - QPointF prevPoint; - QPointF currentPoint; _function = QPixmap(_background); QPainter painter(&_function); @@ -156,19 +153,18 @@ void QFunctionConfigurator::drawFunction() QList points = _config->getPoints(); - for (i = 0; i < points.size(); i++) { - currentPoint = point_to_pixel( points[i] ); // Get the next point and convert it to Widget measures - drawPoint(&painter, currentPoint, QColor(200, 200, 210, 120)); - lastPoint = currentPoint; // Remember which point is the rightmost in the graph + for (int i = 0; i < points.size(); i++) { + drawPoint(&painter, + point_to_pixel(points[i]), + QColor(200, 200, 210, 120)); } + QPen pen(spline_color, 1.2, Qt::SolidLine); - QPen pen(colBezier, 1.2, Qt::SolidLine); - - prevPoint = point_to_pixel( QPointF(0,0) ); // Start at the Axis - double max = _config->maxInput(); + static const constexpr double step = 1.02; + const double max = _config->maxInput(); + QPointF prev = point_to_pixel(QPointF(0, 0)); - const double step = 1.01; for (double i = 0; i < max; i += step) { double val = _config->getValue(i); QPointF cur = point_to_pixel(QPointF(i, val)); @@ -180,66 +176,54 @@ void QFunctionConfigurator::drawFunction() void QFunctionConfigurator::paintEvent(QPaintEvent *e) { - QPointF prevPoint; - QPointF currentPoint; - QPointF actualPos; - int i; - QPainter p(this); p.setRenderHint(QPainter::Antialiasing); - if (_draw_background) { + if (_background.isNull()) drawBackground(); - _draw_background = false; - } p.drawPixmap(e->rect(), _background); if (_draw_function) { - drawFunction(); // Draw the Function on a Pixmap _draw_function = false; + drawFunction(); } - p.drawPixmap(e->rect(), _function); // Always draw the background and the function + p.drawPixmap(e->rect(), _function); if (_config) { QPen pen(Qt::white, 1, Qt::SolidLine); QList points = _config->getPoints(); - if (movingPoint >= 0 && movingPoint < points.size()) { - prevPoint = point_to_pixel( QPointF(0,0) ); // Start at the Axis - for (i = 0; i < points.size(); i++) { - currentPoint = point_to_pixel( points[i] ); // Get the next point and convert it to Widget measures - drawLine(&p, prevPoint, currentPoint, pen); - prevPoint = currentPoint; + if (moving_control_point_idx >= 0 && moving_control_point_idx < points.size()) { + QPointF prev; + for (int i = 0; i < points.size(); i++) { + auto tmp = point_to_pixel(points[i]); + drawLine(&p, prev, tmp, pen); + prev = tmp; } pen.setWidth(1); pen.setColor( Qt::white ); pen.setStyle( Qt::DashLine ); - actualPos = point_to_pixel(points[movingPoint]); - drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); - drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.height() + range.top()), pen); + QPointF pixel_pos = point_to_pixel(points[moving_control_point_idx]); + drawLine(&p, QPoint(pixel_bounds.left(), pixel_pos.y()), QPoint(pixel_pos.x(), pixel_pos.y()), pen); + drawLine(&p, QPoint(pixel_pos.x(), pixel_pos.y()), QPoint(pixel_pos.x(), pixel_bounds.height() + pixel_bounds.top()), pen); } - // // If the Tracker is active, the 'Last Point' it requested is recorded. // Show that point on the graph, with some lines to assist. // This new feature is very handy for tweaking the curves! - // - if (_config->getLastPoint( currentPoint )) { - actualPos = point_to_pixel( QPointF(fabs(currentPoint.x()), fabs(currentPoint.y())) ); - drawPoint(&p, actualPos, QColor(255, 0, 0, 120)); + QPointF last; + if (_config->getLastPoint(last)) { + QPointF pixel_pos = point_to_pixel( QPointF(fabs(last.x()), fabs(last.y())) ); + drawPoint(&p, pixel_pos, QColor(255, 0, 0, 120)); pen.setWidth(1); pen.setColor( Qt::black ); pen.setStyle( Qt::SolidLine ); - drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); - drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.width()), pen); + drawLine(&p, QPoint(pixel_bounds.left(), pixel_pos.y()), QPoint(pixel_pos.x(), pixel_pos.y()), pen); + drawLine(&p, QPoint(pixel_pos.x(), pixel_pos.y()), QPoint(pixel_pos.x(), pixel_bounds.width()), pen); } - } } -// -// Draw the handle, to move the Bezier-curve. -// void QFunctionConfigurator::drawPoint(QPainter *painter, const QPointF &pos, QColor colBG ) { painter->save(); @@ -251,7 +235,7 @@ void QFunctionConfigurator::drawPoint(QPainter *painter, const QPointF &pos, QCo painter->restore(); } -void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen) +void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen &pen) { painter->save(); painter->setPen(pen); @@ -267,12 +251,12 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) QList points = _config->getPoints(); if (e->button() == Qt::LeftButton) { bool bTouchingPoint = false; - movingPoint = -1; + moving_control_point_idx = -1; if (_config) { for (int i = 0; i < points.size(); i++) { if ( point_within_pixel(points[i], e->pos() ) ) { bTouchingPoint = true; - movingPoint = i; + moving_control_point_idx = i; timer.restart(); break; } @@ -296,7 +280,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) if (found_pt != -1) { _config->removePoint(found_pt); } - movingPoint = -1; + moving_control_point_idx = -1; } } _draw_function = true; @@ -307,29 +291,33 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) { if (!_config) return; + + static const constexpr int min_refresh_delay = 25; + + if (timer.isValid() && timer.elapsed() < min_refresh_delay) + return; + + static const constexpr int refresh_delay = 50; QList points = _config->getPoints(); - const int refresh_delay = 50; - if (movingPoint >= 0 && movingPoint < points.size()) { + if (moving_control_point_idx >= 0 && moving_control_point_idx < points.size()) { setCursor(Qt::ClosedHandCursor); if (timer.isValid() && timer.elapsed() > refresh_delay) { timer.restart(); QPointF new_pt = pixel_coord_to_point(e->pos()); - points[movingPoint] = new_pt; - _config->movePoint(movingPoint, new_pt); + points[moving_control_point_idx] = new_pt; + _config->movePoint(moving_control_point_idx, new_pt); _draw_function = true; update(); } } else { bool bTouchingPoint = false; - if (_config) { - for (int i = 0; i < points.size(); i++) { - if ( point_within_pixel(points[i], e->pos() ) ) { - bTouchingPoint = true; - } + for (int i = 0; i < points.size(); i++) { + if ( point_within_pixel(points[i], e->pos() ) ) { + bTouchingPoint = true; } } @@ -346,37 +334,39 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) { if (!_config) return; + QList points = _config->getPoints(); if (e->button() == Qt::LeftButton) { timer.invalidate(); - if (movingPoint >= 0 && movingPoint < points.size()) { + if (moving_control_point_idx >= 0 && moving_control_point_idx < points.size()) { if (_config) { - _config->movePoint(movingPoint, pixel_coord_to_point(e->pos())); + _config->movePoint(moving_control_point_idx, pixel_coord_to_point(e->pos())); } } setCursor(Qt::ArrowCursor); - movingPoint = -1; + moving_control_point_idx = -1; } _draw_function = true; update(); } -bool QFunctionConfigurator::point_within_pixel(QPointF pt, QPointF pixel) const +bool QFunctionConfigurator::point_within_pixel(const QPointF &pt, const QPointF &pixel) { - QPointF pixel2(range.x() + pt.x() * c.x(), (range.y() + range.height() - pt.y() * c.y())); + QPointF pixel2(pixel_bounds.x() + pt.x() * c.x(), + (pixel_bounds.y() + pixel_bounds.height() - pt.y() * c.y())); return pixel2.x() >= pixel.x() - pointSize && pixel2.x() < pixel.x() + pointSize && pixel2.y() >= pixel.y() - pointSize && pixel2.y() < pixel.y() + pointSize; } -QPointF QFunctionConfigurator::pixel_coord_to_point(QPointF point) const +QPointF QFunctionConfigurator::pixel_coord_to_point(const QPointF& point) { if (!_config) return QPointF(-1, -1); - double x = (point.x() - range.x()) / c.x(); - double y = (range.height() - point.y() + range.y()) / c.y(); + double x = (point.x() - pixel_bounds.x()) / c.x(); + double y = (pixel_bounds.height() - point.y() + pixel_bounds.y()) / c.y(); if (x < 0) x = 0; @@ -391,10 +381,10 @@ QPointF QFunctionConfigurator::pixel_coord_to_point(QPointF point) const return QPointF(x, y); } -QPointF QFunctionConfigurator::point_to_pixel(QPointF point) const +QPointF QFunctionConfigurator::point_to_pixel(const QPointF& point) { - return QPointF(range.x() + point.x() * c.x(), - range.y() + range.height() - point.y() * c.y()); + return QPointF(pixel_bounds.x() + point.x() * c.x(), + pixel_bounds.y() + pixel_bounds.height() - point.y() * c.y()); } void QFunctionConfigurator::resizeEvent(QResizeEvent *) diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index e4af0062f..4643f0d59 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012 Stanislaw Halik +/* Copyright (c) 2011-2014 Stanislaw Halik * Adapted to FaceTrackNoIR by Wim Vriend. * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -16,73 +16,69 @@ class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget { Q_OBJECT - Q_PROPERTY(QString Name READ get_name WRITE set_name) + Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier) +public: + QFunctionConfigurator(QWidget *parent = 0); + + FunctionConfig* config(); + void setConfig(FunctionConfig* config, const QString &name); + + void saveSettings(QString settingsFile, const QString &name); QColor colorBezier() const { - return colBezier; + return spline_color; } void setColorBezier(QColor color) { - colBezier = color; + spline_color = color; update(); } - QString get_name() const { - return name; - } - void set_name(QString name) - { - this->name = name; - } -public: - QFunctionConfigurator(QWidget *parent = 0); - FunctionConfig* config(); - - void setConfig(FunctionConfig* config); - void saveSettings(QString settingsFile); -public slots: protected slots: void paintEvent(QPaintEvent *e); void mousePressEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); -protected: +private: void drawBackground(); void drawFunction(); void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); - void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen); - bool point_within_pixel(QPointF pt, QPointF pixel) const; + void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen& pen); + bool point_within_pixel(const QPointF& pt, const QPointF& pixel); protected: virtual void resizeEvent(QResizeEvent *); - private: - QString name; void update_range() { if (!_config) return; - double w = width(), h = height(); + + const double w = width(), h = height(); const double mwl = 40, mhl = 20; const double mwr = 15, mhr = 35; - range = QRectF(mwl, mhl, (w - mwl - mwr), (h - mhl - mhr)); - c = QPointF(range.width() / _config->maxInput(), range.height() / _config->maxOutput()); - _draw_function = _draw_background = true; + + pixel_bounds = QRectF(mwl, mhl, (w - mwl - mwr), (h - mhl - mhr)); + c = QPointF(pixel_bounds.width() / _config->maxInput(), pixel_bounds.height() / _config->maxOutput()); + _draw_function = true; + + _background = QPixmap(); + _function = QPixmap(); } - QRectF range; - QPointF lastPoint; - QPointF pixel_coord_to_point (QPointF point) const; - QPointF point_to_pixel (QPointF point) const; + QPointF pixel_coord_to_point (const QPointF& point); + QPointF point_to_pixel (const QPointF& point); - int movingPoint; + FunctionConfig* _config; + + // bounds of the rectangle user can interact with + QRectF pixel_bounds; + + int moving_control_point_idx; QElapsedTimer timer; QPointF c; - QColor colBezier; - - bool _draw_background; + QColor spline_color; + QPixmap _background; - bool _draw_function; QPixmap _function; - - FunctionConfig* _config; + bool _draw_function; }; -- cgit v1.2.3 From 06416c1581409b1fd0737fa8ce7370f58cbdc417 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 19 Sep 2014 09:45:28 +0200 Subject: cleanup mapping code There was quite a bit of duplicated logic, which wasn't duplicated where it needed to be. Make functions out of the duplicated bits, then call where appropriate. Issue: #56 --- facetracknoir/curve-config.cpp | 109 ++++++++++-------------- facetracknoir/curve-config.h | 2 - facetracknoir/facetracknoir.cpp | 57 +++++++------ facetracknoir/facetracknoir.h | 4 + qfunctionconfigurator/qfunctionconfigurator.cpp | 7 -- qfunctionconfigurator/qfunctionconfigurator.h | 2 - 6 files changed, 79 insertions(+), 102 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 535655c22..813836887 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -4,10 +4,50 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge QWidget( parent, Qt::Dialog ), mainApp(ftnoir) { ui.setupUi( this ); + + // rest of mapping settings taken care of by options::value + mainApp->load_mappings(); + + { + struct { + QFunctionConfigurator* qfc; + Axis axis; + bool altp; + } qfcs[] = + { + { ui.rxconfig, Yaw, false }, + { ui.ryconfig, Pitch, false}, + { ui.rzconfig, Roll, false }, + { ui.txconfig, TX, false }, + { ui.tyconfig, TY, false }, + { ui.tzconfig, TZ, false }, + + { ui.rxconfig_alt, Yaw, true }, + { ui.ryconfig_alt, Pitch, true}, + { ui.rzconfig_alt, Roll, true }, + { ui.txconfig_alt, TX, true }, + { ui.tyconfig_alt, TY, true }, + { ui.tzconfig_alt, TZ, true }, + { nullptr, Yaw, false } + }; + + for (int i = 0; qfcs[i].qfc; i++) + { + const bool altp = qfcs[i].altp; + THeadPoseDOF& axis = mainApp->axis(qfcs[i].axis); + FunctionConfig* conf = altp ? &axis.curveAlt : &axis.curve; + const auto& name = qfcs[i].altp ? axis.name2 : axis.name1; + + qfcs[i].qfc->setConfig(conf, name); + } + } + setFont(qApp->font()); - QPoint offsetpos(120, 30); this->move(parent->pos() + offsetpos); + + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); @@ -42,8 +82,6 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge tie_setting(mainApp->s.a_x.src, ui.src_x); tie_setting(mainApp->s.a_y.src, ui.src_y); tie_setting(mainApp->s.a_z.src, ui.src_z); - - loadSettings(); } void CurveConfigurationDialog::doOK() { @@ -52,69 +90,10 @@ void CurveConfigurationDialog::doOK() { } void CurveConfigurationDialog::doCancel() { - mainApp->b->revert(); - loadSettings(); - close(); -} - -void CurveConfigurationDialog::loadSettings() { - QFunctionConfigurator* configs[6] = { - ui.txconfig, - ui.tyconfig, - ui.tzconfig, - ui.rxconfig, - ui.ryconfig, - ui.rzconfig - }; - - QFunctionConfigurator* alt_configs[6] = { - ui.txconfig_alt, - ui.tyconfig_alt, - ui.tzconfig_alt, - ui.rxconfig_alt, - ui.ryconfig_alt, - ui.rzconfig_alt - }; - - for (int i = 0; i < 6; i++) - { - configs[i]->setConfig(&mainApp->axis(i).curve, mainApp->axis(i).name1); - alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, mainApp->axis(i).name2); - } + mainApp->load_mappings(); + this->close(); } void CurveConfigurationDialog::save() { - QSettings settings("opentrack"); - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ) - .toString(); - - struct { - QFunctionConfigurator* qfc; - Axis axis; - bool altp; - } qfcs[] = - { - { ui.rxconfig, Yaw, false }, - { ui.ryconfig, Pitch, false}, - { ui.rzconfig, Roll, false }, - { ui.txconfig, TX, false }, - { ui.tyconfig, TY, false }, - { ui.tzconfig, TZ, false }, - - { ui.rxconfig_alt, Yaw, true }, - { ui.ryconfig_alt, Pitch, true}, - { ui.rzconfig_alt, Roll, true }, - { ui.txconfig_alt, TX, true }, - { ui.tyconfig_alt, TY, true }, - { ui.tzconfig_alt, TZ, true }, - { nullptr, Yaw, false } - }; - - for (int i = 0; qfcs[i].qfc; i++) - { - THeadPoseDOF& axis = mainApp->axis(qfcs[i].axis); - qfcs[i].qfc->saveSettings(currentFile, qfcs[i].altp ? axis.name2 : axis.name1); - } + mainApp->save_mappings(); } diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index 0949cdc45..49aba7bde 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -10,12 +10,10 @@ class CurveConfigurationDialog: public QWidget Q_OBJECT public: CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); - void loadSettings(); private: Ui::UICCurveConfigurationDialog ui; void save(); FaceTrackNoIR *mainApp; - private slots: void doOK(); void doCancel(); diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index da8fae615..dfa135778 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -259,16 +259,26 @@ void FaceTrackNoIR::open() { } } -void FaceTrackNoIR::save() { - b->save(); - +void FaceTrackNoIR::save_mappings() { QSettings settings("opentrack"); QString currentFile = settings.value("SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini") .toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); + + for (int i = 0; i < 6; i++) + { + axis(i).curve.saveSettings(iniFile, axis(i).name1); + axis(i).curveAlt.saveSettings(iniFile, axis(i).name2); + } +} +void FaceTrackNoIR::save() { + b->save(); + save_mappings(); + #if defined(__unix) || defined(__linux) QByteArray bytes = QFile::encodeName(currentFile); const char* filename_as_asciiz = bytes.constData(); @@ -311,9 +321,21 @@ void FaceTrackNoIR::saveAs() fill_profile_cbx(); } +void FaceTrackNoIR::load_mappings() { + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); + + for (int i = 0; i < 6; i++) + { + axis(i).curve.loadSettings(iniFile, axis(i).name1); + axis(i).curveAlt.loadSettings(iniFile, axis(i).name2); + } +} + void FaceTrackNoIR::loadSettings() { b->reload(); - (dynamic_cast(_curve_config))->loadSettings(); + load_mappings(); } void FaceTrackNoIR::updateButtonState(bool running) @@ -359,18 +381,6 @@ void FaceTrackNoIR::startTracker( ) { delete tracker; } - { - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - for (int i = 0; i < 6; i++) - { - axis(i).curve.loadSettings(iniFile, axis(i).name1); - axis(i).curveAlt.loadSettings(iniFile, axis(i).name2); - } - } - tracker = new Tracker ( this, s ); if (pTrackerDialog && Libraries->pTracker) { @@ -559,17 +569,12 @@ void FaceTrackNoIR::showKeyboardShortcuts() { _keyboard_shortcuts->show(); _keyboard_shortcuts->raise(); } -void FaceTrackNoIR::showCurveConfiguration() { - - if (!_curve_config) - { +void FaceTrackNoIR::showCurveConfiguration() { + if (!_curve_config) _curve_config = new CurveConfigurationDialog( this, this ); - } - - if (_curve_config) { - _curve_config->show(); - _curve_config->raise(); - } + + _curve_config->show(); + _curve_config->raise(); } void FaceTrackNoIR::exit() { diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index dc37ad377..f6f4afdfb 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -152,4 +152,8 @@ private slots: void startTracker(); void stopTracker(); + +public: + void save_mappings(); + void load_mappings(); }; diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 3f94f0941..70f682853 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -49,13 +49,6 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config, const QString& nam update(); } -void QFunctionConfigurator::saveSettings(QString settingsFile, const QString& name) { - QSettings iniFile(settingsFile, QSettings::IniFormat); - - if (_config) - _config->saveSettings(iniFile, name); -} - void QFunctionConfigurator::drawBackground() { if (!_config) diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 4643f0d59..bb2f09cea 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -23,8 +23,6 @@ public: FunctionConfig* config(); void setConfig(FunctionConfig* config, const QString &name); - void saveSettings(QString settingsFile, const QString &name); - QColor colorBezier() const { return spline_color; -- cgit v1.2.3 From 00097d4c2d272bda38e5ebdaa6dffc41a59eba33 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 19 Sep 2014 10:25:25 +0200 Subject: reorder, pedantry --- facetracknoir/tracker.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index db2a7af31..dd37e883f 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -120,11 +120,14 @@ void Tracker::run() { for (int i = 0; i < 6; i++) { - auto& axis = mainApp->axis(i); raw_6dof.axes[i] = newpose[i]; + + auto& axis = mainApp->axis(i); + int k = axis.opts.src; if (k < 0 || k >= 6) continue; + axis.headPos = newpose[k]; } @@ -162,7 +165,7 @@ void Tracker::run() { t_compensate(output_camera.axes, output_camera.axes, mainApp->s.tcomp_tz); if (Libraries->pProtocol) { - Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); + Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); } } -- cgit v1.2.3 From 13b1fd19091ff6c6387828eac816f91152620346 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 20 Sep 2014 15:25:47 +0200 Subject: avoid rebuild after commit Issue: #59 --- CMakeLists.txt | 15 +++++++++------ facetracknoir/facetracknoir.cpp | 5 +++-- facetracknoir/facetracknoir.h | 2 -- facetracknoir/version.c | 5 +++++ opentrack-version.h | 7 ------- 5 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 facetracknoir/version.c delete mode 100644 opentrack-version.h (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index ae54f90fc..633bf587f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,6 +196,8 @@ opentrack_module(opentrack-tracker-rift ftnoir_tracker_rift) opentrack_module(opentrack-tracker-hydra ftnoir_tracker_hydra) opentrack_module(opentrack-tracker-freepie-udp ftnoir_tracker_freepie-udp) +file(GLOB opentrack-version-c "facetracknoir/version.c") + file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp" "ftnoir_csv/*.h") # compat lib for POSIX/win32 @@ -257,6 +259,11 @@ target_link_libraries(opentrack-pose-widget ${MY_QT_LIBS}) add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c}) target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) +add_library(opentrack-version STATIC ${opentrack-version-c}) +set_target_properties(opentrack-version PROPERTIES + COMPILE_DEFINITIONS + "IN_VERSION_UNIT;OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\"") + opentrack_library(opentrack-filter-accela) opentrack_library(opentrack-filter-kalman) opentrack_library(opentrack-filter-ewma) @@ -419,17 +426,13 @@ if(UNIX OR APPLE) target_link_libraries(opentrack-qxt-mini X11) endif() endif() + add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-uih} ${opentrack-bin-rcc}) -set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") -set(OPENTRACK_COMMIT_VERSION \"${OPENTRACK__COMMIT}\") -configure_file("${CMAKE_SOURCE_DIR}/opentrack-version.h" "${CMAKE_BINARY_DIR}/opentrack-version.h" @ONLY NEWLINE_STYLE UNIX) if(APPLE) SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES LINK_FLAGS "-framework Carbon -framework CoreFoundation") endif() -set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") - if(UNIX OR APPLE) target_link_libraries(opentrack opentrack-qxt-mini) endif() @@ -446,7 +449,7 @@ if(CMAKE_SYSTEM STREQUAL LINUX) link_libraries(rt) endif() -target_link_libraries(opentrack opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTWIDGETS_LIB_RELEASE}) +target_link_libraries(opentrack opentrack-version opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTWIDGETS_LIB_RELEASE}) if(NOT WIN32) target_link_libraries(opentrack dl) endif() diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index dfa135778..43c96f137 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -25,7 +25,6 @@ #include "shortcuts.h" #include "tracker.h" #include "curve-config.h" -#include "opentrack-version.h" #include #if defined(_WIN32) @@ -581,6 +580,8 @@ void FaceTrackNoIR::exit() { QCoreApplication::exit(0); } +extern "C" volatile const char* opentrack_version; + void FaceTrackNoIR::fill_profile_cbx() { if (looping) @@ -590,7 +591,7 @@ void FaceTrackNoIR::fill_profile_cbx() QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); qDebug() << "Config file now" << currentFile; QFileInfo pathInfo ( currentFile ); - setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName()); + setWindowTitle(QString( const_cast(opentrack_version) + QStringLiteral(" :: ")) + pathInfo.fileName()); QDir settingsDir( pathInfo.dir() ); QStringList filters; filters << "*.ini"; diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index f6f4afdfb..713a51f0d 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -55,8 +55,6 @@ using namespace options; #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ftnoir_filter_base/ftnoir_filter_base.h" -#include "opentrack-version.h" - class Tracker; // pre-define class to avoid circular includes class FaceTrackNoIR; diff --git a/facetracknoir/version.c b/facetracknoir/version.c new file mode 100644 index 000000000..0ef4ec140 --- /dev/null +++ b/facetracknoir/version.c @@ -0,0 +1,5 @@ +#ifdef IN_VERSION_UNIT +# define IN_CRAPOLA_COMPILE_UNIT +volatile const char* opentrack_version = OPENTRACK_VERSION; +#else +#endif diff --git a/opentrack-version.h b/opentrack-version.h deleted file mode 100644 index f31d5edfd..000000000 --- a/opentrack-version.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef OPENTRACK_VERSION -# define OPENTRACK_VERSION @OPENTRACK_COMMIT_VERSION@ -#else -# ifndef OPENTRACK_VERSION -# define OPENTRACK_VERSION "Mourns-For-Trees" -# endif -#endif -- cgit v1.2.3 From 34cfb18a68c3a626a8927aa1216a642c2aba35f8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 21 Sep 2014 21:23:49 +0200 Subject: nix needless include, less rebuild time --- facetracknoir/global-shortcuts.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/global-shortcuts.cpp b/facetracknoir/global-shortcuts.cpp index 1c10b160c..9b6591a74 100644 --- a/facetracknoir/global-shortcuts.cpp +++ b/facetracknoir/global-shortcuts.cpp @@ -1,4 +1,5 @@ -#include "facetracknoir/facetracknoir.h" +# include +# include #if defined(_WIN32) # ifndef DIRECTINPUT_VERSION -- cgit v1.2.3 From 7298e7c57f0933997b9dd2c417afab50984c0cd2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 21 Sep 2014 21:24:05 +0200 Subject: crop to make icon less bad --- facetracknoir/uielements/curves.png | Bin 2850 -> 3457 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/uielements/curves.png b/facetracknoir/uielements/curves.png index fe21fa157..3f953a0a3 100644 Binary files a/facetracknoir/uielements/curves.png and b/facetracknoir/uielements/curves.png differ -- cgit v1.2.3 From 27109d3fd204f971a920cb034a5499bdb6ebb81b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 21 Sep 2014 17:27:13 +0200 Subject: core: nix support for camera device identifier --- facetracknoir/facetracknoir.cpp | 63 ----------------------------------------- facetracknoir/facetracknoir.h | 1 - 2 files changed, 64 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 43c96f137..ea8574624 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -27,10 +27,6 @@ #include "curve-config.h" #include -#if defined(_WIN32) -# include -# include -#endif #if defined(__APPLE__) # define SONAME "dylib" @@ -154,8 +150,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - GetCameraNameDX(); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); @@ -180,63 +174,6 @@ QFrame* FaceTrackNoIR::get_video_widget() { return ui.video_frame; } -void FaceTrackNoIR::GetCameraNameDX() { -#if defined(_WIN32) - ui.cameraName->setText("No video-capturing device was found in your system: check if it's connected!"); - - HRESULT hr; - ICreateDevEnum *pSysDevEnum = NULL; - hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); - if (FAILED(hr)) - { - qDebug() << "GetWDM says: CoCreateInstance Failed!"; - return; - } - - qDebug() << "GetWDM says: CoCreateInstance succeeded!"; - - IEnumMoniker *pEnumCat = NULL; - hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); - - if (hr == S_OK) { - qDebug() << "GetWDM says: CreateClassEnumerator succeeded!"; - - IMoniker *pMoniker = NULL; - ULONG cFetched; - if (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { - IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); - if (SUCCEEDED(hr)) { - VARIANT varName; - VariantInit(&varName); - hr = pPropBag->Read(L"FriendlyName", &varName, 0); - if (SUCCEEDED(hr)) - { - QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); - qDebug() << "GetWDM says: Moniker found:" << str; - ui.cameraName->setText(str); - } - VariantClear(&varName); - - pPropBag->Release(); - } - pMoniker->Release(); - } - pEnumCat->Release(); - } - pSysDevEnum->Release(); -#else - for (int i = 0; i < 16; i++) { - char buf[128]; - sprintf(buf, "/dev/video%d", i); - if (access(buf, R_OK | W_OK) == 0) { - ui.cameraName->setText(QString(buf)); - break; - } - } -#endif -} - void FaceTrackNoIR::open() { QFileDialog dialog(this); dialog.setFileMode(QFileDialog::ExistingFile); diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 713a51f0d..22a4363ea 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -116,7 +116,6 @@ private: void createIconGroupBox(); - void GetCameraNameDX(); void loadSettings(); void updateButtonState(bool); -- cgit v1.2.3 From 8e2aba0a468c189a6eb733fe3fab5b7889abb7ba Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 21 Sep 2014 19:42:26 +0200 Subject: use more savory UI style on win32 --- facetracknoir/main.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 7462f8c21..aa33522d7 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -1,11 +1,33 @@ #include "facetracknoir.h" #include +#include +#include #include int main(int argc, char** argv) { + // workaround QTBUG-38598 + QCoreApplication::addLibraryPath("."); + + // qt5 designer-made controls look like shit on 'doze -sh 20140921 +#ifdef _WIN32 + { + const QStringList preferred { "fusion", "windowsvista", "jazzbands'-marijuana", "macintosh", "windowsxp" }; + for (const auto& style_name : preferred) + { + QStyle* s = QStyleFactory::create(style_name); + if (s) + { + QApplication::setStyle(s); + break; + } + } + } +#endif + QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); + auto w = std::make_shared(); w->show(); -- cgit v1.2.3 From a33dcb5dc4edca8d34d7778a6b1ddf867e6a4590 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 21 Sep 2014 19:42:56 +0200 Subject: reorder access(2) header for clarity --- facetracknoir/facetracknoir.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index ea8574624..5f4a4e11c 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -27,7 +27,6 @@ #include "curve-config.h" #include - #if defined(__APPLE__) # define SONAME "dylib" #elif defined(_WIN32) @@ -44,10 +43,6 @@ # define LIB_PREFIX "lib" #endif -#if defined(__unix) || defined(__linux) || defined(__APPLE__) -# include -#endif - static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) { Metadata* meta; @@ -211,6 +206,10 @@ void FaceTrackNoIR::save_mappings() { } } +#if defined(__unix) || defined(__linux) || defined(__APPLE__) +# include +#endif + void FaceTrackNoIR::save() { b->save(); save_mappings(); -- cgit v1.2.3 From de2c98a213c32db99b63754fb8520271501eee43 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 21 Sep 2014 19:43:15 +0200 Subject: adjust some UI stuff, breaks muscle memory sadly --- facetracknoir/facetracknoir.ui | 1645 +++++++++++----------------------------- 1 file changed, 438 insertions(+), 1207 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index b257ae304..ab3322880 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -3,15 +3,12 @@ WVR OpentrackUI - - Qt::NonModal - 0 0 - 790 - 500 + 879 + 422 @@ -20,225 +17,76 @@ 0 - - - 0 - 0 - - - - - 65536 - 65536 - - - - Qt::DefaultContextMenu - - - opentrack - :/images/facetracknoir.png:/images/facetracknoir.png - - - - - - - - Qt::ToolButtonIconOnly - - - true - - - false - - - - 0 - 0 - - - - - 0 - 0 - - - - - 65535 - 65535 - - - - - - + - 10 - 130 - 320 - 240 + 715 + 110 + 151 + 38 - + 0 0 - - - 250 - 187 - + + Keys - + + + :/uielements/tools.png:/uielements/tools.png + + - 65536 - 65536 + 98 + 24 - - 0 - - - - - 0 - 0 - 320 - 240 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - + - 100 - 10 - 229 - 121 + 90 + 20 + 169 + 137 - - - 0 - 0 - - - - - 65536 - 65536 - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + Game data - - true - - - - QLayout::SetMinimumSize - - - 0 - - - 0 - - - 0 - - - 0 - - - 10 - - - - - true - - - - 65536 - 65536 - - - - false - - - TZ - - - - - + + + true - - - 65536 - 65536 - - 13 + NoAntialias + false - - false - QFrame::NoFrame - QFrame::Plain - - - 1 + QFrame::Raised - false + true - 5 + 2 QLCDNumber::Flat @@ -246,142 +94,129 @@ - - - - 65536 - 65536 - - + TX - - + + true - - - 65536 - 65536 - - 13 + NoAntialias + false - - false - QFrame::NoFrame - QFrame::Plain - - - 1 + QFrame::Raised - false + true - 5 + 2 QLCDNumber::Flat - - - - - 65536 - 65536 - + + + + true - - yaw + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat - - + + true - - - 65536 - 65536 - - 13 + NoAntialias + false - - false - QFrame::NoFrame - QFrame::Plain - - - 1 + QFrame::Raised - false + true - 5 + 2 QLCDNumber::Flat - - + + + + yaw + + + + + true - - - 65536 - 65536 - - 13 + NoAntialias + false - - false - QFrame::NoFrame - QFrame::Plain - - - 1 + QFrame::Raised - false + true - 5 + 2 QLCDNumber::Flat @@ -389,29 +224,17 @@ - - - - 65536 - 65536 - - + roll - + true - - - 65536 - 65536 - - false @@ -420,205 +243,93 @@ - - - - - 65536 - 65536 - - - - pitch - - - - - + + true - - - 65536 - 65536 - - - - - 13 - - false - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - false - - - 5 - - - QLCDNumber::Flat + + TZ - - + + true - - - 65536 - 65536 - - 13 + NoAntialias + false - - false - QFrame::NoFrame - QFrame::Plain - - - 1 + QFrame::Raised - false + true - 5 + 2 QLCDNumber::Flat + + + + pitch + + + - - - - 10 - 20 - 81 - 100 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - 350 - 270 - 191 - 91 + 345 + 260 + 256 + 65 - - - 180 - 80 - - - - - 65536 - 65536 - - - - - - Game protocol - - - Qt::AlignHCenter|Qt::AlignTop - - - false - - - false + Protocol - - - QLayout::SetDefaultConstraint - - - 6 - - + + - - - 65536 - 65536 - - - - - - - -1 + + + 0 + 0 + - 7 + 42 - + true - - - 65536 - 65536 - - - - Change game protocol settings - - - + + + 0 + 0 + Settings @@ -627,153 +338,42 @@ - + - 580 - 390 - 171 - 38 - - - - - 62 - 38 - - - - - 65536 - 65536 - - - - PointingHandCursor - - - Edit the Curve settings - - - Qt::LeftToRight - - - background:none; - - - Mapping - - - - :/uielements/curves.png:/uielements/curves.png - - - - 98 - 24 - - - - - - - 370 - 40 - 411 - 20 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - Not connected - - - - - - 580 - 210 - 171 - 91 + 345 + 175 + 256 + 65 - - - 0 - 0 - - - - - 65536 - 65536 - - - - - - Filter - - - Qt::AlignHCenter|Qt::AlignTop - - - false - - - false + Tracker - - - QLayout::SetDefaultConstraint - - - - - - 65536 - 65536 - - - - - - - -1 + + + + + + 0 + 0 + - 7 + 42 - - + + true - - - 65536 - 65536 - - - - Change game protocol settings - - - + + + 0 + 0 + Settings @@ -782,59 +382,26 @@ - + - 350 - 60 - 191 - 91 + 630 + 175 + 221 + 65 - - - 0 - 0 - - - - - 65536 - 65536 - - - - - - Main tracker - - - Qt::AlignHCenter|Qt::AlignTop - - - false - - - false + Filter - - - QLayout::SetDefaultConstraint - + - - - - 65536 - 65536 - - - - - - - -1 + + + + 0 + 0 + 42 @@ -842,21 +409,15 @@ - + true - - - 65536 - 65536 - - - - Change tracker settings - - - + + + 0 + 0 + Settings @@ -865,87 +426,26 @@ - - - - 370 - 10 - 411 - 25 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - - - - 350 - 160 - 191 - 91 + 630 + 260 + 221 + 65 - - - 0 - 0 - - - - - 65536 - 65536 - - Auxiliary tracker - - Qt::AlignHCenter|Qt::AlignTop - - - false - - - false - - - - QLayout::SetDefaultConstraint - + - - - 65536 - 65536 - - - - - - - -1 + + + 0 + 0 + 42 @@ -957,17 +457,11 @@ true - - - 65536 - 65536 - - - - Change tracker settings - - - + + + 0 + 0 + Settings @@ -976,93 +470,13 @@ - - - - 350 - 400 - 190 - 65 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - GO! - - - Qt::AlignHCenter|Qt::AlignTop - - - false - - - - QLayout::SetMinimumSize - - - 6 - - - - - - 65536 - 65536 - - - - Start the Tracker - - - - - - Start - - - - - - - false - - - - 65536 - 65536 - - - - Stop the Tracker - - - - - - Stop - - - - - - + - 580 - 340 - 171 - 38 + 10 + 170 + 320 + 240 @@ -1071,151 +485,75 @@ 0 - - - 62 - 38 - - - - - 65536 - 65536 - - - - PointingHandCursor - - - Edit the Keyboard and mouse shortcuts - - - Keys - - - - :/uielements/tools.png:/uielements/tools.png - - - - 98 - 24 - + + 0 - 550 - 60 - 231 - 123 + 450 + 40 + 256 + 111 - - - 0 - 0 - - - - - 65536 - 65536 - - Profile - - Qt::AlignHCenter|Qt::AlignTop - - - false - - - - QLayout::SetDefaultConstraint - - - 6 - - + + - - - 65536 - 65536 - - - - - - - -1 + + + 0 + 0 + 10 - - - - - 65536 - 65536 - - - - Load an INI-file from a folder - - - - - - Load - - - - + true - - - 65536 - 65536 - + + + 0 + 0 + - - Save the current INI-file + + Save - - + + + + + + + 0 + 0 + - Save + Load - + true - - - 65536 - 65536 - - - - Save the INI-file under another name - - - + + + 0 + 0 + Save As ... @@ -1224,495 +562,371 @@ - + + + + 715 + 60 + 151 + 38 + + + + + 0 + 0 + + + + Mapping + + + + :/uielements/curves.png:/uielements/curves.png + + + + 80 + 22 + + + + + + + 0 + 10 + 81 + 100 + + + + + 0 + 0 + + + + - 10 - 380 - 141 - 106 + 520 + 340 + 190 + 65 + + + 0 + 0 + + + + + 65536 + 65536 + + - Raw translation + Controls - Qt::AlignBottom|Qt::AlignHCenter - - - false + Qt::AlignHCenter|Qt::AlignTop - - - QLayout::SetMaximumSize - - - QFormLayout::FieldsStayAtSizeHint - - - QFormLayout::DontWrapRows - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - Qt::AlignHCenter|Qt::AlignTop - - - 0 - - - 0 - - - 0 - - - 0 - + - + - + 0 0 - - - 65536 - 65536 - - - TX + Start - + - true + false - + 0 0 - - - 65536 - 65536 - + + Stop + + + + + + + + + 460 + 10 + 115 + 19 + + + + + 0 + 0 + + + + + + + 270 + 20 + 169 + 137 + + + + Raw pose + + + + + + true - 12 + 13 + NoAntialias + false - - false - QFrame::NoFrame - - 0 - - - 0 + + QFrame::Raised - false + true - 4 + 2 QLCDNumber::Flat - - - - - 0 - 0 - - - - - 65536 - 65536 - - + + - TY + TX - - + + true - - - 0 - 0 - - - - - 65536 - 65536 - - - 12 + 13 + NoAntialias + false - - false - QFrame::NoFrame - - 0 - - - 0 + + QFrame::Raised - false + true - 4 + 2 QLCDNumber::Flat - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - TZ - - - true - - - 0 - 0 - - - - - 65536 - 65536 - - - 12 + 13 + NoAntialias + false - - false - QFrame::NoFrame - - 0 - - - 0 + + QFrame::Raised - false + true - 4 + 2 QLCDNumber::Flat - - - - - - 160 - 380 - 161 - 111 - - - - Raw rotation - - - Qt::AlignBottom|Qt::AlignHCenter - - - false - - - - QLayout::SetMaximumSize - - - QFormLayout::FieldsStayAtSizeHint - - - QFormLayout::DontWrapRows - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - Qt::AlignHCenter|Qt::AlignTop - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - yaw - - - - - + + true - - - 0 - 0 - - - - - 65536 - 65536 - - - 12 + 13 + NoAntialias + false - - false - QFrame::NoFrame - - 0 - - - 0 + + QFrame::Raised - false + true - 4 + 2 QLCDNumber::Flat - - - - - 0 - 0 - - - - - 65536 - 65536 - - + + - pitch + yaw - - + + true - - - 0 - 0 - - - - - 65536 - 65536 - - - 12 + 13 + NoAntialias + false - - false - QFrame::NoFrame - - 0 - - - 0 + + QFrame::Raised - false + true - 4 + 2 QLCDNumber::Flat - - - - - 0 - 0 - + + + + roll + + + + + + + true - - - 65536 - 65536 - + + false - roll + TY - - + + true - - - 0 - 0 - + + false + + + TZ - - - 65536 - 65536 - + + + + + + true - 12 + 13 + NoAntialias + false - - false - QFrame::NoFrame - - 0 - - - 0 + + QFrame::Raised - false + true - 4 + 2 QLCDNumber::Flat + + + + pitch + + + - lcdNumRotZ - label_8 - label_7 - lcdNumRotY - lcdNumRotX - label_9 - GLWidget @@ -1724,4 +938,21 @@ + + + 5 + + + 5 + + + true + + + true + + + true + + -- cgit v1.2.3 From 0fa42ce4822c7b7cdfde6d0fe93abb2d722bc230 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 21 Sep 2014 21:22:39 +0200 Subject: indicate UI contains a "video feed" element --- facetracknoir/facetracknoir.cpp | 28 +++++++------ facetracknoir/facetracknoir.h | 13 +++--- facetracknoir/facetracknoir.ui | 74 +++++++++++++++++++++++------------ facetracknoir/main-facetracknoir.qrc | 1 + facetracknoir/uielements/no-feed.png | Bin 0 -> 20196 bytes 5 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 facetracknoir/uielements/no-feed.png (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 5f4a4e11c..3f6d641ef 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -94,10 +94,14 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : pProtocolDialog(NULL), pFilterDialog(NULL), kbd_quit(QKeySequence("Ctrl+Q"), this), - looping(0) + looping(0), + video_frame_layout(new QVBoxLayout()), + no_feed_pixmap(":/uielements/no-feed.png") { ui.setupUi(this); setFixedSize(size()); + ui.video_frame_label->setPixmap(no_feed_pixmap); + updateButtonState(false); _keyboard_shortcuts = 0; _curve_config = 0; @@ -163,6 +167,7 @@ FaceTrackNoIR::~FaceTrackNoIR() { save(); if (Libraries) delete Libraries; + delete video_frame_layout; } QFrame* FaceTrackNoIR::get_video_widget() { @@ -275,20 +280,17 @@ void FaceTrackNoIR::loadSettings() { void FaceTrackNoIR::updateButtonState(bool running) { - bool e = !running; - ui.iconcomboProfile->setEnabled ( e ); - ui.btnLoad->setEnabled ( e ); - ui.btnSaveAs->setEnabled ( e ); - ui.btnStartTracker->setEnabled ( e ); + bool not_running = !running; + ui.iconcomboProfile->setEnabled ( not_running ); + ui.btnStartTracker->setEnabled ( not_running ); ui.btnStopTracker->setEnabled ( running ); - ui.iconcomboProtocol->setEnabled ( e ); - ui.btnShowServerControls->setEnabled ( e ); - ui.iconcomboFilter->setEnabled ( e ); - ui.iconcomboTrackerSource->setEnabled(e); - ui.cbxSecondTrackerSource->setEnabled(e); - - ui.btnStartTracker->setEnabled(e); + ui.iconcomboProtocol->setEnabled ( not_running ); + ui.iconcomboFilter->setEnabled ( not_running ); + ui.iconcomboTrackerSource->setEnabled(not_running); + ui.cbxSecondTrackerSource->setEnabled(not_running); + ui.btnStartTracker->setEnabled(not_running); ui.btnStopTracker->setEnabled(running); + ui.video_frame_label->setVisible(not_running); } void FaceTrackNoIR::startTracker( ) { diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 22a4363ea..f005a9c14 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -32,13 +32,14 @@ #include #include #include +#include +#include +#include #if !defined(_WIN32) # include "qxt-mini/QxtGlobalShortcut" #else # include #endif -#include -#include #include "ui_facetracknoir.h" @@ -117,18 +118,20 @@ private: void createIconGroupBox(); void loadSettings(); - void updateButtonState(bool); + void updateButtonState(bool running); QList dlopen_filters; QList dlopen_trackers; QList dlopen_protocols; QShortcut kbd_quit; - + int looping; + + QLayout* video_frame_layout; + QPixmap no_feed_pixmap; #ifndef _WIN32 void bind_keyboard_shortcut(QxtGlobalShortcut&, key_opts& k); #endif void fill_profile_cbx(); - int looping; private slots: void open(); diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index ab3322880..d2c784619 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -25,9 +25,9 @@ - 715 - 110 - 151 + 760 + 280 + 96 38 @@ -54,7 +54,7 @@ - 90 + 120 20 169 137 @@ -298,8 +298,8 @@ 345 - 260 - 256 + 255 + 246 65 @@ -343,7 +343,7 @@ 345 175 - 256 + 246 65 @@ -385,9 +385,9 @@ - 630 - 175 - 221 + 345 + 335 + 246 65 @@ -429,8 +429,8 @@ - 630 - 260 + 625 + 180 221 65 @@ -485,16 +485,38 @@ 0 - - 0 - + + + + 0 + 0 + 320 + 240 + + + + + 0 + 0 + + + + + NoAntialias + false + + + + + + - 450 + 525 40 - 256 + 311 111 @@ -565,9 +587,9 @@ - 715 - 60 - 151 + 615 + 280 + 141 38 @@ -586,8 +608,8 @@ - 80 - 22 + 60 + 37 @@ -610,9 +632,9 @@ - 520 - 340 - 190 + 635 + 335 + 201 65 @@ -685,7 +707,7 @@ - 270 + 320 20 169 137 diff --git a/facetracknoir/main-facetracknoir.qrc b/facetracknoir/main-facetracknoir.qrc index 6cb2e3006..e37c25299 100644 --- a/facetracknoir/main-facetracknoir.qrc +++ b/facetracknoir/main-facetracknoir.qrc @@ -4,5 +4,6 @@ images/settings16.png uielements/curves.png images/facetracknoir.png + uielements/no-feed.png diff --git a/facetracknoir/uielements/no-feed.png b/facetracknoir/uielements/no-feed.png new file mode 100644 index 000000000..7c2f52bf8 Binary files /dev/null and b/facetracknoir/uielements/no-feed.png differ -- cgit v1.2.3 From 35d3f9b53f9ee409ef39621e5579699ebf2f645a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 08:43:17 +0200 Subject: only remove "no feed" image if tracker provides a video feed --- facetracknoir/facetracknoir.cpp | 13 ++++++++----- facetracknoir/facetracknoir.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 3f6d641ef..eb9ece52a 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -101,7 +101,7 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : ui.setupUi(this); setFixedSize(size()); ui.video_frame_label->setPixmap(no_feed_pixmap); - updateButtonState(false); + updateButtonState(false, false); _keyboard_shortcuts = 0; _curve_config = 0; @@ -278,7 +278,7 @@ void FaceTrackNoIR::loadSettings() { load_mappings(); } -void FaceTrackNoIR::updateButtonState(bool running) +void FaceTrackNoIR::updateButtonState(bool running, bool inertialp) { bool not_running = !running; ui.iconcomboProfile->setEnabled ( not_running ); @@ -290,7 +290,7 @@ void FaceTrackNoIR::updateButtonState(bool running) ui.cbxSecondTrackerSource->setEnabled(not_running); ui.btnStartTracker->setEnabled(not_running); ui.btnStopTracker->setEnabled(running); - ui.video_frame_label->setVisible(not_running); + ui.video_frame_label->setVisible(not_running || inertialp); } void FaceTrackNoIR::startTracker( ) { @@ -333,7 +333,10 @@ void FaceTrackNoIR::startTracker( ) { timUpdateHeadPose.start(50); - updateButtonState(true); + // NB check valid since SelectedLibraries ctor called + // trackers take care of layout state updates + const bool is_inertial = ui.video_frame->layout() == nullptr; + updateButtonState(true, is_inertial); } void FaceTrackNoIR::stopTracker( ) { @@ -381,7 +384,7 @@ void FaceTrackNoIR::stopTracker( ) { Libraries = NULL; } } - updateButtonState(false); + updateButtonState(false, false); } void FaceTrackNoIR::showHeadPose() { diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index f005a9c14..50f68825a 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -118,7 +118,7 @@ private: void createIconGroupBox(); void loadSettings(); - void updateButtonState(bool running); + void updateButtonState(bool running, bool inertialp); QList dlopen_filters; QList dlopen_trackers; -- cgit v1.2.3 From 1c07a40d12aee0dc1a0167fbfcfe62a2d7142d79 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 09:39:40 +0200 Subject: core: plugin-api.hpp now exclusively provides interface --- facetracknoir/facetracknoir.h | 4 - facetracknoir/main-settings.hpp | 1 - facetracknoir/plugin-api.hpp | 87 ++++++++++++++++++++++ facetracknoir/plugin-support.h | 21 +----- facetracknoir/tracker.h | 1 - facetracknoir/tracker_types.cpp | 1 + facetracknoir/tracker_types.h | 7 +- ftnoir_filter_base/ftnoir_filter_base.h | 19 ----- ftnoir_filter_base/ftnoir_filter_base_global.h | 4 - ftnoir_posewidget/glwidget.h | 10 +-- ftnoir_protocol_base/ftnoir_protocol_base.h | 20 ----- ftnoir_protocol_base/ftnoir_protocol_base_global.h | 4 - ftnoir_tracker_base/ftnoir_tracker_base.h | 21 ------ ftnoir_tracker_base/ftnoir_tracker_base_global.h | 18 ----- ftnoir_tracker_base/ftnoir_tracker_types.h | 4 - qfunctionconfigurator/functionconfig.h | 4 +- qfunctionconfigurator/qfunctionconfigurator.h | 4 +- 17 files changed, 98 insertions(+), 132 deletions(-) create mode 100644 facetracknoir/plugin-api.hpp delete mode 100644 ftnoir_filter_base/ftnoir_filter_base.h delete mode 100644 ftnoir_filter_base/ftnoir_filter_base_global.h delete mode 100644 ftnoir_protocol_base/ftnoir_protocol_base.h delete mode 100644 ftnoir_protocol_base/ftnoir_protocol_base_global.h delete mode 100644 ftnoir_tracker_base/ftnoir_tracker_base.h delete mode 100644 ftnoir_tracker_base/ftnoir_tracker_base_global.h delete mode 100644 ftnoir_tracker_base/ftnoir_tracker_types.h (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 50f68825a..bdec333fd 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -52,10 +52,6 @@ using namespace options; #include "tracker.h" #include "facetracknoir/shortcuts.h" -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_filter_base/ftnoir_filter_base.h" - class Tracker; // pre-define class to avoid circular includes class FaceTrackNoIR; diff --git a/facetracknoir/main-settings.hpp b/facetracknoir/main-settings.hpp index b45c5d9c8..0a1fb968d 100644 --- a/facetracknoir/main-settings.hpp +++ b/facetracknoir/main-settings.hpp @@ -2,7 +2,6 @@ #include #include "facetracknoir/options.h" -#include "ftnoir_tracker_base/ftnoir_tracker_types.h" using namespace options; struct key_opts { diff --git a/facetracknoir/plugin-api.hpp b/facetracknoir/plugin-api.hpp new file mode 100644 index 000000000..1610c5d8a --- /dev/null +++ b/facetracknoir/plugin-api.hpp @@ -0,0 +1,87 @@ +#pragma once + +#include +#include + +#if defined(_WIN32) +# define CALLING_CONVENTION __stdcall +#else +# define CALLING_CONVENTION +#endif + +enum Axis { + TX = 0, TY, TZ, Yaw, Pitch, Roll +}; + +struct Metadata +{ + Metadata() {} + virtual ~Metadata() {} + + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; + virtual void getIcon(QIcon *icon) = 0; +}; + +struct IFilter +{ + virtual ~IFilter() = 0; + virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) = 0; + virtual void reset() = 0; +}; + +inline IFilter::~IFilter() {} + +struct IFilterDialog +{ + virtual ~IFilterDialog() {} + virtual void registerFilter(IFilter* tracker) = 0; + virtual void unregisterFilter() = 0; +}; + +struct 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() {} + virtual void registerProtocol(IProtocol *protocol) = 0; + virtual void unRegisterProtocol() = 0; +}; + +struct ITracker +{ + virtual ~ITracker() = 0; + virtual void StartTracker( QFrame* frame ) = 0; + virtual void GetHeadPoseData(double *data) = 0; + virtual int preferredHz() { return 200; } +}; + +inline ITracker::~ITracker() {} + +struct ITrackerDialog +{ + virtual ~ITrackerDialog() {} + virtual void registerTracker(ITracker *tracker) = 0; + virtual void unRegisterTracker() = 0; +}; + +#ifndef OPENTRACK_EXPORT +# ifdef IN_OPENTRACK +# if !defined(_MSC_VER) +# define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) Q_DECL_EXPORT +# else +# error "MSVC support removed" +# endif +# else +# define OPENTRACK_EXPORT Q_DECL_IMPORT +# endif +#endif diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h index 931f0fa1c..bb7b3c026 100644 --- a/facetracknoir/plugin-support.h +++ b/facetracknoir/plugin-support.h @@ -1,5 +1,7 @@ #pragma once +#include "facetracknoir/plugin-api.hpp" + #if defined(_WIN32) # define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "@0" # ifdef _MSC_VER @@ -19,15 +21,6 @@ #include #include #include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_filter_base/ftnoir_filter_base.h" -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" - -#if defined(_WIN32) -# define CALLING_CONVENTION __stdcall -#else -# define CALLING_CONVENTION -#endif class IDynamicLibraryProvider; @@ -66,16 +59,6 @@ private: #endif }; -struct Metadata -{ - Metadata() {} - virtual ~Metadata() {} - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; - virtual void getIcon(QIcon *icon) = 0; -}; // merely to break a circular header dependency -sh class IDynamicLibraryProvider { diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index d06ac9d27..543501640 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -11,7 +11,6 @@ #include #include #include "plugin-support.h" -#include #include #include diff --git a/facetracknoir/tracker_types.cpp b/facetracknoir/tracker_types.cpp index ba3ac552d..2d7ec45a5 100644 --- a/facetracknoir/tracker_types.cpp +++ b/facetracknoir/tracker_types.cpp @@ -1,5 +1,6 @@ #include "tracker_types.h" #include "rotation.h" +#include "facetracknoir/plugin-api.hpp" #define PI 3.14159265358979323846264 #define D2R PI/180.0 diff --git a/facetracknoir/tracker_types.h b/facetracknoir/tracker_types.h index 043c04201..80b747597 100644 --- a/facetracknoir/tracker_types.h +++ b/facetracknoir/tracker_types.h @@ -1,7 +1,4 @@ -#ifndef __TRACKER_TYPES_H__ -#define __TRACKER_TYPES_H__ - -#include "ftnoir_tracker_base/ftnoir_tracker_types.h" +#pragma once struct T6DOF { public: @@ -12,5 +9,3 @@ public: T6DOF operator-(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B T6DOF operator+(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B^-1 - -#endif //__TRACKER_TYPES_H__ diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h deleted file mode 100644 index 366ff1495..000000000 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "ftnoir_filter_base_global.h" -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" - -struct IFilter -{ - virtual ~IFilter() = 0; - virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) = 0; - virtual void reset() = 0; -}; - -inline IFilter::~IFilter() { } - -struct IFilterDialog -{ - virtual ~IFilterDialog() {} - virtual void registerFilter(IFilter* tracker) = 0; - virtual void unregisterFilter() = 0; -}; diff --git a/ftnoir_filter_base/ftnoir_filter_base_global.h b/ftnoir_filter_base/ftnoir_filter_base_global.h deleted file mode 100644 index 091727564..000000000 --- a/ftnoir_filter_base/ftnoir_filter_base_global.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" - -#define FTNOIR_FILTER_BASE_EXPORT FTNOIR_TRACKER_BASE_EXPORT diff --git a/ftnoir_posewidget/glwidget.h b/ftnoir_posewidget/glwidget.h index c4b2e09de..eef238ec7 100644 --- a/ftnoir_posewidget/glwidget.h +++ b/ftnoir_posewidget/glwidget.h @@ -5,12 +5,11 @@ * copyright notice and this permission notice appear in all copies. */ -#ifndef GLWIDGET_H -#define GLWIDGET_H +#pragma once #include #include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "facetracknoir/plugin-api.hpp" struct Point { Point(int x, int y) : @@ -48,7 +47,7 @@ struct Vec2f { } }; -class FTNOIR_TRACKER_BASE_EXPORT GLWidget : public QWidget +class OPENTRACK_EXPORT GLWidget : public QWidget { Q_OBJECT @@ -56,7 +55,6 @@ public: GLWidget(QWidget *parent); ~GLWidget(); void rotateBy(double xAngle, double yAngle, double zAngle); - protected: void paintEvent ( QPaintEvent * event ); @@ -93,5 +91,3 @@ private: QImage back; QImage texture; }; - -#endif diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h deleted file mode 100644 index 84f1c0e51..000000000 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "ftnoir_protocol_base_global.h" -#include "ftnoir_tracker_base/ftnoir_tracker_types.h" - -struct 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() {} - virtual void registerProtocol(IProtocol *protocol) = 0; - virtual void unRegisterProtocol() = 0; -}; diff --git a/ftnoir_protocol_base/ftnoir_protocol_base_global.h b/ftnoir_protocol_base/ftnoir_protocol_base_global.h deleted file mode 100644 index 24f3f6c9b..000000000 --- a/ftnoir_protocol_base/ftnoir_protocol_base_global.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" - -#define FTNOIR_PROTOCOL_BASE_EXPORT FTNOIR_TRACKER_BASE_EXPORT diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h deleted file mode 100644 index 8415e38c8..000000000 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "ftnoir_tracker_base_global.h" -#include "ftnoir_tracker_types.h" -#include - -struct ITracker -{ - virtual ~ITracker() = 0; - virtual void StartTracker( QFrame* frame ) = 0; - virtual void GetHeadPoseData(double *data) = 0; - virtual int preferredHz() { return 200; } -}; - -inline ITracker::~ITracker() { } - -struct ITrackerDialog -{ - virtual ~ITrackerDialog() {} - virtual void registerTracker(ITracker *tracker) = 0; - virtual void unRegisterTracker() = 0; -}; diff --git a/ftnoir_tracker_base/ftnoir_tracker_base_global.h b/ftnoir_tracker_base/ftnoir_tracker_base_global.h deleted file mode 100644 index 5b53ba82f..000000000 --- a/ftnoir_tracker_base/ftnoir_tracker_base_global.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef FTNOIR_TRACKER_BASE_GLOBAL_H -#define FTNOIR_TRACKER_BASE_GLOBAL_H - -#include - -#ifndef FTNOIR_TRACKER_BASE_EXPORT -# ifdef IN_OPENTRACK -# if !defined(_MSC_VER) -# define FTNOIR_TRACKER_BASE_EXPORT __attribute__ ((visibility ("default"))) Q_DECL_EXPORT -# else -# error "MSVC support removed" -# endif -# else -# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT -# endif -#endif - -#endif // FTNOIR_TRACKER_BASE_GLOBAL_H diff --git a/ftnoir_tracker_base/ftnoir_tracker_types.h b/ftnoir_tracker_base/ftnoir_tracker_types.h deleted file mode 100644 index d38baee43..000000000 --- a/ftnoir_tracker_base/ftnoir_tracker_types.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -enum Axis { - TX = 0, TY, TZ, Yaw, Pitch, Roll -}; diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index ee2087a05..66e7f3e8b 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -13,7 +13,7 @@ #include #include #include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "facetracknoir/plugin-api.hpp" #include #define MEMOIZE_PRECISION 100 @@ -52,7 +52,7 @@ public: } }; -class FTNOIR_TRACKER_BASE_EXPORT FunctionConfig { +class OPENTRACK_EXPORT FunctionConfig { private: void reload(); float getValueInternal(int x); diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index bb2f09cea..facc5bbe3 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -11,9 +11,9 @@ #include #include #include "qfunctionconfigurator/functionconfig.h" -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "facetracknoir/plugin-api.hpp" -class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget +class OPENTRACK_EXPORT QFunctionConfigurator : public QWidget { Q_OBJECT Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier) -- cgit v1.2.3 From 2c242165e3e3881dfffa31d1b8cf727a71c68be1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 09:59:44 +0200 Subject: unused #define declspec dllimport -> #error --- facetracknoir/plugin-api.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/plugin-api.hpp b/facetracknoir/plugin-api.hpp index 1610c5d8a..f50b9617b 100644 --- a/facetracknoir/plugin-api.hpp +++ b/facetracknoir/plugin-api.hpp @@ -82,6 +82,6 @@ struct ITrackerDialog # error "MSVC support removed" # endif # else -# define OPENTRACK_EXPORT Q_DECL_IMPORT +# error "Use only for exporting dynamic modules" # endif #endif -- cgit v1.2.3 From e0322730ab08421113e5538c5202cfcb64b59ce6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 10:43:15 +0200 Subject: core: clean up dll logic --- facetracknoir/plugin-support.cpp | 69 +++++++++++++++++++++++++++++++--------- facetracknoir/plugin-support.h | 2 +- 2 files changed, 55 insertions(+), 16 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp index 2e80c5e44..50b8ad1af 100644 --- a/facetracknoir/plugin-support.cpp +++ b/facetracknoir/plugin-support.cpp @@ -76,19 +76,44 @@ SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : correct = true; } -DynamicLibrary::DynamicLibrary(const QString& filename) +DynamicLibrary::DynamicLibrary(const QString& filename) : + handle(nullptr), + Dialog(nullptr), + Constructor(nullptr), + Metadata(nullptr) { this->filename = filename; #if defined(_WIN32) QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; handle = new QLibrary(fullPath); - qDebug() << handle->errorString(); + + struct _foo { + static bool die(QLibrary*& l, bool failp) + { + if (failp) + { + qDebug() << "failed" << l->errorString(); + delete l; + l = nullptr; + } + return failp; + } + }; + + if (_foo::die(handle, !handle->load())) + return; + Dialog = (DIALOG_FUNPTR) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); - qDebug() << handle->errorString(); + if (_foo::die(handle, !Dialog)) + return; + Constructor = (CTOR_FUNPTR) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); - qDebug() << handle->errorString(); + if (_foo::die(handle, !Constructor)) + return; + Metadata = (METADATA_FUNPTR) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); - qDebug() << handle->errorString(); + if (_foo::die(handle, !Metadata)) + return; #else QByteArray latin1 = QFile::encodeName(filename); handle = dlopen(latin1.constData(), RTLD_NOW | @@ -102,20 +127,34 @@ DynamicLibrary::DynamicLibrary(const QString& filename) ); if (handle) { - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); + struct _foo { + static bool err(void*& handle) + { + const char* err = dlerror(); + if (err) + { + fprintf(stderr, "Error, ignoring: %s\n", err); + fflush(stderr); + dlclose(handle); + handle = nullptr; + return true; + } + false; + } + }; + if (_foo::err(handle)) + return; Dialog = (DIALOG_FUNPTR) dlsym(handle, "GetDialog"); - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); + if (_foo::err(handle)) + return; Constructor = (CTOR_FUNPTR) dlsym(handle, "GetConstructor"); - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); + if (_foo::err(handle)) + return; Metadata = (METADATA_FUNPTR) dlsym(handle, "GetMetadata"); - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); + if (_foo::err(handle)) + return; } else { - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); + (void) _foo::err(handle); } #endif } diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h index bb7b3c026..f3270aa69 100644 --- a/facetracknoir/plugin-support.h +++ b/facetracknoir/plugin-support.h @@ -46,7 +46,7 @@ extern "C" typedef void* (CALLING_CONVENTION* DIALOG_FUNPTR)(void); class DynamicLibrary { public: DynamicLibrary(const QString& filename); - virtual ~DynamicLibrary(); + ~DynamicLibrary(); DIALOG_FUNPTR Dialog; CTOR_FUNPTR Constructor; METADATA_FUNPTR Metadata; -- cgit v1.2.3 From 766fc776421a85958d52bf6f3bfbc189b65a0d5f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 10:43:58 +0200 Subject: remove "second tracker" support Was always a kludge. --- facetracknoir/facetracknoir.cpp | 43 +++++---------------------------------- facetracknoir/facetracknoir.h | 11 +++------- facetracknoir/facetracknoir.ui | 44 ---------------------------------------- facetracknoir/plugin-support.cpp | 18 +--------------- facetracknoir/plugin-support.h | 2 -- facetracknoir/tracker.cpp | 7 ------- 6 files changed, 9 insertions(+), 116 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index eb9ece52a..3c36ab56f 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -54,7 +54,7 @@ static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) return true; } -static void fill_combobox(const QString& filter, QList& list, QComboBox* cbx, QComboBox* cbx2) +static void fill_combobox(const QString& filter, QList& list, QComboBox& cbx) { QDir settingsDir( QCoreApplication::applicationDirPath() ); QStringList filenames = settingsDir.entryList( QStringList() << (LIB_PREFIX + filter + SONAME), QDir::Files, QDir::Name ); @@ -71,9 +71,7 @@ static void fill_combobox(const QString& filter, QList& list, Q continue; } list.push_back(lib); - cbx->addItem(icon, longName); - if (cbx2) - cbx2->addItem(icon, longName); + cbx.addItem(icon, longName); } } @@ -90,7 +88,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : pose(std::vector{&s.a_x, &s.a_y, &s.a_z, &s.a_yaw, &s.a_pitch, &s.a_roll}), timUpdateHeadPose(this), pTrackerDialog(NULL), - pSecondTrackerDialog(NULL), pProtocolDialog(NULL), pFilterDialog(NULL), kbd_quit(QKeySequence("Ctrl+Q"), this), @@ -129,20 +126,17 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); - connect(ui.btnShowSecondTrackerSettings, SIGNAL(clicked()), this, SLOT(showSecondTrackerSettings())); connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); - ui.cbxSecondTrackerSource->addItem(QIcon(), ""); dlopen_filters.push_back((DynamicLibrary*) NULL); ui.iconcomboFilter->addItem(QIcon(), ""); - fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol, NULL); - fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); - fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); + fill_combobox("opentrack-proto-*.", dlopen_protocols, *ui.iconcomboProtocol); + fill_combobox("opentrack-tracker-*.", dlopen_trackers, *ui.iconcomboTrackerSource); + fill_combobox("opentrack-filter-*.", dlopen_filters, *ui.iconcomboFilter); tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); - tie_setting(s.tracker2_dll, ui.cbxSecondTrackerSource); tie_setting(s.protocol_dll, ui.iconcomboProtocol); tie_setting(s.filter_dll, ui.iconcomboFilter); @@ -287,7 +281,6 @@ void FaceTrackNoIR::updateButtonState(bool running, bool inertialp) ui.iconcomboProtocol->setEnabled ( not_running ); ui.iconcomboFilter->setEnabled ( not_running ); ui.iconcomboTrackerSource->setEnabled(not_running); - ui.cbxSecondTrackerSource->setEnabled(not_running); ui.btnStartTracker->setEnabled(not_running); ui.btnStopTracker->setEnabled(running); ui.video_frame_label->setVisible(not_running || inertialp); @@ -369,12 +362,6 @@ void FaceTrackNoIR::stopTracker( ) { delete pFilterDialog; pFilterDialog = nullptr; } - if (pSecondTrackerDialog) - { - pSecondTrackerDialog->unRegisterTracker(); - delete pSecondTrackerDialog; - pSecondTrackerDialog = nullptr; - } if ( tracker ) { delete tracker; @@ -442,26 +429,6 @@ void FaceTrackNoIR::showTrackerSettings() { } } -void FaceTrackNoIR::showSecondTrackerSettings() { - if (pSecondTrackerDialog) { - delete pSecondTrackerDialog; - pSecondTrackerDialog = NULL; - } - - DynamicLibrary* lib = dlopen_trackers.value(ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); - - if (lib) { - pSecondTrackerDialog = (ITrackerDialog*) lib->Dialog(); - if (pSecondTrackerDialog) { - auto foo = dynamic_cast(pSecondTrackerDialog); - foo->setFixedSize(foo->size()); - if (Libraries && Libraries->pSecondTracker) - pSecondTrackerDialog->registerTracker(Libraries->pSecondTracker); - dynamic_cast(pSecondTrackerDialog)->show(); - } - } -} - void FaceTrackNoIR::showServerControls() { if (pProtocolDialog) { delete pProtocolDialog; diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index bdec333fd..9bdda7490 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -68,16 +68,13 @@ public: QFrame *get_video_widget(); Tracker *tracker; void bindKeyboardShortcuts(); - DynamicLibrary* current_tracker1() { + DynamicLibrary* current_tracker1() override { return dlopen_trackers.value(ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); } - DynamicLibrary* current_tracker2() { - return dlopen_trackers.value(ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); - } - DynamicLibrary* current_protocol() { + DynamicLibrary* current_protocol() override { return dlopen_protocols.value(ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL); } - DynamicLibrary* current_filter() { + DynamicLibrary* current_filter() override { return dlopen_filters.value(ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); } THeadPoseDOF& axis(int idx) { @@ -104,7 +101,6 @@ private: QTimer timUpdateHeadPose; ITrackerDialog* pTrackerDialog; - ITrackerDialog* pSecondTrackerDialog; IProtocolDialog* pProtocolDialog; IFilterDialog* pFilterDialog; @@ -137,7 +133,6 @@ private slots: void profileSelected(int index); void showTrackerSettings(); - void showSecondTrackerSettings(); void showServerControls(); void showFilterControls(); diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index d2c784619..481260d38 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -426,50 +426,6 @@ - - - - 625 - 180 - 221 - 65 - - - - Auxiliary tracker - - - - - - - 0 - 0 - - - - 42 - - - - - - - true - - - - 0 - 0 - - - - Settings - - - - - diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp index 50b8ad1af..71279cb92 100644 --- a/facetracknoir/plugin-support.cpp +++ b/facetracknoir/plugin-support.cpp @@ -14,11 +14,6 @@ SelectedLibraries::~SelectedLibraries() pTracker = NULL; } - if (pSecondTracker) { - delete pSecondTracker; - pSecondTracker = NULL; - } - if (pFilter) delete pFilter; @@ -27,7 +22,7 @@ SelectedLibraries::~SelectedLibraries() } SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : - pTracker(NULL), pSecondTracker(NULL), pFilter(NULL), pProtocol(NULL) + pTracker(NULL), pFilter(NULL), pProtocol(NULL) { correct = false; if (!mainApp) @@ -42,13 +37,6 @@ SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : pTracker = (ITracker*) ptr(); } - lib = mainApp->current_tracker2(); - - if (lib && lib->Constructor) { - ptr = (CTOR_FUNPTR) lib->Constructor; - pSecondTracker = (ITracker*) ptr(); - } - lib = mainApp->current_protocol(); if (lib && lib->Constructor) { @@ -69,15 +57,11 @@ SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : if (pTracker) { pTracker->StartTracker( mainApp->get_video_widget() ); } - if (pSecondTracker) { - pSecondTracker->StartTracker( mainApp->get_video_widget() ); - } correct = true; } DynamicLibrary::DynamicLibrary(const QString& filename) : - handle(nullptr), Dialog(nullptr), Constructor(nullptr), Metadata(nullptr) diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h index f3270aa69..1e02bd605 100644 --- a/facetracknoir/plugin-support.h +++ b/facetracknoir/plugin-support.h @@ -27,7 +27,6 @@ class IDynamicLibraryProvider; struct SelectedLibraries { public: ITracker* pTracker; - ITracker* pSecondTracker; IFilter* pFilter; IProtocol* pProtocol; SelectedLibraries(IDynamicLibraryProvider* main = NULL); @@ -64,7 +63,6 @@ private: class IDynamicLibraryProvider { public: virtual DynamicLibrary* current_tracker1() = 0; - virtual DynamicLibrary* current_tracker2() = 0; virtual DynamicLibrary* current_protocol() = 0; virtual DynamicLibrary* current_filter() = 0; virtual QFrame* get_video_widget() = 0; diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index dd37e883f..90e9bdad8 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -91,9 +91,6 @@ void Tracker::run() { if (Libraries->pTracker) sleep_ms = std::min(sleep_ms, 1000 / Libraries->pTracker->preferredHz()); - if (Libraries->pSecondTracker) - sleep_ms = std::min(sleep_ms, 1000 / Libraries->pSecondTracker->preferredHz()); - qDebug() << "tracker Hz:" << 1000 / sleep_ms; #if defined(_WIN32) @@ -107,10 +104,6 @@ void Tracker::run() { if (should_quit) break; - if (Libraries->pSecondTracker) { - Libraries->pSecondTracker->GetHeadPoseData(newpose); - } - if (Libraries->pTracker) { Libraries->pTracker->GetHeadPoseData(newpose); } -- cgit v1.2.3 From 45d89cfd526bf7fa3f7865f2e78f10cd9a85a2f6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 15:20:15 +0200 Subject: fix Linux build --- facetracknoir/export.hpp | 7 ++++ facetracknoir/plugin-api.hpp | 78 +++------------------------------------- facetracknoir/plugin-qt-api.hpp | 65 +++++++++++++++++++++++++++++++++ facetracknoir/plugin-support.cpp | 33 +++++++++-------- 4 files changed, 94 insertions(+), 89 deletions(-) create mode 100644 facetracknoir/export.hpp create mode 100644 facetracknoir/plugin-qt-api.hpp (limited to 'facetracknoir') diff --git a/facetracknoir/export.hpp b/facetracknoir/export.hpp new file mode 100644 index 000000000..8c8bdc691 --- /dev/null +++ b/facetracknoir/export.hpp @@ -0,0 +1,7 @@ +#pragma once +#ifdef _WIN32 +# define OPENTRACK_LINKAGE __declspec(dllexport) +#else +# define OPENTRACK_LINKAGE +#endif +#define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE diff --git a/facetracknoir/plugin-api.hpp b/facetracknoir/plugin-api.hpp index f50b9617b..d458d25cc 100644 --- a/facetracknoir/plugin-api.hpp +++ b/facetracknoir/plugin-api.hpp @@ -1,7 +1,6 @@ #pragma once -#include -#include +#include "facetracknoir/export.hpp" #if defined(_WIN32) # define CALLING_CONVENTION __stdcall @@ -13,75 +12,6 @@ enum Axis { TX = 0, TY, TZ, Yaw, Pitch, Roll }; -struct Metadata -{ - Metadata() {} - virtual ~Metadata() {} - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; - virtual void getIcon(QIcon *icon) = 0; -}; - -struct IFilter -{ - virtual ~IFilter() = 0; - virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) = 0; - virtual void reset() = 0; -}; - -inline IFilter::~IFilter() {} - -struct IFilterDialog -{ - virtual ~IFilterDialog() {} - virtual void registerFilter(IFilter* tracker) = 0; - virtual void unregisterFilter() = 0; -}; - -struct 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() {} - virtual void registerProtocol(IProtocol *protocol) = 0; - virtual void unRegisterProtocol() = 0; -}; - -struct ITracker -{ - virtual ~ITracker() = 0; - virtual void StartTracker( QFrame* frame ) = 0; - virtual void GetHeadPoseData(double *data) = 0; - virtual int preferredHz() { return 200; } -}; - -inline ITracker::~ITracker() {} - -struct ITrackerDialog -{ - virtual ~ITrackerDialog() {} - virtual void registerTracker(ITracker *tracker) = 0; - virtual void unRegisterTracker() = 0; -}; - -#ifndef OPENTRACK_EXPORT -# ifdef IN_OPENTRACK -# if !defined(_MSC_VER) -# define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) Q_DECL_EXPORT -# else -# error "MSVC support removed" -# endif -# else -# error "Use only for exporting dynamic modules" -# endif -#endif +#ifndef OPENTRACK_CROSS_ONLY +# include "facetracknoir/plugin-qt-api.hpp" +#endif \ No newline at end of file diff --git a/facetracknoir/plugin-qt-api.hpp b/facetracknoir/plugin-qt-api.hpp new file mode 100644 index 000000000..a8dd153be --- /dev/null +++ b/facetracknoir/plugin-qt-api.hpp @@ -0,0 +1,65 @@ +#pragma once + +#include +#include + +struct Metadata +{ + Metadata() {} + virtual ~Metadata() {} + + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; + virtual void getIcon(QIcon *icon) = 0; +}; + +struct IFilter +{ + virtual ~IFilter() = 0; + virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) = 0; + virtual void reset() = 0; +}; +inline IFilter::~IFilter() {} + +struct IFilterDialog +{ + virtual ~IFilterDialog() = 0; + virtual void registerFilter(IFilter* tracker) = 0; + virtual void unregisterFilter() = 0; +}; +inline IFilterDialog::~IFilterDialog() {} + +struct 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() = 0; + virtual void registerProtocol(IProtocol *protocol) = 0; + virtual void unRegisterProtocol() = 0; +}; +inline IProtocolDialog::~IProtocolDialog() {} + +struct ITracker +{ + virtual ~ITracker() = 0; + virtual void StartTracker( QFrame* frame ) = 0; + virtual void GetHeadPoseData(double *data) = 0; + virtual int preferredHz() { return 200; } +}; +inline ITracker::~ITracker() {} + +struct ITrackerDialog +{ + virtual ~ITrackerDialog() = 0; + virtual void registerTracker(ITracker *tracker) = 0; + virtual void unRegisterTracker() = 0; +}; +inline ITrackerDialog::~ITrackerDialog() {} \ No newline at end of file diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp index 71279cb92..c6622fe04 100644 --- a/facetracknoir/plugin-support.cpp +++ b/facetracknoir/plugin-support.cpp @@ -1,5 +1,6 @@ #include "plugin-support.h" #include +#include #if !(defined(_WIN32)) # include @@ -109,23 +110,25 @@ DynamicLibrary::DynamicLibrary(const QString& filename) : 0 # endif ); - if (handle) - { - struct _foo { - static bool err(void*& handle) + + struct _foo { + static bool err(void*& handle) + { + const char* err = dlerror(); + if (err) { - const char* err = dlerror(); - if (err) - { - fprintf(stderr, "Error, ignoring: %s\n", err); - fflush(stderr); - dlclose(handle); - handle = nullptr; - return true; - } - false; + fprintf(stderr, "Error, ignoring: %s\n", err); + fflush(stderr); + dlclose(handle); + handle = nullptr; + return true; } - }; + false; + } + }; + + if (handle) + { if (_foo::err(handle)) return; Dialog = (DIALOG_FUNPTR) dlsym(handle, "GetDialog"); -- cgit v1.2.3 From 906d19822771df7bbd60246ff9f05a00ad87eba3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 15:22:28 +0200 Subject: fixup! fix Linux build --- facetracknoir/facetracknoir.cpp | 2 ++ ftnoir_protocol_ft/ftnoir_protocol_ft.h | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 3c36ab56f..868b6dbfc 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -214,6 +214,8 @@ void FaceTrackNoIR::save() { save_mappings(); #if defined(__unix) || defined(__linux) + QSettings settings("opentrack"); + const QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QByteArray bytes = QFile::encodeName(currentFile); const char* filename_as_asciiz = bytes.constData(); diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index dc534fda2..5b45e41aa 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -60,7 +60,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol(); + ~FTNoIR_Protocol() override; bool checkServerInstallationOK( ); void sendHeadposeToGame( const double *headpose ); QString getGameName() { diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index b9f002a40..ea2cb75e9 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -36,7 +36,7 @@ class Tracker : public QObject, public ITracker Q_OBJECT public: Tracker(); - virtual ~Tracker(); + ~Tracker() override; void StartTracker(QFrame* frame); void GetHeadPoseData(double *data); void load_settings(ht_config_t* config); -- cgit v1.2.3 From d2809d533b7b0b85dec34fe31c1d4fa023cd5259 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 22:37:35 +0200 Subject: options: bundle no longer a QObject --- facetracknoir/options.h | 68 +++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 474d4ec23..d751051ae 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013 Stanislaw Halik +/* Copyright (c) 2013-2014 Stanislaw Halik * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -14,8 +15,6 @@ #include #include #include -#include -#include #include #include #include @@ -67,26 +66,24 @@ namespace options { private: QMap map; QString name; + static const QString ini_pathname() + { + QSettings settings(group::org); + return settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + } public: group(const QString& name) : name(name) { - QSettings settings(group::org); - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile(currentFile, QSettings::IniFormat); - iniFile.beginGroup(name); - for (auto& k : iniFile.childKeys()) - map[k] = iniFile.value(k); - iniFile.endGroup(); + QSettings conf(ini_pathname(), QSettings::IniFormat); + conf.beginGroup(name); + for (auto& k : conf.childKeys()) + map[k] = conf.value(k); + conf.endGroup(); } static constexpr const char* org = "opentrack"; void save() { - QSettings settings(group::org); - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings s(currentFile, QSettings::IniFormat); + QSettings s(ini_pathname(), QSettings::IniFormat); s.beginGroup(name); for (auto& k : map.keys()) s.setValue(k, map[k]); @@ -96,7 +93,6 @@ namespace options { T get(const QString& k) { return qcruft_to_t(map.value(k)); } - void put(const QString& s, const QVariant& d) { map[s] = d; @@ -107,8 +103,7 @@ namespace options { } }; - class impl_bundle : public QObject { - Q_OBJECT + class impl_bundle { private: QMutex mtx; const QString group_name; @@ -117,6 +112,7 @@ namespace options { impl_bundle(const impl_bundle&) = delete; impl_bundle& operator=(const impl_bundle&) = delete; bool modified; + long priv_cookie; public: impl_bundle(const QString& group_name) : mtx(QMutex::Recursive), @@ -130,11 +126,7 @@ namespace options { QMutexLocker l(&mtx); saved = group(group_name); transient = saved; - emit reloaded(); - } - - std::shared_ptr make(const QString& name) { - return std::make_shared(name); + priv_cookie++; } void store(const QString& name, const QVariant& datum) { @@ -142,10 +134,10 @@ namespace options { if (!transient.contains(name) || datum != transient.get(name)) { if (!modified) - qDebug() << name << transient.get(name) << datum; + qDebug() << "bundle" << group_name << "modified due to" << name << transient.get(name) << datum; modified = true; transient.put(name, datum); - emit bundleChanged(); + priv_cookie++; } } bool contains(const QString& name) @@ -170,16 +162,16 @@ namespace options { QMutexLocker l(&mtx); modified = false; transient = saved; - emit bundleChanged(); + priv_cookie++; } bool modifiedp() { QMutexLocker l(&mtx); return modified; } - signals: - void bundleChanged(); - void reloaded(); + long cookie() const { + return priv_cookie; + } }; typedef std::shared_ptr pbundle; @@ -187,17 +179,21 @@ namespace options { class base_value : public QObject { Q_OBJECT public: - base_value(pbundle b, const QString& name) : b(b), self_name(name) { - connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value())); - } + base_value(pbundle b, const QString& name) : b(b), self_name(name), cookie_snap(b->cookie()) {} protected: virtual QVariant operator=(const QVariant& datum) = 0; pbundle b; QString self_name; - public slots: + private: + long cookie_snap; void reread_value() { - this->operator=(b->get(self_name)); + long cookie = b->cookie(); + if (cookie_snap != cookie) + { + cookie_snap = cookie; + this->operator=(b->get(self_name)); + } } public slots: #define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(qVariantFromValue(datum)); } -- cgit v1.2.3 From 29d11bc97afb5932aa1d394a6df295a364d983a9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 22:48:45 +0200 Subject: get rid of evil CALLING_CONVENTION macro --- facetracknoir/plugin-api.hpp | 6 - facetracknoir/plugin-support.cpp | 11 +- facetracknoir/plugin-support.h | 20 +-- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 134 ++++++++++----------- .../ftnoir_filter_accela_dialog.cpp | 2 +- ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp | 2 +- ftnoir_filter_kalman/kalman.cpp | 6 +- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp | 2 +- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 2 +- .../ftnoir_protocol_fsuipc_dialog.cpp | 2 +- .../ftnoir_protocol_fsuipc_dll.cpp | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp | 2 +- .../ftnoir_protocol_libevdev.cpp | 2 +- .../ftnoir_protocol_libevdev_dialog.cpp | 2 +- .../ftnoir_protocol_libevdev_dll.cpp | 2 +- ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 2 +- .../ftnoir_protocol_mouse_dialog.cpp | 2 +- .../ftnoir_protocol_mouse_dll.cpp | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | 2 +- .../ftnoir_protocol_vjoy_dialog.cpp | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp | 2 +- ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 2 +- .../ftnoir_protocol_wine_dialog.cpp | 2 +- ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +- .../ftnoir_tracker_freepie-udp.cpp | 2 +- .../ftnoir_tracker_freepie-udp_dialog.cpp | 2 +- .../ftnoir_tracker_freepie-udp_dll.cpp | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 6 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 2 +- .../ftnoir_tracker_hydra_dialog.cpp | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp | 2 +- .../ftnoir_tracker_joystick.cpp | 2 +- .../ftnoir_tracker_joystick_dialog.cpp | 2 +- .../ftnoir_tracker_joystick_dll.cpp | 2 +- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 2 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 2 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 2 +- 57 files changed, 133 insertions(+), 156 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/plugin-api.hpp b/facetracknoir/plugin-api.hpp index d458d25cc..f352a6a99 100644 --- a/facetracknoir/plugin-api.hpp +++ b/facetracknoir/plugin-api.hpp @@ -2,12 +2,6 @@ #include "facetracknoir/export.hpp" -#if defined(_WIN32) -# define CALLING_CONVENTION __stdcall -#else -# define CALLING_CONVENTION -#endif - enum Axis { TX = 0, TY, TZ, Yaw, Pitch, Roll }; diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp index c6622fe04..35cf8f298 100644 --- a/facetracknoir/plugin-support.cpp +++ b/facetracknoir/plugin-support.cpp @@ -1,11 +1,8 @@ +#include #include "plugin-support.h" #include #include -#if !(defined(_WIN32)) -# include -#endif - SelectedLibraries* Libraries = NULL; SelectedLibraries::~SelectedLibraries() @@ -88,15 +85,15 @@ DynamicLibrary::DynamicLibrary(const QString& filename) : if (_foo::die(handle, !handle->load())) return; - Dialog = (DIALOG_FUNPTR) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + Dialog = (DIALOG_FUNPTR) handle->resolve("GetDialog"); if (_foo::die(handle, !Dialog)) return; - Constructor = (CTOR_FUNPTR) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + Constructor = (CTOR_FUNPTR) handle->resolve("GetConstructor"); if (_foo::die(handle, !Constructor)) return; - Metadata = (METADATA_FUNPTR) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + Metadata = (METADATA_FUNPTR) handle->resolve("GetMetadata"); if (_foo::die(handle, !Metadata)) return; #else diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h index 1e02bd605..3924fc09b 100644 --- a/facetracknoir/plugin-support.h +++ b/facetracknoir/plugin-support.h @@ -2,20 +2,6 @@ #include "facetracknoir/plugin-api.hpp" -#if defined(_WIN32) -# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "@0" -# ifdef _MSC_VER -# error "No support for MSVC anymore" -#else -# define MAYBE_STDCALL_UNDERSCORE "" -# endif -#else -# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "" -# define MAYBE_STDCALL_UNDERSCORE "" -#endif - -#include - #include #include #include @@ -38,9 +24,9 @@ extern SelectedLibraries* Libraries; struct Metadata; -extern "C" typedef void* (CALLING_CONVENTION * CTOR_FUNPTR)(void); -extern "C" typedef Metadata* (CALLING_CONVENTION* METADATA_FUNPTR)(void); -extern "C" typedef void* (CALLING_CONVENTION* DIALOG_FUNPTR)(void); +extern "C" typedef void* (*CTOR_FUNPTR)(void); +extern "C" typedef Metadata* (*METADATA_FUNPTR)(void); +extern "C" typedef void* (*DIALOG_FUNPTR)(void); class DynamicLibrary { public: diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index b7aee77cd..9b7b2cb21 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -1,67 +1,67 @@ -/* Copyright (c) 2012-2013 Stanislaw Halik - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ -#include "ftnoir_filter_accela/ftnoir_filter_accela.h" -#include -#include -#include -#include -#include "facetracknoir/plugin-support.h" -using namespace std; - -FTNoIR_Filter::FTNoIR_Filter() : first_run(true) -{ -} - -static inline double parabola(const double a, const double x, const double dz, const double expt) -{ - const double sign = x > 0 ? 1 : -1; - const double a1 = 1./a; - return a1 * pow(std::max(fabs(x) - dz, 0), expt) * sign; -} - -void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, - double *new_camera_position) -{ - if (first_run) - { - for (int i = 0; i < 6; i++) - { - new_camera_position[i] = target_camera_position[i]; - for (int j = 0; j < 3; j++) - last_output[j][i] = target_camera_position[i]; - } - - first_run = false; - return; - } - - for (int i=0;i<6;i++) - { - const double vec = target_camera_position[i] - last_output[0][i]; - const double vec2 = target_camera_position[i] - last_output[1][i]; - const double vec3 = target_camera_position[i] - last_output[2][i]; - const int sign = vec < 0 ? -1 : 1; - const double a = i >= 3 ? s.rotation_alpha : s.translation_alpha; - const double a2 = a * s.second_order_alpha; - const double a3 = a * s.third_order_alpha; - const double deadzone = i >= 3 ? s.rot_deadzone : s.trans_deadzone; - const double velocity = - parabola(a, vec, deadzone, s.expt) + - parabola(a2, vec2, deadzone, s.expt) + - parabola(a3, vec3, deadzone, s.expt); - const double result = last_output[0][i] + velocity; - const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i]; - last_output[2][i] = last_output[1][i]; - last_output[1][i] = last_output[0][i]; - last_output[0][i] = new_camera_position[i] = done ? target_camera_position[i] : result; - } -} - -extern "C" OPENTRACK_EXPORT IFilter* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Filter; -} +/* Copyright (c) 2012-2013 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ +#include "ftnoir_filter_accela/ftnoir_filter_accela.h" +#include +#include +#include +#include +#include "facetracknoir/plugin-support.h" +using namespace std; + +FTNoIR_Filter::FTNoIR_Filter() : first_run(true) +{ +} + +static inline double parabola(const double a, const double x, const double dz, const double expt) +{ + const double sign = x > 0 ? 1 : -1; + const double a1 = 1./a; + return a1 * pow(std::max(fabs(x) - dz, 0), expt) * sign; +} + +void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, + double *new_camera_position) +{ + if (first_run) + { + for (int i = 0; i < 6; i++) + { + new_camera_position[i] = target_camera_position[i]; + for (int j = 0; j < 3; j++) + last_output[j][i] = target_camera_position[i]; + } + + first_run = false; + return; + } + + for (int i=0;i<6;i++) + { + const double vec = target_camera_position[i] - last_output[0][i]; + const double vec2 = target_camera_position[i] - last_output[1][i]; + const double vec3 = target_camera_position[i] - last_output[2][i]; + const int sign = vec < 0 ? -1 : 1; + const double a = i >= 3 ? s.rotation_alpha : s.translation_alpha; + const double a2 = a * s.second_order_alpha; + const double a3 = a * s.third_order_alpha; + const double deadzone = i >= 3 ? s.rot_deadzone : s.trans_deadzone; + const double velocity = + parabola(a, vec, deadzone, s.expt) + + parabola(a2, vec2, deadzone, s.expt) + + parabola(a3, vec3, deadzone, s.expt); + const double result = last_output[0][i] + velocity; + const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i]; + last_output[2][i] = last_output[1][i]; + last_output[1][i] = last_output[0][i]; + last_output[0][i] = new_camera_position[i] = done ? target_camera_position[i] : result; + } +} + +extern "C" OPENTRACK_EXPORT IFilter* GetConstructor() +{ + return new FTNoIR_Filter; +} diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 7afcd014e..965cb3ea5 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -52,7 +52,7 @@ void FilterControls::save() { accela_filter->receiveSettings(); } -extern "C" OPENTRACK_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog() +extern "C" OPENTRACK_EXPORT IFilterDialog* GetDialog() { return new FilterControls; } diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp index e908b873a..65bee3142 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp @@ -1,7 +1,7 @@ #include "ftnoir_filter_accela.h" #include "facetracknoir/plugin-support.h" -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_FilterDll; } diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 810cfef9a..c7169faae 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -91,7 +91,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, } } -extern "C" OPENTRACK_EXPORT IFilter* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IFilter* GetConstructor() { return new FTNoIR_Filter; } diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index 9e89bdb74..a32875b93 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -43,7 +43,7 @@ void FilterControls::save() { pFilter->receiveSettings(); } -extern "C" OPENTRACK_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT IFilterDialog* GetDialog( ) { return new FilterControls; } diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp index 9a5a91480..5ec6138a2 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp @@ -1,7 +1,7 @@ #include "ftnoir_filter_ewma2.h" #include "facetracknoir/plugin-support.h" -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_FilterDll; } diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp index cb622d796..70bbba8d0 100644 --- a/ftnoir_filter_kalman/kalman.cpp +++ b/ftnoir_filter_kalman/kalman.cpp @@ -121,16 +121,16 @@ void FilterControls::doCancel() { close(); } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_FilterDll; } -extern "C" OPENTRACK_EXPORT IFilter* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IFilter* GetConstructor() { return new FTNoIR_Filter; } -extern "C" OPENTRACK_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog() { +extern "C" OPENTRACK_EXPORT IFilterDialog* GetDialog() { return new FilterControls; } diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index 452937965..b2d29118f 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -57,7 +57,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); } -extern "C" OPENTRACK_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() { return new FTNoIR_Protocol; } diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index eb8b9a812..1aa67b433 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -63,7 +63,7 @@ void FGControls::doCancel() { this->close(); } -extern "C" OPENTRACK_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT IProtocolDialog* GetDialog( ) { return new FGControls; } diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp index a1f065c7b..f830f8f73 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp @@ -26,7 +26,7 @@ #include #include "facetracknoir/plugin-support.h" -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_ProtocolDll; } diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index f5e6d5eab..822cdb4d3 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -158,7 +158,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } -extern "C" OPENTRACK_EXPORT FTNoIR_Protocol* CALLING_CONVENTION GetConstructor(void) +extern "C" OPENTRACK_EXPORT FTNoIR_Protocol* GetConstructor(void) { return new FTNoIR_Protocol; } diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index e8c04dfee..d2af714ff 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -56,7 +56,7 @@ void FSUIPCControls::getLocationOfDLL() } } -extern "C" OPENTRACK_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog(void) +extern "C" OPENTRACK_EXPORT IProtocolDialog* GetDialog(void) { return new FSUIPCControls; } diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp index b2cd6e025..dbea2c467 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp @@ -25,7 +25,7 @@ #include "ftnoir_protocol_fsuipc.h" #include "facetracknoir/plugin-support.h" -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata(void) +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata(void) { return new FTNoIR_ProtocolDll; } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 8b8be63df..5c365697e 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -171,7 +171,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } -extern "C" OPENTRACK_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() { return new FTNoIR_Protocol; } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index 626d5358f..654f6c18c 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -73,7 +73,7 @@ void FTControls::selectDLL() { } } -extern "C" OPENTRACK_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog() +extern "C" OPENTRACK_EXPORT IProtocolDialog* GetDialog() { return new FTControls; } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp index d6f05badd..d7a13fa58 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp @@ -1,7 +1,7 @@ #include "facetracknoir/plugin-support.h" #include "ftnoir_protocol_ft/ftnoir_protocol_ft.h" -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_ProtocolDll; } diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp index 4ee7362ba..ccff1ba5a 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp @@ -48,7 +48,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); } -extern "C" OPENTRACK_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() { return new FTNoIR_Protocol; } diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index b4a92b395..cab5b4ba9 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -56,7 +56,7 @@ void FTNControls::doCancel() { this->close(); } -extern "C" OPENTRACK_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT IProtocolDialog* GetDialog( ) { return new FTNControls; } diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp index da89a9ca7..0d24ccf85 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp @@ -25,7 +25,7 @@ #include "ftnoir_protocol_ftn.h" #include "facetracknoir/plugin-support.h" -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_ProtocolDll; } diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index ca395b34b..1840fa03c 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -94,7 +94,7 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { (void) libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0); } -extern "C" OPENTRACK_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() { return new FTNoIR_Protocol; } diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp index 152095d40..d522610bf 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp @@ -20,7 +20,7 @@ void LibevdevControls::doCancel() { void LibevdevControls::save() { } -extern "C" OPENTRACK_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT IProtocolDialog* GetDialog( ) { return new LibevdevControls; } diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp index 01f7ff5fe..e258b077c 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp @@ -10,7 +10,7 @@ FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_ProtocolDll; } diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index f78eb16df..47f7a67ee 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -63,7 +63,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } -extern "C" OPENTRACK_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() { return new FTNoIR_Protocol; } diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index 50ea8f2e1..4b12a4f0e 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -63,7 +63,7 @@ void MOUSEControls::doCancel() { this->close(); } -extern "C" OPENTRACK_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT IProtocolDialog* 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 50f889dbe..39bdf6e54 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp @@ -25,7 +25,7 @@ #include "ftnoir_protocol_mouse.h" #include "facetracknoir/plugin-support.h" -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_ProtocolDll; } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 0901546a3..72b800d25 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -246,7 +246,7 @@ void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData } } -extern "C" OPENTRACK_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() { return new FTNoIR_Protocol; } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index 8845bec63..cd8c21f91 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -48,7 +48,7 @@ void SCControls::doCancel() { close(); } -extern "C" OPENTRACK_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT IProtocolDialog* GetDialog( ) { return new SCControls; } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp index 6effb6d51..9bdbef09c 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp @@ -26,7 +26,7 @@ #include #include "facetracknoir/plugin-support.h" -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_ProtocolDll; } diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp index 2b8aa017e..58fa2ab13 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp @@ -28,7 +28,7 @@ void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { VJoy_UpdateJoyState(0, state); } -extern "C" OPENTRACK_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() { return new FTNoIR_Protocol; } diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp index 440b12dc1..6bd82d9af 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp @@ -20,7 +20,7 @@ void VJoyControls::doCancel() { void VJoyControls::save() { } -extern "C" OPENTRACK_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT IProtocolDialog* GetDialog( ) { return new VJoyControls; } diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp index 812a2af9a..367a0df61 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp @@ -10,7 +10,7 @@ FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_ProtocolDll; } diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp index 8ebc394d2..29a2a70c1 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp @@ -56,7 +56,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return lck_shm.success(); } -extern "C" OPENTRACK_EXPORT void* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT void* GetConstructor() { return (IProtocol*) new FTNoIR_Protocol; } diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp index bcd3df458..c092de427 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp @@ -17,7 +17,7 @@ void FTControls::doCancel() { this->close(); } -extern "C" OPENTRACK_EXPORT void* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT void* GetDialog( ) { return (IProtocolDialog*) new FTControls; } diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp index 16e3e7c71..c6e3d433f 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp @@ -9,7 +9,7 @@ FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() { } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_ProtocolDll; } diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index b27b96b8f..97830c9a3 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -421,19 +421,19 @@ void TrackerDll::getIcon(QIcon *icon) //----------------------------------------------------------------------------- //#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new TrackerDll; } //#pragma comment(linker, "/export:GetTracker=_GetTracker@0") -extern "C" OPENTRACK_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() { return new Tracker; } -extern "C" OPENTRACK_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog( ) { return new TrackerControls; } diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp index c1faebebb..39b1f4a2a 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -97,7 +97,7 @@ void TrackerImpl::GetHeadPoseData(double *data) data[Roll] = pose[Roll]; } -extern "C" OPENTRACK_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() { return new TrackerImpl; } diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp index ee6c4284b..5a0cade45 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp @@ -21,7 +21,7 @@ void TrackerDialog::doCancel() { this->close(); } -extern "C" OPENTRACK_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog() +extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog() { return new TrackerDialog; } diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dll.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dll.cpp index 7578150f2..afcc8c6e1 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dll.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dll.cpp @@ -21,7 +21,7 @@ void TrackerMeta::getIcon(QIcon *icon) *icon = QIcon(":/glovepie.png"); } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new TrackerMeta; } diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 15bf3a767..05eb116c4 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -229,17 +229,17 @@ void TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/ht.png"); } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new TrackerDll; } -extern "C" OPENTRACK_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() { return new Tracker; } -extern "C" OPENTRACK_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog( ) { return new TrackerControls; } diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 03c756f97..42de16c17 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -45,7 +45,7 @@ void Hydra_Tracker::GetHeadPoseData(double *data) data[Roll] = ypr[2] * r2d; } -extern "C" OPENTRACK_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() { return new Hydra_Tracker; } diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index 80b5fb22c..dbd9981fa 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -21,7 +21,7 @@ void TrackerControls::doCancel() { close(); } -extern "C" OPENTRACK_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog( ) { return new TrackerControls; } diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp index 8388ddfec..18efea05a 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp @@ -23,7 +23,7 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/facetracknoir.png"); } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_TrackerDll; } diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 9b98d4bed..bb1076ddc 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -200,7 +200,7 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data) data[i] = values[i] * limits[i] / AXIS_MAX; } -extern "C" OPENTRACK_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() { return new FTNoIR_Tracker; } diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 67e480a3c..4ddbcb0c8 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -53,7 +53,7 @@ void TrackerControls::doCancel() { this->close(); } -extern "C" OPENTRACK_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog( ) { return new TrackerControls; } diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp index 075ed5558..af1a9679a 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp @@ -22,7 +22,7 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/facetracknoir.png"); } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_TrackerDll; } diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 768a3a71f..7e5ccc6c5 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -245,7 +245,7 @@ void Tracker::GetHeadPoseData(THeadPoseData *data) //----------------------------------------------------------------------------- #ifdef OPENTRACK_API -extern "C" OPENTRACK_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() #else #pragma comment(linker, "/export:GetTracker=_GetTracker@0") OPENTRACK_EXPORT ITrackerPtr __stdcall GetTracker() diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index 0e58a2e4a..9529e2688 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -290,7 +290,7 @@ void TrackerDialog::unRegisterTracker() //ui.center_button->setEnabled(false); } -extern "C" OPENTRACK_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog( ) { return new TrackerDialog; } diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp index 07e1d9e75..fb756a867 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp @@ -32,7 +32,7 @@ void TrackerDll::getIcon(QIcon *icon) #ifdef OPENTRACK_API # include "facetracknoir/plugin-support.h" -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() #else # pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") OPENTRACK_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index 1cca60758..4198a4b88 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -67,7 +67,7 @@ void Rift_Tracker::GetHeadPoseData(double *data) } } -extern "C" OPENTRACK_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() { return new Rift_Tracker; } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index c95ce3641..a66eb83b7 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -25,7 +25,7 @@ void TrackerControls::doCancel() { close(); } -extern "C" OPENTRACK_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog() +extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog() { return new TrackerControls; } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp index 22eec9b9b..902c8051c 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp @@ -35,7 +35,7 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/rift_tiny.png"); } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_TrackerDll; } diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index 6253529dc..136e075d2 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -36,7 +36,7 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data) data[i] = last_recv_pose[i]; } -extern "C" OPENTRACK_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() { return new FTNoIR_Tracker; } diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index 59683ddc8..b0f40ee94 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -22,7 +22,7 @@ void TrackerControls::doCancel() { this->close(); } -extern "C" OPENTRACK_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog( ) { return new TrackerControls; } diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp index 525a618f4..7cd235522 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -21,7 +21,7 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/facetracknoir.png"); } -extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { return new FTNoIR_TrackerDll; } -- cgit v1.2.3 From 7a9d80c1897db4a67384a93bccaff5416b30cb76 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 23:06:30 +0200 Subject: fixup! fix Wine proto bitrot --- facetracknoir/plugin-support.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp index 35cf8f298..553d4aed1 100644 --- a/facetracknoir/plugin-support.cpp +++ b/facetracknoir/plugin-support.cpp @@ -3,6 +3,10 @@ #include #include +#ifndef _WIN32 +# include +#endif + SelectedLibraries* Libraries = NULL; SelectedLibraries::~SelectedLibraries() -- cgit v1.2.3 From 460eb42ae913700903df7b25d50282397da95395 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Sep 2014 23:37:28 +0200 Subject: fix timer uninitialized memory access --- facetracknoir/timer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp index 24d62e37a..d2df1efde 100644 --- a/facetracknoir/timer.hpp +++ b/facetracknoir/timer.hpp @@ -53,8 +53,8 @@ public: long start() { struct timespec cur; (void) clock_gettime(CLOCK_MONOTONIC, &cur); - int ret = conv(cur); state = cur; + int ret = conv(cur); return ret; } long elapsed() { -- cgit v1.2.3 From c678574f6fd84ede6744a1fcc4453cd67d8a60da Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 23 Sep 2014 02:11:45 +0200 Subject: options: fix cookie logic --- facetracknoir/options.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index d751051ae..0e275c77d 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -179,14 +179,12 @@ namespace options { class base_value : public QObject { Q_OBJECT public: - base_value(pbundle b, const QString& name) : b(b), self_name(name), cookie_snap(b->cookie()) {} + base_value(pbundle b, const QString& name) : b(b), self_name(name), cookie_snap(0) {} protected: virtual QVariant operator=(const QVariant& datum) = 0; pbundle b; QString self_name; - private: - long cookie_snap; - void reread_value() + void maybe_lazy_change() { long cookie = b->cookie(); if (cookie_snap != cookie) @@ -195,6 +193,8 @@ namespace options { this->operator=(b->get(self_name)); } } + private: + long cookie_snap; public slots: #define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(qVariantFromValue(datum)); } DEFINE_SLOT(double) @@ -229,7 +229,11 @@ namespace options { this->operator=(qVariantFromValue(def)); } } - operator T() { return b->get(self_name); } + operator T() + { + maybe_lazy_change(); + return b->get(self_name); + } QVariant operator=(const T& datum) { return this->operator =(qVariantFromValue(datum)); -- cgit v1.2.3 From 43096962390dfa8005aa81def09aa274ac6c90cb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 23 Sep 2014 02:11:53 +0200 Subject: qdebug harder --- facetracknoir/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 0e275c77d..ce705033d 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -134,7 +134,7 @@ namespace options { if (!transient.contains(name) || datum != transient.get(name)) { if (!modified) - qDebug() << "bundle" << group_name << "modified due to" << name << transient.get(name) << datum; + qDebug() << "bundle" << group_name << "modified due to" << name << transient.get(name) << datum << "->" << datum; modified = true; transient.put(name, datum); priv_cookie++; -- cgit v1.2.3 From cf84c354b30b39fe04a79f457947f7f778bc8fc7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 23 Sep 2014 02:12:02 +0200 Subject: fix warn !_WIN32 --- facetracknoir/plugin-support.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp index 553d4aed1..e9154bb75 100644 --- a/facetracknoir/plugin-support.cpp +++ b/facetracknoir/plugin-support.cpp @@ -124,7 +124,7 @@ DynamicLibrary::DynamicLibrary(const QString& filename) : handle = nullptr; return true; } - false; + return false; } }; -- cgit v1.2.3 From 749b04f00d58974bb1afe4d271f8b1216519cd92 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 24 Sep 2014 19:23:04 +0200 Subject: New UI --- facetracknoir/facetracknoir.ui | 442 +++++++++++++++++++++++++---------------- 1 file changed, 275 insertions(+), 167 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 481260d38..215b9b55d 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -7,8 +7,8 @@ 0 0 - 879 - 422 + 597 + 506 @@ -22,42 +22,13 @@ :/images/facetracknoir.png:/images/facetracknoir.png - - - - 760 - 280 - 96 - 38 - - - - - 0 - 0 - - - - Keys - - - - :/uielements/tools.png:/uielements/tools.png - - - - 98 - 24 - - - - 120 - 20 - 169 - 137 + 140 + 15 + 126 + 161 @@ -297,10 +268,10 @@ - 345 - 255 - 246 - 65 + 405 + 380 + 181 + 56 @@ -341,10 +312,10 @@ - 345 - 175 - 246 - 65 + 405 + 215 + 181 + 56 @@ -385,10 +356,10 @@ - 345 - 335 - 246 - 65 + 405 + 325 + 181 + 56 @@ -426,13 +397,57 @@ + + + + 405 + 270 + 181 + 56 + + + + Auxiliary tracker + + + + + + + 0 + 0 + + + + 42 + + + + + + + true + + + + 0 + 0 + + + + Settings + + + + + - 10 - 170 - 320 - 240 + 24 + 204 + 366 + 281 @@ -446,8 +461,8 @@ 0 0 - 320 - 240 + 366 + 281 @@ -470,29 +485,16 @@ - 525 - 40 - 311 - 111 + 405 + 15 + 181 + 81 Profile - - - - - 0 - 0 - - - - 10 - - - @@ -538,60 +540,28 @@ + + + + + 0 + 0 + + + + 10 + + + - - - - 615 - 280 - 141 - 38 - - - - - 0 - 0 - - - - Mapping - - - - :/uielements/curves.png:/uielements/curves.png - - - - 60 - 37 - - - - - - - 0 - 10 - 81 - 100 - - - - - 0 - 0 - - - - 635 - 335 - 201 - 65 + 405 + 440 + 181 + 56 @@ -609,9 +579,6 @@ Controls - - Qt::AlignHCenter|Qt::AlignTop - @@ -644,37 +611,28 @@ - - - - 460 - 10 - 115 - 19 - - - - - 0 - 0 - - - - 320 - 20 - 169 - 137 + 273 + 15 + 126 + 161 Raw pose - - + + + + TX + + + + + true @@ -702,13 +660,6 @@ - - - - TX - - - @@ -738,8 +689,8 @@ - - + + true @@ -796,13 +747,6 @@ - - - - yaw - - - @@ -832,13 +776,6 @@ - - - - roll - - - @@ -901,8 +838,179 @@ + + + + yaw + + + + + + + roll + + + + + + + 15 + 179 + 386 + 316 + + + + Video preview + + + + + + 405 + 95 + 181 + 80 + + + + Settings + + + + + 10 + 45 + 161 + 26 + + + + + 0 + 0 + + + + Keys + + + + :/uielements/tools.png:/uielements/tools.png + + + + 98 + 24 + + + + + + + 10 + 15 + 161 + 26 + + + + + 0 + 0 + + + + Mapping + + + + :/uielements/curves.png:/uielements/curves.png + + + + 60 + 37 + + + + + + + + 15 + 15 + 116 + 161 + + + + Tracking preview + + + + + 5 + 15 + 106 + 141 + + + + + 0 + 0 + + + + + + + + 405 + 180 + 181 + 36 + + + + Detected app + + + + + 10 + 15 + 115 + 16 + + + + + 0 + 0 + + + + + box_mapped_headpose + groupGameProtocol + groupTrackerSource + groupFilter + groupBox_3 + video_frame + groupProfile + groupStartStop + box_raw_headpose + video_frame_label + video_frame_label + groupBox + groupBox_2 + groupBox_4 + groupBox_5 -- cgit v1.2.3 From cdbb9238b898369e778f546272ed563636f1fdb0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 17:54:28 +0200 Subject: timer: convert to ms on demand --- facetracknoir/timer.hpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp index d2df1efde..8eb6b943b 100644 --- a/facetracknoir/timer.hpp +++ b/facetracknoir/timer.hpp @@ -62,4 +62,7 @@ public: (void) clock_gettime(CLOCK_MONOTONIC, &cur); return conv(cur); } + long elapsed_ms() { + return elapsed() / 1000000L; + } }; -- cgit v1.2.3 From 3685c645e0c3ffba4edc61536957ac6b9f9cac3e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 17:54:53 +0200 Subject: core: fix timer units --- facetracknoir/facetracknoir.ui | 2088 ++++++++++++++++++++-------------------- facetracknoir/tracker.cpp | 384 ++++---- 2 files changed, 1236 insertions(+), 1236 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 215b9b55d..7f6b863c1 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -1,1044 +1,1044 @@ - - - WVR - OpentrackUI - - - - 0 - 0 - 597 - 506 - - - - - 0 - 0 - - - - - :/images/facetracknoir.png:/images/facetracknoir.png - - - - - - 140 - 15 - 126 - 161 - - - - Game data - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - TX - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - yaw - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - roll - - - - - - - true - - - false - - - TY - - - - - - - true - - - false - - - TZ - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - pitch - - - - - - - - - 405 - 380 - 181 - 56 - - - - Protocol - - - - - - - 0 - 0 - - - - 42 - - - - - - - true - - - - 0 - 0 - - - - Settings - - - - - - - - - 405 - 215 - 181 - 56 - - - - Tracker - - - - - - - 0 - 0 - - - - 42 - - - - - - - true - - - - 0 - 0 - - - - Settings - - - - - - - - - 405 - 325 - 181 - 56 - - - - Filter - - - - - - - 0 - 0 - - - - 42 - - - - - - - true - - - - 0 - 0 - - - - Settings - - - - - - - - - 405 - 270 - 181 - 56 - - - - Auxiliary tracker - - - - - - - 0 - 0 - - - - 42 - - - - - - - true - - - - 0 - 0 - - - - Settings - - - - - - - - - 24 - 204 - 366 - 281 - - - - - 0 - 0 - - - - - - 0 - 0 - 366 - 281 - - - - - 0 - 0 - - - - - NoAntialias - false - - - - - - - - - - - 405 - 15 - 181 - 81 - - - - Profile - - - - - - true - - - - 0 - 0 - - - - Save - - - - - - - - 0 - 0 - - - - Load - - - - - - - true - - - - 0 - 0 - - - - Save As ... - - - - - - - - 0 - 0 - - - - 10 - - - - - - - - - 405 - 440 - 181 - 56 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - Controls - - - - - - - 0 - 0 - - - - Start - - - - - - - false - - - - 0 - 0 - - - - Stop - - - - - - - - - 273 - 15 - 126 - 161 - - - - Raw pose - - - - - - TX - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - false - - - TY - - - - - - - true - - - false - - - TZ - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - pitch - - - - - - - yaw - - - - - - - roll - - - - - - - - - 15 - 179 - 386 - 316 - - - - Video preview - - - - - - 405 - 95 - 181 - 80 - - - - Settings - - - - - 10 - 45 - 161 - 26 - - - - - 0 - 0 - - - - Keys - - - - :/uielements/tools.png:/uielements/tools.png - - - - 98 - 24 - - - - - - - 10 - 15 - 161 - 26 - - - - - 0 - 0 - - - - Mapping - - - - :/uielements/curves.png:/uielements/curves.png - - - - 60 - 37 - - - - - - - - 15 - 15 - 116 - 161 - - - - Tracking preview - - - - - 5 - 15 - 106 - 141 - - - - - 0 - 0 - - - - - - - - 405 - 180 - 181 - 36 - - - - Detected app - - - - - 10 - 15 - 115 - 16 - - - - - 0 - 0 - - - - - box_mapped_headpose - groupGameProtocol - groupTrackerSource - groupFilter - groupBox_3 - video_frame - groupProfile - groupStartStop - box_raw_headpose - video_frame_label - video_frame_label - groupBox - groupBox_2 - groupBox_4 - groupBox_5 - - - - - GLWidget - QWidget -
glwidget.h
-
-
- - - - - - - 5 - - - 5 - - - true - - - true - - - true - - -
+ + + WVR + OpentrackUI + + + + 0 + 0 + 597 + 506 + + + + + 0 + 0 + + + + + :/images/facetracknoir.png:/images/facetracknoir.png + + + + + + 140 + 15 + 126 + 161 + + + + Game data + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + TX + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + yaw + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + roll + + + + + + + true + + + false + + + TY + + + + + + + true + + + false + + + TZ + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + pitch + + + + + + + + + 405 + 380 + 181 + 56 + + + + Protocol + + + + + + + 0 + 0 + + + + 42 + + + + + + + true + + + + 0 + 0 + + + + Settings + + + + + + + + + 405 + 215 + 181 + 56 + + + + Tracker + + + + + + + 0 + 0 + + + + 42 + + + + + + + true + + + + 0 + 0 + + + + Settings + + + + + + + + + 405 + 325 + 181 + 56 + + + + Filter + + + + + + + 0 + 0 + + + + 42 + + + + + + + true + + + + 0 + 0 + + + + Settings + + + + + + + + + 405 + 270 + 181 + 56 + + + + Auxiliary tracker + + + + + + + 0 + 0 + + + + 42 + + + + + + + true + + + + 0 + 0 + + + + Settings + + + + + + + + + 24 + 204 + 366 + 281 + + + + + 0 + 0 + + + + + + 0 + 0 + 366 + 281 + + + + + 0 + 0 + + + + + NoAntialias + false + + + + + + + + + + + 405 + 15 + 181 + 81 + + + + Profile + + + + + + true + + + + 0 + 0 + + + + Save + + + + + + + + 0 + 0 + + + + Load + + + + + + + true + + + + 0 + 0 + + + + Save As ... + + + + + + + + 0 + 0 + + + + 10 + + + + + + + + + 405 + 440 + 181 + 56 + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + Controls + + + + + + + 0 + 0 + + + + Start + + + + + + + false + + + + 0 + 0 + + + + Stop + + + + + + + + + 273 + 15 + 126 + 161 + + + + Raw pose + + + + + + TX + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + true + + + false + + + TY + + + + + + + true + + + false + + + TZ + + + + + + + true + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 2 + + + QLCDNumber::Flat + + + + + + + pitch + + + + + + + yaw + + + + + + + roll + + + + + + + + + 15 + 179 + 386 + 316 + + + + Video preview + + + + + + 405 + 95 + 181 + 80 + + + + Settings + + + + + 10 + 45 + 161 + 26 + + + + + 0 + 0 + + + + Keys + + + + :/uielements/tools.png:/uielements/tools.png + + + + 98 + 24 + + + + + + + 10 + 15 + 161 + 26 + + + + + 0 + 0 + + + + Mapping + + + + :/uielements/curves.png:/uielements/curves.png + + + + 60 + 37 + + + + + + + + 15 + 15 + 116 + 161 + + + + Tracking preview + + + + + 5 + 15 + 106 + 141 + + + + + 0 + 0 + + + + + + + + 405 + 180 + 181 + 36 + + + + Detected app + + + + + 10 + 15 + 115 + 16 + + + + + 0 + 0 + + + + + box_mapped_headpose + groupGameProtocol + groupTrackerSource + groupFilter + groupBox_3 + video_frame + groupProfile + groupStartStop + box_raw_headpose + video_frame_label + video_frame_label + groupBox + groupBox_2 + groupBox_4 + groupBox_5 + + + + + GLWidget + QWidget +
glwidget.h
+
+
+ + + + + + + 5 + + + 5 + + + true + + + true + + + true + + +
diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 90e9bdad8..72ad22b42 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -1,192 +1,192 @@ -/* Copyright (c) 2012-2013 Stanislaw Halik - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -/* - * this file appeared originally in facetracknoir, was rewritten completely - * following opentrack fork. - * - * originally written by Wim Vriend. - */ - -#include "tracker.h" -#include "facetracknoir.h" -#include -#include -#include - -#if defined(_WIN32) -# include -#endif - -Tracker::Tracker(FaceTrackNoIR *parent , main_settings& s) : - mainApp(parent), - s(s), - should_quit(false), - do_center(false), - enabled(true) -{ -} - -Tracker::~Tracker() -{ - should_quit = true; - wait(); -} - -static void get_curve(double pos, double& out, THeadPoseDOF& axis) { - bool altp = (pos < 0) && axis.opts.altp; - axis.curve.setTrackingActive( !altp ); - axis.curveAlt.setTrackingActive( altp ); - auto& fc = altp ? axis.curveAlt : axis.curve; - out = (axis.opts.invert ? -1 : 1) * fc.getValue(pos); - - out += axis.opts.zero; -} - -static void t_compensate(double* input, double* output, bool rz) -{ - const auto H = input[Yaw] * M_PI / -180; - const auto P = input[Pitch] * M_PI / -180; - const auto B = input[Roll] * M_PI / 180; - - const auto cosH = cos(H); - const auto sinH = sin(H); - const auto cosP = cos(P); - const auto sinP = sin(P); - const auto cosB = cos(B); - const auto sinB = sin(B); - - double foo[] = { - cosH * cosB - sinH * sinP * sinB, - - sinB * cosP, - sinH * cosB + cosH * sinP * sinB, - cosH * sinB + sinH * sinP * cosB, - cosB * cosP, - sinB * sinH - cosH * sinP * cosB, - - sinH * cosP, - - sinP, - cosH * cosP, - }; - - cv::Mat rmat(3, 3, CV_64F, foo); - const cv::Mat tvec(3, 1, CV_64F, input); - cv::Mat ret = rmat * tvec; - - const int max = !rz ? 3 : 2; - - for (int i = 0; i < max; i++) - output[i] = ret.at(i); -} - -void Tracker::run() { - T6DOF offset_camera; - - double newpose[6] = {0}; - int sleep_ms = 15; - - if (Libraries->pTracker) - sleep_ms = std::min(sleep_ms, 1000 / Libraries->pTracker->preferredHz()); - - qDebug() << "tracker Hz:" << 1000 / sleep_ms; - -#if defined(_WIN32) - (void) timeBeginPeriod(1); -#endif - - for (;;) - { - t.start(); - - if (should_quit) - break; - - if (Libraries->pTracker) { - Libraries->pTracker->GetHeadPoseData(newpose); - } - - { - QMutexLocker foo(&mtx); - - for (int i = 0; i < 6; i++) - { - raw_6dof.axes[i] = newpose[i]; - - auto& axis = mainApp->axis(i); - - int k = axis.opts.src; - if (k < 0 || k >= 6) - continue; - - axis.headPos = newpose[k]; - } - - if (do_center) { - for (int i = 0; i < 6; i++) - offset_camera.axes[i] = mainApp->axis(i).headPos; - - do_center = false; - - if (Libraries->pFilter) - Libraries->pFilter->reset(); - } - - T6DOF target_camera, target_camera2, new_camera; - - if (enabled) - { - for (int i = 0; i < 6; i++) - target_camera.axes[i] = mainApp->axis(i).headPos; - - target_camera2 = target_camera - offset_camera; - } - - if (Libraries->pFilter) { - Libraries->pFilter->FilterHeadPoseData(target_camera2.axes, new_camera.axes); - } else { - new_camera = target_camera2; - } - - for (int i = 0; i < 6; i++) { - get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); - } - - if (mainApp->s.tcomp_p) - t_compensate(output_camera.axes, output_camera.axes, mainApp->s.tcomp_tz); - - if (Libraries->pProtocol) { - Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); - } - } - - const long q = std::max(0L, sleep_ms * 1000L - std::max(0L, t.elapsed())); - - usleep(q); - } -#if defined(_WIN32) - (void) timeEndPeriod(1); -#endif - - for (int i = 0; i < 6; i++) - { - mainApp->axis(i).curve.setTrackingActive(false); - mainApp->axis(i).curveAlt.setTrackingActive(false); - } -} - -void Tracker::getHeadPose( double *data ) { - QMutexLocker foo(&mtx); - for (int i = 0; i < 6; i++) - { - data[i] = raw_6dof.axes[i]; - } -} - -void Tracker::getOutputHeadPose( double *data ) { - QMutexLocker foo(&mtx); - for (int i = 0; i < 6; i++) - data[i] = output_camera.axes[i]; -} +/* Copyright (c) 2012-2013 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +/* + * this file appeared originally in facetracknoir, was rewritten completely + * following opentrack fork. + * + * originally written by Wim Vriend. + */ + +#include "tracker.h" +#include "facetracknoir.h" +#include +#include +#include + +#if defined(_WIN32) +# include +#endif + +Tracker::Tracker(FaceTrackNoIR *parent , main_settings& s) : + mainApp(parent), + s(s), + should_quit(false), + do_center(false), + enabled(true) +{ +} + +Tracker::~Tracker() +{ + should_quit = true; + wait(); +} + +static void get_curve(double pos, double& out, THeadPoseDOF& axis) { + bool altp = (pos < 0) && axis.opts.altp; + axis.curve.setTrackingActive( !altp ); + axis.curveAlt.setTrackingActive( altp ); + auto& fc = altp ? axis.curveAlt : axis.curve; + out = (axis.opts.invert ? -1 : 1) * fc.getValue(pos); + + out += axis.opts.zero; +} + +static void t_compensate(double* input, double* output, bool rz) +{ + const auto H = input[Yaw] * M_PI / -180; + const auto P = input[Pitch] * M_PI / -180; + const auto B = input[Roll] * M_PI / 180; + + const auto cosH = cos(H); + const auto sinH = sin(H); + const auto cosP = cos(P); + const auto sinP = sin(P); + const auto cosB = cos(B); + const auto sinB = sin(B); + + double foo[] = { + cosH * cosB - sinH * sinP * sinB, + - sinB * cosP, + sinH * cosB + cosH * sinP * sinB, + cosH * sinB + sinH * sinP * cosB, + cosB * cosP, + sinB * sinH - cosH * sinP * cosB, + - sinH * cosP, + - sinP, + cosH * cosP, + }; + + cv::Mat rmat(3, 3, CV_64F, foo); + const cv::Mat tvec(3, 1, CV_64F, input); + cv::Mat ret = rmat * tvec; + + const int max = !rz ? 3 : 2; + + for (int i = 0; i < max; i++) + output[i] = ret.at(i); +} + +void Tracker::run() { + T6DOF offset_camera; + + double newpose[6] = {0}; + int sleep_ms = 15; + + if (Libraries->pTracker) + sleep_ms = std::min(sleep_ms, 1000 / Libraries->pTracker->preferredHz()); + + qDebug() << "tracker Hz:" << 1000 / sleep_ms; + +#if defined(_WIN32) + (void) timeBeginPeriod(1); +#endif + + for (;;) + { + t.start(); + + if (should_quit) + break; + + if (Libraries->pTracker) { + Libraries->pTracker->GetHeadPoseData(newpose); + } + + { + QMutexLocker foo(&mtx); + + for (int i = 0; i < 6; i++) + { + raw_6dof.axes[i] = newpose[i]; + + auto& axis = mainApp->axis(i); + + int k = axis.opts.src; + if (k < 0 || k >= 6) + continue; + + axis.headPos = newpose[k]; + } + + if (do_center) { + for (int i = 0; i < 6; i++) + offset_camera.axes[i] = mainApp->axis(i).headPos; + + do_center = false; + + if (Libraries->pFilter) + Libraries->pFilter->reset(); + } + + T6DOF target_camera, target_camera2, new_camera; + + if (enabled) + { + for (int i = 0; i < 6; i++) + target_camera.axes[i] = mainApp->axis(i).headPos; + + target_camera2 = target_camera - offset_camera; + } + + if (Libraries->pFilter) { + Libraries->pFilter->FilterHeadPoseData(target_camera2.axes, new_camera.axes); + } else { + new_camera = target_camera2; + } + + for (int i = 0; i < 6; i++) { + get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); + } + + if (mainApp->s.tcomp_p) + t_compensate(output_camera.axes, output_camera.axes, mainApp->s.tcomp_tz); + + if (Libraries->pProtocol) { + Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); + } + } + + const long q = std::max(0L, sleep_ms * 1000L - std::max(0L, t.elapsed())); + + usleep(q); + } +#if defined(_WIN32) + (void) timeEndPeriod(1); +#endif + + for (int i = 0; i < 6; i++) + { + mainApp->axis(i).curve.setTrackingActive(false); + mainApp->axis(i).curveAlt.setTrackingActive(false); + } +} + +void Tracker::getHeadPose( double *data ) { + QMutexLocker foo(&mtx); + for (int i = 0; i < 6; i++) + { + data[i] = raw_6dof.axes[i]; + } +} + +void Tracker::getOutputHeadPose( double *data ) { + QMutexLocker foo(&mtx); + for (int i = 0; i < 6; i++) + data[i] = output_camera.axes[i]; +} -- cgit v1.2.3 From bc8ad8274d9dd0d5693fa48db5325bcacff9cadf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 17:55:05 +0200 Subject: half gain logic done --- facetracknoir/gain-control.hpp | 175 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 facetracknoir/gain-control.hpp (limited to 'facetracknoir') diff --git a/facetracknoir/gain-control.hpp b/facetracknoir/gain-control.hpp new file mode 100644 index 000000000..288877003 --- /dev/null +++ b/facetracknoir/gain-control.hpp @@ -0,0 +1,175 @@ +#pragma once + +#include +#undef NDEBUG +#include +#include +#include +#include +#include + +#include "timer.hpp" + +#include +#include +#include + +#include + +namespace detail { + template + class zip_iterator : public std::iterator + { + private: + using self = zip_iterator; + t1 x1, z1; + t2 x2, z2; + void maybe_end() { if (x1 == z1 || x2 == z2) *this = end(); } + public: + zip_iterator(const t1& it1, const t1& end1, const t2& it2, const t2& end2) + : x1(it1), z1(end1), x2(it2), z2(end2) { maybe_end(); } + constexpr zip_iterator() {} + + static constexpr self end() { return self(); } + + self operator++() { x1++; x2++; self tmp = *this; maybe_end(); return tmp; } + self operator++(int) { self tmp(*this); x1++; x2++; maybe_end(); return tmp; } + bool operator==(const self& rhs) const { return x1 == rhs.x1 && x2 == rhs.x2; } + bool operator!=(const self& rhs) const { return !this->operator ==(rhs); } + t operator*() { return m(*x1, *x2); } + }; +} + +class Gain { +private: + static constexpr bool use_box_filter = true; + static constexpr int box_size = 20 / 640.; + static constexpr double control_upper_bound = 1.0; // XXX FIXME implement for logitech crapola + static constexpr int GAIN_HISTORY_COUNT = 15, GAIN_HISTORY_EVERY_MS = 200; + + int control; + double step, eps; + + std::deque means_history; + + Timer debug_timer, history_timer; + + typedef unsigned char px; + template + using zip_iterator = detail::zip_iterator; + + static double mean(const cv::Mat& frame) + { + // grayscale only + assert(frame.channels() == 1); + assert(frame.elemSize() == 1); + assert(!frame.empty()); + + return std::accumulate(frame.begin(), frame.end(), 0.) / (frame.rows * frame.cols); + } + + static double get_variance(const cv::Mat& frame, double mean) + { + struct variance { + private: + double mu; + public: + variance(double mu) : mu(mu) {} + double operator()(double seed, px p) + { + double tmp = p - mu; + return seed + tmp * tmp; + } + } logic(mean); + + return std::accumulate(frame.begin(), frame.end(), 0., logic) / (frame.rows * frame.cols); + } + + static double get_covariance(const cv::Mat& frame, double mean, double prev_mean) + { + struct covariance { + public: + using pair = std::tuple; + private: + double mu_0, mu_1; + + inline double Cov(double seed, const pair& t) + { + px p0 = std::get<0>(t); + px p1 = std::get<1>(t); + return seed + (p0 - mu_0) * (p1 - mu_1); + } + public: + covariance(double mu_0, double mu_1) : mu_0(mu_0), mu_1(mu_1) {} + + double operator()(double seed, const pair& t) + { + return Cov(seed, t); + } + } logic(mean, prev_mean); + + const double N = frame.rows * frame.cols; + + using zipper = zip_iterator, + cv::MatConstIterator_, + std::tuple>; + + zipper zip(frame.begin(), + frame.end(), + frame.begin(), + frame.end()); + std::vector values(zip, zipper::end()); + + return std::accumulate(values.begin(), values.end(), 0., logic) / N; + } + +#pragma GCC diagnostic ignored "-Wsign-compare" + +public: + Gain(int control = CV_CAP_PROP_GAIN, double step = 0.3, double eps = 0.02) : + control(control), step(step), eps(eps) + { + } + + void tick(cv::VideoCapture&, const cv::Mat& frame_) + { + cv::Mat frame; + + if (use_box_filter) + { + cv::Mat tmp(frame_); + static constexpr int min_box = 3; + static constexpr int box = 2 * box_size; + cv::blur(frame_, tmp, cv::Size(min_box + box * frame_.cols, min_box + box * frame_.rows)); + frame = tmp; + } + else + frame = frame_; + + const double mu = mean(frame); + const double var = get_variance(frame, mu); + + if (debug_timer.elapsed_ms() > 500) + { + debug_timer.start(); + qDebug() << "gain:" << "mean" << mu << "variance" << var; + } + + const int sz = means_history.size(); + + for (int i = 0; i < sz; i++) + { + const double cov = get_covariance(frame, mu, means_history[i]); + + qDebug() << "cov" << i << cov; + } + + if (GAIN_HISTORY_COUNT > means_history.size() && history_timer.elapsed_ms() > GAIN_HISTORY_EVERY_MS) + { + means_history.push_front(mu); + + if (GAIN_HISTORY_COUNT == means_history.size()) + means_history.pop_back(); + } + } +}; -- cgit v1.2.3 From 609008e798f3d59f50fa3f5dc4b3f04d5da24092 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 19:27:58 +0200 Subject: gain: more work, still incomplete --- facetracknoir/gain-control.hpp | 44 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/gain-control.hpp b/facetracknoir/gain-control.hpp index 288877003..dcaee692f 100644 --- a/facetracknoir/gain-control.hpp +++ b/facetracknoir/gain-control.hpp @@ -43,14 +43,15 @@ namespace detail { class Gain { private: static constexpr bool use_box_filter = true; - static constexpr int box_size = 20 / 640.; + static constexpr int box_size = 32 / 640.; static constexpr double control_upper_bound = 1.0; // XXX FIXME implement for logitech crapola - static constexpr int GAIN_HISTORY_COUNT = 15, GAIN_HISTORY_EVERY_MS = 200; + static constexpr int GAIN_HISTORY_COUNT = 15, GAIN_HISTORY_EVERY_MS = 115; int control; double step, eps; std::deque means_history; + cv::Mat last_frame; Timer debug_timer, history_timer; @@ -85,8 +86,10 @@ private: return std::accumulate(frame.begin(), frame.end(), 0., logic) / (frame.rows * frame.cols); } - static double get_covariance(const cv::Mat& frame, double mean, double prev_mean) + static double get_covariance(const cv::Mat& frame, const cv::Mat& old_frame) { + double mean_0 = mean(frame), mean_1 = mean(old_frame); + struct covariance { public: using pair = std::tuple; @@ -106,18 +109,18 @@ private: { return Cov(seed, t); } - } logic(mean, prev_mean); + } logic(mean_0, mean_1); const double N = frame.rows * frame.cols; using zipper = zip_iterator, - cv::MatConstIterator_, - std::tuple>; + cv::MatConstIterator_, + std::tuple>; zipper zip(frame.begin(), - frame.end(), - frame.begin(), - frame.end()); + frame.end(), + old_frame.begin(), + old_frame.end()); std::vector values(zip, zipper::end()); return std::accumulate(values.begin(), values.end(), 0., logic) / N; @@ -145,28 +148,27 @@ public: } else frame = frame_; - - const double mu = mean(frame); - const double var = get_variance(frame, mu); - if (debug_timer.elapsed_ms() > 500) + if (debug_timer.elapsed_ms() > 1000) { + const double mu = mean(frame); + const double var = get_variance(frame, mu); + debug_timer.start(); - qDebug() << "gain:" << "mean" << mu << "variance" << var; + qDebug() << "---- gain:" << "mean" << mu << "variance" << var; + for (int i = 0; i < means_history.size(); i++) + qDebug() << "cov" << i << means_history[i]; } - const int sz = means_history.size(); - - for (int i = 0; i < sz; i++) + if (last_frame.cols != frame.cols || last_frame.rows != frame.rows) { - const double cov = get_covariance(frame, mu, means_history[i]); - - qDebug() << "cov" << i << cov; + last_frame = frame; + means_history.clear(); } if (GAIN_HISTORY_COUNT > means_history.size() && history_timer.elapsed_ms() > GAIN_HISTORY_EVERY_MS) { - means_history.push_front(mu); + means_history.push_front(get_covariance(frame, last_frame)); if (GAIN_HISTORY_COUNT == means_history.size()) means_history.pop_back(); -- cgit v1.2.3 From 4b21008a53f2d89a0143976305368584d4ed1e44 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 19:38:08 +0200 Subject: CRLF -> LF conversion .git/index removal Forgot to do it earlier, hence trash commits in recent days --- facetracknoir/clientfiles/FlightGear/readme.txt | 16 +- facetracknoir/ftnoir_curves.ui | 2354 ++++++++++---------- facetracknoir/ftnoir_keyboardshortcuts.ui | 434 ++-- ftnoir_filter_accela/ftnoir_filter_accela.h | 158 +- ftnoir_protocol_fg/ftnoir_fgcontrols.ui | 286 +-- ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui | 268 +-- ftnoir_protocol_ft/ftnoir_ftcontrols.ui | 446 ++-- ftnoir_protocol_ftn/ftnoir_ftncontrols.ui | 532 ++--- ftnoir_protocol_mouse/ftnoir_mousecontrols.ui | 410 ++-- ftnoir_protocol_sc/ftnoir_sccontrols.ui | 144 +- ftnoir_tracker_aruco/trans_calib.cpp | 88 +- ftnoir_tracker_aruco/trans_calib.h | 76 +- ftnoir_tracker_freepie-udp/freepie-udp-controls.ui | 138 +- ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui | 132 +- qxt-mini/plat/qxtglobalshortcut_mac.cpp | 456 ++-- qxt-mini/plat/qxtglobalshortcut_x11.cpp | 470 ++-- qxt-mini/qxtglobalshortcut.cpp | 448 ++-- qxt-mini/qxtglobalshortcut.h | 128 +- 18 files changed, 3492 insertions(+), 3492 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/FlightGear/readme.txt b/facetracknoir/clientfiles/FlightGear/readme.txt index 0b3d9dfe9..48cee8375 100644 --- a/facetracknoir/clientfiles/FlightGear/readme.txt +++ b/facetracknoir/clientfiles/FlightGear/readme.txt @@ -1,8 +1,8 @@ -Copy Protocol/headtracker.xml to fgdata/Protocol/headtracker.xml - -$ fgfs --generic=socket,in,25,localhost,5542,udp,headtracker - -Adjust paths as necessary. - -cheers, --sh 20131008 +Copy Protocol/headtracker.xml to fgdata/Protocol/headtracker.xml + +$ fgfs --generic=socket,in,25,localhost,5542,udp,headtracker + +Adjust paths as necessary. + +cheers, +-sh 20131008 diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index f98bf8849..7d6671aaf 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -1,1177 +1,1177 @@ - - - UICCurveConfigurationDialog - - - - 0 - 0 - 970 - 655 - - - - - 0 - 0 - - - - Mapping properties - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - background-color: #ccc; - - - - - - - - - QTabWidget::North - - - 6 - - - - Yaw - - - - - 0 - 0 - 930 - 260 - - - - 180 - - - 180 - - - 5 - - - - 255 - 0 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 166 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 180 - - - 180 - - - 5 - - - - 255 - 0 - 0 - - - - - 255 - 255 - 255 - - - - - - - Pitch - - - - - 0 - 0 - 930 - 260 - - - - 90 - - - 90 - - - 10 - - - 2 - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 199 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 90 - - - 90 - - - 10 - - - 2 - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Roll - - - - - 0 - 0 - 930 - 260 - - - - 180 - - - 180 - - - 5 - - - 1 - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 271 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 180 - - - 180 - - - 5 - - - 1 - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - X - - - - - 0 - 0 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 228 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - Y - - - - - 0 - 0 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 229 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Z - - - - - 0 - 0 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 263 - 21 - - - - Asymmetric mapping below - - - - - - 0 - 300 - 930 - 260 - - - - 100 - - - 100 - - - 28 - - - 2 - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - Options - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Center pose - - - Qt::AlignCenter - - - true - - - false - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - TX - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RY - - - - - - - TY - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - TZ - - - - - - - RZ - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RX - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - - - - - 65536 - 65536 - - - - - true - - - - Output remap - - - Qt::AlignCenter - - - true - - - false - - - - QLayout::SetMinAndMaxSize - - - 6 - - - - - X - - - - - - - Yaw - - - - - - - Pitch - - - - - - - Y - - - - - - - Z - - - - - - - Roll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - Source - - - - - - - Invert - - - - - - - Destination - - - - - - - - - - - 0 - 0 - - - - - - - Translation compensation - - - true - - - - - - - 0 - 0 - - - - - - - Enable - - - - - - - - - - Disable Z axis compensation - - - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - QFunctionConfigurator - QWidget -
qfunctionconfigurator.h
-
-
- - pos_rx - pos_ry - pos_rz - ry_altp - rz_altp - tx_altp - ty_altp - tz_altp - tcomp_enable - tabWidget - pos_tx - buttonBox - pos_ty - rx_altp - pos_tz - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
+ + + UICCurveConfigurationDialog + + + + 0 + 0 + 970 + 655 + + + + + 0 + 0 + + + + Mapping properties + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + background-color: #ccc; + + + + + + + + + QTabWidget::North + + + 6 + + + + Yaw + + + + + 0 + 0 + 930 + 260 + + + + 180 + + + 180 + + + 5 + + + + 255 + 0 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 166 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 180 + + + 180 + + + 5 + + + + 255 + 0 + 0 + + + + + 255 + 255 + 255 + + + + + + + Pitch + + + + + 0 + 0 + 930 + 260 + + + + 90 + + + 90 + + + 10 + + + 2 + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 199 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 90 + + + 90 + + + 10 + + + 2 + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Roll + + + + + 0 + 0 + 930 + 260 + + + + 180 + + + 180 + + + 5 + + + 1 + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 271 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 180 + + + 180 + + + 5 + + + 1 + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + X + + + + + 0 + 0 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 228 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + Y + + + + + 0 + 0 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 229 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Z + + + + + 0 + 0 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 263 + 21 + + + + Asymmetric mapping below + + + + + + 0 + 300 + 930 + 260 + + + + 100 + + + 100 + + + 28 + + + 2 + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + Options + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Center pose + + + Qt::AlignCenter + + + true + + + false + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + TX + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RY + + + + + + + TY + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + TZ + + + + + + + RZ + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RX + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + + + + + 65536 + 65536 + + + + + true + + + + Output remap + + + Qt::AlignCenter + + + true + + + false + + + + QLayout::SetMinAndMaxSize + + + 6 + + + + + X + + + + + + + Yaw + + + + + + + Pitch + + + + + + + Y + + + + + + + Z + + + + + + + Roll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + Source + + + + + + + Invert + + + + + + + Destination + + + + + + + + + + + 0 + 0 + + + + + + + Translation compensation + + + true + + + + + + + 0 + 0 + + + + + + + Enable + + + + + + + + + + Disable Z axis compensation + + + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + QFunctionConfigurator + QWidget +
qfunctionconfigurator.h
+
+
+ + pos_rx + pos_ry + pos_rz + ry_altp + rz_altp + tx_altp + ty_altp + tz_altp + tcomp_enable + tabWidget + pos_tx + buttonBox + pos_ty + rx_altp + pos_tz + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index 5bdc3334e..245b503a3 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -1,217 +1,217 @@ - - - UICKeyboardShortcutDialog - - - - 0 - 0 - 371 - 125 - - - - - 0 - 0 - - - - Keyboard shortcuts - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Toggle - - - false - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Keyboard - - - Qt::AlignCenter - - - false - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 0 - 0 - - - - Center - - - false - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - Ding! - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICKeyboardShortcutDialog + + + + 0 + 0 + 371 + 125 + + + + + 0 + 0 + + + + Keyboard shortcuts + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Toggle + + + false + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Keyboard + + + Qt::AlignCenter + + + false + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 0 + 0 + + + + Center + + + false + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + Ding! + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index c9a434e79..0a7360424 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -1,79 +1,79 @@ -#pragma once -#include "ui_ftnoir_accela_filtercontrols.h" -#include "facetracknoir/plugin-api.hpp" -#include - -#define ACCELA_SMOOTHING_ROTATION 60.0 -#define ACCELA_SMOOTHING_TRANSLATION 40.0 -#define ACCELA_SECOND_ORDER_ALPHA 100.0 -#define ACCELA_THIRD_ORDER_ALPHA 180.0 - -#include -using namespace options; - -struct settings { - pbundle b; - value rotation_alpha, - translation_alpha, - second_order_alpha, - third_order_alpha, - rot_deadzone, - trans_deadzone, - expt; - settings() : - b(bundle("Accela")), - rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), - translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), - second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), - third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), - rot_deadzone(b, "rotation-deadband", 0), - trans_deadzone(b, "translation-deadband", 0), - expt(b, "exponent", 2) - {} -}; - -class FTNoIR_Filter : public IFilter -{ -public: - FTNoIR_Filter(); - void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position); - void reset() { - first_run = true; - } - void receiveSettings() { - s.b->reload(); - } - -private: - settings s; - bool first_run; - double last_output[3][6]; -}; - -class FilterControls: public QWidget, public IFilterDialog -{ - Q_OBJECT -public: - FilterControls(); - void registerFilter(IFilter* filter); - void unregisterFilter(); -private: - Ui::AccelaUICFilterControls ui; - void discard(); - void save(); - FTNoIR_Filter* accela_filter; - settings s; -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_FilterDll : public Metadata -{ -public: - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk4"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk4"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk4"); } - - void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } -}; +#pragma once +#include "ui_ftnoir_accela_filtercontrols.h" +#include "facetracknoir/plugin-api.hpp" +#include + +#define ACCELA_SMOOTHING_ROTATION 60.0 +#define ACCELA_SMOOTHING_TRANSLATION 40.0 +#define ACCELA_SECOND_ORDER_ALPHA 100.0 +#define ACCELA_THIRD_ORDER_ALPHA 180.0 + +#include +using namespace options; + +struct settings { + pbundle b; + value rotation_alpha, + translation_alpha, + second_order_alpha, + third_order_alpha, + rot_deadzone, + trans_deadzone, + expt; + settings() : + b(bundle("Accela")), + rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), + translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), + second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), + third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), + rot_deadzone(b, "rotation-deadband", 0), + trans_deadzone(b, "translation-deadband", 0), + expt(b, "exponent", 2) + {} +}; + +class FTNoIR_Filter : public IFilter +{ +public: + FTNoIR_Filter(); + void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position); + void reset() { + first_run = true; + } + void receiveSettings() { + s.b->reload(); + } + +private: + settings s; + bool first_run; + double last_output[3][6]; +}; + +class FilterControls: public QWidget, public IFilterDialog +{ + Q_OBJECT +public: + FilterControls(); + void registerFilter(IFilter* filter); + void unregisterFilter(); +private: + Ui::AccelaUICFilterControls ui; + void discard(); + void save(); + FTNoIR_Filter* accela_filter; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_FilterDll : public Metadata +{ +public: + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk4"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk4"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk4"); } + + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } +}; diff --git a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui index a4092c055..575549d6f 100644 --- a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui +++ b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui @@ -1,143 +1,143 @@ - - - UICFGControls - - - Qt::NonModal - - - - 0 - 0 - 415 - 112 - - - - FlightGear protocol settings - - - - :/images/filter-16.png:/images/filter-16.png - - - Qt::LeftToRight - - - false - - - - - - IP-address remote PC - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - spinIPFirstNibble - spinIPSecondNibble - spinIPThirdNibble - spinIPFourthNibble - spinPortNumber - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFGControls + + + Qt::NonModal + + + + 0 + 0 + 415 + 112 + + + + FlightGear protocol settings + + + + :/images/filter-16.png:/images/filter-16.png + + + Qt::LeftToRight + + + false + + + + + + IP-address remote PC + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui index 6cb066bd6..637e4dba4 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui +++ b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui @@ -1,134 +1,134 @@ - - - UICFSUIPCControls - - - Qt::NonModal - - - - 0 - 0 - 512 - 100 - - - - FSUIPC settings FaceTrackNoIR - - - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - 230 - 0 - - - - Location of FSUIPC.dll - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - Location of FSUIPC.dll - - - - - - - The DLL should be located in the Modules/ directory of MS FS 2004 - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 35 - 16777215 - - - - ... - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFSUIPCControls + + + Qt::NonModal + + + + 0 + 0 + 512 + 100 + + + + FSUIPC settings FaceTrackNoIR + + + + images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + 230 + 0 + + + + Location of FSUIPC.dll + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + Location of FSUIPC.dll + + + + + + + The DLL should be located in the Modules/ directory of MS FS 2004 + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 35 + 16777215 + + + + ... + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui index 941aaff02..554e681ad 100644 --- a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui +++ b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui @@ -1,223 +1,223 @@ - - - UICFTControls - - - Qt::NonModal - - - true - - - - 0 - 0 - 489 - 402 - - - - - 0 - 0 - - - - - 0 - 0 - - - - freetrack protocol settings - - - - :/images/freetrack.png:/images/freetrack.png - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - TIRViews - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - Qt::RightToLeft - - - Memory hacks - - - - - - - Only for very old and buggy old games such as CFS3. - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - - - - - 0 - 0 - - - - TrackIR.exe - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - Qt::RightToLeft - - - Using EZCA - - - - - - - FSX-specific EZCA protocol hacks - - - true - - - - - - - - - - - 0 - 0 - - - - Select interface - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - - - - Disable one of the protocols if game is confused by presence of both at the same time. - - - true - - - - - - - - - - - 0 - 0 - - - - Repair NPClient location - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - Locate DLL - - - - - - - Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically. - - - true - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFTControls + + + Qt::NonModal + + + true + + + + 0 + 0 + 489 + 402 + + + + + 0 + 0 + + + + + 0 + 0 + + + + freetrack protocol settings + + + + :/images/freetrack.png:/images/freetrack.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + TIRViews + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Qt::RightToLeft + + + Memory hacks + + + + + + + Only for very old and buggy old games such as CFS3. + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + + + + + 0 + 0 + + + + TrackIR.exe + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Qt::RightToLeft + + + Using EZCA + + + + + + + FSX-specific EZCA protocol hacks + + + true + + + + + + + + + + + 0 + 0 + + + + Select interface + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + + + + Disable one of the protocols if game is confused by presence of both at the same time. + + + true + + + + + + + + + + + 0 + 0 + + + + Repair NPClient location + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Locate DLL + + + + + + + Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically. + + + true + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui index 48679f3c2..ca811e99a 100644 --- a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui +++ b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui @@ -1,266 +1,266 @@ - - - UICFTNControls - - - Qt::NonModal - - - - 0 - 0 - 411 - 169 - - - - UDP protocol settings - - - - :/images/facetracknoir.png:/images/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - IP-address remote PC - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Enter IP-address and port-number for the remote PC. - - - true - - - - - - - Remember: you may have to change firewall-settings too! - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - spinIPFirstNibble - spinIPSecondNibble - spinIPThirdNibble - spinIPFourthNibble - spinPortNumber - btnOK - btnCancel - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFTNControls + + + Qt::NonModal + + + + 0 + 0 + 411 + 169 + + + + UDP protocol settings + + + + :/images/facetracknoir.png:/images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + IP-address remote PC + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Enter IP-address and port-number for the remote PC. + + + true + + + + + + + Remember: you may have to change firewall-settings too! + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + btnOK + btnCancel + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui index 2705fff7a..258ed06a8 100644 --- a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui +++ b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui @@ -1,205 +1,205 @@ - - - UICMOUSEControls - - - Qt::NonModal - - - - 0 - 0 - 257 - 114 - - - - Mouse protocol settings - - - - :/images/mouse.png:/images/mouse.png - - - Qt::LeftToRight - - - false - - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Map mouse Y to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 0 - 0 - - - - Map mouse X to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICMOUSEControls + + + Qt::NonModal + + + + 0 + 0 + 257 + 114 + + + + Mouse protocol settings + + + + :/images/mouse.png:/images/mouse.png + + + Qt::LeftToRight + + + false + + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Map mouse Y to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 0 + 0 + + + + Map mouse X to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui index 87dc8d861..5b2fd2919 100644 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ b/ftnoir_protocol_sc/ftnoir_sccontrols.ui @@ -1,72 +1,72 @@ - - - UICSCControls - - - Qt::NonModal - - - - 0 - 0 - 290 - 79 - - - - SimConnect settings FaceTrackNoIR - - - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png - - - Qt::LeftToRight - - - false - - - - - - FSX version - - - - - - - - SP1 - - - - - SP2 - - - - - Acceleration - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICSCControls + + + Qt::NonModal + + + + 0 + 0 + 290 + 79 + + + + SimConnect settings FaceTrackNoIR + + + + images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + + Qt::LeftToRight + + + false + + + + + + FSX version + + + + + + + + SP1 + + + + + SP2 + + + + + Acceleration + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_aruco/trans_calib.cpp b/ftnoir_tracker_aruco/trans_calib.cpp index dd18399a1..b1f956b45 100644 --- a/ftnoir_tracker_aruco/trans_calib.cpp +++ b/ftnoir_tracker_aruco/trans_calib.cpp @@ -1,44 +1,44 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "trans_calib.h" - -using namespace cv; - -//----------------------------------------------------------------------------- -TranslationCalibrator::TranslationCalibrator() -{ - reset(); -} - -void TranslationCalibrator::reset() -{ - P = Matx66f::zeros(); - y = Vec6f(0,0,0, 0,0,0); -} - -void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) -{ - Matx H_k_T = Matx::zeros(); - for (int i=0; i<3; ++i) { - for (int j=0; j<3; ++j) { - H_k_T(i,j) = R_CM_k(j,i); - } - } - for (int i=0; i<3; ++i) - { - H_k_T(3+i,i) = 1.0; - } - P += H_k_T * H_k_T.t(); - y += H_k_T * t_CM_k; -} - -Vec3f TranslationCalibrator::get_estimate() -{ - Vec6f x = P.inv() * y; - return Vec3f(x[0], x[1], x[2]); -} +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "trans_calib.h" + +using namespace cv; + +//----------------------------------------------------------------------------- +TranslationCalibrator::TranslationCalibrator() +{ + reset(); +} + +void TranslationCalibrator::reset() +{ + P = Matx66f::zeros(); + y = Vec6f(0,0,0, 0,0,0); +} + +void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) +{ + Matx H_k_T = Matx::zeros(); + for (int i=0; i<3; ++i) { + for (int j=0; j<3; ++j) { + H_k_T(i,j) = R_CM_k(j,i); + } + } + for (int i=0; i<3; ++i) + { + H_k_T(3+i,i) = 1.0; + } + P += H_k_T * H_k_T.t(); + y += H_k_T * t_CM_k; +} + +Vec3f TranslationCalibrator::get_estimate() +{ + Vec6f x = P.inv() * y; + return Vec3f(x[0], x[1], x[2]); +} diff --git a/ftnoir_tracker_aruco/trans_calib.h b/ftnoir_tracker_aruco/trans_calib.h index f25216900..609c9af15 100644 --- a/ftnoir_tracker_aruco/trans_calib.h +++ b/ftnoir_tracker_aruco/trans_calib.h @@ -1,39 +1,39 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef TRANSCALIB_H -#define TRANSCALIB_H - -#include - -//----------------------------------------------------------------------------- -// Calibrates the translation from head to model = t_MH -// by recursive least squares / -// kalman filter in information form with identity noise covariance -// measurement equation when head position = t_CH is fixed: -// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k - -class TranslationCalibrator -{ -public: - TranslationCalibrator(); - - // reset the calibration process - void reset(); - - // update the current estimate - void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); - - // get the current estimate for t_MH - cv::Vec3f get_estimate(); - -protected: - cv::Matx66f P; // normalized precision matrix = inverse covariance - cv::Vec6f y; // P*(-t_MH, t_CH) -}; - +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef TRANSCALIB_H +#define TRANSCALIB_H + +#include + +//----------------------------------------------------------------------------- +// Calibrates the translation from head to model = t_MH +// by recursive least squares / +// kalman filter in information form with identity noise covariance +// measurement equation when head position = t_CH is fixed: +// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k + +class TranslationCalibrator +{ +public: + TranslationCalibrator(); + + // reset the calibration process + void reset(); + + // update the current estimate + void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); + + // get the current estimate for t_MH + cv::Vec3f get_estimate(); + +protected: + cv::Matx66f P; // normalized precision matrix = inverse covariance + cv::Vec6f y; // P*(-t_MH, t_CH) +}; + #endif //TRANSCALIB_H \ No newline at end of file diff --git a/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui b/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui index 9870372a7..48290bf2e 100644 --- a/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui +++ b/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui @@ -1,69 +1,69 @@ - - - UI_freepie_udp_dialog - - - Qt::NonModal - - - - 0 - 0 - 198 - 71 - - - - UDP tracker settings - - - - ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - UDP port - - - - - - - 0 - - - 65535 - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UI_freepie_udp_dialog + + + Qt::NonModal + + + + 0 + 0 + 198 + 71 + + + + UDP tracker settings + + + + ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + UDP port + + + + + + + 0 + + + 65535 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui index f485e67fd..4a5624cf5 100644 --- a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui +++ b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui @@ -1,66 +1,66 @@ - - - UICFTNClientControls - - - Qt::NonModal - - - - 0 - 0 - 216 - 71 - - - - UDP tracker settings - - - - ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - Port - - - - - - - 0 - - - 65535 - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - spinPortNumber - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - + + + UICFTNClientControls + + + Qt::NonModal + + + + 0 + 0 + 216 + 71 + + + + UDP tracker settings + + + + ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + Port + + + + + + + 0 + + + 65535 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + spinPortNumber + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/qxt-mini/plat/qxtglobalshortcut_mac.cpp b/qxt-mini/plat/qxtglobalshortcut_mac.cpp index f43c773a4..fbf86a944 100644 --- a/qxt-mini/plat/qxtglobalshortcut_mac.cpp +++ b/qxt-mini/plat/qxtglobalshortcut_mac.cpp @@ -1,4 +1,4 @@ -#include +#include /**************************************************************************** ** Copyright (c) 2006 - 2011, the LibQxt project. ** See the Qxt AUTHORS file for a list of authors and copyright holders. @@ -29,235 +29,235 @@ ** *****************************************************************************/ -#include "qxtglobalshortcut_p.h" -#include -#include -#include -#include - -typedef QPair Identifier; -static QMap keyRefs; -static QHash keyIDs; -static quint32 hotKeySerial = 0; -static bool qxt_mac_handler_installed = false; - -OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) -{ - Q_UNUSED(nextHandler); - Q_UNUSED(data); - if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) - { - EventHotKeyID keyID; - GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); - Identifier id = keyIDs.key(keyID.id); +#include "qxtglobalshortcut_p.h" +#include +#include +#include +#include + +typedef QPair Identifier; +static QMap keyRefs; +static QHash keyIDs; +static quint32 hotKeySerial = 0; +static bool qxt_mac_handler_installed = false; + +OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) +{ + Q_UNUSED(nextHandler); + Q_UNUSED(data); + if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) + { + EventHotKeyID keyID; + GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); + Identifier id = keyIDs.key(keyID.id); if(id != Identifier()) - QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); - } - return noErr; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= shiftKey; - if (modifiers & Qt::ControlModifier) - native |= cmdKey; - if (modifiers & Qt::AltModifier) - native |= optionKey; - if (modifiers & Qt::MetaModifier) - native |= controlKey; - if (modifiers & Qt::KeypadModifier) - native |= kEventKeyModifierNumLockMask; - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - UTF16Char ch; - // Constants found in NSEvent.h from AppKit.framework - switch (key) - { - case Qt::Key_Return: - return kVK_Return; - case Qt::Key_Enter: - return kVK_ANSI_KeypadEnter; - case Qt::Key_Tab: - return kVK_Tab; - case Qt::Key_Space: - return kVK_Space; - case Qt::Key_Backspace: - return kVK_Delete; - case Qt::Key_Control: - return kVK_Command; - case Qt::Key_Shift: - return kVK_Shift; - case Qt::Key_CapsLock: - return kVK_CapsLock; - case Qt::Key_Option: - return kVK_Option; - case Qt::Key_Meta: - return kVK_Control; - case Qt::Key_F17: - return kVK_F17; - case Qt::Key_VolumeUp: - return kVK_VolumeUp; - case Qt::Key_VolumeDown: - return kVK_VolumeDown; - case Qt::Key_F18: - return kVK_F18; - case Qt::Key_F19: - return kVK_F19; - case Qt::Key_F20: - return kVK_F20; - case Qt::Key_F5: - return kVK_F5; - case Qt::Key_F6: - return kVK_F6; - case Qt::Key_F7: - return kVK_F7; - case Qt::Key_F3: - return kVK_F3; - case Qt::Key_F8: - return kVK_F8; - case Qt::Key_F9: - return kVK_F9; - case Qt::Key_F11: - return kVK_F11; - case Qt::Key_F13: - return kVK_F13; - case Qt::Key_F16: - return kVK_F16; - case Qt::Key_F14: - return kVK_F14; - case Qt::Key_F10: - return kVK_F10; - case Qt::Key_F12: - return kVK_F12; - case Qt::Key_F15: - return kVK_F15; - case Qt::Key_Help: - return kVK_Help; - case Qt::Key_Home: - return kVK_Home; - case Qt::Key_PageUp: - return kVK_PageUp; - case Qt::Key_Delete: - return kVK_ForwardDelete; - case Qt::Key_F4: - return kVK_F4; - case Qt::Key_End: - return kVK_End; - case Qt::Key_F2: - return kVK_F2; - case Qt::Key_PageDown: - return kVK_PageDown; - case Qt::Key_F1: - return kVK_F1; - case Qt::Key_Left: - return kVK_LeftArrow; - case Qt::Key_Right: - return kVK_RightArrow; - case Qt::Key_Down: - return kVK_DownArrow; - case Qt::Key_Up: - return kVK_UpArrow; - default: - ; - } - - if (key == Qt::Key_Escape) ch = 27; - else if (key == Qt::Key_Return) ch = 13; - else if (key == Qt::Key_Enter) ch = 3; - else if (key == Qt::Key_Tab) ch = 9; - else ch = key; - - CFDataRef currentLayoutData; - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); - - if (currentKeyboard == NULL) - return 0; - - currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); - CFRelease(currentKeyboard); - if (currentLayoutData == NULL) - return 0; - - UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); - UCKeyboardTypeHeader* table = header->keyboardTypeList; - - uint8_t *data = (uint8_t*)header; - // God, would a little documentation for this shit kill you... - for (quint32 i=0; i < header->keyboardTypeCount; i++) - { - UCKeyStateRecordsIndex* stateRec = 0; - if (table[i].keyStateRecordsIndexOffset != 0) - { - stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); - if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; - } - - UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); - if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; - - for (quint32 j=0; j < charTable->keyToCharTableCount; j++) - { - UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); - for (quint32 k=0; k < charTable->keyToCharTableSize; k++) - { - if (keyToChar[k] & kUCKeyOutputTestForIndexMask) - { - long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; - if (stateRec && idx < stateRec->keyStateRecordCount) - { - UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); - if (rec->stateZeroCharData == ch) return k; - } - } - else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) - { - if (keyToChar[k] == ch) return k; - } - } // for k - } // for j - } // for i - return 0; -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - if (!qxt_mac_handler_installed) - { + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); + } + return noErr; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= shiftKey; + if (modifiers & Qt::ControlModifier) + native |= cmdKey; + if (modifiers & Qt::AltModifier) + native |= optionKey; + if (modifiers & Qt::MetaModifier) + native |= controlKey; + if (modifiers & Qt::KeypadModifier) + native |= kEventKeyModifierNumLockMask; + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + UTF16Char ch; + // Constants found in NSEvent.h from AppKit.framework + switch (key) + { + case Qt::Key_Return: + return kVK_Return; + case Qt::Key_Enter: + return kVK_ANSI_KeypadEnter; + case Qt::Key_Tab: + return kVK_Tab; + case Qt::Key_Space: + return kVK_Space; + case Qt::Key_Backspace: + return kVK_Delete; + case Qt::Key_Control: + return kVK_Command; + case Qt::Key_Shift: + return kVK_Shift; + case Qt::Key_CapsLock: + return kVK_CapsLock; + case Qt::Key_Option: + return kVK_Option; + case Qt::Key_Meta: + return kVK_Control; + case Qt::Key_F17: + return kVK_F17; + case Qt::Key_VolumeUp: + return kVK_VolumeUp; + case Qt::Key_VolumeDown: + return kVK_VolumeDown; + case Qt::Key_F18: + return kVK_F18; + case Qt::Key_F19: + return kVK_F19; + case Qt::Key_F20: + return kVK_F20; + case Qt::Key_F5: + return kVK_F5; + case Qt::Key_F6: + return kVK_F6; + case Qt::Key_F7: + return kVK_F7; + case Qt::Key_F3: + return kVK_F3; + case Qt::Key_F8: + return kVK_F8; + case Qt::Key_F9: + return kVK_F9; + case Qt::Key_F11: + return kVK_F11; + case Qt::Key_F13: + return kVK_F13; + case Qt::Key_F16: + return kVK_F16; + case Qt::Key_F14: + return kVK_F14; + case Qt::Key_F10: + return kVK_F10; + case Qt::Key_F12: + return kVK_F12; + case Qt::Key_F15: + return kVK_F15; + case Qt::Key_Help: + return kVK_Help; + case Qt::Key_Home: + return kVK_Home; + case Qt::Key_PageUp: + return kVK_PageUp; + case Qt::Key_Delete: + return kVK_ForwardDelete; + case Qt::Key_F4: + return kVK_F4; + case Qt::Key_End: + return kVK_End; + case Qt::Key_F2: + return kVK_F2; + case Qt::Key_PageDown: + return kVK_PageDown; + case Qt::Key_F1: + return kVK_F1; + case Qt::Key_Left: + return kVK_LeftArrow; + case Qt::Key_Right: + return kVK_RightArrow; + case Qt::Key_Down: + return kVK_DownArrow; + case Qt::Key_Up: + return kVK_UpArrow; + default: + ; + } + + if (key == Qt::Key_Escape) ch = 27; + else if (key == Qt::Key_Return) ch = 13; + else if (key == Qt::Key_Enter) ch = 3; + else if (key == Qt::Key_Tab) ch = 9; + else ch = key; + + CFDataRef currentLayoutData; + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + + if (currentKeyboard == NULL) + return 0; + + currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + CFRelease(currentKeyboard); + if (currentLayoutData == NULL) + return 0; + + UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); + UCKeyboardTypeHeader* table = header->keyboardTypeList; + + uint8_t *data = (uint8_t*)header; + // God, would a little documentation for this shit kill you... + for (quint32 i=0; i < header->keyboardTypeCount; i++) + { + UCKeyStateRecordsIndex* stateRec = 0; + if (table[i].keyStateRecordsIndexOffset != 0) + { + stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); + if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; + } + + UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); + if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; + + for (quint32 j=0; j < charTable->keyToCharTableCount; j++) + { + UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); + for (quint32 k=0; k < charTable->keyToCharTableSize; k++) + { + if (keyToChar[k] & kUCKeyOutputTestForIndexMask) + { + long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; + if (stateRec && idx < stateRec->keyStateRecordCount) + { + UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); + if (rec->stateZeroCharData == ch) return k; + } + } + else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) + { + if (keyToChar[k] == ch) return k; + } + } // for k + } // for j + } // for i + return 0; +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + if (!qxt_mac_handler_installed) + { qxt_mac_handler_installed = true; - EventTypeSpec t; - t.eventClass = kEventClassKeyboard; - t.eventKind = kEventHotKeyPressed; - InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); - } - - EventHotKeyID keyID; - keyID.signature = 'cute'; - keyID.id = ++hotKeySerial; - - EventHotKeyRef ref = 0; - bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); - if (rv) - { - keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); - keyRefs.insert(keyID.id, ref); - } - return rv; -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Identifier id(nativeMods, nativeKey); - if (!keyIDs.contains(id)) return false; - - EventHotKeyRef ref = keyRefs.take(keyIDs[id]); - keyIDs.remove(id); - return !UnregisterEventHotKey(ref); -} + EventTypeSpec t; + t.eventClass = kEventClassKeyboard; + t.eventKind = kEventHotKeyPressed; + InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); + } + + EventHotKeyID keyID; + keyID.signature = 'cute'; + keyID.id = ++hotKeySerial; + + EventHotKeyRef ref = 0; + bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); + if (rv) + { + keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); + keyRefs.insert(keyID.id, ref); + } + return rv; +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Identifier id(nativeMods, nativeKey); + if (!keyIDs.contains(id)) return false; + + EventHotKeyRef ref = keyRefs.take(keyIDs[id]); + keyIDs.remove(id); + return !UnregisterEventHotKey(ref); +} bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, void *message, long *result) { diff --git a/qxt-mini/plat/qxtglobalshortcut_x11.cpp b/qxt-mini/plat/qxtglobalshortcut_x11.cpp index 0c203dd80..f18f86dbe 100644 --- a/qxt-mini/plat/qxtglobalshortcut_x11.cpp +++ b/qxt-mini/plat/qxtglobalshortcut_x11.cpp @@ -1,235 +1,235 @@ -#include "../qxtglobalshortcut_p.h" -/**************************************************************************** -** Copyright (c) 2006 - 2011, the LibQxt project. -** See the Qxt AUTHORS file for a list of authors and copyright holders. -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the LibQxt project nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -** -*****************************************************************************/ - -#include -#include -// include private header for great justice -sh 20131015 -#include -#include -#include "qplatformnativeinterface.h" - -namespace { - -const QVector maskModifiers = QVector() - << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask); - -typedef int (*X11ErrorHandler)(Display *display, XErrorEvent *event); - -class QxtX11ErrorHandler { -public: - static bool error; - - static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) - { - Q_UNUSED(display); - switch (event->error_code) - { - case BadAccess: - case BadValue: - case BadWindow: - if (event->request_code == 33 /* X_GrabKey */ || - event->request_code == 34 /* X_UngrabKey */) - { - error = true; - //TODO: - //char errstr[256]; - //XGetErrorText(dpy, err->error_code, errstr, 256); - } - } - return 0; - } - - QxtX11ErrorHandler() - { - error = false; - m_previousErrorHandler = XSetErrorHandler(qxtX11ErrorHandler); - } - - ~QxtX11ErrorHandler() - { - XSetErrorHandler(m_previousErrorHandler); - } - -private: - X11ErrorHandler m_previousErrorHandler; -}; - -bool QxtX11ErrorHandler::error = false; - -class QxtX11Data { -public: - QxtX11Data() - { -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) - m_display = QX11Info::display(); -#else - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - void *display = native->nativeResourceForScreen(QByteArray("display"), - QGuiApplication::primaryScreen()); - m_display = reinterpret_cast(display); -#endif - } - - bool isValid() - { - return m_display != 0; - } - - Display *display() - { - Q_ASSERT(isValid()); - return m_display; - } - - Window rootWindow() - { - return DefaultRootWindow(display()); - } - - bool grabKey(quint32 keycode, quint32 modifiers, Window window) - { - QxtX11ErrorHandler errorHandler; - - for (int i = 0; !errorHandler.error && i < maskModifiers.size(); ++i) { - XGrabKey(display(), keycode, modifiers | maskModifiers[i], window, True, - GrabModeAsync, GrabModeAsync); - } - - if (errorHandler.error) { - ungrabKey(keycode, modifiers, window); - return false; - } - - return true; - } - - bool ungrabKey(quint32 keycode, quint32 modifiers, Window window) - { - QxtX11ErrorHandler errorHandler; - - foreach (quint32 maskMods, maskModifiers) { - XUngrabKey(display(), keycode, modifiers | maskMods, window); - } - - return !errorHandler.error; - } - -private: - Display *m_display; -}; - -} // namespace - -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) -bool QxtGlobalShortcutPrivate::eventFilter(void *message) -{ - XEvent *event = static_cast(message); - if (event->type == KeyPress) - { - XKeyEvent *key = reinterpret_cast(event); - unsigned int keycode = key->keycode; - unsigned int keystate = key->state; -#else -bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, - void *message, long *result) -{ - Q_UNUSED(result); - - xcb_key_press_event_t *kev = 0; - if (eventType == "xcb_generic_event_t") { - xcb_generic_event_t *ev = static_cast(message); - if ((ev->response_type & 127) == XCB_KEY_PRESS) - kev = static_cast(message); - } - - if (kev != 0) { - unsigned int keycode = kev->detail; - unsigned int keystate = 0; - if(kev->state & XCB_MOD_MASK_1) - keystate |= Mod1Mask; - if(kev->state & XCB_MOD_MASK_CONTROL) - keystate |= ControlMask; - if(kev->state & XCB_MOD_MASK_4) - keystate |= Mod4Mask; - if(kev->state & XCB_MOD_MASK_SHIFT) - keystate |= ShiftMask; -#endif - activateShortcut(keycode, - // Mod1Mask == Alt, Mod4Mask == Meta - keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); - } - return false; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= ShiftMask; - if (modifiers & Qt::ControlModifier) - native |= ControlMask; - if (modifiers & Qt::AltModifier) - native |= Mod1Mask; - if (modifiers & Qt::MetaModifier) - native |= Mod4Mask; - - // TODO: resolve these? - //if (modifiers & Qt::MetaModifier) - //if (modifiers & Qt::KeypadModifier) - //if (modifiers & Qt::GroupSwitchModifier) - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - QxtX11Data x11; - if (!x11.isValid()) - return 0; - - KeySym keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); - if (keysym == NoSymbol) - keysym = static_cast(key); - - return XKeysymToKeycode(x11.display(), keysym); -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - QxtX11Data x11; - return x11.isValid() && x11.grabKey(nativeKey, nativeMods, x11.rootWindow()); -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - QxtX11Data x11; - return x11.isValid() && x11.ungrabKey(nativeKey, nativeMods, x11.rootWindow()); -} +#include "../qxtglobalshortcut_p.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include +#include +// include private header for great justice -sh 20131015 +#include +#include +#include "qplatformnativeinterface.h" + +namespace { + +const QVector maskModifiers = QVector() + << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask); + +typedef int (*X11ErrorHandler)(Display *display, XErrorEvent *event); + +class QxtX11ErrorHandler { +public: + static bool error; + + static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) + { + Q_UNUSED(display); + switch (event->error_code) + { + case BadAccess: + case BadValue: + case BadWindow: + if (event->request_code == 33 /* X_GrabKey */ || + event->request_code == 34 /* X_UngrabKey */) + { + error = true; + //TODO: + //char errstr[256]; + //XGetErrorText(dpy, err->error_code, errstr, 256); + } + } + return 0; + } + + QxtX11ErrorHandler() + { + error = false; + m_previousErrorHandler = XSetErrorHandler(qxtX11ErrorHandler); + } + + ~QxtX11ErrorHandler() + { + XSetErrorHandler(m_previousErrorHandler); + } + +private: + X11ErrorHandler m_previousErrorHandler; +}; + +bool QxtX11ErrorHandler::error = false; + +class QxtX11Data { +public: + QxtX11Data() + { +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + m_display = QX11Info::display(); +#else + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + void *display = native->nativeResourceForScreen(QByteArray("display"), + QGuiApplication::primaryScreen()); + m_display = reinterpret_cast(display); +#endif + } + + bool isValid() + { + return m_display != 0; + } + + Display *display() + { + Q_ASSERT(isValid()); + return m_display; + } + + Window rootWindow() + { + return DefaultRootWindow(display()); + } + + bool grabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + for (int i = 0; !errorHandler.error && i < maskModifiers.size(); ++i) { + XGrabKey(display(), keycode, modifiers | maskModifiers[i], window, True, + GrabModeAsync, GrabModeAsync); + } + + if (errorHandler.error) { + ungrabKey(keycode, modifiers, window); + return false; + } + + return true; + } + + bool ungrabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + foreach (quint32 maskMods, maskModifiers) { + XUngrabKey(display(), keycode, modifiers | maskMods, window); + } + + return !errorHandler.error; + } + +private: + Display *m_display; +}; + +} // namespace + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +bool QxtGlobalShortcutPrivate::eventFilter(void *message) +{ + XEvent *event = static_cast(message); + if (event->type == KeyPress) + { + XKeyEvent *key = reinterpret_cast(event); + unsigned int keycode = key->keycode; + unsigned int keystate = key->state; +#else +bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, + void *message, long *result) +{ + Q_UNUSED(result); + + xcb_key_press_event_t *kev = 0; + if (eventType == "xcb_generic_event_t") { + xcb_generic_event_t *ev = static_cast(message); + if ((ev->response_type & 127) == XCB_KEY_PRESS) + kev = static_cast(message); + } + + if (kev != 0) { + unsigned int keycode = kev->detail; + unsigned int keystate = 0; + if(kev->state & XCB_MOD_MASK_1) + keystate |= Mod1Mask; + if(kev->state & XCB_MOD_MASK_CONTROL) + keystate |= ControlMask; + if(kev->state & XCB_MOD_MASK_4) + keystate |= Mod4Mask; + if(kev->state & XCB_MOD_MASK_SHIFT) + keystate |= ShiftMask; +#endif + activateShortcut(keycode, + // Mod1Mask == Alt, Mod4Mask == Meta + keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); + } + return false; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= ShiftMask; + if (modifiers & Qt::ControlModifier) + native |= ControlMask; + if (modifiers & Qt::AltModifier) + native |= Mod1Mask; + if (modifiers & Qt::MetaModifier) + native |= Mod4Mask; + + // TODO: resolve these? + //if (modifiers & Qt::MetaModifier) + //if (modifiers & Qt::KeypadModifier) + //if (modifiers & Qt::GroupSwitchModifier) + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + QxtX11Data x11; + if (!x11.isValid()) + return 0; + + KeySym keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); + if (keysym == NoSymbol) + keysym = static_cast(key); + + return XKeysymToKeycode(x11.display(), keysym); +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.grabKey(nativeKey, nativeMods, x11.rootWindow()); +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.ungrabKey(nativeKey, nativeMods, x11.rootWindow()); +} diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp index 8515a6b27..45576d371 100644 --- a/qxt-mini/qxtglobalshortcut.cpp +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -1,224 +1,224 @@ -#include "qxtglobalshortcut.h" -/**************************************************************************** -** Copyright (c) 2006 - 2011, the LibQxt project. -** See the Qxt AUTHORS file for a list of authors and copyright holders. -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the LibQxt project nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -** -*****************************************************************************/ - -#include "qxtglobalshortcut_p.h" -#include -#include - -#ifndef Q_OS_MAC -int QxtGlobalShortcutPrivate::ref = 0; -# if QT_VERSION < QT_VERSION_CHECK(5,0,0) -QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0; -# endif -#endif // Q_OS_MAC -QHash, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; - -QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) -{ -#ifndef Q_OS_MAC - if (ref == 0) { -# if QT_VERSION < QT_VERSION_CHECK(5,0,0) - prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter); -# else - QAbstractEventDispatcher::instance()->installNativeEventFilter(this); -#endif - } - ++ref; -#endif // Q_OS_MAC -} - -QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() -{ -#ifndef Q_OS_MAC - --ref; - if (ref == 0) { - QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance(); - if (ed != 0) { -# if QT_VERSION < QT_VERSION_CHECK(5,0,0) - ed->setEventFilter(prevEventFilter); -# else - ed->removeNativeEventFilter(this); -# endif - } - } -#endif // Q_OS_MAC -} - -bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) -{ - if (shortcut.toString() == "") return false; - Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; - key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); - mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); - const quint32 nativeKey = nativeKeycode(key); - const quint32 nativeMods = nativeModifiers(mods); - const bool res = registerShortcut(nativeKey, nativeMods); - if (res) - shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); - else - qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); - return res; -} - -bool QxtGlobalShortcutPrivate::unsetShortcut() -{ - bool res = false; - const quint32 nativeKey = nativeKeycode(key); - const quint32 nativeMods = nativeModifiers(mods); - if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p()) - res = unregisterShortcut(nativeKey, nativeMods); - if (res) - shortcuts.remove(qMakePair(nativeKey, nativeMods)); - else - qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString(); - key = Qt::Key(0); - mods = Qt::KeyboardModifiers(0); - return res; -} - -void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods) -{ - QxtGlobalShortcut* shortcut = shortcuts.value(qMakePair(nativeKey, nativeMods)); - if (shortcut && shortcut->isEnabled()) - emit shortcut->activated(); -} - -/*! - \class QxtGlobalShortcut - \inmodule QxtWidgets - \brief The QxtGlobalShortcut class provides a global shortcut aka "hotkey". - - A global shortcut triggers even if the application is not active. This - makes it easy to implement applications that react to certain shortcuts - still if some other application is active or if the application is for - example minimized to the system tray. - - Example usage: - \code - QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(window); - connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility())); - shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12")); - \endcode - - \bold {Note:} Since Qxt 0.6 QxtGlobalShortcut no more requires QxtApplication. - */ - -/*! - \fn QxtGlobalShortcut::activated() - - This signal is emitted when the user types the shortcut's key sequence. - - \sa shortcut - */ - -/*! - Constructs a new QxtGlobalShortcut with \a parent. - */ -QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) - : QObject(parent) -{ - QXT_INIT_PRIVATE(QxtGlobalShortcut); -} - -/*! - Constructs a new QxtGlobalShortcut with \a shortcut and \a parent. - */ -QxtGlobalShortcut::QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent) - : QObject(parent) -{ - QXT_INIT_PRIVATE(QxtGlobalShortcut); - setShortcut(shortcut); -} - -/*! - Destructs the QxtGlobalShortcut. - */ -QxtGlobalShortcut::~QxtGlobalShortcut() -{ - if (qxt_d().key != 0) - qxt_d().unsetShortcut(); -} - -/*! - \property QxtGlobalShortcut::shortcut - \brief the shortcut key sequence - - \bold {Note:} Notice that corresponding key press and release events are not - delivered for registered global shortcuts even if they are disabled. - Also, comma separated key sequences are not supported. - Only the first part is used: - - \code - qxtShortcut->setShortcut(QKeySequence("Ctrl+Alt+A,Ctrl+Alt+B")); - Q_ASSERT(qxtShortcut->shortcut() == QKeySequence("Ctrl+Alt+A")); - \endcode - */ -QKeySequence QxtGlobalShortcut::shortcut() const -{ - return QKeySequence(qxt_d().key | qxt_d().mods); -} - -bool QxtGlobalShortcut::setShortcut(const QKeySequence& shortcut) -{ - if (qxt_d().key != 0) - qxt_d().unsetShortcut(); - return qxt_d().setShortcut(shortcut); -} - -/*! - \property QxtGlobalShortcut::enabled - \brief whether the shortcut is enabled - - A disabled shortcut does not get activated. - - The default value is \c true. - - \sa setDisabled() - */ -bool QxtGlobalShortcut::isEnabled() const -{ - return qxt_d().enabled; -} - -void QxtGlobalShortcut::setEnabled(bool enabled) -{ - qxt_d().enabled = enabled; -} - -/*! - Sets the shortcut \a disabled. - - \sa enabled - */ -void QxtGlobalShortcut::setDisabled(bool disabled) -{ - qxt_d().enabled = !disabled; -} +#include "qxtglobalshortcut.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include "qxtglobalshortcut_p.h" +#include +#include + +#ifndef Q_OS_MAC +int QxtGlobalShortcutPrivate::ref = 0; +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) +QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0; +# endif +#endif // Q_OS_MAC +QHash, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; + +QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) +{ +#ifndef Q_OS_MAC + if (ref == 0) { +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) + prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter); +# else + QAbstractEventDispatcher::instance()->installNativeEventFilter(this); +#endif + } + ++ref; +#endif // Q_OS_MAC +} + +QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() +{ +#ifndef Q_OS_MAC + --ref; + if (ref == 0) { + QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance(); + if (ed != 0) { +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) + ed->setEventFilter(prevEventFilter); +# else + ed->removeNativeEventFilter(this); +# endif + } + } +#endif // Q_OS_MAC +} + +bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) +{ + if (shortcut.toString() == "") return false; + Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; + key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); + mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); + const quint32 nativeKey = nativeKeycode(key); + const quint32 nativeMods = nativeModifiers(mods); + const bool res = registerShortcut(nativeKey, nativeMods); + if (res) + shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); + else + qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); + return res; +} + +bool QxtGlobalShortcutPrivate::unsetShortcut() +{ + bool res = false; + const quint32 nativeKey = nativeKeycode(key); + const quint32 nativeMods = nativeModifiers(mods); + if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p()) + res = unregisterShortcut(nativeKey, nativeMods); + if (res) + shortcuts.remove(qMakePair(nativeKey, nativeMods)); + else + qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString(); + key = Qt::Key(0); + mods = Qt::KeyboardModifiers(0); + return res; +} + +void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtGlobalShortcut* shortcut = shortcuts.value(qMakePair(nativeKey, nativeMods)); + if (shortcut && shortcut->isEnabled()) + emit shortcut->activated(); +} + +/*! + \class QxtGlobalShortcut + \inmodule QxtWidgets + \brief The QxtGlobalShortcut class provides a global shortcut aka "hotkey". + + A global shortcut triggers even if the application is not active. This + makes it easy to implement applications that react to certain shortcuts + still if some other application is active or if the application is for + example minimized to the system tray. + + Example usage: + \code + QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(window); + connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility())); + shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12")); + \endcode + + \bold {Note:} Since Qxt 0.6 QxtGlobalShortcut no more requires QxtApplication. + */ + +/*! + \fn QxtGlobalShortcut::activated() + + This signal is emitted when the user types the shortcut's key sequence. + + \sa shortcut + */ + +/*! + Constructs a new QxtGlobalShortcut with \a parent. + */ +QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) + : QObject(parent) +{ + QXT_INIT_PRIVATE(QxtGlobalShortcut); +} + +/*! + Constructs a new QxtGlobalShortcut with \a shortcut and \a parent. + */ +QxtGlobalShortcut::QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent) + : QObject(parent) +{ + QXT_INIT_PRIVATE(QxtGlobalShortcut); + setShortcut(shortcut); +} + +/*! + Destructs the QxtGlobalShortcut. + */ +QxtGlobalShortcut::~QxtGlobalShortcut() +{ + if (qxt_d().key != 0) + qxt_d().unsetShortcut(); +} + +/*! + \property QxtGlobalShortcut::shortcut + \brief the shortcut key sequence + + \bold {Note:} Notice that corresponding key press and release events are not + delivered for registered global shortcuts even if they are disabled. + Also, comma separated key sequences are not supported. + Only the first part is used: + + \code + qxtShortcut->setShortcut(QKeySequence("Ctrl+Alt+A,Ctrl+Alt+B")); + Q_ASSERT(qxtShortcut->shortcut() == QKeySequence("Ctrl+Alt+A")); + \endcode + */ +QKeySequence QxtGlobalShortcut::shortcut() const +{ + return QKeySequence(qxt_d().key | qxt_d().mods); +} + +bool QxtGlobalShortcut::setShortcut(const QKeySequence& shortcut) +{ + if (qxt_d().key != 0) + qxt_d().unsetShortcut(); + return qxt_d().setShortcut(shortcut); +} + +/*! + \property QxtGlobalShortcut::enabled + \brief whether the shortcut is enabled + + A disabled shortcut does not get activated. + + The default value is \c true. + + \sa setDisabled() + */ +bool QxtGlobalShortcut::isEnabled() const +{ + return qxt_d().enabled; +} + +void QxtGlobalShortcut::setEnabled(bool enabled) +{ + qxt_d().enabled = enabled; +} + +/*! + Sets the shortcut \a disabled. + + \sa enabled + */ +void QxtGlobalShortcut::setDisabled(bool disabled) +{ + qxt_d().enabled = !disabled; +} diff --git a/qxt-mini/qxtglobalshortcut.h b/qxt-mini/qxtglobalshortcut.h index a81942d2c..641c07c9e 100644 --- a/qxt-mini/qxtglobalshortcut.h +++ b/qxt-mini/qxtglobalshortcut.h @@ -1,64 +1,64 @@ -#ifndef QXTGLOBALSHORTCUT_H -/**************************************************************************** -** Copyright (c) 2006 - 2011, the LibQxt project. -** See the Qxt AUTHORS file for a list of authors and copyright holders. -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the LibQxt project nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -** -*****************************************************************************/ - -#define QXTGLOBALSHORTCUT_H - -#include "qxtglobal.h" -#include -#include -class QxtGlobalShortcutPrivate; - -class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject -{ - Q_OBJECT - QXT_DECLARE_PRIVATE(QxtGlobalShortcut) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) - Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) - -public: - explicit QxtGlobalShortcut(QObject* parent = 0); - explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = 0); - virtual ~QxtGlobalShortcut(); - - QKeySequence shortcut() const; - bool setShortcut(const QKeySequence& shortcut); - - bool isEnabled() const; - -public Q_SLOTS: - void setEnabled(bool enabled = true); - void setDisabled(bool disabled = true); - -Q_SIGNALS: - void activated(); -}; - -#endif // QXTGLOBALSHORTCUT_H +#ifndef QXTGLOBALSHORTCUT_H +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#define QXTGLOBALSHORTCUT_H + +#include "qxtglobal.h" +#include +#include +class QxtGlobalShortcutPrivate; + +class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject +{ + Q_OBJECT + QXT_DECLARE_PRIVATE(QxtGlobalShortcut) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) + Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) + +public: + explicit QxtGlobalShortcut(QObject* parent = 0); + explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = 0); + virtual ~QxtGlobalShortcut(); + + QKeySequence shortcut() const; + bool setShortcut(const QKeySequence& shortcut); + + bool isEnabled() const; + +public Q_SLOTS: + void setEnabled(bool enabled = true); + void setDisabled(bool disabled = true); + +Q_SIGNALS: + void activated(); +}; + +#endif // QXTGLOBALSHORTCUT_H -- cgit v1.2.3 From c656655dfc7def89c7ed6001039b93d12582ed4d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 22:53:18 +0200 Subject: missing header --- facetracknoir/facetracknoir.h | 1 + 1 file changed, 1 insertion(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 9bdda7490..c722ad5ca 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -35,6 +35,7 @@ #include #include #include +#include #if !defined(_WIN32) # include "qxt-mini/QxtGlobalShortcut" #else -- cgit v1.2.3 From 71acf73ec93f370d7bee4240c9b17891e257f129 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 22:53:30 +0200 Subject: stock octopus drawing --- .../cute-octopus-vector-material_15-1831.jpg | Bin 0 -> 71514 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 facetracknoir/clientfiles/cute-octopus-vector-material_15-1831.jpg (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/cute-octopus-vector-material_15-1831.jpg b/facetracknoir/clientfiles/cute-octopus-vector-material_15-1831.jpg new file mode 100644 index 000000000..c4e5318fb Binary files /dev/null and b/facetracknoir/clientfiles/cute-octopus-vector-material_15-1831.jpg differ -- cgit v1.2.3 From e18f3e2172bd85bfaa227b250a51d2e08952481e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 23:11:02 +0200 Subject: fix UI somewhat After @KyokushinPL made look-and-feel changes, fix Qt layouts and property values. --- facetracknoir/facetracknoir.ui | 2067 ++++++++++++++++++++++------------------ 1 file changed, 1164 insertions(+), 903 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 7f6b863c1..6a645acbd 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -7,8 +7,8 @@ 0 0 - 597 - 506 + 956 + 740 @@ -21,996 +21,1274 @@ :/images/facetracknoir.png:/images/facetracknoir.png + + #headpose, #video_frame_label, #controls, #video_frame { border: 0; } +#video_frame { margin: 0; padding: 0; } + - + - 140 - 15 - 126 - 161 + 10 + 225 + 655 + 505 - Game data + Video preview - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + - - - TX - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - yaw - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - roll - - - - - - - true - - - false - - - TY - - - - - - - true - - - false - - - TZ - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - pitch - - - - - - - - - 405 - 380 - 181 - 56 - - - - Protocol - - - - - - - 0 - 0 - - - - 42 - - - - - - - true - + - + 0 0 - - Settings - + + + 640 + 480 + + + + + 640 + 480 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 640 + 480 + + + + + 640 + 480 + + + + + + + + - + - 405 - 215 - 181 - 56 + 675 + 225 + 271 + 506 - Tracker + + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Connected game + + + + 6 + + + 6 + + + 3 + + + + + Not connected + + + + + + - + 0 0 - - 42 - + + Profile + + + + 6 + + + 6 + + + 3 + + + + + true + + + + 0 + 0 + + + + Save + + + + + + + + 0 + 0 + + + + Load + + + + + + + + 0 + 0 + + + + 10 + + + + + + + true + + + + 0 + 0 + + + + Save As ... + + + + - - - true - + - + 0 0 - + Settings + + + 6 + + + 6 + + + 3 + + + + + + 0 + 0 + + + + Mapping + + + + :/uielements/curves.png:/uielements/curves.png + + + + 91 + 25 + + + + + + + + + 0 + 0 + + + + Keys + + + + :/uielements/tools.png:/uielements/tools.png + + + + 98 + 24 + + + + + - - - - - - 405 - 325 - 181 - 56 - - - - Filter - - - + 0 0 - - 42 - + + Tracker + + + + 6 + + + 6 + + + 3 + + + + + + 0 + 0 + + + + + + + + true + + + + 0 + 0 + + + + Settings + + + + - - - true - + - + 0 0 - - Settings - + + Filter + + + + 6 + + + 6 + + + 3 + + + + + + 0 + 0 + + + + + + + + true + + + + 0 + 0 + + + + Settings + + + + - - - - - - 405 - 270 - 181 - 56 - - - - Auxiliary tracker - - - + 0 0 - - 42 - + + Protocol + + + + 6 + + + 6 + + + 3 + + + + + true + + + + 0 + 0 + + + + Settings + + + + + + + + 0 + 0 + + + + + - - - true - + - + 0 0 - - Settings - + + + 0 + 0 + + + + + 65536 + 65536 + + + + Controls + + + + 6 + + + 6 + + + 3 + + + + + + 0 + 0 + + + + Start + + + + + + + false + + + + 0 + 0 + + + + Stop + + + + - + - 24 - 204 - 366 - 281 + 185 + 10 + 761 + 211 - - - 0 - 0 - + + - - - - 0 - 0 - 366 - 281 - + + + 10 - - - 0 - 0 - + + 0 - - - NoAntialias - false - + + 0 - - + + 0 - - - - - - 405 - 15 - 181 - 81 - - - - Profile - - - - - - true - - - - 0 - 0 - - - - Save - - - - - - - - 0 - 0 - - - - Load - - - - - - - true - - - - 0 - 0 - - - - Save As ... - - - - - - - - 0 - 0 - - - - 10 - - - - - - - - - 405 - 440 - 181 - 56 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - Controls - - - - - - - 0 - 0 - - - - Start - - - - - - - false - - - - 0 - 0 - - - - Stop - - - - - - - - - 273 - 15 - 126 - 161 - - - - Raw pose - - - - - - TX - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - true - - - false - - - TY - - - - - - - true - - - false - - - TZ - - - - - - - true - - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 2 - - - QLCDNumber::Flat - - - - - - - pitch - - - - - - - yaw - + + 0 + + + + + Game data + + + + + + + 0 + 0 + + + + + NoAntialias + false + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + + NoAntialias + false + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + + NoAntialias + false + + + + false + + + QFrame::Raised + + + TZ + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + + NoAntialias + false + + + + false + + + QFrame::Raised + + + TY + + + + + + + + 0 + 0 + + + + + NoAntialias + false + + + + QFrame::Raised + + + yaw + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + + NoAntialias + false + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + - - - - roll - + + + + Raw pose + + + + + + + 0 + 0 + + + + TX + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + yaw + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + false + + + TY + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + pitch + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + false + + + TZ + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + roll + + + + + + + true + + + + 0 + 0 + + + + + 13 + NoAntialias + false + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 4 + + + QLCDNumber::Flat + + + + - - - - 15 - 179 - 386 - 316 - - - - Video preview - - - + - 405 - 95 - 181 - 80 + 10 + 10 + 166 + 211 - - Settings - - - - - 10 - 45 - 161 - 26 - - - - - 0 - 0 - - - - Keys - - - - :/uielements/tools.png:/uielements/tools.png - - - - 98 - 24 - - - - - - - 10 - 15 - 161 - 26 - - - - - 0 - 0 - - - - Mapping - - - - :/uielements/curves.png:/uielements/curves.png - - - - 60 - 37 - - - - - - - - 15 - 15 - 116 - 161 - + + + 0 + 0 + Tracking preview - - - - 5 - 15 - 106 - 141 - + + + 0 - - - 0 - 0 - + + 0 - - - - - - 405 - 180 - 181 - 36 - - - - Detected app - - - - - 10 - 15 - 115 - 16 - + + 0 + + + 0 - - - 0 - 0 - + + 0 - + + + +
- box_mapped_headpose - groupGameProtocol - groupTrackerSource - groupFilter - groupBox_3 - video_frame - groupProfile - groupStartStop - box_raw_headpose - video_frame_label - video_frame_label - groupBox - groupBox_2 - groupBox_4 - groupBox_5 @@ -1024,21 +1302,4 @@ - - - 5 - - - 5 - - - true - - - true - - - true - - -- cgit v1.2.3 From 6467fde8a45d71a0dca639a934f648461383867a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Sep 2014 23:17:10 +0200 Subject: reorder some widgets --- facetracknoir/facetracknoir.ui | 264 ++++++++++++++++++++--------------------- 1 file changed, 132 insertions(+), 132 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 6a645acbd..5cc2ab0e3 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -129,7 +129,7 @@ 675 225 271 - 506 + 505 @@ -140,7 +140,7 @@ - 0 + 3 0 @@ -262,7 +262,7 @@ - + 0 @@ -270,9 +270,9 @@ - Settings + Tracker - + 6 @@ -283,48 +283,28 @@ 3 - + - + 0 0 - - Mapping - - - - :/uielements/curves.png:/uielements/curves.png - - - - 91 - 25 - - - - + + + + true + - + 0 0 - Keys - - - - :/uielements/tools.png:/uielements/tools.png - - - - 98 - 24 - + Settings @@ -332,17 +312,17 @@ - + - + 0 0 - Tracker + Filter - + 6 @@ -353,7 +333,7 @@ 3 - + 0 @@ -363,7 +343,7 @@ - + true @@ -382,17 +362,17 @@ - + - + 0 0 - Filter + Protocol - + 6 @@ -402,18 +382,8 @@ 3 - - - - - 0 - 0 - - - - - + true @@ -428,11 +398,21 @@ + + + + + 0 + 0 + + + + - + 0 @@ -440,9 +420,9 @@ - Protocol + Settings - + 6 @@ -452,30 +432,50 @@ 3 - - - - true - + + - + 0 0 - Settings + Mapping + + + + :/uielements/curves.png:/uielements/curves.png + + + + 91 + 20 + - - + + - + 0 0 + + Keys + + + + :/uielements/tools.png:/uielements/tools.png + + + + 98 + 24 + + @@ -514,8 +514,11 @@ 3 - - + + + + false + 0 @@ -523,15 +526,12 @@ - Start + Stop - - - - false - + + 0 @@ -539,7 +539,7 @@ - Stop + Start @@ -945,21 +945,8 @@ Raw pose - - - - - 0 - 0 - - - - TX - - - - - + + true @@ -993,19 +980,6 @@ - - - - - 0 - 0 - - - - yaw - - - @@ -1041,27 +1015,34 @@ - - - - true - + + 0 0 - - false + + pitch + + + + + + + + 0 + 0 + - TY + TX - - + + true @@ -1095,21 +1076,8 @@ - - - - - 0 - 0 - - - - pitch - - - - - + + true @@ -1162,8 +1130,27 @@ - - + + + + true + + + + 0 + 0 + + + + false + + + TY + + + + + true @@ -1197,6 +1184,19 @@ + + + + + 0 + 0 + + + + yaw + + + -- cgit v1.2.3 From 2cd3d41a6b35ea978ebf797dcc10a800bd78c658 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 25 Sep 2014 01:16:15 +0200 Subject: gain progress --- facetracknoir/gain-control.hpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/gain-control.hpp b/facetracknoir/gain-control.hpp index dcaee692f..005ef9cc3 100644 --- a/facetracknoir/gain-control.hpp +++ b/facetracknoir/gain-control.hpp @@ -8,6 +8,8 @@ #include #include +#include + #include "timer.hpp" #include @@ -43,16 +45,14 @@ namespace detail { class Gain { private: static constexpr bool use_box_filter = true; - static constexpr int box_size = 32 / 640.; + static constexpr int box_size = 16 / 640.; static constexpr double control_upper_bound = 1.0; // XXX FIXME implement for logitech crapola - static constexpr int GAIN_HISTORY_COUNT = 15, GAIN_HISTORY_EVERY_MS = 115; + static constexpr int GAIN_HISTORY_COUNT = 90, GAIN_HISTORY_EVERY_MS = 85; int control; double step, eps; - std::deque means_history; - cv::Mat last_frame; - + std::deque means_history; Timer debug_timer, history_timer; typedef unsigned char px; @@ -156,19 +156,30 @@ public: debug_timer.start(); qDebug() << "---- gain:" << "mean" << mu << "variance" << var; - for (int i = 0; i < means_history.size(); i++) - qDebug() << "cov" << i << means_history[i]; - } - - if (last_frame.cols != frame.cols || last_frame.rows != frame.rows) - { - last_frame = frame; - means_history.clear(); + + const int sz = means_history.size(); + + if (sz) + fprintf(stderr, "covs: "); + + for (int i = 0; i < sz; i++) + { + if (means_history[i].rows != frame.rows || means_history[i].cols != frame.cols) + { + means_history.clear(); + qDebug() << "\n!!! resolution reset"; + break; + } + fprintf(stderr, "%f ", get_covariance(frame, means_history[i])); + } + + if (sz) + fprintf(stderr, "\n"); } if (GAIN_HISTORY_COUNT > means_history.size() && history_timer.elapsed_ms() > GAIN_HISTORY_EVERY_MS) { - means_history.push_front(get_covariance(frame, last_frame)); + means_history.push_front(frame); if (GAIN_HISTORY_COUNT == means_history.size()) means_history.pop_back(); -- cgit v1.2.3 From b4663bbb85428ec3e4dd6725bb2d2ff2afa57bf6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 25 Sep 2014 13:38:53 +0200 Subject: frames got clobbered, opencv sucks as usual --- facetracknoir/gain-control.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/gain-control.hpp b/facetracknoir/gain-control.hpp index 005ef9cc3..98d45711e 100644 --- a/facetracknoir/gain-control.hpp +++ b/facetracknoir/gain-control.hpp @@ -179,7 +179,7 @@ public: if (GAIN_HISTORY_COUNT > means_history.size() && history_timer.elapsed_ms() > GAIN_HISTORY_EVERY_MS) { - means_history.push_front(frame); + means_history.push_front(frame.clone()); if (GAIN_HISTORY_COUNT == means_history.size()) means_history.pop_back(); -- cgit v1.2.3 From 6f43254665afbef2b4e44889e10d397fee2f7ce6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 25 Sep 2014 13:53:24 +0200 Subject: how about this no-feed image? --- facetracknoir/uielements/no-feed.png | Bin 20196 -> 128664 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/uielements/no-feed.png b/facetracknoir/uielements/no-feed.png index 7c2f52bf8..6494e9c6c 100644 Binary files a/facetracknoir/uielements/no-feed.png and b/facetracknoir/uielements/no-feed.png differ -- cgit v1.2.3 From 63e5d03cd8ccdb0c21d0b7e96bb08e656f1f99ca Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 26 Sep 2014 23:53:10 +0200 Subject: replace raw headpose box a bit --- facetracknoir/facetracknoir.ui | 460 ++++++++++++++++------------------------- 1 file changed, 173 insertions(+), 287 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 5cc2ab0e3..1a006809c 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -23,7 +23,8 @@ #headpose, #video_frame_label, #controls, #video_frame { border: 0; } -#video_frame { margin: 0; padding: 0; } +#video_frame { margin: 0; padding: 0; } + @@ -577,35 +578,13 @@ 0 - + - Game data + Raw pose - - - - - - 0 - 0 - - - - - NoAntialias - false - - - - QFrame::Raised - - - TX - - - - - + + + true @@ -615,32 +594,19 @@ 0 - - - 13 - NoAntialias - false - - QFrame::NoFrame - - QFrame::Raised - - - true - - 4 + 1 - QLCDNumber::Flat + QLCDNumber::Outline - - + + true @@ -650,117 +616,67 @@ 0 - - - 13 - NoAntialias - false - - QFrame::NoFrame - - QFrame::Raised - - - true - - 4 + 1 - QLCDNumber::Flat + QLCDNumber::Outline - + 0 0 - - - NoAntialias - false - - - - QFrame::Raised - pitch - - - - true - + + - + 0 0 - - - 13 - NoAntialias - false - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - - 4 - - - QLCDNumber::Flat + + TX - - + + true - + 0 0 - - - NoAntialias - false - - - - false + + QFrame::NoFrame - - QFrame::Raised + + 1 - - TZ + + QLCDNumber::Outline - - + + true @@ -770,32 +686,19 @@ 0 - - - 13 - NoAntialias - false - - QFrame::NoFrame - - QFrame::Raised - - - true - - 4 + 1 - QLCDNumber::Flat + QLCDNumber::Outline - - + + true @@ -805,47 +708,35 @@ 0 - - - NoAntialias - false - - false - - QFrame::Raised - - TY + TZ - - + + + + true + 0 0 - - - NoAntialias - false - - - - QFrame::Raised + + false - yaw + TY - - + + true @@ -855,46 +746,37 @@ 0 - - - 13 - NoAntialias - false - - QFrame::NoFrame - - QFrame::Raised - - - true - - 4 + 1 - QLCDNumber::Flat + QLCDNumber::Outline - - + + 0 0 - - - NoAntialias - false - + + yaw - - QFrame::Raised + + + + + + + 0 + 0 + roll @@ -902,7 +784,7 @@ - + true @@ -912,27 +794,14 @@ 0 - - - 13 - NoAntialias - false - - QFrame::NoFrame - - QFrame::Raised - - - true - - 4 + 1 - QLCDNumber::Flat + QLCDNumber::Outline @@ -940,29 +809,44 @@ - + - Raw pose + Game data - - - - - true - + + + - + 0 0 - 13 NoAntialias false + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + QFrame::NoFrame @@ -973,15 +857,15 @@ true - 4 + 1 QLCDNumber::Flat - - + + true @@ -991,13 +875,6 @@ 0 - - - 13 - NoAntialias - false - - QFrame::NoFrame @@ -1008,7 +885,7 @@ true - 4 + 1 QLCDNumber::Flat @@ -1016,33 +893,29 @@ - + 0 0 - - pitch + + + NoAntialias + false + - - - - - - - 0 - 0 - + + QFrame::Raised - TX + pitch - - + + true @@ -1052,13 +925,6 @@ 0 - - - 13 - NoAntialias - false - - QFrame::NoFrame @@ -1069,31 +935,52 @@ true - 4 + 1 QLCDNumber::Flat - - + + true - + 0 0 - 13 NoAntialias false + + false + + + QFrame::Raised + + + TZ + + + + + + + true + + + + 0 + 0 + + QFrame::NoFrame @@ -1104,15 +991,15 @@ true - 4 + 1 QLCDNumber::Flat - - + + true @@ -1122,35 +1009,47 @@ 0 + + + NoAntialias + false + + false + + QFrame::Raised + - TZ + TY - - - - true - + + 0 0 - - false + + + NoAntialias + false + + + + QFrame::Raised - TY + yaw - - + + true @@ -1160,13 +1059,6 @@ 0 - - - 13 - NoAntialias - false - - QFrame::NoFrame @@ -1177,33 +1069,29 @@ true - 4 + 1 QLCDNumber::Flat - - + + 0 0 - - yaw + + + NoAntialias + false + - - - - - - - 0 - 0 - + + QFrame::Raised roll @@ -1211,7 +1099,7 @@ - + true @@ -1221,13 +1109,6 @@ 0 - - - 13 - NoAntialias - false - - QFrame::NoFrame @@ -1238,7 +1119,7 @@ true - 4 + 1 QLCDNumber::Flat @@ -1250,7 +1131,7 @@ - + 10 @@ -1289,6 +1170,11 @@ + video_feed + controls + headpose + octopus + box_mapped_headpose -- cgit v1.2.3 From d20dde371d1ddac288267d7d051735b685a24697 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 26 Sep 2014 23:56:50 +0200 Subject: gain: stupido --- facetracknoir/gain-control.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/gain-control.hpp b/facetracknoir/gain-control.hpp index 98d45711e..73155cd8f 100644 --- a/facetracknoir/gain-control.hpp +++ b/facetracknoir/gain-control.hpp @@ -47,7 +47,7 @@ private: static constexpr bool use_box_filter = true; static constexpr int box_size = 16 / 640.; static constexpr double control_upper_bound = 1.0; // XXX FIXME implement for logitech crapola - static constexpr int GAIN_HISTORY_COUNT = 90, GAIN_HISTORY_EVERY_MS = 85; + static constexpr int GAIN_HISTORY_COUNT = 50, GAIN_HISTORY_EVERY_MS = 998; int control; double step, eps; @@ -179,6 +179,7 @@ public: if (GAIN_HISTORY_COUNT > means_history.size() && history_timer.elapsed_ms() > GAIN_HISTORY_EVERY_MS) { + history_timer.start(); means_history.push_front(frame.clone()); if (GAIN_HISTORY_COUNT == means_history.size()) -- cgit v1.2.3 From 01f1a5f2b9ed1846423eee0336450f32b836536b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 27 Sep 2014 20:04:47 +0200 Subject: make stuff private, not protected clang generates warnings for unused private stuff, so use that. --- facetracknoir/rotation.h | 60 ++++++++++++++++++------------------- ftnoir_tracker_aruco/trans_calib.h | 22 +++++++------- ftnoir_tracker_pt/camera.h | 53 ++++++++++++++++---------------- ftnoir_tracker_pt/point_extractor.h | 26 ++++++++-------- ftnoir_tracker_pt/trans_calib.h | 22 +++++++------- 5 files changed, 92 insertions(+), 91 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/rotation.h b/facetracknoir/rotation.h index d40fb6cf3..5ff5ce61b 100644 --- a/facetracknoir/rotation.h +++ b/facetracknoir/rotation.h @@ -11,40 +11,40 @@ class RotationType { public: - RotationType() : a(1.0),b(0.0),c(0.0),d(0.0) {} - RotationType(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } - RotationType(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} - - RotationType inv(){ - return RotationType(a,-b,-c, -d); - } - - - // conversions - // see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles - void fromEuler(double yaw, double pitch, double roll) - { - - double sin_phi = sin(roll/2.0); - double cos_phi = cos(roll/2.0); - double sin_the = sin(pitch/2.0); - double cos_the = cos(pitch/2.0); - double sin_psi = sin(yaw/2.0); - double cos_psi = cos(yaw/2.0); - - a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; - b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; - c = cos_phi*sin_the*cos_psi + sin_phi*cos_the*sin_psi; - d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; - } - + RotationType() : a(1.0),b(0.0),c(0.0),d(0.0) {} + RotationType(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } + RotationType(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} + + RotationType inv(){ + return RotationType(a,-b,-c, -d); + } + + + // conversions + // see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles + void fromEuler(double yaw, double pitch, double roll) + { + + double sin_phi = sin(roll/2.0); + double cos_phi = cos(roll/2.0); + double sin_the = sin(pitch/2.0); + double cos_the = cos(pitch/2.0); + double sin_psi = sin(yaw/2.0); + double cos_psi = cos(yaw/2.0); + + a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; + b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; + c = cos_phi*sin_the*cos_psi + sin_phi*cos_the*sin_psi; + d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; + } + void toEuler(double& yaw, double& pitch, double& roll) const { roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); pitch = asin(2.0*(a*c - b*d)); yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); } - + const RotationType operator*(const RotationType& B) const { const RotationType& A = *this; @@ -54,6 +54,6 @@ public: A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); } -protected: - double a,b,c,d; // quaternion coefficients +private: + double a,b,c,d; // quaternion coefficients }; diff --git a/ftnoir_tracker_aruco/trans_calib.h b/ftnoir_tracker_aruco/trans_calib.h index 609c9af15..5c321b2c9 100644 --- a/ftnoir_tracker_aruco/trans_calib.h +++ b/ftnoir_tracker_aruco/trans_calib.h @@ -20,20 +20,20 @@ class TranslationCalibrator { public: - TranslationCalibrator(); + TranslationCalibrator(); - // reset the calibration process - void reset(); + // reset the calibration process + void reset(); - // update the current estimate - void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); + // update the current estimate + void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); - // get the current estimate for t_MH - cv::Vec3f get_estimate(); + // get the current estimate for t_MH + cv::Vec3f get_estimate(); -protected: - cv::Matx66f P; // normalized precision matrix = inverse covariance - cv::Vec6f y; // P*(-t_MH, t_CH) +private: + cv::Matx66f P; // normalized precision matrix = inverse covariance + cv::Vec6f y; // P*(-t_MH, t_CH) }; -#endif //TRANSCALIB_H \ No newline at end of file +#endif //TRANSCALIB_H diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h index 86cafd42c..2bca88a16 100644 --- a/ftnoir_tracker_pt/camera.h +++ b/ftnoir_tracker_pt/camera.h @@ -25,11 +25,11 @@ void get_camera_device_names(std::vector& device_names); // ---------------------------------------------------------------------------- struct CamInfo { - CamInfo() : res_x(0), res_y(0), fps(0) {} + CamInfo() : res_x(0), res_y(0), fps(0) {} - int res_x; - int res_y; - int fps; + int res_x; + int res_y; + int fps; }; // ---------------------------------------------------------------------------- @@ -65,7 +65,7 @@ protected: virtual void _set_device_index() = 0; virtual void _set_fps() = 0; virtual void _set_res() = 0; - +private: float dt_valid; float dt_mean; int desired_index; @@ -82,18 +82,19 @@ inline Camera::~Camera() {} class CVCamera : public Camera { public: - CVCamera() : cap(NULL) {} - ~CVCamera() { stop(); } + CVCamera() : cap(NULL) {} + ~CVCamera() { stop(); } - void start() override; - void stop() override; + void start() override; + void stop() override; protected: - bool _get_frame(cv::Mat* frame) override; - void _set_fps() override; - void _set_res() override; + bool _get_frame(cv::Mat* frame) override; + void _set_fps() override; + void _set_res() override; void _set_device_index() override; +private: cv::VideoCapture* cap; }; #else @@ -102,21 +103,21 @@ protected: class VICamera : public Camera { public: - VICamera(); - ~VICamera() { stop(); } + VICamera(); + ~VICamera() { stop(); } - virtual void start(); - virtual void stop(); + virtual void start(); + virtual void stop(); protected: - virtual bool _get_frame(cv::Mat* frame); - virtual void _set_device_index(); - virtual void _set_fps(); - virtual void _set_res(); - - videoInput VI; - cv::Mat new_frame; - unsigned char* frame_buffer; + virtual bool _get_frame(cv::Mat* frame); + virtual void _set_device_index(); + virtual void _set_fps(); + virtual void _set_res(); + + videoInput VI; + cv::Mat new_frame; + unsigned char* frame_buffer; }; #endif @@ -128,12 +129,12 @@ enum RotationType }; // ---------------------------------------------------------------------------- -class FrameRotation +class FrameRotation { public: RotationType rotation; - cv::Mat rotate_frame(cv::Mat frame); + cv::Mat rotate_frame(cv::Mat frame); }; #endif //CAMERA_H diff --git a/ftnoir_tracker_pt/point_extractor.h b/ftnoir_tracker_pt/point_extractor.h index 21d548af3..3ef829005 100644 --- a/ftnoir_tracker_pt/point_extractor.h +++ b/ftnoir_tracker_pt/point_extractor.h @@ -15,21 +15,21 @@ // Extracts points from an opencv image class PointExtractor { -public: - // extracts points from frame and draws some processing info into frame, if draw_output is set - // dt: time since last call in seconds - // WARNING: returned reference is valid as long as object - const std::vector& extract_points(cv::Mat &frame); - const std::vector& get_points() { return points; } - PointExtractor(); +public: + // extracts points from frame and draws some processing info into frame, if draw_output is set + // dt: time since last call in seconds + // WARNING: returned reference is valid as long as object + const std::vector& extract_points(cv::Mat &frame); + const std::vector& get_points() { return points; } + PointExtractor(); - int threshold_val; - int threshold_secondary_val; - int min_size, max_size; + int threshold_val; + int threshold_secondary_val; + int min_size, max_size; -protected: - std::vector points; - cv::Mat frame_last; +private: + std::vector points; + cv::Mat frame_last; }; #endif //POINTEXTRACTOR_H diff --git a/ftnoir_tracker_pt/trans_calib.h b/ftnoir_tracker_pt/trans_calib.h index 609c9af15..5c321b2c9 100644 --- a/ftnoir_tracker_pt/trans_calib.h +++ b/ftnoir_tracker_pt/trans_calib.h @@ -20,20 +20,20 @@ class TranslationCalibrator { public: - TranslationCalibrator(); + TranslationCalibrator(); - // reset the calibration process - void reset(); + // reset the calibration process + void reset(); - // update the current estimate - void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); + // update the current estimate + void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); - // get the current estimate for t_MH - cv::Vec3f get_estimate(); + // get the current estimate for t_MH + cv::Vec3f get_estimate(); -protected: - cv::Matx66f P; // normalized precision matrix = inverse covariance - cv::Vec6f y; // P*(-t_MH, t_CH) +private: + cv::Matx66f P; // normalized precision matrix = inverse covariance + cv::Vec6f y; // P*(-t_MH, t_CH) }; -#endif //TRANSCALIB_H \ No newline at end of file +#endif //TRANSCALIB_H -- cgit v1.2.3 From e44bc913ca3d212e5e8eea8c70c47d58c633f335 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 27 Sep 2014 20:58:23 +0200 Subject: options: move to base class for clarity --- facetracknoir/options.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index ce705033d..291ac0719 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -29,6 +29,8 @@ namespace options { template + // don't elide usages of the function, qvariant default implicit + // conversion results in nonsensical runtime behavior -sh inline T qcruft_to_t (const QVariant& t); template<> @@ -174,16 +176,28 @@ namespace options { } }; - typedef std::shared_ptr pbundle; + using pbundle = std::shared_ptr; class base_value : public QObject { Q_OBJECT public: base_value(pbundle b, const QString& name) : b(b), self_name(name), cookie_snap(0) {} - protected: virtual QVariant operator=(const QVariant& datum) = 0; + template + QVariant operator=(const T& datum) + { + return this->operator =(qVariantFromValue(datum)); + } + protected: pbundle b; QString self_name; + template + QVariant store(const T& datum) + { + b->store(self_name, qVariantFromValue(datum)); + emit valueChanged(datum); + return datum; + } void maybe_lazy_change() { long cookie = b->cookie(); @@ -211,33 +225,22 @@ namespace options { template class value : public base_value { - protected: + public: QVariant operator=(const QVariant& datum) { - auto foo = qcruft_to_t(datum); - b->store(self_name, qVariantFromValue(foo)); - emit valueChanged(foo); - return datum; + return store(qcruft_to_t(datum)); } - public: static constexpr const Qt::ConnectionType QT_CONNTYPE = Qt::UniqueConnection; static constexpr const Qt::ConnectionType OPT_CONNTYPE = Qt::UniqueConnection; - value(pbundle b, const QString& name, T def) : - base_value(b, name) + value(pbundle b, const QString& name, T def) : base_value(b, name) { if (!b->contains(name) || b->get(name).type() == QVariant::Invalid) - { this->operator=(qVariantFromValue(def)); - } } operator T() { maybe_lazy_change(); return b->get(self_name); } - QVariant operator=(const T& datum) - { - return this->operator =(qVariantFromValue(datum)); - } }; template -- cgit v1.2.3 From 8ba44aa35d45c1b16e755e2917421281b3e3f7bd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 27 Sep 2014 20:58:40 +0200 Subject: whitespace only --- facetracknoir/curve-config.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 813836887..abf03a5e4 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -3,11 +3,11 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidget *parent) : QWidget( parent, Qt::Dialog ), mainApp(ftnoir) { - ui.setupUi( this ); - + ui.setupUi( this ); + // rest of mapping settings taken care of by options::value mainApp->load_mappings(); - + { struct { QFunctionConfigurator* qfc; @@ -21,7 +21,7 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge { ui.txconfig, TX, false }, { ui.tyconfig, TY, false }, { ui.tzconfig, TZ, false }, - + { ui.rxconfig_alt, Yaw, true }, { ui.ryconfig_alt, Pitch, true}, { ui.rzconfig_alt, Roll, true }, @@ -30,24 +30,21 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge { ui.tzconfig_alt, TZ, true }, { nullptr, Yaw, false } }; - + for (int i = 0; qfcs[i].qfc; i++) { const bool altp = qfcs[i].altp; THeadPoseDOF& axis = mainApp->axis(qfcs[i].axis); FunctionConfig* conf = altp ? &axis.curveAlt : &axis.curve; const auto& name = qfcs[i].altp ? axis.name2 : axis.name1; - + qfcs[i].qfc->setConfig(conf, name); } } - + setFont(qApp->font()); QPoint offsetpos(120, 30); - this->move(parent->pos() + offsetpos); - - - + this->move(parent->pos() + offsetpos); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); @@ -75,7 +72,7 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge tie_setting(mainApp->s.a_x.invert, ui.invert_x); tie_setting(mainApp->s.a_y.invert, ui.invert_y); tie_setting(mainApp->s.a_z.invert, ui.invert_z); - + tie_setting(mainApp->s.a_yaw.src, ui.src_yaw); tie_setting(mainApp->s.a_pitch.src, ui.src_pitch); tie_setting(mainApp->s.a_roll.src, ui.src_roll); @@ -85,8 +82,8 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge } void CurveConfigurationDialog::doOK() { - save(); - this->close(); + save(); + this->close(); } void CurveConfigurationDialog::doCancel() { -- cgit v1.2.3 From 64c4efe12e7cc1739551578b242b73481b99931b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 27 Sep 2014 20:59:22 +0200 Subject: don't recalculate covariance for N frames like a drooling retard --- facetracknoir/gain-control.hpp | 96 ++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 45 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/gain-control.hpp b/facetracknoir/gain-control.hpp index 73155cd8f..5958e945d 100644 --- a/facetracknoir/gain-control.hpp +++ b/facetracknoir/gain-control.hpp @@ -31,9 +31,9 @@ namespace detail { zip_iterator(const t1& it1, const t1& end1, const t2& it2, const t2& end2) : x1(it1), z1(end1), x2(it2), z2(end2) { maybe_end(); } constexpr zip_iterator() {} - + static constexpr self end() { return self(); } - + self operator++() { x1++; x2++; self tmp = *this; maybe_end(); return tmp; } self operator++(int) { self tmp(*this); x1++; x2++; maybe_end(); return tmp; } bool operator==(const self& rhs) const { return x1 == rhs.x1 && x2 == rhs.x2; } @@ -48,27 +48,30 @@ private: static constexpr int box_size = 16 / 640.; static constexpr double control_upper_bound = 1.0; // XXX FIXME implement for logitech crapola static constexpr int GAIN_HISTORY_COUNT = 50, GAIN_HISTORY_EVERY_MS = 998; - + + using t_frame = cv::Mat_; + int control; double step, eps; - - std::deque means_history; + + t_frame last_frame; + std::deque means_history; Timer debug_timer, history_timer; - + typedef unsigned char px; template using zip_iterator = detail::zip_iterator; - + static double mean(const cv::Mat& frame) { // grayscale only assert(frame.channels() == 1); assert(frame.elemSize() == 1); assert(!frame.empty()); - + return std::accumulate(frame.begin(), frame.end(), 0.) / (frame.rows * frame.cols); } - + static double get_variance(const cv::Mat& frame, double mean) { struct variance { @@ -82,20 +85,20 @@ private: return seed + tmp * tmp; } } logic(mean); - + return std::accumulate(frame.begin(), frame.end(), 0., logic) / (frame.rows * frame.cols); } - + static double get_covariance(const cv::Mat& frame, const cv::Mat& old_frame) { double mean_0 = mean(frame), mean_1 = mean(old_frame); - + struct covariance { public: using pair = std::tuple; private: double mu_0, mu_1; - + inline double Cov(double seed, const pair& t) { px p0 = std::get<0>(t); @@ -104,40 +107,40 @@ private: } public: covariance(double mu_0, double mu_1) : mu_0(mu_0), mu_1(mu_1) {} - + double operator()(double seed, const pair& t) { return Cov(seed, t); } } logic(mean_0, mean_1); - + const double N = frame.rows * frame.cols; - + using zipper = zip_iterator, cv::MatConstIterator_, std::tuple>; - + zipper zip(frame.begin(), frame.end(), old_frame.begin(), old_frame.end()); std::vector values(zip, zipper::end()); - + return std::accumulate(values.begin(), values.end(), 0., logic) / N; } - + #pragma GCC diagnostic ignored "-Wsign-compare" - + public: Gain(int control = CV_CAP_PROP_GAIN, double step = 0.3, double eps = 0.02) : control(control), step(step), eps(eps) { } - + void tick(cv::VideoCapture&, const cv::Mat& frame_) { cv::Mat frame; - + if (use_box_filter) { cv::Mat tmp(frame_); @@ -148,42 +151,45 @@ public: } else frame = frame_; - + + if (last_frame.rows != frame.rows || last_frame.cols != frame.cols) + last_frame = t_frame(); + + if (last_frame.empty()) + { + last_frame = frame.clone(); + //return; + } + + if (history_timer.elapsed_ms() > GAIN_HISTORY_EVERY_MS) + { + const double cov = get_covariance(frame, last_frame); + history_timer.start(); + last_frame = frame.clone(); + + if (means_history.size() == GAIN_HISTORY_COUNT) + means_history.pop_back(); + } + if (debug_timer.elapsed_ms() > 1000) { const double mu = mean(frame); const double var = get_variance(frame, mu); - + debug_timer.start(); qDebug() << "---- gain:" << "mean" << mu << "variance" << var; const int sz = means_history.size(); if (sz) - fprintf(stderr, "covs: "); - - for (int i = 0; i < sz; i++) { - if (means_history[i].rows != frame.rows || means_history[i].cols != frame.cols) - { - means_history.clear(); - qDebug() << "\n!!! resolution reset"; - break; - } - fprintf(stderr, "%f ", get_covariance(frame, means_history[i])); - } + fprintf(stderr, "covs{%d}: ", sz); + + for (int i = 0; i < sz; i++) + fprintf(stderr, "%f ", means_history[i]); - if (sz) fprintf(stderr, "\n"); - } - - if (GAIN_HISTORY_COUNT > means_history.size() && history_timer.elapsed_ms() > GAIN_HISTORY_EVERY_MS) - { - history_timer.start(); - means_history.push_front(frame.clone()); - - if (GAIN_HISTORY_COUNT == means_history.size()) - means_history.pop_back(); + } } } }; -- cgit v1.2.3 From e1d3df8a07177ae04948dc6e9b7c4d2af7972b5f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 28 Sep 2014 00:33:21 +0200 Subject: fix pose digitcount --- facetracknoir/facetracknoir.ui | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 1a006809c..1d769f0d0 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -598,7 +598,7 @@ QFrame::NoFrame - 1 + 3 QLCDNumber::Outline @@ -620,7 +620,7 @@ QFrame::NoFrame - 1 + 3 QLCDNumber::Outline @@ -668,7 +668,7 @@ QFrame::NoFrame - 1 + 3 QLCDNumber::Outline @@ -690,7 +690,7 @@ QFrame::NoFrame - 1 + 3 QLCDNumber::Outline @@ -750,7 +750,7 @@ QFrame::NoFrame - 1 + 3 QLCDNumber::Outline @@ -798,7 +798,7 @@ QFrame::NoFrame - 1 + 3 QLCDNumber::Outline @@ -857,7 +857,7 @@ true - 1 + 3 QLCDNumber::Flat @@ -885,7 +885,7 @@ true - 1 + 3 QLCDNumber::Flat @@ -935,7 +935,7 @@ true - 1 + 3 QLCDNumber::Flat @@ -991,7 +991,7 @@ true - 1 + 3 QLCDNumber::Flat @@ -1069,7 +1069,7 @@ true - 1 + 3 QLCDNumber::Flat @@ -1119,7 +1119,7 @@ true - 1 + 3 QLCDNumber::Flat @@ -1170,11 +1170,6 @@ - video_feed - controls - headpose - octopus - box_mapped_headpose -- cgit v1.2.3 From 3f18a2e9bf16ea1f9eb681d42aefe0d1270612a8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Oct 2014 20:53:30 +0200 Subject: prevent reset to origin on pause hotkey Issue: #72 Reported-by: @Pretagonist --- facetracknoir/tracker.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 72ad22b42..003324a7c 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -40,10 +40,10 @@ Tracker::~Tracker() static void get_curve(double pos, double& out, THeadPoseDOF& axis) { bool altp = (pos < 0) && axis.opts.altp; axis.curve.setTrackingActive( !altp ); - axis.curveAlt.setTrackingActive( altp ); + axis.curveAlt.setTrackingActive( altp ); auto& fc = altp ? axis.curveAlt : axis.curve; out = (axis.opts.invert ? -1 : 1) * fc.getValue(pos); - + out += axis.opts.zero; } @@ -114,13 +114,13 @@ void Tracker::run() { for (int i = 0; i < 6; i++) { raw_6dof.axes[i] = newpose[i]; - + auto& axis = mainApp->axis(i); - + int k = axis.opts.src; if (k < 0 || k >= 6) continue; - + axis.headPos = newpose[k]; } @@ -143,6 +143,8 @@ void Tracker::run() { target_camera2 = target_camera - offset_camera; } + else + target_camera2 = raw_6dof; if (Libraries->pFilter) { Libraries->pFilter->FilterHeadPoseData(target_camera2.axes, new_camera.axes); @@ -158,7 +160,7 @@ void Tracker::run() { t_compensate(output_camera.axes, output_camera.axes, mainApp->s.tcomp_tz); if (Libraries->pProtocol) { - Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); + Libraries->pProtocol->sendHeadposeToGame(output_camera.axes); } } -- cgit v1.2.3 From b8c5e24223988c84331693371bb9b0d71b7ef821 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Oct 2014 21:12:41 +0200 Subject: fix toggle axis enablement properly --- facetracknoir/tracker.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 003324a7c..17f1af5fb 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -136,15 +136,13 @@ void Tracker::run() { T6DOF target_camera, target_camera2, new_camera; - if (enabled) - { + if (!enabled) + target_camera = raw_6dof; + else for (int i = 0; i < 6; i++) target_camera.axes[i] = mainApp->axis(i).headPos; - target_camera2 = target_camera - offset_camera; - } - else - target_camera2 = raw_6dof; + target_camera2 = target_camera - offset_camera; if (Libraries->pFilter) { Libraries->pFilter->FilterHeadPoseData(target_camera2.axes, new_camera.axes); -- cgit v1.2.3 From 97bd173ee4b6f30c12ca590e213b21bbc83f8617 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Oct 2014 17:28:49 +0200 Subject: flush before windows breaks and data lossage --- CMakeLists.txt | 14 +- .../README-CREDIT.txt | 6 + .../ft_tester/Makefile.am | 54 +++ .../ft_tester/Makefile.in | 491 ++++++++++++++++++++ .../ft_tester/fttester.rc.in | 67 +++ .../ft_tester/main.cpp | 211 +++++++++ .../ft_tester/resource.h | 27 ++ .../important-stuff/NPClient.h | 17 + .../important-stuff/NPClient.spec | 23 + .../important-stuff/NPClient_dll.h | 58 +++ .../important-stuff/NPClient_main.c | 444 ++++++++++++++++++ .../important-stuff/game_data.c | 149 ++++++ .../important-stuff/game_data.h | 17 + .../tester/Makefile.am | 78 ++++ .../tester/Makefile.in | 512 +++++++++++++++++++++ .../tester/main.cpp | 100 ++++ .../tester/npifc.c | 302 ++++++++++++ .../tester/npifc.h | 66 +++ .../tester/npview.rc.in | 49 ++ .../tester/resource.h | 23 + .../tester/rest.c | 1 + .../tester/rest.h | 1 + facetracknoir/curve-config.cpp | 71 +-- facetracknoir/curve-config.h | 8 +- facetracknoir/facetracknoir.cpp | 213 ++++----- facetracknoir/facetracknoir.h | 59 ++- facetracknoir/mappings.hpp | 79 ++++ facetracknoir/plugin-qt-api.hpp | 8 +- facetracknoir/plugin-support.h | 2 +- facetracknoir/qcopyable-mutex.hpp | 37 ++ facetracknoir/rotation.h | 19 +- facetracknoir/tracker.cpp | 82 ++-- facetracknoir/tracker.h | 77 +--- facetracknoir/tracker_types.cpp | 43 -- facetracknoir/tracker_types.h | 65 ++- freetrackclient/freetrackclient.c | 38 +- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 11 +- ftnoir_protocol_ft/fttypes.h | 10 +- qfunctionconfigurator/functionconfig.cpp | 24 +- qfunctionconfigurator/functionconfig.h | 81 +--- qfunctionconfigurator/qfunctionconfigurator.cpp | 2 +- qfunctionconfigurator/qfunctionconfigurator.h | 6 +- 42 files changed, 3173 insertions(+), 472 deletions(-) create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/README-CREDIT.txt create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.am create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.in create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/fttester.rc.in create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/main.cpp create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/resource.h create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/NPClient.h create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/NPClient.spec create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/NPClient_dll.h create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/NPClient_main.c create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.c create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.h create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.am create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.in create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/main.cpp create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.c create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.h create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npview.rc.in create mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/resource.h create mode 120000 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.c create mode 120000 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.h create mode 100644 facetracknoir/mappings.hpp create mode 100644 facetracknoir/qcopyable-mutex.hpp delete mode 100644 facetracknoir/tracker_types.cpp (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ceffd54a..655d70c3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.11) cmake_policy(SET CMP0020 NEW) if(MSVC) - message(FATAL_ERROR "Support for MSVC removed due to incomplete C++11 support") + message(FATAL_ERROR "Support for MSVC removed due to incomplete C++11 support") endif() include(CMakeParseArguments) @@ -131,9 +131,9 @@ endif() set(EXTRA-MOCS "${CMAKE_SOURCE_DIR}/facetracknoir/options.h") function(link_with_dinput8 n) - if(WIN32) - target_link_libraries(${n} dinput8 dxguid strmiids) - endif() + if(WIN32) + target_link_libraries(${n} dinput8 dxguid strmiids) + endif() endfunction() macro(opentrack_module n dir) @@ -376,9 +376,9 @@ if(SDK_RIFT) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm setupapi ws2_32 imagehlp wbemuuid) else() if(NOT APPLE) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) else() - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") endif() endif() endif() @@ -426,7 +426,7 @@ if(UNIX OR APPLE) SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES COMPILE_FLAGS "-DBUILD_QXT_CORE=42 -DBUILD_QXT_WIDGETS=42 -DBUILD_QXT_GUI=42") target_link_libraries(opentrack-qxt-mini ${MY_QT_LIBS}) if(NOT APPLE) - target_link_libraries(opentrack-qxt-mini X11) + target_link_libraries(opentrack-qxt-mini X11) endif() endif() diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/README-CREDIT.txt b/facetracknoir/clientfiles/important-source-code-really-important-really-really/README-CREDIT.txt new file mode 100644 index 000000000..822141393 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/README-CREDIT.txt @@ -0,0 +1,6 @@ +The contents of the directory written by one and only, uglyDwarf. + +Obtained at epoch time 1412397452 from the mithril-mine's shaft, where +the elite dwarves reside. + +For the latest happenings, visit diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.am b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.am new file mode 100644 index 000000000..02747edb4 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.am @@ -0,0 +1,54 @@ +noinst_SCRIPTS = +if WINE_PLUGIN + noinst_SCRIPTS += ftc.exe.so +endif #WINE_PLUGIN + +if DARWIN + LDFLAGS += -Wl,-no_arch_warnings +else + LDFLAGS += -Wl,--no-warn-search-mismatch +endif + +CC = winegcc + +CXX = wineg++ + +SUFFIXES = .o .cpp .c .rc + +.cpp.o : + $(CXX) -c $(CXXFLAGS_PRE) $(CXXFLAGS) $(CPPFLAGS) -m32 -o $@ $< + +.c.o : + $(CC) -c $(CFLAGS_PRE) $(CFLAGS) $(CPPFLAGS) -m32 -o $@ $< + +.rc.o : + wrc -o $@ $(RCFLAGS) $< + +CXXFLAGS_PRE = -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@ +CFLAGS_PRE = -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@ +RCFLAGS = -I @srcdir@ +#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ +vpath %.h @srcdir@/../.. +vpath %.h @top_builddir@ +vpath %.c @srcdir@ +vpath %.c @srcdir@/../.. + +ftc.exe.so : main.o fttester.o + wineg++ -g -o $@ -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ + +fttester.o : fttester.rc resource.h config.h + +main.o : main.cpp + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +distclean-local: distclean-local-check +.PHONY: distclean-local-check +distclean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +EXTRA_DIST = resource.h fttester.rc main.cpp + diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.in b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.in new file mode 100644 index 000000000..d1fff34d1 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.in @@ -0,0 +1,491 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@WINE_PLUGIN_TRUE@am__append_1 = ftc.exe.so +@DARWIN_TRUE@am__append_2 = -Wl,-no_arch_warnings +@DARWIN_FALSE@am__append_3 = -Wl,--no-warn-search-mismatch +subdir = src/wine_bridge/ft_tester +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(srcdir)/fttester.rc.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = fttester.rc +CONFIG_CLEAN_VPATH_FILES = +SCRIPTS = $(noinst_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +depcomp = +am__depfiles_maybe = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BISON = @BISON@ +CC = winegcc +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = wineg++ +CXXCPP = @CXXCPP@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ $(am__append_2) $(am__append_3) +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIB32DIR = @LIB32DIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCFLAGS = @OBJCFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENCV_CFLAGS = @OPENCV_CFLAGS@ +OPENCV_LIBS = @OPENCV_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +QMAKE_PATH = @QMAKE_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +WINE64_LIBS = @WINE64_LIBS@ +WINE_LIBS = @WINE_LIBS@ +XPL_CPPFLAGS = @XPL_CPPFLAGS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_OBJC = @ac_ct_OBJC@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +with_makensis = @with_makensis@ +with_wine64 = @with_wine64@ +noinst_SCRIPTS = $(am__append_1) +SUFFIXES = .o .cpp .c .rc +CXXFLAGS_PRE = -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@ +CFLAGS_PRE = -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@ +RCFLAGS = -I @srcdir@ +EXTRA_DIST = resource.h fttester.rc main.cpp +all: all-am + +.SUFFIXES: +.SUFFIXES: .o .cpp .c .rc +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/ft_tester/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/ft_tester/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +fttester.rc: $(top_builddir)/config.status $(srcdir)/fttester.rc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-local mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-local + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + clean-local cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distclean-local distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am + + +.cpp.o : + $(CXX) -c $(CXXFLAGS_PRE) $(CXXFLAGS) $(CPPFLAGS) -m32 -o $@ $< + +.c.o : + $(CC) -c $(CFLAGS_PRE) $(CFLAGS) $(CPPFLAGS) -m32 -o $@ $< + +.rc.o : + wrc -o $@ $(RCFLAGS) $< +#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ +vpath %.h @srcdir@/../.. +vpath %.h @top_builddir@ +vpath %.c @srcdir@ +vpath %.c @srcdir@/../.. + +ftc.exe.so : main.o fttester.o + wineg++ -g -o $@ -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ + +fttester.o : fttester.rc resource.h config.h + +main.o : main.cpp + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +distclean-local: distclean-local-check +.PHONY: distclean-local-check +distclean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/fttester.rc.in b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/fttester.rc.in new file mode 100644 index 000000000..332f3c73c --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/fttester.rc.in @@ -0,0 +1,67 @@ +// Generated by ResEdit 1.5.9 +// Copyright (C) 2006-2011 +// http://www.resedit.net + +#include +#include +#include +#include "resource.h" + +#ifdef HAVE_CONFIG_H + #include "../../../config.h" +#endif + + + + +// +// Dialog resources +// +//LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +IDD_DIALOG1 DIALOGEX 0, 0, 333, 183 +STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU +CAPTION "FreeTrack client test utility v@PACKAGE_VERSION@" +FONT 8, "Ms Shell Dlg", 400, 0, 1 +{ + DEFPUSHBUTTON "Quit", IDQUIT, 262, 153, 50, 14 + PUSHBUTTON "Start", IDC_START, 199, 153, 50, 14 + EDITTEXT IDC_YAW, 38, 15, 48, 14, ES_AUTOHSCROLL + RTEXT "Yaw", IDC_STATIC, 12, 17, 21, 14, SS_RIGHT + EDITTEXT IDC_PITCH, 38, 38, 48, 14, ES_AUTOHSCROLL + RTEXT "Pitch", IDC_STATIC, 16, 40, 17, 14, SS_RIGHT + EDITTEXT IDC_ROLL, 38, 61, 48, 14, ES_AUTOHSCROLL + RTEXT "Roll", IDC_STATIC, 20, 63, 13, 14, SS_RIGHT + EDITTEXT IDC_X, 38, 84, 48, 14, ES_AUTOHSCROLL + RTEXT "X", IDC_STATIC, 27, 86, 6, 14, SS_RIGHT + EDITTEXT IDC_Y, 38, 107, 48, 14, ES_AUTOHSCROLL + RTEXT "Y", IDC_STATIC, 27, 109, 6, 14, SS_RIGHT + EDITTEXT IDC_Z, 38, 130, 48, 14, ES_AUTOHSCROLL + RTEXT "Z", IDC_STATIC, 27, 132, 6, 14, SS_RIGHT + EDITTEXT IDC_RYAW, 137, 15, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Yaw", IDC_STATIC, 101, 17, 32, 8, SS_RIGHT + EDITTEXT IDC_RPITCH, 137, 38, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Pitch", IDC_STATIC, 99, 40, 34, 8, SS_RIGHT + EDITTEXT IDC_RROLL, 137, 61, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Roll", IDC_STATIC, 103, 63, 30, 8, SS_RIGHT + EDITTEXT IDC_RX, 137, 84, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw X", IDC_STATIC, 111, 86, 22, 8, SS_RIGHT + EDITTEXT IDC_RY, 137, 107, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Y", IDC_STATIC, 111, 109, 22, 8, SS_RIGHT + EDITTEXT IDC_RZ, 137, 130, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Z", IDC_STATIC, 111, 132, 22, 8, SS_RIGHT + EDITTEXT IDC_NUM, 264, 15, 48, 14, ES_AUTOHSCROLL + RTEXT "Frame Number", IDC_STATIC, 212, 17, 47, 8, SS_RIGHT + EDITTEXT IDC_RES, 264, 38, 48, 14, ES_AUTOHSCROLL + RTEXT "Camera Resolution", IDC_STATIC, 199, 40, 60, 8, SS_RIGHT + EDITTEXT IDC_PT0, 227, 61, 85, 14, ES_AUTOHSCROLL + RTEXT "Point 1", IDC_STATIC, 199, 63, 23, 8, SS_RIGHT + EDITTEXT IDC_PT1, 227, 84, 85, 14, ES_AUTOHSCROLL + RTEXT "Point 2", IDC_STATIC, 199, 86, 23, 8, SS_RIGHT + EDITTEXT IDC_PT2, 227, 107, 85, 14, ES_AUTOHSCROLL + RTEXT "Point 3", IDC_STATIC, 199, 109, 23, 8, SS_RIGHT + EDITTEXT IDC_PT3, 227, 130, 85, 14, ES_AUTOHSCROLL + RTEXT "Point 4", IDC_STATIC, 199, 132, 23, 8, SS_RIGHT + EDITTEXT IDC_TITLE, 38, 153, 147, 14, ES_AUTOHSCROLL + RTEXT "Title", IDC_STATIC, 19, 155, 14, 8, SS_RIGHT +} + diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/main.cpp b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/main.cpp new file mode 100644 index 000000000..a737f88f5 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/main.cpp @@ -0,0 +1,211 @@ +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include +#include +#include +#include + +#include "resource.h" + +HINSTANCE hInst; +UINT_PTR timer = 0; + +HMODULE ftclient; + +typedef struct +{ + unsigned int dataID; + int res_x; int res_y; + float yaw; // positive yaw to the left + float pitch;// positive pitch up + float roll;// positive roll to the left + float x; + float y; + float z; + // raw pose with no smoothing, sensitivity, response curve etc. + float ryaw; + float rpitch; + float rroll; + float rx; + float ry; + float rz; + // raw points, sorted by Y, origin top left corner + float x0, y0; + float x1, y1; + float x2, y2; + float x3, y3; +}FreeTrackData; + + +typedef bool (WINAPI *importGetData)(FreeTrackData * data); +typedef char *(WINAPI *importGetDllVersion)(void); +typedef void (WINAPI *importReportName)(char *name); +typedef char *(WINAPI *importProvider)(void); + +importGetData getData; +importGetDllVersion getDllVersion; +importReportName reportName; +importProvider provider; + + +char *client_path() +{ + HKEY hkey = 0; + RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Freetrack\\FreetrackClient", 0, + KEY_QUERY_VALUE, &hkey); + if(!hkey){ + printf("Can't open registry key\n"); + return NULL; + } + + BYTE path[1024]; + DWORD buf_len = 1024; + LONG result = RegQueryValueEx(hkey, "Path", NULL, NULL, path, &buf_len); + char *full_path = (char *)malloc(2048); + if(result == ERROR_SUCCESS && buf_len > 0){ + sprintf(full_path, "%s\\FreeTrackClient.dll", path); + } + RegCloseKey(hkey); + return full_path; +} + + +bool start(HWND hwnd) +{ + char *libname = client_path(); + if(libname == NULL){ + printf("Freetrack client not found!\n"); + return false; + } + ftclient = LoadLibrary(libname); + if(ftclient == NULL){ + printf("Couldn't load Freetrack client library '%s'!\n", libname); + return false; + } + printf("Freetrack client library %s loaded.\n", client_path()); + + + getData = (importGetData)GetProcAddress(ftclient, "FTGetData"); + getDllVersion = (importGetDllVersion)GetProcAddress(ftclient, "FTGetDllVersion"); + reportName = (importReportName)GetProcAddress(ftclient, "FTReportName"); + provider = (importProvider)GetProcAddress(ftclient, "FTProvider"); + + if((getData == NULL) || (getDllVersion == NULL) || (reportName == NULL) || (provider == NULL)){ + printf("Couldn't load Freetrack client functions!\n"); + FreeLibrary(ftclient); + return false; + } + + printf("Dll version: %s\n", getDllVersion()); + printf("Provider: %s\n", provider()); + char title[1024]; + GetDlgItemText(hwnd, IDC_TITLE, title, 1020); + reportName(title); + return true; +} + +void reportError(std::string msg) +{ + MessageBoxA(0, "FreeTrack client test", msg.c_str(), 0); +} +VOID CALLBACK TimerProcedure(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + (void) uMsg; + (void) idEvent; + (void) dwTime; + FreeTrackData d; + getData(&d); + SetDlgItemInt(hwnd, IDC_PITCH, d.pitch, true); + SetDlgItemInt(hwnd, IDC_ROLL, d.roll, true); + SetDlgItemInt(hwnd, IDC_YAW, d.yaw, true); + + SetDlgItemInt(hwnd, IDC_X, d.x, true); + SetDlgItemInt(hwnd, IDC_Y, d.y, true); + SetDlgItemInt(hwnd, IDC_Z, d.z, true); + + SetDlgItemInt(hwnd, IDC_RPITCH, d.rpitch, true); + SetDlgItemInt(hwnd, IDC_RROLL, d.rroll, true); + SetDlgItemInt(hwnd, IDC_RYAW, d.ryaw, true); + + SetDlgItemInt(hwnd, IDC_RX, d.rx, true); + SetDlgItemInt(hwnd, IDC_RY, d.ry, true); + SetDlgItemInt(hwnd, IDC_RZ, d.rz, true); + + std::ostringstream s; + s.str(std::string()); + s<<"("< +#include "rest.h" +//#include "config.h" +#define __WINESRC__ + +#include +#include +#include +#include +#include +#include +#include "windef.h" +#include "winbase.h" +#include "NPClient_dll.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(NPClient); + +bool crypted = false; +static unsigned char table[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static int dbg_flag; + +static void dbg_report(const char *msg,...) +{ + static FILE *f = NULL; + if(dbg_flag){ + if(f == NULL){ + f = fopen("NPClient.log", "w"); + } + va_list ap; + va_start(ap,msg); + vfprintf(f, msg, ap); + fflush(f); + va_end(ap); + } +} + + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); + + switch (fdwReason) + { + case DLL_WINE_PREATTACH: + return TRUE; + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + dbg_flag = getDebugFlag('w'); + dbg_report("Attach request\n"); + break; + case DLL_PROCESS_DETACH: + linuxtrack_shutdown(); + break; + } + + return TRUE; +} +/****************************************************************** + * NPPriv_ClientNotify (NPCLIENT.1) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_ClientNotify() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_GetLastError (NPCLIENT.2) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_GetLastError() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetData (NPCLIENT.3) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetData() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetLastError (NPCLIENT.4) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetLastError() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetParameter (NPCLIENT.5) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetParameter() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetSignature (NPCLIENT.6) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetSignature() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetVersion (NPCLIENT.7) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetVersion() +{ + /* @stub in .spec */ +} +#endif + +static float limit_num(float min, float val, float max) +{ + if(val < min) return min; + if(val > max) return max; + return val; +} + +static unsigned int cksum(unsigned char buf[], unsigned int size) +{ + if((size == 0) || (buf == NULL)){ + return 0; + } + + int rounds = size >> 2; + int rem = size % 4; + + int c = size; + int a0, a2; +// printf("Orig: "); +//for(a0 = 0; a0 < (int)size; ++a0) +//{ +// printf("%02X", buf[a0]); +//} +//printf("\n"); + while(rounds != 0){ + a0 = *(short int*)buf; + a2 = *(short int*)(buf+2); + buf += 4; + c += a0; + a2 ^= (c << 5); + a2 <<= 11; + c ^= a2; + c += (c >> 11); + --rounds; + } + switch(rem){ + case 3: + a0 = *(short int*)buf; + a2 = *(signed char*)(buf+2); + c += a0; + a2 = (a2 << 2) ^ c; + c ^= (a2 << 16); + a2 = (c >> 11); + break; + case 2: + a2 = *(short int*)buf; + c += a2; + c ^= (c << 11); + a2 = (c >> 17); + break; + case 1: + a2 = *(signed char*)(buf); + c += a2; + c ^= (c << 10); + a2 = (c >> 1); + break; + default: + break; + } + if(rem != 0){ + c+=a2; + } + + c ^= (c << 3); + c += (c >> 5); + c ^= (c << 4); + c += (c >> 17); + c ^= (c << 25); + c += (c >> 6); + + return (unsigned int)c; +} + +static void enhance(unsigned char buf[], unsigned int size, + unsigned char codetable[], unsigned int table_size) +{ + unsigned int table_ptr = 0; + unsigned char var = 0x88; + unsigned char tmp; + if((size <= 0) || (table_size <= 0) || + (buf == NULL) || (codetable == NULL)){ + return; + } + do{ + tmp = buf[--size]; + buf[size] = tmp ^ codetable[table_ptr] ^ var; + var += size + tmp; + ++table_ptr; + if(table_ptr >= table_size){ + table_ptr -= table_size; + } + }while(size != 0); +} + + +/****************************************************************** + * NP_GetData (NPCLIENT.8) + * + * + */ +int __stdcall NPCLIENT_NP_GetData(tir_data_t * data) +{ + float r, p, y, tx, ty, tz; + unsigned int frame; + int res = linuxtrack_get_pose(&y, &p, &r, &tx, &ty, &tz, &frame); + memset((char *)data, 0, sizeof(tir_data_t)); + data->status = (linuxtrack_get_tracking_state() == RUNNING) ? 0 : 1; + data->frame = frame & 0xFFFF; + data->cksum = 0; + data->roll = r / 180.0 * 16383; + data->pitch = -p / 180.0 * 16383; + data->yaw = y / 180.0 * 16383; + data->tx = -limit_num(-16383.0, 15 * tx, 16383); + data->ty = limit_num(-16383.0, 15 * ty, 16383); + data->tz = limit_num(-16383.0, 15 * tz, 16383); + data->cksum = cksum((unsigned char*)data, sizeof(tir_data_t)); + //printf("Cksum: %04X\n", data->cksum); + if(crypted){ + enhance((unsigned char*)data, sizeof(tir_data_t), table, sizeof(table)); + } + return (res >= 0) ? 0: 1; +} +/****************************************************************** + * NP_GetParameter (NPCLIENT.9) + * + * + */ +int __stdcall NPCLIENT_NP_GetParameter(int arg0, int arg1) +{ + dbg_report("GetParameter request: %d %d\n", arg0, arg1); + TRACE("(void): stub\n"); + return (int) 0; +} + +/****************************************************************** + * NP_GetSignature (NPCLIENT.10) + * + * + */ +int __stdcall NPCLIENT_NP_GetSignature(tir_signature_t * sig) +{ + dbg_report("GetSignature request\n"); + if(getSomeSeriousPoetry(sig->DllSignature, sig->AppSignature)){ + printf("Signature result: OK\n"); + return 0; + }else{ + printf("Signature result: NOT OK!\n"); + return 1; + } +} +/****************************************************************** + * NP_QueryVersion (NPCLIENT.11) + * + * + */ +int __stdcall NPCLIENT_NP_QueryVersion(unsigned short * version) +{ + dbg_report("QueryVersion request\n"); + *version=0x0500; + return 0; +} +/****************************************************************** + * NP_ReCenter (NPCLIENT.12) + * + * + */ +int __stdcall NPCLIENT_NP_ReCenter(void) +{ + dbg_report("ReCenter request\n"); + linuxtrack_recenter(); + return 0; +} + +/****************************************************************** + * NP_RegisterProgramProfileID (NPCLIENT.13) + * + * + */ +int __stdcall NPCLIENT_NP_RegisterProgramProfileID(unsigned short id) +{ + dbg_report("RegisterProgramProfileID request: %d\n", id); + game_desc_t gd; + if(game_data_get_desc(id, &gd)){ + printf("Application ID: %d - %s!!!\n", id, gd.name); + if(game_data_get_desc(id, &gd)){ + crypted = gd.encrypted; + if(gd.encrypted){ + printf("Table: %02X %02X %02X %02X %02X %02X %02X %02X\n", table[0],table[1],table[2],table[3],table[4], + table[5], table[6], table[7]); + table[0] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[1] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[2] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[3] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[4] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[5] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[6] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[7] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + } + } + if(linuxtrack_init(gd.name) != 0){ + return 1; + } + }else{ + if(!linuxtrack_init("Default")){ + return 1; + } + } + linuxtrack_suspend(); + return 0; +} +/****************************************************************** + * NP_RegisterWindowHandle (NPCLIENT.14) + * + * + */ +int __stdcall NPCLIENT_NP_RegisterWindowHandle(HWND hwnd) +{ + dbg_report("RegisterWindowHandle request: 0x%X\n", hwnd); + TRACE("((HWND)%p): stub\n",hwnd); + return (int) 0; +} +/****************************************************************** + * NP_RequestData (NPCLIENT.15) + * + * + */ +int __stdcall NPCLIENT_NP_RequestData(unsigned short req) +{ + dbg_report("RequestData request: %d\n", req); + TRACE("((unsigned short)%d): stub\n",req); + return (int) 0; +} +/****************************************************************** + * NP_SetParameter (NPCLIENT.16) + * + * + */ +int __stdcall NPCLIENT_NP_SetParameter(int arg0, int arg1) +{ + dbg_report("SetParameter request: %d %d\n", arg0, arg1); + TRACE("(void): stub\n"); + return (int) 0; +} +/****************************************************************** + * NP_StartCursor (NPCLIENT.17) + * + * + */ +int __stdcall NPCLIENT_NP_StartCursor(void) +{ + dbg_report("StartCursor request\n"); + TRACE("(void): stub\n"); + return (int) 0; +} +/****************************************************************** + * NP_StartDataTransmission (NPCLIENT.18) + * + * + */ +int __stdcall NPCLIENT_NP_StartDataTransmission(void) +{ + dbg_report("StartDataTransmission request\n"); + linuxtrack_wakeup(); + return 0; +} +/****************************************************************** + * NP_StopCursor (NPCLIENT.19) + * + * + */ +int __stdcall NPCLIENT_NP_StopCursor(void) +{ + dbg_report("StopCursor request\n"); + TRACE("(void): stub\n"); + return (int) 0; +} +/****************************************************************** + * NP_StopDataTransmission (NPCLIENT.20) + * + * + */ +int __stdcall NPCLIENT_NP_StopDataTransmission(void) +{ + dbg_report("StopDataTransmission request\n"); + linuxtrack_suspend(); + return 0; +} +/****************************************************************** + * NP_UnregisterWindowHandle (NPCLIENT.21) + * + * + */ +int __stdcall NPCLIENT_NP_UnregisterWindowHandle(void) +{ + dbg_report("UnregisterWindowHandle request\n"); + TRACE("(void): stub\n"); + return (int) 0; +} + diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.c b/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.c new file mode 100644 index 000000000..3197ba379 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.c @@ -0,0 +1,149 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + + +//First 5 bytes is MD5 hash of "NaturalPoint" +static uint8_t secret_key[] = {0x0e, 0x9a, 0x63, 0x71, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static uint8_t S[256] = {0}; + +static char *decoded = NULL; + +static mxml_node_t *xml = NULL; +static mxml_node_t *tree = NULL; + +static void ksa(uint8_t key[], size_t len) +{ + unsigned int i, j; + for(i = 0; i < 256; ++i){ + S[i] = i; + } + j = 0; + for(i = 0; i < 256; ++i){ + j = (j + S[i] + key[i % len]) % 256; + uint8_t tmp = S[i]; + S[i] = S[j]; + S[j] = tmp; + } +} + +static uint8_t rc4() +{ + static uint8_t i = 0; + static uint8_t j = 0; + + i += 1; + j += S[i]; + uint8_t tmp = S[i]; + S[i] = S[j]; + S[j] = tmp; + return S[(S[i] + S[j]) % 256]; +} + +static bool decrypt_file(const char *fname, bool from_update) +{ + uint32_t header[5]; + size_t datlen; + ksa(secret_key, 16); + FILE *inp; + struct stat fst; + + if((inp = fopen(fname, "rb")) == NULL){ + printf("Can't open input file '%s'", fname); + return false; + } + + if(fstat(fileno(inp), &fst) != 0){ + fclose(inp); + printf("Cannot stat file '%s'\n", fname); + return false; + } + + if(from_update){ + if(fread(&header, sizeof(uint32_t), 5, inp) != 5){ + fclose(inp); + printf("Can't read the header - file '%s' is less than 20 bytes long?\n", fname); + return false; + } + datlen = header[4]; + }else{ + datlen = fst.st_size; + } + if((decoded = (char *)malloc(datlen+1)) == NULL){ + printf("malloc failed!\n"); + return false; + } + memset(decoded, 0, datlen+1); + size_t i; + size_t len = fread(decoded, 1, datlen, inp); + (void) len; + for(i = 0; i < datlen; ++i) decoded[i] ^= rc4(); + fclose(inp); + + //inp = fopen("tmp.dump", "w"); + //fwrite(decoded, 1, datlen, inp); + //fclose(inp); + + return true; +} + +static bool game_data_init(const char *fname, bool from_update) +{ + static bool initialized = false; + if(initialized){ + return true; + } + if(!decrypt_file(fname, from_update)){ + printf("Error decrypting file!\n"); + return false; + } + xml = mxmlNewXML("1.0"); + tree = mxmlLoadString(xml, decoded, MXML_TEXT_CALLBACK); + return (tree != NULL); +} + +static void game_data_close() +{ + mxmlDelete(tree); + free(decoded); +} + +bool get_game_data(const char *input_fname, const char *output_fname, bool from_update) +{ + FILE *outfile = NULL; + if((outfile = fopen(output_fname, "w")) == NULL){ + ltr_int_log_message("Can't open the output file '%s'!\n", output_fname); + return false; + } + if(!game_data_init(input_fname, from_update)){ + ltr_int_log_message("Can't process the data file '%s'!\n", input_fname); + return false; + } + + mxml_node_t *game; + const char *name; + const char *id; + for(game = mxmlFindElement(tree, tree, "Game", NULL, NULL, MXML_DESCEND); + game != NULL; + game = mxmlFindElement(game, tree, "Game", NULL, NULL, MXML_DESCEND)){ + name = mxmlElementGetAttr(game, "Name"); + id = mxmlElementGetAttr(game, "Id"); + + mxml_node_t *appid = mxmlFindElement(game, game, "ApplicationID", NULL, NULL, MXML_DESCEND); + if(appid == NULL){ + fprintf(outfile, "%s \"%s\"\n", id, name); + }else{ + fprintf(outfile, "%s \"%s\" (%s)\n", id, name, appid->child->value.text.string); + } + } + fclose(outfile); + game_data_close(); + return true; +} + diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.h b/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.h new file mode 100644 index 000000000..b71f7a15d --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.h @@ -0,0 +1,17 @@ +#ifndef GAME_DATA__H +#define GAME_DATA__H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +bool get_game_data(const char *input_fname, const char *output_fname, bool from_update); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.am b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.am new file mode 100644 index 000000000..e025209a2 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.am @@ -0,0 +1,78 @@ +noinst_SCRIPTS = +if WINE_PLUGIN + noinst_SCRIPTS += Tester.exe +if WINE64 + noinst_SCRIPTS += Tester64.exe +endif #WINE64 +endif #WINE_PLUGIN + +if DARWIN + LDFLAGS += -Wl,-no_arch_warnings +else + LDFLAGS += -Wl,--no-warn-search-mismatch +endif + +CC = winegcc + +CXX = wineg++ + +SUFFIXES = .o .cpp .c .rc 64.o + +.cpp.o : + $(CXX) -c $(CXXFLAGS) -m32 -o $@ $< + +.c.o : + $(CC) -c $(CFLAGS) -m32 -o $@ $< + +.cpp64.o : + $(CXX) -c $(CXXFLAGS) -o $@ $< + +.c64.o : + $(CC) -c $(CFLAGS) -o $@ $< + +.rc.o : + wrc -o $@ $(RCFLAGS) $< + +CXXFLAGS += -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@ +CFLAGS += -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@ +RCFLAGS = -I @srcdir@ +#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ +vpath %.h @srcdir@/../.. +vpath %.h @top_builddir@ +vpath %.c @srcdir@ +vpath %.c @srcdir@/../.. + + +Tester64.exe : main64.o rest64.o npifc64.o npview.o + wineg++ -g -o Tester64 -L. $(WINE64_LIBS) $(LDFLAGS) -Wall -Wextra $^ + +Tester.exe : main.o npview.o rest.o npifc.o + wineg++ -g -o Tester -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ + +main.o : main.cpp Makefile + +main64.o : main.cpp Makefile + +npview.o : npview.rc + +rest.o : rest.c rest.h Makefile + +rest64.o : rest.c rest.h Makefile + +npifc.o : npifc.c npifc.h Makefile + +npifc64.o : CFLAGS+="-DFOR_WIN64=1" +npifc64.o : npifc.c npifc.h Makefile + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +distclean-local: distclean-local-check +.PHONY: distclean-local-check +distclean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +EXTRA_DIST = main.cpp npifc.c npifc.h resource.h rest.c rest.h + diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.in b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.in new file mode 100644 index 000000000..cc49d7542 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.in @@ -0,0 +1,512 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@WINE_PLUGIN_TRUE@am__append_1 = Tester.exe +@WINE64_TRUE@@WINE_PLUGIN_TRUE@am__append_2 = Tester64.exe +@DARWIN_TRUE@am__append_3 = -Wl,-no_arch_warnings +@DARWIN_FALSE@am__append_4 = -Wl,--no-warn-search-mismatch +subdir = src/wine_bridge/tester +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(srcdir)/npview.rc.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = npview.rc +CONFIG_CLEAN_VPATH_FILES = +SCRIPTS = $(noinst_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +depcomp = +am__depfiles_maybe = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BISON = @BISON@ +CC = winegcc +CFLAGS = @CFLAGS@ -g -I../.. -I../../.. -DHAVE_CONFIG_H \ + -I@srcdir@/../.. -I@top_builddir@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = wineg++ +CXXCPP = @CXXCPP@ +CXXFLAGS = @CXXFLAGS@ -g -DHAVE_CONFIG_H -I../../.. -I. \ + -I@srcdir@/../.. -I@top_builddir@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ $(am__append_3) $(am__append_4) +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIB32DIR = @LIB32DIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCFLAGS = @OBJCFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENCV_CFLAGS = @OPENCV_CFLAGS@ +OPENCV_LIBS = @OPENCV_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +QMAKE_PATH = @QMAKE_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +WINE64_LIBS = @WINE64_LIBS@ +WINE_LIBS = @WINE_LIBS@ +XPL_CPPFLAGS = @XPL_CPPFLAGS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_OBJC = @ac_ct_OBJC@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +with_makensis = @with_makensis@ +with_wine64 = @with_wine64@ +noinst_SCRIPTS = $(am__append_1) $(am__append_2) +SUFFIXES = .o .cpp .c .rc 64.o +RCFLAGS = -I @srcdir@ +EXTRA_DIST = main.cpp npifc.c npifc.h resource.h rest.c rest.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .o .cpp .c .rc 64.o +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/tester/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/tester/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +npview.rc: $(top_builddir)/config.status $(srcdir)/npview.rc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-local mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-local + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + clean-local cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distclean-local distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am + + +.cpp.o : + $(CXX) -c $(CXXFLAGS) -m32 -o $@ $< + +.c.o : + $(CC) -c $(CFLAGS) -m32 -o $@ $< + +.cpp64.o : + $(CXX) -c $(CXXFLAGS) -o $@ $< + +.c64.o : + $(CC) -c $(CFLAGS) -o $@ $< + +.rc.o : + wrc -o $@ $(RCFLAGS) $< +#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ +vpath %.h @srcdir@/../.. +vpath %.h @top_builddir@ +vpath %.c @srcdir@ +vpath %.c @srcdir@/../.. + +Tester64.exe : main64.o rest64.o npifc64.o npview.o + wineg++ -g -o Tester64 -L. $(WINE64_LIBS) $(LDFLAGS) -Wall -Wextra $^ + +Tester.exe : main.o npview.o rest.o npifc.o + wineg++ -g -o Tester -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ + +main.o : main.cpp Makefile + +main64.o : main.cpp Makefile + +npview.o : npview.rc + +rest.o : rest.c rest.h Makefile + +rest64.o : rest.c rest.h Makefile + +npifc.o : npifc.c npifc.h Makefile + +npifc64.o : CFLAGS+="-DFOR_WIN64=1" +npifc64.o : npifc.c npifc.h Makefile + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +distclean-local: distclean-local-check +.PHONY: distclean-local-check +distclean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/main.cpp b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/main.cpp new file mode 100644 index 000000000..95ca0d9b3 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/main.cpp @@ -0,0 +1,100 @@ +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include +#include "resource.h" +#include "rest.h" +#include "npifc.h" + +HINSTANCE hInst; +UINT_PTR timer = 0; + +VOID CALLBACK TimerProcedure(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + (void) uMsg; + (void) idEvent; + (void) dwTime; + tir_data_t td; + npifc_getdata(&td); + SetDlgItemInt(hwnd, IDC_PITCH, td.pitch, true); + SetDlgItemInt(hwnd, IDC_ROLL, td.roll, true); + SetDlgItemInt(hwnd, IDC_YAW, td.yaw, true); + + SetDlgItemInt(hwnd, IDC_X1, td.tx, true); + SetDlgItemInt(hwnd, IDC_Y1, td.ty, true); + SetDlgItemInt(hwnd, IDC_Z1, td.tz, true); + + SetDlgItemInt(hwnd, IDC_X2, td.padding[0], true); + SetDlgItemInt(hwnd, IDC_Y2, td.padding[1], true); + SetDlgItemInt(hwnd, IDC_Z2, td.padding[2], true); + SetDlgItemInt(hwnd, IDC_X3, td.padding[3], true); + SetDlgItemInt(hwnd, IDC_Y3, td.padding[4], true); + SetDlgItemInt(hwnd, IDC_Z3, td.padding[5], true); + SetDlgItemInt(hwnd, IDC_S, td.status, true); + SetDlgItemInt(hwnd, IDC_F, td.frame, true); +} + +BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + (void) lParam; + switch(uMsg) + { + case WM_INITDIALOG: + SetDlgItemInt(hwndDlg, IDC_APPID, 2307, true); + return TRUE; + + case WM_CLOSE: + EndDialog(hwndDlg, 0); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + /* + * TODO: Add more control ID's, when needed. + */ + case IDQUIT: + npifc_close(); + EndDialog(hwndDlg, 0); + return TRUE; + case IDSTART: + int ok; + int num = GetDlgItemInt(hwndDlg, IDC_APPID, (BOOL*)&ok, false); + if(!ok){ + num = 2307; + } + game_desc_t gd; + if(timer != 0){ + KillTimer(hwndDlg, timer); + timer = 0; + } + if(game_data_get_desc(num, &gd)){ + printf("Application ID: %d - %s\n", num, gd.name); + if(npifc_init(hwndDlg, num)){ + timer = SetTimer(hwndDlg, 0, 50, TimerProcedure); + } + }else{ + printf("Unknown Application ID: %d\n", num); + } + break; + + } + } + + return FALSE; +} + + +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) +{ + (void) hPrevInstance; + (void) lpCmdLine; + (void) nShowCmd; + hInst = hInstance; + + // The user interface is a modal dialog box + return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DialogProc); +} + + diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.c b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.c new file mode 100644 index 000000000..b036464ec --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.c @@ -0,0 +1,302 @@ +#define _GNU_SOURCE +#include +#include +#define WIN32_LEAN_AND_MEAN +#include +#include "npifc.h" +#include "rest.h" + + +tir_signature_t ts; +HMODULE npclient; +/* +typedef int (*NP_RegisterWindowHandle_t)(HWND hwnd); +typedef int (*NP_UnregisterWindowHandle_t)(void); +typedef int (*NP_RegisterProgramProfileID_t)(unsigned short id); +typedef int (*NP_QueryVersion_t)(unsigned short *version); +typedef int (*NP_RequestData_t)(unsigned short req); +typedef int (*NP_GetSignature_t)(tir_signature_t *sig); +typedef int (*NP_GetData_t)(tir_data_t *data); +typedef int (*NP_GetParameter_t)(void); +typedef int (*NP_SetParameter_t)(void); +typedef int (*NP_StartCursor_t)(void); +typedef int (*NP_StopCursor_t)(void); +typedef int (*NP_ReCenter_t)(void); +typedef int (*NP_StartDataTransmission_t)(void); +typedef int (*NP_StopDataTransmission_t)(void); +*/ +NP_RegisterWindowHandle_t NP_RegisterWindowHandle = NULL; +NP_UnregisterWindowHandle_t NP_UnregisterWindowHandle = NULL; +NP_RegisterProgramProfileID_t NP_RegisterProgramProfileID = NULL; +NP_QueryVersion_t NP_QueryVersion = NULL; +NP_RequestData_t NP_RequestData = NULL; +NP_GetSignature_t NP_GetSignature = NULL; +NP_GetData_t NP_GetData = NULL; +NP_GetParameter_t NP_GetParameter = NULL; +NP_SetParameter_t NP_SetParameter = NULL; +NP_StartCursor_t NP_StartCursor = NULL; +NP_StopCursor_t NP_StopCursor = NULL; +NP_ReCenter_t NP_ReCenter = NULL; +NP_StartDataTransmission_t NP_StartDataTransmission = NULL; +NP_StopDataTransmission_t NP_StopDataTransmission = NULL; + +bool crypted = false; + + + +unsigned char table[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +char *client_path() +{ + HKEY hkey = 0; + RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\NaturalPoint\\NATURALPOINT\\NPClient Location", 0, + KEY_QUERY_VALUE, &hkey); + if(!hkey){ + printf("Can't open registry key\n"); + return NULL; + } + + BYTE path[1024]; + DWORD buf_len = 1024; + LONG result = RegQueryValueEx(hkey, "Path", NULL, NULL, path, &buf_len); + char *full_path = NULL; + int res = -1; + if(result == ERROR_SUCCESS && buf_len > 0){ +#ifdef FOR_WIN64 + res = asprintf(&full_path, "%s/NPClient64.dll", path); +#else + res = asprintf(&full_path, "%s/NPClient.dll", path); +#endif + } + RegCloseKey(hkey); + if(res > 0){ + return full_path; + }else{ + return NULL; + } +} + +bool initialized = false; + +bool npifc_init(HWND wnd, int id) +{ + //table[] = {0xb3, 0x16, 0x36, 0xeb, 0xb9, 0x05, 0x4f, 0xa4}; + game_desc_t gd; + if(game_data_get_desc(id, &gd)){ + crypted = gd.encrypted; + if(gd.encrypted){ + table[0] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[1] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[2] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[3] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[4] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[5] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[6] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[7] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + } + } + printf("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", + table[0], table[1], table[2], table[3], + table[4], table[5], table[6], table[7]); + + char *client = client_path(); + if(client == NULL){ + printf("Couldn't obtain client path!\n"); + return false; + } + npclient = LoadLibrary(client); + if(!npclient){ + printf("Can't load client %s\n", client); + return false; + } + + NP_RegisterWindowHandle = (NP_RegisterWindowHandle_t)GetProcAddress(npclient, "NP_RegisterWindowHandle"); + NP_UnregisterWindowHandle = (NP_UnregisterWindowHandle_t)GetProcAddress(npclient, "NP_UnregisterWindowHandle"); + NP_RegisterProgramProfileID = (NP_RegisterProgramProfileID_t)GetProcAddress(npclient, "NP_RegisterProgramProfileID"); + NP_QueryVersion = (NP_QueryVersion_t)GetProcAddress(npclient, "NP_QueryVersion"); + NP_RequestData = (NP_RequestData_t)GetProcAddress(npclient, "NP_RequestData"); + NP_GetSignature = (NP_GetSignature_t)GetProcAddress(npclient, "NP_GetSignature"); + NP_GetData = (NP_GetData_t)GetProcAddress(npclient, "NP_GetData"); + NP_GetParameter = (NP_GetParameter_t)GetProcAddress(npclient, "NP_GetParameter"); + NP_SetParameter = (NP_SetParameter_t)GetProcAddress(npclient, "NP_SetParameter"); + NP_StartCursor = (NP_StartCursor_t)GetProcAddress(npclient, "NP_StartCursor"); + NP_StopCursor = (NP_StopCursor_t)GetProcAddress(npclient, "NP_StopCursor"); + NP_ReCenter = (NP_ReCenter_t)GetProcAddress(npclient, "NP_ReCenter"); + NP_StartDataTransmission = (NP_StartDataTransmission_t)GetProcAddress(npclient, "NP_StartDataTransmission"); + NP_StopDataTransmission = (NP_StopDataTransmission_t)GetProcAddress(npclient, "NP_StopDataTransmission"); + if((NP_RegisterWindowHandle == NULL) || (NP_UnregisterWindowHandle == NULL) + || (NP_RegisterProgramProfileID == NULL) || (NP_QueryVersion == NULL) || (NP_RequestData == NULL) + || (NP_GetSignature == NULL) || (NP_GetData == NULL) || (NP_GetParameter == NULL) + || (NP_SetParameter == NULL) || (NP_StartCursor == NULL) || (NP_StopCursor == NULL) + || (NP_ReCenter == NULL) || (NP_StartDataTransmission == NULL) || (NP_StopDataTransmission == NULL)){ + printf("Couldn't bind all necessary functions!\n"); + return false; + } + tir_signature_t sig; + int res; + if((res = NP_GetSignature(&sig)) != 0){ + printf("Error retrieving signature! %d\n", res); + return false; + } + printf("Dll Sig:%s\nApp Sig2:%s\n", sig.DllSignature, sig.AppSignature); + NP_RegisterWindowHandle(wnd); + if(NP_RegisterProgramProfileID(id) != 0){ + printf("Couldn't register profile id!\n"); + return false; + } + printf("Program profile registered!\n"); + NP_RequestData(65535); + NP_StopCursor(); + NP_StartDataTransmission(); + initialized = true; + return true; +} + +void npifc_close() +{ + if(initialized){ + NP_StopDataTransmission(); + NP_StartCursor(); + NP_UnregisterWindowHandle(); + } + initialized = false; +} + +void c_encrypt(unsigned char buf[], unsigned int size, + unsigned char code_table[], unsigned int table_size) +{ + unsigned int table_ptr = 0; + unsigned char var = 0x88; + unsigned char tmp; + if((size <= 0) || (table_size <= 0) || + (buf == NULL) || (code_table == NULL)) + return; + do{ + tmp = buf[--size]; + buf[size] = tmp ^ code_table[table_ptr] ^ var; + var += size + tmp; + ++table_ptr; + if(table_ptr >= table_size){ + table_ptr -= table_size; + } + }while(size != 0); +} + + + +void decrypt(unsigned char buf[], unsigned int size, + unsigned char code_table[], unsigned int table_size) +{ + unsigned int table_ptr = 0; + unsigned char var = 0x88; + unsigned char tmp; + if((size <= 0) || (table_size <= 0) || + (buf == NULL) || (code_table == NULL)){ + return; + } + do{ + tmp = buf[--size]; + buf[size] = tmp ^ code_table[table_ptr] ^ var; + var += size + buf[size]; + ++table_ptr; + if(table_ptr >= table_size){ + table_ptr -= table_size; + } + }while(size != 0); +} + +unsigned int cksum(unsigned char buf[], unsigned int size) +{ + if((size == 0) || (buf == NULL)){ + return 0; + } + int rounds = size >> 2; + int rem = size % 4; + + int c = size; + int a0 = 0; + int a2 = 0; + + while(rounds != 0){ + a0 = *(short int*)buf; + a2 = *(short int*)(buf+2); + buf += 4; + c += a0; + a2 ^= (c << 5); + a2 <<= 11; + c ^= a2; + c += (c >> 11); + --rounds; + } + switch(rem){ + case 3: + a0 = *(short int*)buf; + a2 = *(signed char*)(buf+2); + c += a0; + a2 = (a2 << 2) ^ c; + c ^= (a2 << 16); + a2 = (c >> 11); + break; + case 2: + a2 = *(short int*)buf; + c += a2; + c ^= (c << 11); + a2 = (c >> 17); + break; + case 1: + a2 = *(signed char*)(buf); + c += a2; + c ^= (c << 10); + a2 = (c >> 1); + break; + default: + break; + } + if(rem != 0){ + c+=a2; + } + + c ^= (c << 3); + c += (c >> 5); + c ^= (c << 4); + c += (c >> 17); + c ^= (c << 25); + c += (c >> 6); + + return (unsigned int)c; +} + +int decode_frame(tir_data_t *td) +{ + //printf("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", + // table[0], table[1], table[2], table[3], + // table[4], table[5], table[6], table[7]); + unsigned int csum; + decrypt((unsigned char*)td, sizeof(*td), table, sizeof(table)); + csum = td->cksum; + td->cksum = 0; + if(csum != cksum((unsigned char*)td, sizeof(*td))){ + printf("Problem with frame!\n"); + //int a0; + //printf("Dec: "); + //for(a0 = 0; a0 < (int)sizeof(tir_data_t); ++a0) + //{ + // printf("%02X", ((unsigned char *)td)[a0]); + //} + //printf("\n"); + //printf("Cksum: %04X vs computed: %04X\n", csum, cksum((unsigned char*)td, sizeof(*td))); + return -1; + } + //printf("Frame OK!\n"); + return 0; +} + +int npifc_getdata(tir_data_t *data) +{ + int res = NP_GetData(data); + if(crypted){ + decode_frame(data); + } + return res; +} + diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.h b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.h new file mode 100644 index 000000000..d580e16d6 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.h @@ -0,0 +1,66 @@ +#ifndef NPIFC__H +#define NPIFC__H + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + bool npifc_init(HWND wnd, int id); + void npifc_close(); + +#pragma pack(1) +typedef struct tir_data{ + short status; + short frame; + unsigned int cksum; + float roll, pitch, yaw; + float tx, ty, tz; + float padding[9]; +} tir_data_t; + +typedef struct tir_signature{ + char DllSignature[200]; + char AppSignature[200]; +} tir_signature_t; +#pragma pack(0) + +int npifc_getdata(tir_data_t *data); + +typedef int __stdcall (*NP_RegisterWindowHandle_t)(HWND hwnd); +typedef int __stdcall (*NP_UnregisterWindowHandle_t)(void); +typedef int __stdcall (*NP_RegisterProgramProfileID_t)(unsigned short id); +typedef int __stdcall (*NP_QueryVersion_t)(unsigned short *version); +typedef int __stdcall (*NP_RequestData_t)(unsigned short req); +typedef int __stdcall (*NP_GetSignature_t)(tir_signature_t *sig); +typedef int __stdcall (*NP_GetData_t)(tir_data_t *data); +typedef int __stdcall (*NP_GetParameter_t)(void); +typedef int __stdcall (*NP_SetParameter_t)(void); +typedef int __stdcall (*NP_StartCursor_t)(void); +typedef int __stdcall (*NP_StopCursor_t)(void); +typedef int __stdcall (*NP_ReCenter_t)(void); +typedef int __stdcall (*NP_StartDataTransmission_t)(void); +typedef int __stdcall (*NP_StopDataTransmission_t)(void); + +extern NP_RegisterWindowHandle_t NP_RegisterWindowHandle; +extern NP_UnregisterWindowHandle_t NP_UnregisterWindowHandle; +extern NP_RegisterProgramProfileID_t NP_RegisterProgramProfileID; +extern NP_QueryVersion_t NP_QueryVersion; +extern NP_RequestData_t NP_RequestData; +extern NP_GetSignature_t NP_GetSignature; +extern NP_GetData_t NP_GetData; +extern NP_GetParameter_t NP_GetParameter; +extern NP_SetParameter_t NP_SetParameter; +extern NP_StartCursor_t NP_StartCursor; +extern NP_StopCursor_t NP_StopCursor; +extern NP_ReCenter_t NP_ReCenter; +extern NP_StartDataTransmission_t NP_StartDataTransmission; +extern NP_StopDataTransmission_t NP_StopDataTransmission; + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npview.rc.in b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npview.rc.in new file mode 100644 index 000000000..231002f18 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npview.rc.in @@ -0,0 +1,49 @@ +// Generated by ResEdit 1.5.9 +// Copyright (C) 2006-2011 +// http://www.resedit.net + +#include +#include +#include +#include "resource.h" + +#ifdef HAVE_CONFIG_H + #include "../../../config.h" +#endif + + + +// +// Dialog resources +// +//LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +IDD_DIALOG1 DIALOGEX 0, 0, 379, 124 +STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU +CAPTION "NPTest v@PACKAGE_VERSION@" +FONT 8, "Ms Shell Dlg", 400, 0, 1 +{ + DEFPUSHBUTTON "Quit", IDQUIT, 262, 102, 50, 14 + DEFPUSHBUTTON "Start", IDSTART, 7, 102, 50, 14 + EDITTEXT IDC_PITCH, 32, 32, 51, 14, ES_AUTOHSCROLL + LTEXT "Pitch", IDC_STATIC, 11, 34, 20, 8, SS_LEFT + LTEXT "Yaw", IDC_STATIC, 11, 59, 20, 8, SS_LEFT + EDITTEXT IDC_YAW, 32, 57, 51, 14, ES_AUTOHSCROLL + LTEXT "Roll", IDC_STATIC, 11, 84, 20, 8, SS_LEFT + EDITTEXT IDC_ROLL, 32, 82, 51, 14, ES_AUTOHSCROLL + LTEXT "X", IDC_STATIC, 101, 35, 6, 8, SS_LEFT + EDITTEXT IDC_X1, 112, 32, 51, 14, ES_AUTOHSCROLL + LTEXT "Y", IDC_STATIC, 101, 60, 6, 8, SS_LEFT + EDITTEXT IDC_Y1, 112, 57, 51, 14, ES_AUTOHSCROLL + LTEXT "Z", IDC_STATIC, 101, 85, 6, 8, SS_LEFT + EDITTEXT IDC_Z1, 112, 82, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_X2, 172, 32, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_Y2, 172, 57, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_Z2, 172, 82, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_X3, 232, 32, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_Y3, 232, 57, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_Z3, 232, 82, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_S, 292, 32, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_F, 292, 57, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_APPID, 32, 12, 51, 12, ES_AUTOHSCROLL + LTEXT "ID", IDC_STATIC, 17, 14, 8, 8, SS_LEFT +} diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/resource.h b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/resource.h new file mode 100644 index 000000000..328d9cb78 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/resource.h @@ -0,0 +1,23 @@ +#ifndef IDC_STATIC +#define IDC_STATIC (-1) +#endif + +#define IDD_DIALOG1 100 +#define IDQUIT 1002 +#define IDSTART 1003 +#define IDC_APPID 1016 +#define IDC_PITCH 1017 +#define IDC_YAW 1018 +#define IDC_ROLL 1019 +#define IDC_X1 1020 +#define IDC_X2 1021 +#define IDC_X3 1022 +#define IDC_Y1 1023 +#define IDC_Y2 1024 +#define IDC_Y3 1025 +#define IDC_Z1 1026 +#define IDC_Z2 1027 +#define IDC_Z3 1028 +#define IDC_S 1029 +#define IDC_F 1030 + diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.c b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.c new file mode 120000 index 000000000..663c21a99 --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.c @@ -0,0 +1 @@ +../client/rest.c \ No newline at end of file diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.h b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.h new file mode 120000 index 000000000..6dca182ae --- /dev/null +++ b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.h @@ -0,0 +1 @@ +../client/rest.h \ No newline at end of file diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index abf03a5e4..886e40fad 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -1,12 +1,13 @@ -#include "facetracknoir/facetracknoir.h" -#include "facetracknoir/curve-config.h" -CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidget *parent) : - QWidget( parent, Qt::Dialog ), mainApp(ftnoir) +#include "./facetracknoir.h" +#include "./curve-config.h" +#include "./main-settings.hpp" +CurveConfigurationDialog::CurveConfigurationDialog(Mappings& m, main_settings& s, QWidget *parent) : QWidget(parent, Qt::Dialog), + m(m) { ui.setupUi( this ); // rest of mapping settings taken care of by options::value - mainApp->load_mappings(); + m.load_mappings(); { struct { @@ -34,8 +35,8 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge for (int i = 0; qfcs[i].qfc; i++) { const bool altp = qfcs[i].altp; - THeadPoseDOF& axis = mainApp->axis(qfcs[i].axis); - FunctionConfig* conf = altp ? &axis.curveAlt : &axis.curve; + Mapping& axis = m(qfcs[i].axis); + Map* conf = altp ? &axis.curveAlt : &axis.curve; const auto& name = qfcs[i].altp ? axis.name2 : axis.name1; qfcs[i].qfc->setConfig(conf, name); @@ -49,36 +50,36 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - tie_setting(mainApp->s.a_x.altp, ui.tx_altp); - tie_setting(mainApp->s.a_y.altp, ui.ty_altp); - tie_setting(mainApp->s.a_z.altp, ui.tz_altp); - tie_setting(mainApp->s.a_yaw.altp, ui.rx_altp); - tie_setting(mainApp->s.a_pitch.altp, ui.ry_altp); - tie_setting(mainApp->s.a_roll.altp, ui.rz_altp); + tie_setting(s.a_x.altp, ui.tx_altp); + tie_setting(s.a_y.altp, ui.ty_altp); + tie_setting(s.a_z.altp, ui.tz_altp); + tie_setting(s.a_yaw.altp, ui.rx_altp); + tie_setting(s.a_pitch.altp, ui.ry_altp); + tie_setting(s.a_roll.altp, ui.rz_altp); - tie_setting(mainApp->s.tcomp_p, ui.tcomp_enable); - tie_setting(mainApp->s.tcomp_tz, ui.tcomp_rz); + tie_setting(s.tcomp_p, ui.tcomp_enable); + tie_setting(s.tcomp_tz, ui.tcomp_rz); - tie_setting(mainApp->s.a_x.zero, ui.pos_tx); - tie_setting(mainApp->s.a_y.zero, ui.pos_ty); - tie_setting(mainApp->s.a_z.zero, ui.pos_tz); - tie_setting(mainApp->s.a_yaw.zero, ui.pos_rx); - tie_setting(mainApp->s.a_pitch.zero, ui.pos_ry); - tie_setting(mainApp->s.a_roll.zero, ui.pos_rz); + tie_setting(s.a_x.zero, ui.pos_tx); + tie_setting(s.a_y.zero, ui.pos_ty); + tie_setting(s.a_z.zero, ui.pos_tz); + tie_setting(s.a_yaw.zero, ui.pos_rx); + tie_setting(s.a_pitch.zero, ui.pos_ry); + tie_setting(s.a_roll.zero, ui.pos_rz); - tie_setting(mainApp->s.a_yaw.invert, ui.invert_yaw); - tie_setting(mainApp->s.a_pitch.invert, ui.invert_pitch); - tie_setting(mainApp->s.a_roll.invert, ui.invert_roll); - tie_setting(mainApp->s.a_x.invert, ui.invert_x); - tie_setting(mainApp->s.a_y.invert, ui.invert_y); - tie_setting(mainApp->s.a_z.invert, ui.invert_z); + tie_setting(s.a_yaw.invert, ui.invert_yaw); + tie_setting(s.a_pitch.invert, ui.invert_pitch); + tie_setting(s.a_roll.invert, ui.invert_roll); + tie_setting(s.a_x.invert, ui.invert_x); + tie_setting(s.a_y.invert, ui.invert_y); + tie_setting(s.a_z.invert, ui.invert_z); - tie_setting(mainApp->s.a_yaw.src, ui.src_yaw); - tie_setting(mainApp->s.a_pitch.src, ui.src_pitch); - tie_setting(mainApp->s.a_roll.src, ui.src_roll); - tie_setting(mainApp->s.a_x.src, ui.src_x); - tie_setting(mainApp->s.a_y.src, ui.src_y); - tie_setting(mainApp->s.a_z.src, ui.src_z); + tie_setting(s.a_yaw.src, ui.src_yaw); + tie_setting(s.a_pitch.src, ui.src_pitch); + tie_setting(s.a_roll.src, ui.src_roll); + tie_setting(s.a_x.src, ui.src_x); + tie_setting(s.a_y.src, ui.src_y); + tie_setting(s.a_z.src, ui.src_z); } void CurveConfigurationDialog::doOK() { @@ -87,10 +88,10 @@ void CurveConfigurationDialog::doOK() { } void CurveConfigurationDialog::doCancel() { - mainApp->load_mappings(); + m.load_mappings(); this->close(); } void CurveConfigurationDialog::save() { - mainApp->save_mappings(); + m.save_mappings(); } diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index 49aba7bde..67a588e22 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -1,19 +1,17 @@ #pragma once #include -#include +#include "./mappings.hpp" #include "ui_ftnoir_curves.h" -class FaceTrackNoIR; - class CurveConfigurationDialog: public QWidget { Q_OBJECT public: - CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); + CurveConfigurationDialog(Mappings &m, main_settings &s, QWidget *parent ); private: Ui::UICCurveConfigurationDialog ui; + Mappings& m; void save(); - FaceTrackNoIR *mainApp; private slots: void doOK(); void doCancel(); diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 868b6dbfc..af76f09b3 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -75,8 +75,8 @@ static void fill_combobox(const QString& filter, QList& list, Q } } -FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : - QMainWindow(parent), +FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : QMainWindow(parent), + tracker(nullptr), #if defined(_WIN32) keybindingWorker(NULL), #else @@ -87,34 +87,21 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : s(b), pose(std::vector{&s.a_x, &s.a_y, &s.a_z, &s.a_yaw, &s.a_pitch, &s.a_roll}), timUpdateHeadPose(this), - pTrackerDialog(NULL), - pProtocolDialog(NULL), - pFilterDialog(NULL), + pTrackerDialog(nullptr), + pProtocolDialog(nullptr), + pFilterDialog(nullptr), + shortcuts_widget(nullptr), + mapping_widget(new CurveConfigurationDialog(pose, s, this)), kbd_quit(QKeySequence("Ctrl+Q"), this), looping(0), video_frame_layout(new QVBoxLayout()), no_feed_pixmap(":/uielements/no-feed.png") -{ +{ ui.setupUi(this); setFixedSize(size()); ui.video_frame_label->setPixmap(no_feed_pixmap); updateButtonState(false, false); - _keyboard_shortcuts = 0; - _curve_config = 0; - - tracker = 0; - - CurveConfigurationDialog* ccd; - - if (!_curve_config) - { - ccd = new CurveConfigurationDialog( this, this ); - _curve_config = ccd; - } else { - ccd = dynamic_cast(_curve_config); - } - QDir::setCurrent(QCoreApplication::applicationDirPath()); fill_profile_cbx(); @@ -157,7 +144,7 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : FaceTrackNoIR::~FaceTrackNoIR() { - stopTracker(); + stopTracker(); save(); if (Libraries) delete Libraries; @@ -171,38 +158,26 @@ QFrame* FaceTrackNoIR::get_video_widget() { void FaceTrackNoIR::open() { QFileDialog dialog(this); dialog.setFileMode(QFileDialog::ExistingFile); - - QString fileName = dialog.getOpenFileName( - this, + + QString fileName = dialog.getOpenFileName( + this, tr("Open the settings file"), - QCoreApplication::applicationDirPath() + "/settings/", + QCoreApplication::applicationDirPath() + "/settings/", tr("Settings file (*.ini);;All Files (*)"), NULL); - if (! fileName.isEmpty() ) { + if (! fileName.isEmpty() ) { { QSettings settings("opentrack"); settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); } fill_profile_cbx(); - loadSettings(); + loadSettings(); } } void FaceTrackNoIR::save_mappings() { - QSettings settings("opentrack"); - - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini") - .toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - for (int i = 0; i < 6; i++) - { - axis(i).curve.saveSettings(iniFile, axis(i).name1); - axis(i).curveAlt.saveSettings(iniFile, axis(i).name2); - } + pose.save_mappings(); } #if defined(__unix) || defined(__linux) || defined(__APPLE__) @@ -212,7 +187,7 @@ void FaceTrackNoIR::save_mappings() { void FaceTrackNoIR::save() { b->save(); save_mappings(); - + #if defined(__unix) || defined(__linux) QSettings settings("opentrack"); const QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); @@ -229,27 +204,27 @@ void FaceTrackNoIR::save() { void FaceTrackNoIR::saveAs() { looping++; - QSettings settings("opentrack"); - QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings settings("opentrack"); + QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), - oldFile, + QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), + oldFile, tr("Settings file (*.ini);;All Files (*)")); - if (!fileName.isEmpty()) { + if (!fileName.isEmpty()) { - QFileInfo newFileInfo ( fileName ); - if ((newFileInfo.exists()) && (oldFile != fileName)) { - QFile newFileFile ( fileName ); - newFileFile.remove(); - } + QFileInfo newFileInfo ( fileName ); + if ((newFileInfo.exists()) && (oldFile != fileName)) { + QFile newFileFile ( fileName ); + newFileFile.remove(); + } - QFileInfo oldFileInfo ( oldFile ); - if (oldFileInfo.exists()) { - QFile oldFileFile ( oldFile ); - oldFileFile.copy( fileName ); - } + QFileInfo oldFileInfo ( oldFile ); + if (oldFileInfo.exists()) { + QFile oldFileFile ( oldFile ); + oldFileFile.copy( fileName ); + } - settings.setValue ("SettingsFile", fileName); + settings.setValue ("SettingsFile", fileName); save(); } @@ -258,15 +233,7 @@ void FaceTrackNoIR::saveAs() } void FaceTrackNoIR::load_mappings() { - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - for (int i = 0; i < 6; i++) - { - axis(i).curve.loadSettings(iniFile, axis(i).name1); - axis(i).curveAlt.loadSettings(iniFile, axis(i).name2); - } + pose.load_mappings(); } void FaceTrackNoIR::loadSettings() { @@ -303,7 +270,7 @@ void FaceTrackNoIR::startTracker( ) { stopTracker(); return; } - + #if defined(_WIN32) keybindingWorker = new KeybindingWorker(*this, keyCenter, keyToggle); keybindingWorker->start(); @@ -313,15 +280,15 @@ void FaceTrackNoIR::startTracker( ) { delete tracker; } - tracker = new Tracker ( this, s ); + tracker = new Tracker(s, pose); if (pTrackerDialog && Libraries->pTracker) { pTrackerDialog->registerTracker( Libraries->pTracker ); - } - + } + if (pFilterDialog && Libraries->pFilter) pFilterDialog->registerFilter(Libraries->pFilter); - + tracker->start(); ui.video_frame->show(); @@ -345,7 +312,7 @@ void FaceTrackNoIR::stopTracker( ) { keybindingWorker = NULL; } #endif - timUpdateHeadPose.stop(); + timUpdateHeadPose.stop(); ui.pose_display->rotateBy(0, 0, 0); if (pTrackerDialog) { @@ -366,44 +333,41 @@ void FaceTrackNoIR::stopTracker( ) { } if ( tracker ) { - delete tracker; - tracker = 0; + delete tracker; + tracker = 0; if (Libraries) { delete Libraries; Libraries = NULL; } - } + } updateButtonState(false, false); } -void FaceTrackNoIR::showHeadPose() { - double newdata[6]; - - tracker->getHeadPose(newdata); - ui.lcdNumX->display(newdata[TX]); - ui.lcdNumY->display(newdata[TY]); - ui.lcdNumZ->display(newdata[TZ]); - +void FaceTrackNoIR::showHeadPose() +{ + double mapped[6], raw[6]; - ui.lcdNumRotX->display(newdata[Yaw]); - ui.lcdNumRotY->display(newdata[Pitch]); - ui.lcdNumRotZ->display(newdata[Roll]); + tracker->get_raw_and_mapped_poses(mapped, raw); - tracker->getOutputHeadPose(newdata); + ui.pose_display->rotateBy(mapped[Yaw], mapped[Roll], mapped[Pitch]); - ui.pose_display->rotateBy(newdata[Yaw], newdata[Roll], newdata[Pitch]); + if (mapping_widget) + mapping_widget->update(); - ui.lcdNumOutputPosX->display(newdata[TX]); - ui.lcdNumOutputPosY->display(newdata[TY]); - ui.lcdNumOutputPosZ->display(newdata[TZ]); + ui.lcdNumX->display(raw[TX]); + ui.lcdNumY->display(raw[TY]); + ui.lcdNumZ->display(raw[TZ]); + ui.lcdNumRotX->display(raw[Yaw]); + ui.lcdNumRotY->display(raw[Pitch]); + ui.lcdNumRotZ->display(raw[Roll]); - ui.lcdNumOutputRotX->display(newdata[Yaw]); - ui.lcdNumOutputRotY->display(newdata[Pitch]); - ui.lcdNumOutputRotZ->display(newdata[Roll]); + ui.lcdNumOutputPosX->display(mapped[TX]); + ui.lcdNumOutputPosY->display(mapped[TY]); + ui.lcdNumOutputPosZ->display(mapped[TZ]); + ui.lcdNumOutputRotX->display(mapped[Yaw]); + ui.lcdNumOutputRotY->display(mapped[Pitch]); + ui.lcdNumOutputRotZ->display(mapped[Roll]); - if (_curve_config) { - _curve_config->update(); - } if (Libraries->pProtocol) { const QString name = Libraries->pProtocol->getGameName(); @@ -411,11 +375,12 @@ void FaceTrackNoIR::showHeadPose() { } } -void FaceTrackNoIR::showTrackerSettings() { - if (pTrackerDialog) { - delete pTrackerDialog; - pTrackerDialog = NULL; - } +void FaceTrackNoIR::showTrackerSettings() +{ + if (pTrackerDialog) { + delete pTrackerDialog; + pTrackerDialog = NULL; + } DynamicLibrary* lib = dlopen_trackers.value(ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); @@ -470,24 +435,24 @@ void FaceTrackNoIR::showFilterControls() { } void FaceTrackNoIR::showKeyboardShortcuts() { - if (!_keyboard_shortcuts) + if (!shortcuts_widget) { - _keyboard_shortcuts = new KeyboardShortcutDialog( this, this ); + shortcuts_widget = new KeyboardShortcutDialog( this, this ); } - _keyboard_shortcuts->show(); - _keyboard_shortcuts->raise(); + shortcuts_widget->show(); + shortcuts_widget->raise(); } -void FaceTrackNoIR::showCurveConfiguration() { - if (!_curve_config) - _curve_config = new CurveConfigurationDialog( this, this ); - - _curve_config->show(); - _curve_config->raise(); +void FaceTrackNoIR::showCurveConfiguration() { + if (!mapping_widget) + mapping_widget = new CurveConfigurationDialog(pose, s, this); + + mapping_widget->show(); + mapping_widget->raise(); } void FaceTrackNoIR::exit() { - QCoreApplication::exit(0); + QCoreApplication::exit(0); } extern "C" volatile const char* opentrack_version; @@ -515,11 +480,11 @@ void FaceTrackNoIR::fill_profile_cbx() void FaceTrackNoIR::profileSelected(int index) { - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QFileInfo pathInfo ( currentFile ); settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + ui.iconcomboProfile->itemText(index)); - loadSettings(); + loadSettings(); } #if !defined(_WIN32) @@ -542,8 +507,8 @@ void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, key_opts& k) key.setShortcut(QKeySequence::fromString(seq, QKeySequence::PortableText)); key.setEnabled(); } else { - key.setDisabled(); - } + key.setDisabled(); + } } } #else @@ -590,20 +555,18 @@ void FaceTrackNoIR::bindKeyboardShortcuts() void FaceTrackNoIR::shortcutRecentered() { + qDebug() << "Center"; if (s.dingp) QApplication::beep(); - - qDebug() << "Center"; if (tracker) - tracker->do_center = true; + tracker->center(); } void FaceTrackNoIR::shortcutToggled() { + qDebug() << "Toggle"; if (s.dingp) QApplication::beep(); - - qDebug() << "Toggle"; if (tracker) - tracker->enabled = !tracker->enabled; + tracker->toggle_enabled(); } diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index c722ad5ca..09f96147c 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -44,31 +44,29 @@ #include "ui_facetracknoir.h" -#include "facetracknoir/options.h" -using namespace options; - -#include "facetracknoir/main-settings.hpp" - -#include "facetracknoir/plugin-support.h" -#include "tracker.h" -#include "facetracknoir/shortcuts.h" +#include "./options.h" +#include "./main-settings.hpp" +#include "./plugin-support.h" +#include "./tracker.h" +#include "./shortcuts.h" +#include "./curve-config.h" -class Tracker; // pre-define class to avoid circular includes -class FaceTrackNoIR; - -class KeybindingWorker; +using namespace options; class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider { - Q_OBJECT + Q_OBJECT public: FaceTrackNoIR(QWidget *parent = 0); - ~FaceTrackNoIR(); + ~FaceTrackNoIR(); QFrame *get_video_widget(); Tracker *tracker; void bindKeyboardShortcuts(); + + // XXX this shit stinks -sh 20141004 + // TODO move to separate class representing running tracker state DynamicLibrary* current_tracker1() override { return dlopen_trackers.value(ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); } @@ -78,15 +76,12 @@ public: DynamicLibrary* current_filter() override { return dlopen_filters.value(ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); } - THeadPoseDOF& axis(int idx) { - return pose.axes[idx]; - } #if defined(_WIN32) Key keyCenter; Key keyToggle; KeybindingWorker* keybindingWorker; -#else +#else QxtGlobalShortcut keyCenter; QxtGlobalShortcut keyToggle; #endif @@ -95,22 +90,20 @@ public: public slots: void shortcutRecentered(); void shortcutToggled(); - private: - HeadPoseData pose; + Mappings pose; Ui::OpentrackUI ui; - QTimer timUpdateHeadPose; + QTimer timUpdateHeadPose; ITrackerDialog* pTrackerDialog; IProtocolDialog* pProtocolDialog; IFilterDialog* pFilterDialog; - QWidget *_keyboard_shortcuts; - QWidget *_curve_config; + QWidget *shortcuts_widget; + CurveConfigurationDialog* mapping_widget; - void createIconGroupBox(); - - void loadSettings(); + void createIconGroupBox(); + void loadSettings(); void updateButtonState(bool running, bool inertialp); QList dlopen_filters; @@ -118,33 +111,33 @@ private: QList dlopen_protocols; QShortcut kbd_quit; int looping; - + QLayout* video_frame_layout; QPixmap no_feed_pixmap; #ifndef _WIN32 void bind_keyboard_shortcut(QxtGlobalShortcut&, key_opts& k); #endif void fill_profile_cbx(); - + private slots: void open(); void save(); void saveAs(); void exit(); void profileSelected(int index); - + void showTrackerSettings(); - + void showServerControls(); void showFilterControls(); void showKeyboardShortcuts(); void showCurveConfiguration(); - + void showHeadPose(); - + void startTracker(); void stopTracker(); - + public: void save_mappings(); void load_mappings(); diff --git a/facetracknoir/mappings.hpp b/facetracknoir/mappings.hpp new file mode 100644 index 000000000..4dae7a908 --- /dev/null +++ b/facetracknoir/mappings.hpp @@ -0,0 +1,79 @@ +#pragma once + +#include +#include "options.h" +using namespace options; +#include "../qfunctionconfigurator/functionconfig.h" +#include "main-settings.hpp" + +class Mapping { +public: + Mapping(QString primary, + QString secondary, + int maxInput1, + int maxOutput1, + int maxInput2, + int maxOutput2, + axis_opts& opts) : + curve(maxInput1, maxOutput1), + curveAlt(maxInput2, maxOutput2), + opts(opts), + name1(primary), + name2(secondary) + { + // XXX TODO move all this qsettings boilerplate into a single header -sh 20141004 + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile(currentFile, QSettings::IniFormat); + curve.loadSettings(iniFile, primary); + curveAlt.loadSettings(iniFile, secondary); + } + Map curve; + Map curveAlt; + axis_opts& opts; + QString name1, name2; +}; + +class Mappings { +private: + Mapping axes[6]; +public: + Mappings(std::vector opts) : + axes { + Mapping("tx","tx_alt", 100, 100, 100, 100, *opts[TX]), + Mapping("ty","ty_alt", 100, 100, 100, 100, *opts[TY]), + Mapping("tz","tz_alt", 100, 100, 100, 100, *opts[TZ]), + Mapping("rx", "rx_alt", 180, 180, 180, 180, *opts[Yaw]), + Mapping("ry", "ry_alt", 90, 90, 90, 90, *opts[Pitch]), + Mapping("rz", "rz_alt", 180, 180, 180, 180, *opts[Roll]) + } + {} + + inline Mapping& operator()(int i) { return axes[i]; } + inline const Mapping& operator()(int i) const { return axes[i]; } + + void load_mappings() + { + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); + + for (int i = 0; i < 6; i++) + { + axes[i].curve.loadSettings(iniFile, axes[i].name1); + axes[i].curveAlt.loadSettings(iniFile, axes[i].name2); + } + } + void save_mappings() + { + QSettings settings("opentrack"); + QString currentFile = settings.value("SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini").toString(); + QSettings iniFile(currentFile, QSettings::IniFormat); + + for (int i = 0; i < 6; i++) + { + axes[i].curve.saveSettings(iniFile, axes[i].name1); + axes[i].curveAlt.saveSettings(iniFile, axes[i].name2); + } + } +}; diff --git a/facetracknoir/plugin-qt-api.hpp b/facetracknoir/plugin-qt-api.hpp index a8dd153be..0e2e3c32e 100644 --- a/facetracknoir/plugin-qt-api.hpp +++ b/facetracknoir/plugin-qt-api.hpp @@ -14,11 +14,15 @@ struct Metadata virtual void getIcon(QIcon *icon) = 0; }; +// XXX TODO get rid of QString/QFrame to fix ABI woes +// will lead plugins from different C++ runtimes working -sh 20141004 + +// XXX TODO make virtual public the mess -sh 20141004 + struct IFilter { virtual ~IFilter() = 0; virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) = 0; - virtual void reset() = 0; }; inline IFilter::~IFilter() {} @@ -62,4 +66,4 @@ struct ITrackerDialog virtual void registerTracker(ITracker *tracker) = 0; virtual void unRegisterTracker() = 0; }; -inline ITrackerDialog::~ITrackerDialog() {} \ No newline at end of file +inline ITrackerDialog::~ITrackerDialog() {} diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h index 3924fc09b..c3914cfb7 100644 --- a/facetracknoir/plugin-support.h +++ b/facetracknoir/plugin-support.h @@ -45,7 +45,7 @@ private: }; -// merely to break a circular header dependency -sh +// TODO it can die if running tracker state separated into class -sh 20141004 class IDynamicLibraryProvider { public: virtual DynamicLibrary* current_tracker1() = 0; diff --git a/facetracknoir/qcopyable-mutex.hpp b/facetracknoir/qcopyable-mutex.hpp new file mode 100644 index 000000000..f7f36f932 --- /dev/null +++ b/facetracknoir/qcopyable-mutex.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include + +class MyMutex { +private: + QMutex inner; + +public: + QMutex* operator->() { return &inner; } + QMutex* operator->() const { return &const_cast(this)->inner; } + + MyMutex operator=(const MyMutex& datum) + { + auto mode = + datum->isRecursive() + ? QMutex::Recursive + : QMutex::NonRecursive; + + return MyMutex(mode); + } + + MyMutex(const MyMutex& datum) + { + *this = datum; + } + + MyMutex(QMutex::RecursionMode mode = QMutex::NonRecursive) : + inner(mode) + { + } + + QMutex* operator&() + { + return &inner; + } +}; diff --git a/facetracknoir/rotation.h b/facetracknoir/rotation.h index 5ff5ce61b..b3bb891ec 100644 --- a/facetracknoir/rotation.h +++ b/facetracknoir/rotation.h @@ -8,18 +8,17 @@ #pragma once #include -class RotationType { +class Quat { public: - RotationType() : a(1.0),b(0.0),c(0.0),d(0.0) {} - RotationType(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } - RotationType(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} + Quat() : a(1.0),b(0.0),c(0.0),d(0.0) {} + Quat(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } + Quat(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} - RotationType inv(){ - return RotationType(a,-b,-c, -d); + Quat inv(){ + return Quat(a,-b,-c, -d); } - // conversions // see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles void fromEuler(double yaw, double pitch, double roll) @@ -45,10 +44,10 @@ public: yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); } - const RotationType operator*(const RotationType& B) const + const Quat operator*(const Quat& B) const { - const RotationType& A = *this; - return RotationType(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication + const Quat& A = *this; + return Quat(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 17f1af5fb..0c2d289f4 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -22,12 +22,12 @@ # include #endif -Tracker::Tracker(FaceTrackNoIR *parent , main_settings& s) : - mainApp(parent), +Tracker::Tracker(main_settings& s, Mappings &m) : s(s), - should_quit(false), - do_center(false), - enabled(true) + m(m), + centerp(false), + enabledp(true), + should_quit(false) { } @@ -37,7 +37,7 @@ Tracker::~Tracker() wait(); } -static void get_curve(double pos, double& out, THeadPoseDOF& axis) { +void Tracker::get_curve(double pos, double& out, Mapping& axis) { bool altp = (pos < 0) && axis.opts.altp; axis.curve.setTrackingActive( !altp ); axis.curveAlt.setTrackingActive( altp ); @@ -83,7 +83,7 @@ static void t_compensate(double* input, double* output, bool rz) } void Tracker::run() { - T6DOF offset_camera; + T6DOF pose_offset, unstopped_pose; double newpose[6] = {0}; int sleep_ms = 15; @@ -113,52 +113,42 @@ void Tracker::run() { for (int i = 0; i < 6; i++) { - raw_6dof.axes[i] = newpose[i]; - - auto& axis = mainApp->axis(i); - + auto& axis = m(i); int k = axis.opts.src; if (k < 0 || k >= 6) continue; - - axis.headPos = newpose[k]; + // not really raw, after axis remap -sh + raw_6dof(i) = newpose[k]; } - if (do_center) { - for (int i = 0; i < 6; i++) - offset_camera.axes[i] = mainApp->axis(i).headPos; - - do_center = false; - - if (Libraries->pFilter) - Libraries->pFilter->reset(); + if (centerp) { + centerp = false; + pose_offset = raw_6dof; } - T6DOF target_camera, target_camera2, new_camera; + { + if (enabledp) + unstopped_pose = raw_6dof; - if (!enabled) - target_camera = raw_6dof; - else - for (int i = 0; i < 6; i++) - target_camera.axes[i] = mainApp->axis(i).headPos; + { - target_camera2 = target_camera - offset_camera; + if (Libraries->pFilter) + Libraries->pFilter->FilterHeadPoseData(unstopped_pose, output_pose); + else + output_pose = unstopped_pose; - if (Libraries->pFilter) { - Libraries->pFilter->FilterHeadPoseData(target_camera2.axes, new_camera.axes); - } else { - new_camera = target_camera2; - } + output_pose = output_pose - pose_offset; + } - for (int i = 0; i < 6; i++) { - get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); + for (int i = 0; i < 6; i++) + get_curve(output_pose(i), output_pose(i), m(i)); } - if (mainApp->s.tcomp_p) - t_compensate(output_camera.axes, output_camera.axes, mainApp->s.tcomp_tz); + if (s.tcomp_p) + t_compensate(output_pose, output_pose, s.tcomp_tz); if (Libraries->pProtocol) { - Libraries->pProtocol->sendHeadposeToGame(output_camera.axes); + Libraries->pProtocol->sendHeadposeToGame(output_pose); } } @@ -172,21 +162,17 @@ void Tracker::run() { for (int i = 0; i < 6; i++) { - mainApp->axis(i).curve.setTrackingActive(false); - mainApp->axis(i).curveAlt.setTrackingActive(false); + m(i).curve.setTrackingActive(false); + m(i).curveAlt.setTrackingActive(false); } } -void Tracker::getHeadPose( double *data ) { - QMutexLocker foo(&mtx); +void Tracker::get_raw_and_mapped_poses(double* mapped, double* raw) const { + QMutexLocker foo(&const_cast(*this).mtx); for (int i = 0; i < 6; i++) { - data[i] = raw_6dof.axes[i]; + raw[i] = raw_6dof(i); + mapped[i] = output_pose(i); } } -void Tracker::getOutputHeadPose( double *data ) { - QMutexLocker foo(&mtx); - for (int i = 0; i < 6; i++) - data[i] = output_camera.axes[i]; -} diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 543501640..05ae41807 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -11,85 +11,42 @@ #include #include #include "plugin-support.h" +#include "mappings.hpp" + #include +#include #include #include "tracker_types.h" #include "facetracknoir/main-settings.hpp" #include "facetracknoir/options.h" #include "facetracknoir/timer.hpp" -using namespace options; -class THeadPoseDOF { -public: - THeadPoseDOF(QString primary, - QString secondary, - int maxInput1, - int maxOutput1, - int maxInput2, - int maxOutput2, - axis_opts* opts) : - headPos(0), - curve(maxInput1, maxOutput1), - curveAlt(maxInput2, maxOutput2), - opts(*opts), - name1(primary), - name2(secondary) - { - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - curve.loadSettings(iniFile, primary); - curveAlt.loadSettings(iniFile, secondary); - } - volatile double headPos; - FunctionConfig curve; - FunctionConfig curveAlt; - axis_opts& opts; - QString name1, name2; -}; -class FaceTrackNoIR; class Tracker : protected QThread { - Q_OBJECT - + Q_OBJECT private: - FaceTrackNoIR *mainApp; QMutex mtx; main_settings& s; - volatile bool should_quit; + // XXX can be const-cast when functionconfig const-correct -sh 20141004 + Mappings& m; Timer t; -protected: - void run(); + T6DOF output_pose, raw_6dof; + std::atomic centerp; + std::atomic enabledp; + std::atomic should_quit; + static void get_curve(double pos, double& out, Mapping& axis); +protected: + void run() override; public: - Tracker( FaceTrackNoIR *parent, main_settings& s); + Tracker(main_settings& s, Mappings& m); ~Tracker(); - void getHeadPose(double *data); - void getOutputHeadPose(double *data); - volatile bool do_center; - volatile bool enabled; - - T6DOF output_camera, raw_6dof; - + void get_raw_and_mapped_poses(double* mapped, double* raw) const; void start() { QThread::start(); } + void center() { centerp.store(true); } + void toggle_enabled() { enabledp.store(!enabledp.load()); } }; - -class HeadPoseData { -public: - THeadPoseDOF axes[6]; - HeadPoseData(std::vector opts) : - axes { - THeadPoseDOF("tx","tx_alt", 100, 100, 100, 100, opts[TX]), - THeadPoseDOF("ty","ty_alt", 100, 100, 100, 100, opts[TY]), - THeadPoseDOF("tz","tz_alt", 100, 100, 100, 100, opts[TZ]), - THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180, opts[Yaw]), - THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90, opts[Pitch]), - THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180, opts[Roll]) - } - {} -}; - #endif diff --git a/facetracknoir/tracker_types.cpp b/facetracknoir/tracker_types.cpp deleted file mode 100644 index 2d7ec45a5..000000000 --- a/facetracknoir/tracker_types.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "tracker_types.h" -#include "rotation.h" -#include "facetracknoir/plugin-api.hpp" - -#define PI 3.14159265358979323846264 -#define D2R PI/180.0 -#define R2D 180.0/PI - -T6DOF operator-(const T6DOF& A, const T6DOF& B) -{ - RotationType R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); - RotationType R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); - RotationType R_C = R_A * R_B.inv(); - - T6DOF C; - R_C.toEuler(C.axes[Yaw], C.axes[Pitch], C.axes[Roll]); - C.axes[Yaw] *= R2D; - C.axes[Pitch] *= R2D; - C.axes[Roll] *= R2D; - - C.axes[TX] = A.axes[TX] - B.axes[TX]; - C.axes[TY] = A.axes[TY] - B.axes[TY]; - C.axes[TZ] = A.axes[TZ] - B.axes[TZ]; - return C; -} - -T6DOF operator+(const T6DOF& A, const T6DOF& B) -{ - RotationType R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); - RotationType R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); - RotationType R_C = R_A * R_B; - - T6DOF C; - R_C.toEuler(C.axes[Yaw], C.axes[Pitch], C.axes[Roll]); - C.axes[Yaw] *= R2D; - C.axes[Pitch] *= R2D; - C.axes[Roll] *= R2D; - - C.axes[TX] = A.axes[TX] + B.axes[TX]; - C.axes[TY] = A.axes[TY] + B.axes[TY]; - C.axes[TZ] = A.axes[TZ] + B.axes[TZ]; - return C; -} diff --git a/facetracknoir/tracker_types.h b/facetracknoir/tracker_types.h index 80b747597..c667498ec 100644 --- a/facetracknoir/tracker_types.h +++ b/facetracknoir/tracker_types.h @@ -1,11 +1,66 @@ #pragma once +#include +#include +#include "rotation.h" +#include "plugin-api.hpp" + struct T6DOF { -public: - double axes[6]; +private: + static constexpr double PI = 3.14159265358979323846264; + static constexpr double D2R = PI/180.0; + static constexpr double R2D = 180.0/PI; + double axes[6]; +public: T6DOF() : axes {0,0,0, 0,0,0 } {} -}; -T6DOF operator-(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B -T6DOF operator+(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B^-1 + inline operator double*() { return axes; } + inline operator const double*() const { return axes; } + + inline double& operator()(int i) { return axes[i]; } + inline double operator()(int i) const { return axes[i]; } + + Quat quat() const + { + return Quat(axes[Yaw]*D2R, axes[Pitch]*D2R, axes[Roll]*D2R); + } + + static T6DOF fromQuat(const Quat& q) + { + T6DOF ret; + q.toEuler(ret(Yaw), ret(Pitch), ret(Roll)); + return ret; + } + + T6DOF operator-(const T6DOF& B) const + { + const Quat q = (quat() * B.quat().inv()); + T6DOF ret = fromQuat(q); + for (int i = TX; i < Yaw; i++) + ret(i) = B(i); + return ret; + } + + T6DOF operator+(const T6DOF& B) const + { + const Quat q = (quat() * B.quat().inv()); + T6DOF ret = fromQuat(q); + for (int i = TX; i < Yaw; i++) + ret(i) = B(i); + return ret; + } + + T6DOF operator|(const T6DOF& replacement) const + { + T6DOF ret = *this; + for (int i = 0; i < 6; i++) + { + static constexpr double eps = 1e-5; + // NB replace zero-valued elements with argument's + if (std::abs(ret(i)) < eps) + ret(i) = replacement(i); + } + return ret; + } +}; diff --git a/freetrackclient/freetrackclient.c b/freetrackclient/freetrackclient.c index 5323bcaeb..200242b9b 100644 --- a/freetrackclient/freetrackclient.c +++ b/freetrackclient/freetrackclient.c @@ -27,27 +27,27 @@ #include #include -#include "ftnoir_protocol_ft/fttypes.h" +#include "../ftnoir_protocol_ft/fttypes.h" #define FT_EXPORT(t) __declspec(dllexport) t __stdcall #if 0 -#include +# include static FILE *debug_stream = fopen("c:\\FreeTrackClient.log", "a"); -#define dbg_report(...) if (debug_stream) { fprintf(debug_stream, __VA_ARGS__); fflush(debug_stream); } +# define dbg_report(...) if (debug_stream) { fprintf(debug_stream, __VA_ARGS__); fflush(debug_stream); } #else #define dbg_report(...) ((void)0) #endif static HANDLE hFTMemMap = 0; -static FTHeap *pMemData = 0; -static HANDLE hFTMutex = 0; +static FTHeap* ipc_heap = 0; +static HANDLE ipc_mutex = 0; static const char* dllVersion = "1.0.0.0"; static const char* dllProvider = "FreeTrack"; -static bool FTCreateMapping(void) +static bool impl_create_mapping(void) { - if (pMemData != NULL) + if (ipc_heap != NULL) return true; hFTMemMap = CreateFileMappingA(INVALID_HANDLE_VALUE, @@ -58,26 +58,27 @@ static bool FTCreateMapping(void) (LPCSTR) FREETRACK_HEAP); if (hFTMemMap == NULL) - return (pMemData = NULL), false; + return (ipc_heap = NULL), false; - pMemData = (FTHeap*) MapViewOfFile(hFTMemMap, FILE_MAP_WRITE, 0, 0, sizeof(FTHeap)); - hFTMutex = CreateMutexA(NULL, false, FREETRACK_MUTEX); + ipc_heap = (FTHeap*) MapViewOfFile(hFTMemMap, FILE_MAP_WRITE, 0, 0, sizeof(FTHeap)); + ipc_mutex = CreateMutexA(NULL, false, FREETRACK_MUTEX); return true; } +#pragma comment (linker, "/export:FTGetData") FT_EXPORT(bool) FTGetData(FTData* data) { - if (FTCreateMapping() == false) + if (impl_create_mapping() == false) return false; - if (hFTMutex && WaitForSingleObject(hFTMutex, 16) == WAIT_OBJECT_0) { - if (pMemData) { - if (pMemData->data.DataID > (1 << 29)) - pMemData->data.DataID = 0; - data->DataID = pMemData->data.DataID; + if (ipc_mutex && WaitForSingleObject(ipc_mutex, 16) == WAIT_OBJECT_0) { + if (ipc_heap) { + if (ipc_heap->data.DataID > (1 << 29)) + ipc_heap->data.DataID = 0; + data->DataID = ipc_heap->data.DataID; } - ReleaseMutex(hFTMutex); + ReleaseMutex(ipc_mutex); } return true; } @@ -87,17 +88,20 @@ FT_EXPORT(bool) FTGetData(FTData* data) // The Delphi-code from the FreeTrack repo suggest a char * as argument, so it cost me an afternoon to figure it out (and keep ArmA2 from crashing). // Thanks guys! */ +#pragma comment (linker, "/export:FTReportName") FT_EXPORT(void) FTReportName( int name ) { dbg_report("FTReportName request (ID = %d).\n", name); } +#pragma comment (linker, "/export:FTGetDllVersion") FT_EXPORT(const char*) FTGetDllVersion(void) { dbg_report("FTGetDllVersion request.\n"); return dllVersion; } +#pragma comment (linker, "/export:FTProvider") FT_EXPORT(const char*) FTProvider(void) { dbg_report("FTProvider request.\n"); diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index a47ebf4ff..cbe728ab0 100755 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -1,6 +1,6 @@ #pragma once /* Copyright (c) 2013 Stanisław Halik - * + * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. @@ -10,13 +10,12 @@ #include "ui_ftnoir_kalman_filtercontrols.h" #include "facetracknoir/plugin-api.hpp" -#include +#include +#include #include #include -#include -#include #include -#include +#include #include "facetracknoir/options.h" using namespace options; @@ -24,7 +23,7 @@ class OPENTRACK_EXPORT FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - void reset() override; + void reset(); void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) override; cv::KalmanFilter kalman; diff --git a/ftnoir_protocol_ft/fttypes.h b/ftnoir_protocol_ft/fttypes.h index 0558f8812..f41350c87 100644 --- a/ftnoir_protocol_ft/fttypes.h +++ b/ftnoir_protocol_ft/fttypes.h @@ -19,7 +19,11 @@ #pragma once -#include +#ifndef _MSC_VER +# include +#else +typedef unsigned __int32 uint32_t; +#endif #define FREETRACK_HEAP "FT_SharedMem" #define FREETRACK_MUTEX "FT_Mutext" @@ -54,7 +58,9 @@ typedef struct __FTData { float Y4; } FTData; -typedef struct __FTAlloc { +/* we add some shit at the end for other legacy proto, sadly */ + +typedef struct __FTHeap { FTData data; int32_t GameID; unsigned char table[8]; diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 159f350e5..f39562c1b 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -17,12 +17,12 @@ #include #include -void FunctionConfig::setTrackingActive(bool blnActive) +void Map::setTrackingActive(bool blnActive) { activep = blnActive; } -FunctionConfig::FunctionConfig() : +Map::Map() : _mutex(QMutex::Recursive), data(0), activep(false), @@ -31,7 +31,7 @@ FunctionConfig::FunctionConfig() : { } -float FunctionConfig::getValue(float x) { +float Map::getValue(float x) { QMutexLocker foo(&_mutex); int x2 = (int) (std::min(std::max(x, -360), 360) * MEMOIZE_PRECISION); float ret = getValueInternal(x2); @@ -40,13 +40,13 @@ float FunctionConfig::getValue(float x) { return ret; } -bool FunctionConfig::getLastPoint(QPointF& point ) { +bool Map::getLastPoint(QPointF& point ) { QMutexLocker foo(&_mutex); point = last_input_value; return activep; } -float FunctionConfig::getValueInternal(int x) { +float Map::getValueInternal(int x) { float sign = x < 0 ? -1 : 1; x = x < 0 ? -x : x; float ret; @@ -75,7 +75,7 @@ static bool sortFn(const QPointF& one, const QPointF& two) { return one.x() < two.x(); } -void FunctionConfig::reload() { +void Map::reload() { if (input.size()) qStableSort(input.begin(), input.end(), sortFn); @@ -132,7 +132,7 @@ void FunctionConfig::reload() { } } -void FunctionConfig::removePoint(int i) { +void Map::removePoint(int i) { QMutexLocker foo(&_mutex); if (i >= 0 && i < input.size()) { @@ -141,13 +141,13 @@ void FunctionConfig::removePoint(int i) { } } -void FunctionConfig::addPoint(QPointF pt) { +void Map::addPoint(QPointF pt) { QMutexLocker foo(&_mutex); input.append(pt); reload(); } -void FunctionConfig::movePoint(int idx, QPointF pt) { +void Map::movePoint(int idx, QPointF pt) { QMutexLocker foo(&_mutex); if (idx >= 0 && idx < input.size()) { @@ -156,13 +156,13 @@ void FunctionConfig::movePoint(int idx, QPointF pt) { } } -const QList FunctionConfig::getPoints() { +const QList Map::getPoints() { QMutexLocker foo(&_mutex); // NB can't pass by reference return input; } -void FunctionConfig::loadSettings(QSettings& settings, const QString& title) { +void Map::loadSettings(QSettings& settings, const QString& title) { QMutexLocker foo(&_mutex); QPointF newPoint; @@ -187,7 +187,7 @@ void FunctionConfig::loadSettings(QSettings& settings, const QString& title) { reload(); } -void FunctionConfig::saveSettings(QSettings& settings, const QString& title) { +void Map::saveSettings(QSettings& settings, const QString& title) { QMutexLocker foo(&_mutex); settings.beginGroup(QString("Curves-%1").arg(title)); int max = input.size(); diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 66e7f3e8b..ccfd1ba38 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -13,88 +13,55 @@ #include #include #include -#include "facetracknoir/plugin-api.hpp" #include +#include "../facetracknoir/plugin-api.hpp" +#include "../facetracknoir/qcopyable-mutex.hpp" #define MEMOIZE_PRECISION 100 -class MyMutex { -private: - QMutex inner; - -public: - QMutex* operator->() { return &inner; } - QMutex* operator->() const { return &const_cast(this)->inner; } - - MyMutex operator=(const MyMutex& datum) - { - auto mode = - datum->isRecursive() - ? QMutex::Recursive - : QMutex::NonRecursive; - - return MyMutex(mode); - } - - MyMutex(const MyMutex& datum) - { - *this = datum; - } - - MyMutex(QMutex::RecursionMode mode = QMutex::NonRecursive) : - inner(mode) - { - } - - QMutex* operator&() - { - return &inner; - } -}; - -class OPENTRACK_EXPORT FunctionConfig { +class OPENTRACK_EXPORT Map { private: void reload(); float getValueInternal(int x); - + MyMutex _mutex; - QList input; + QList input; std::vector data; - QPointF last_input_value; + QPointF last_input_value; volatile bool activep; - int max_x; - int max_y; + int max_x; + int max_y; public: int maxInput() const { return max_x; } int maxOutput() const { return max_y; } - FunctionConfig(); - FunctionConfig(int maxx, int maxy) + Map(); + Map(int maxx, int maxy) { setMaxInput(maxx); setMaxOutput(maxy); } float getValue(float x); - bool getLastPoint(QPointF& point); - void removePoint(int i); + bool getLastPoint(QPointF& point); + void removePoint(int i); void removeAllPoints() { QMutexLocker foo(&_mutex); input.clear(); reload(); } - void addPoint(QPointF pt); - void movePoint(int idx, QPointF pt); - const QList getPoints(); - void setMaxInput(int MaxInput) { - max_x = MaxInput; - } - void setMaxOutput(int MaxOutput) { - max_y = MaxOutput; - } + void addPoint(QPointF pt); + void movePoint(int idx, QPointF pt); + const QList getPoints(); + void setMaxInput(int MaxInput) { + max_x = MaxInput; + } + void setMaxOutput(int MaxOutput) { + max_y = MaxOutput; + } - void saveSettings(QSettings& settings, const QString& title); - void loadSettings(QSettings& settings, const QString& title); + void saveSettings(QSettings& settings, const QString& title); + void loadSettings(QSettings& settings, const QString& title); - void setTrackingActive(bool blnActive); + void setTrackingActive(bool blnActive); }; diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 1e5b957cc..57d1500ac 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -37,7 +37,7 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) : setMouseTracking(true); } -void QFunctionConfigurator::setConfig(FunctionConfig* config, const QString& name) { +void QFunctionConfigurator::setConfig(Map* config, const QString& name) { QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index facc5bbe3..e35d0bc38 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -20,8 +20,8 @@ class OPENTRACK_EXPORT QFunctionConfigurator : public QWidget public: QFunctionConfigurator(QWidget *parent = 0); - FunctionConfig* config(); - void setConfig(FunctionConfig* config, const QString &name); + Map* config(); + void setConfig(Map* config, const QString &name); QColor colorBezier() const { @@ -65,7 +65,7 @@ private: QPointF pixel_coord_to_point (const QPointF& point); QPointF point_to_pixel (const QPointF& point); - FunctionConfig* _config; + Map* _config; // bounds of the rectangle user can interact with QRectF pixel_bounds; -- cgit v1.2.3 From cfffa29e29db6b2234c7f534b1ebcd612b7f4914 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Oct 2014 01:22:11 +0200 Subject: flush --- CMakeLists.txt | 3 +- facetracknoir/quat.hpp | 66 ++++++++++ facetracknoir/rotation.h | 58 -------- facetracknoir/tracker.h | 2 - facetracknoir/tracker_types.h | 14 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 148 ++++++++++----------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 13 +- ftnoir_tracker_aruco/include/aruco.h | 29 ++-- ftnoir_tracker_aruco/include/arucofidmarkers.h | 15 +-- ftnoir_tracker_aruco/include/board.h | 168 ------------------------ ftnoir_tracker_aruco/include/boarddetector.h | 139 -------------------- ftnoir_tracker_aruco/include/cameraparameters.h | 6 +- ftnoir_tracker_aruco/include/cvdrawingutils.h | 19 +-- ftnoir_tracker_aruco/include/exports.h | 6 +- ftnoir_tracker_aruco/include/marker.h | 16 +-- ftnoir_tracker_aruco/include/markerdetector.h | 56 ++++---- ftnoir_tracker_aruco/trans_calib.h | 2 +- ftnoir_tracker_pt/camera.h | 2 +- ftnoir_tracker_pt/ftnoir_tracker_pt.h | 54 ++++---- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 88 ++++++------- ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 4 +- ftnoir_tracker_pt/point_extractor.h | 4 +- ftnoir_tracker_pt/point_tracker.h | 74 +++++------ ftnoir_tracker_pt/pt_video_widget.h | 2 +- ftnoir_tracker_pt/trans_calib.h | 2 +- 25 files changed, 338 insertions(+), 652 deletions(-) create mode 100644 facetracknoir/quat.hpp delete mode 100644 facetracknoir/rotation.h delete mode 100644 ftnoir_tracker_aruco/include/board.h delete mode 100644 ftnoir_tracker_aruco/include/boarddetector.h (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 655d70c3c..2de8856d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,7 +344,6 @@ opentrack_library(opentrack-tracker-ht) target_link_libraries(opentrack-tracker-ht opentrack-compat) if(SDK_ARUCO_LIBPATH) - include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) opentrack_library(opentrack-tracker-aruco) target_link_libraries(opentrack-tracker-aruco ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) endif() @@ -477,7 +476,7 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) install(FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe" DESTINATION .) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetracknoir/clientfiles" DESTINATION .) -if(NOT WIN32 AND SDK_WINE_PREFIX) +if(NOT WIN32 AND SDK_WINE_PREFIX AND NOT SDK_WINE_NO_WRAPPER) install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" DESTINATION .) endif() diff --git a/facetracknoir/quat.hpp b/facetracknoir/quat.hpp new file mode 100644 index 000000000..1e2689630 --- /dev/null +++ b/facetracknoir/quat.hpp @@ -0,0 +1,66 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#pragma once +#include + +class Quat { +private: + static constexpr double pi = 3.141592653; + static constexpr double r2d = 180./pi; + double a,b,c,d; // quaternion coefficients +public: + Quat() : a(1.0),b(0.0),c(0.0),d(0.0) {} + Quat(double yaw, double pitch, double roll) { from_euler_rads(yaw, pitch, roll); } + Quat(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} + + Quat inv(){ + return Quat(a,-b,-c, -d); + } + + // conversions + // see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles + void from_euler_rads(double yaw, double pitch, double roll) + { + + double sin_phi = sin(roll/2.0); + double cos_phi = cos(roll/2.0); + double sin_the = sin(pitch/2.0); + double cos_the = cos(pitch/2.0); + double sin_psi = sin(yaw/2.0); + double cos_psi = cos(yaw/2.0); + + a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; + b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; + c = cos_phi*sin_the*cos_psi + sin_phi*cos_the*sin_psi; + d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; + } + + void to_euler_rads(double& yaw, double& pitch, double& roll) const + { + roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); + pitch = asin(2.0*(a*c - b*d)); + yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); + } + + void to_euler_degrees(double& yaw, double& pitch, double& roll) const + { + to_euler_rads(yaw, pitch, roll); + yaw *= r2d; + pitch *= r2d; + roll *= r2d; + } + + const Quat operator*(const Quat& B) const + { + const Quat& A = *this; + return Quat(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication + A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, + A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, + A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); + } +}; diff --git a/facetracknoir/rotation.h b/facetracknoir/rotation.h deleted file mode 100644 index b3bb891ec..000000000 --- a/facetracknoir/rotation.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#pragma once -#include - -class Quat { - -public: - Quat() : a(1.0),b(0.0),c(0.0),d(0.0) {} - Quat(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } - Quat(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} - - Quat inv(){ - return Quat(a,-b,-c, -d); - } - - // conversions - // see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles - void fromEuler(double yaw, double pitch, double roll) - { - - double sin_phi = sin(roll/2.0); - double cos_phi = cos(roll/2.0); - double sin_the = sin(pitch/2.0); - double cos_the = cos(pitch/2.0); - double sin_psi = sin(yaw/2.0); - double cos_psi = cos(yaw/2.0); - - a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; - b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; - c = cos_phi*sin_the*cos_psi + sin_phi*cos_the*sin_psi; - d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; - } - - void toEuler(double& yaw, double& pitch, double& roll) const - { - roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); - pitch = asin(2.0*(a*c - b*d)); - yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); - } - - const Quat operator*(const Quat& B) const - { - const Quat& A = *this; - return Quat(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication - A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, - A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, - A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); - } - -private: - double a,b,c,d; // quaternion coefficients -}; diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 05ae41807..3d9a3858c 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -22,8 +22,6 @@ #include "facetracknoir/options.h" #include "facetracknoir/timer.hpp" - - class Tracker : protected QThread { Q_OBJECT private: diff --git a/facetracknoir/tracker_types.h b/facetracknoir/tracker_types.h index c667498ec..02aacdcf6 100644 --- a/facetracknoir/tracker_types.h +++ b/facetracknoir/tracker_types.h @@ -2,14 +2,14 @@ #include #include -#include "rotation.h" -#include "plugin-api.hpp" +#include "./quat.hpp" +#include "./plugin-api.hpp" struct T6DOF { private: - static constexpr double PI = 3.14159265358979323846264; - static constexpr double D2R = PI/180.0; - static constexpr double R2D = 180.0/PI; + static constexpr double pi = 3.141592653; + static constexpr double d2r = pi/180.0; + static constexpr double r2d = 180./pi; double axes[6]; public: @@ -23,13 +23,13 @@ public: Quat quat() const { - return Quat(axes[Yaw]*D2R, axes[Pitch]*D2R, axes[Roll]*D2R); + return Quat(axes[Yaw]*d2r, axes[Pitch]*d2r, axes[Roll]*d2r); } static T6DOF fromQuat(const Quat& q) { T6DOF ret; - q.toEuler(ret(Yaw), ret(Pitch), ret(Roll)); + q.to_euler_rads(ret(Yaw), ret(Pitch), ret(Roll)); return ret; } diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index e216d3196..a1e15721f 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -8,13 +8,13 @@ #include "ftnoir_tracker_aruco.h" #include "ui_aruco-trackercontrols.h" #include "facetracknoir/plugin-api.hpp" -#include #include -#include -#include -#include +#include "include/markerdetector.h" +#include +#include #include #include +#include #if defined(_WIN32) # undef NOMINMAX @@ -29,51 +29,51 @@ static QList get_camera_names(void) { QList ret; #if defined(_WIN32) - // Create the System Device Enumerator. - HRESULT hr; - ICreateDevEnum *pSysDevEnum = NULL; - hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); - if (FAILED(hr)) - { - return ret; - } - // Obtain a class enumerator for the video compressor category. - IEnumMoniker *pEnumCat = NULL; - hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); - - if (hr == S_OK) { - // Enumerate the monikers. - IMoniker *pMoniker = NULL; - ULONG cFetched; - while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { - IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); - if (SUCCEEDED(hr)) { - // To retrieve the filter's friendly name, do the following: - VARIANT varName; - VariantInit(&varName); - hr = pPropBag->Read(L"FriendlyName", &varName, 0); - if (SUCCEEDED(hr)) - { - // Display the name in your UI somehow. - QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); - ret.append(str); - } - VariantClear(&varName); - - ////// To create an instance of the filter, do the following: - ////IBaseFilter *pFilter; - ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, - //// (void**)&pFilter); - // Now add the filter to the graph. - //Remember to release pFilter later. - pPropBag->Release(); - } - pMoniker->Release(); - } - pEnumCat->Release(); - } - pSysDevEnum->Release(); + // Create the System Device Enumerator. + HRESULT hr; + ICreateDevEnum *pSysDevEnum = NULL; + hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); + if (FAILED(hr)) + { + return ret; + } + // Obtain a class enumerator for the video compressor category. + IEnumMoniker *pEnumCat = NULL; + hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); + + if (hr == S_OK) { + // Enumerate the monikers. + IMoniker *pMoniker = NULL; + ULONG cFetched; + while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { + IPropertyBag *pPropBag; + hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); + if (SUCCEEDED(hr)) { + // To retrieve the filter's friendly name, do the following: + VARIANT varName; + VariantInit(&varName); + hr = pPropBag->Read(L"FriendlyName", &varName, 0); + if (SUCCEEDED(hr)) + { + // Display the name in your UI somehow. + QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); + ret.append(str); + } + VariantClear(&varName); + + ////// To create an instance of the filter, do the following: + ////IBaseFilter *pFilter; + ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, + //// (void**)&pFilter); + // Now add the filter to the graph. + //Remember to release pFilter later. + pPropBag->Release(); + } + pMoniker->Release(); + } + pEnumCat->Release(); + } + pSysDevEnum->Release(); #else for (int i = 0; i < 16; i++) { char buf[128]; @@ -89,15 +89,15 @@ static QList get_camera_names(void) { } typedef struct { - int width; - int height; + int width; + int height; } resolution_tuple; static resolution_tuple resolution_choices[] = { - { 640, 480 }, - { 320, 240 }, - { 320, 200 }, - { 0, 0 } + { 640, 480 }, + { 320, 240 }, + { 320, 200 }, + { 0, 0 } }; Tracker::Tracker() : stop(false), layout(nullptr), videoWidget(nullptr) @@ -108,8 +108,8 @@ Tracker::~Tracker() { stop = true; wait(); - if (videoWidget) - delete videoWidget; + if (videoWidget) + delete videoWidget; if(layout) delete layout; qDebug() << "releasing camera, brace for impact"; @@ -178,7 +178,7 @@ void Tracker::run() } if (fps) camera.set(CV_CAP_PROP_FPS, fps); - + aruco::MarkerDetector detector; detector.setDesiredSpeed(3); @@ -187,7 +187,7 @@ void Tracker::run() cv::Mat color, color_, grayscale, rvec, tvec; const double stateful_coeff = 0.88; - + if (!camera.isOpened()) { fprintf(stderr, "aruco tracker: can't open camera\n"); @@ -214,7 +214,7 @@ void Tracker::run() grayscale = channel[2]; } else cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); - + gain.tick(camera, grayscale); const int scale = frame.cols > 480 ? 2 : 1; @@ -280,11 +280,11 @@ void Tracker::run() cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(0, 255, 0), scale); ::sprintf(buf, "Jiffies: %ld", (long) (10000 * (time - tm) / freq)); cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); - + if (markers.size() == 1 && markers[0].size() == 4) { const auto& m = markers.at(0); const float size = 40; - + const double p = s.marker_pitch; const double sq = sin(p * HT_PI / 180); const double cq = cos(p * HT_PI / 180); @@ -380,7 +380,7 @@ void Tracker::run() void Tracker::GetHeadPoseData(double *data) { QMutexLocker lck(&mtx); - + data[Yaw] = pose[Yaw]; data[Pitch] = pose[Pitch]; data[Roll] = pose[Roll]; @@ -391,11 +391,11 @@ void Tracker::GetHeadPoseData(double *data) class TrackerDll : public Metadata { - // ITrackerDll interface - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); + // ITrackerDll interface + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); }; //----------------------------------------------------------------------------- @@ -406,12 +406,12 @@ void TrackerDll::getFullName(QString *strToBeFilled) void TrackerDll::getShortName(QString *strToBeFilled) { - *strToBeFilled = "aruco"; + *strToBeFilled = "aruco"; } void TrackerDll::getDescription(QString *strToBeFilled) { - *strToBeFilled = ""; + *strToBeFilled = ""; } void TrackerDll::getIcon(QIcon *icon) @@ -425,7 +425,7 @@ void TrackerDll::getIcon(QIcon *icon) extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() { - return new TrackerDll; + return new TrackerDll; } //#pragma comment(linker, "/export:GetTracker=_GetTracker@0") @@ -444,11 +444,11 @@ TrackerControls::TrackerControls() { tracker = nullptr; calib_timer.setInterval(200); - ui.setupUi(this); + ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); ui.cameraName->addItems(get_camera_names()); tie_setting(s.camera_index, ui.cameraName); - tie_setting(s.resolution, ui.resolution); + tie_setting(s.resolution, ui.resolution); tie_setting(s.force_fps, ui.cameraFPS); tie_setting(s.fov, ui.cameraFOV); tie_setting(s.headpos_x, ui.cx); @@ -500,7 +500,7 @@ void TrackerControls::doOK() s.b->save(); if (tracker) tracker->reload(); - this->close(); + this->close(); } void TrackerControls::doCancel() diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 5416bb52f..9ac574172 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -16,12 +16,9 @@ #include #include #include -#include -#include #include "facetracknoir/options.h" #include "ftnoir_tracker_aruco/trans_calib.h" #include "facetracknoir/plugin-api.hpp" - #include "facetracknoir/gain-control.hpp" using namespace options; @@ -50,7 +47,7 @@ class Tracker : protected QThread, public ITracker { Q_OBJECT public: - Tracker(); + Tracker(); ~Tracker() override; void StartTracker(QFrame* frame); void GetHeadPoseData(double *data); @@ -61,7 +58,7 @@ private: QMutex mtx; volatile bool stop; QHBoxLayout* layout; - ArucoVideoWidget* videoWidget; + ArucoVideoWidget* videoWidget; settings s; double pose[6]; cv::Mat frame; @@ -83,14 +80,14 @@ public: tracker = nullptr; } private: - Ui::Form ui; + Ui::Form ui; Tracker* tracker; settings s; TranslationCalibrator calibrator; QTimer calib_timer; private slots: - void doOK(); - void doCancel(); + void doOK(); + void doCancel(); void toggleCalibrate(); void cleanupCalib(); void update_tracker_calibration(); diff --git a/ftnoir_tracker_aruco/include/aruco.h b/ftnoir_tracker_aruco/include/aruco.h index 569b95fb8..8ea583a8b 100644 --- a/ftnoir_tracker_aruco/include/aruco.h +++ b/ftnoir_tracker_aruco/include/aruco.h @@ -26,12 +26,12 @@ The views and conclusions contained in the software and documentation are those authors and should not be interpreted as representing official policies, either expressed or implied, of Rafael Muñoz Salinas. - - + + \mainpage ArUco: Augmented Reality library from the University of Cordoba -ArUco is a minimal C++ library for detection of Augmented Reality markers based on OpenCv exclusively. +ArUco is a minimal C++ library for detection of Augmented Reality markers based on OpenCv exclusively. It is an educational project to show student how to detect augmented reality markers and it is provided under BSD license. @@ -54,11 +54,11 @@ Aruco allows the possibility to employ board. Boards are markers composed by an The library comes with five applications that will help you to learn how to use the library: - aruco_create_marker: which creates marker and saves it in a jpg file you can print. - - aruco_simple : simple test aplication that detects the markers in a image + - aruco_simple : simple test aplication that detects the markers in a image - aruco_test: this is the main application for detection. It reads images either from the camera of from a video and detect markers. Additionally, if you provide the intrinsics of the camera(obtained by OpenCv calibration) and the size of the marker in meters, the library calculates the marker intrinsics so that you can easily create your AR applications. - aruco_test_gl: shows how to use the library AR applications using OpenGL for rendering - aruco_create_board: application that helps you to create a board - - aruco_simple_board: simple test aplication that detects a board of markers in a image + - aruco_simple_board: simple test aplication that detects a board of markers in a image - aruco_test_board: application that detects boards - aruco_test_board_gl: application that detects boards and uses OpenGL to draw @@ -66,7 +66,7 @@ The library comes with five applications that will help you to learn how to use The ArUco library contents are divided in two main directories. The src directory, which contains the library itself. And the utils directory which contains the applications. -The library main classes are: +The library main classes are: - aruco::CameraParameters: represent the information of the camera that captures the images. Here you must set the calibration info. - aruco::Marker: which represent a marker detected in the image - aruco::MarkerDetector: that is in charge of deteting the markers in a image Detection is done by simple calling the member funcion ArMarkerDetector::detect(). Additionally, the classes contain members to create the required matrices for rendering using OpenGL. See aruco_test_gl for details @@ -101,34 +101,33 @@ The library has been compiled using MinGW and codeblocks. Below I describe the b -# Download the source code and compile it using cmake and codeblocks. Note: install the library in C:\ if you want it to be easily detected by cmake afterwards - step 4) aruco -# Download and decompress. - -# Open cmake gui application and set the path to the main library directory and also set a path where the project is going to be built. + -# Open cmake gui application and set the path to the main library directory and also set a path where the project is going to be built. -# Generate the codeblock project. -# Open the project with codeblock and compile then, install. The programs will be probably generated into the bin directory OpenGL: by default, the mingw version installed has not the glut library. So, the opengl programs are not compiled. If you want to compile with OpenGL support, you must install glut, or prefereably freeglut. -Thus, - - Download the library (http://www.martinpayne.me.uk/software/development/GLUT/freeglut-MinGW.zip) for mingw. - - Decompress in a directory X. +Thus, + - Download the library (http://www.martinpayne.me.uk/software/development/GLUT/freeglut-MinGW.zip) for mingw. + - Decompress in a directory X. - Then, rerun cmake setting the variable GLU_PATH to that directory (>cmake .. -DGLUT_PATH="C:\X") - Finally, recompile and test. Indeed, you should move the freeglut.dll to the directory with the binaries or to any other place in the PATH. CONCLUSION: Move to Linux, things are simpler :P - -\section Testing + +\section Testing For testing the applications, the library provides videos and the corresponding camera parameters of these videos. Into the directories you will find information on how to run the examples. - + \section Final Notes - REQUIREMENTS: OpenCv >= 2.1.0. and OpenGL for (aruco_test_gl and aruco_test_board_gl) - CONTACT: Rafael Munoz-Salinas: rmsalinas@uco.es - This libary is free software and come with no guaratee! - + */ #include "markerdetector.h" -#include "boarddetector.h" #include "cvdrawingutils.h" diff --git a/ftnoir_tracker_aruco/include/arucofidmarkers.h b/ftnoir_tracker_aruco/include/arucofidmarkers.h index 7dad46728..15eb8e4c7 100644 --- a/ftnoir_tracker_aruco/include/arucofidmarkers.h +++ b/ftnoir_tracker_aruco/include/arucofidmarkers.h @@ -31,7 +31,6 @@ or implied, of Rafael Muñoz Salinas. #include #include "exports.h" #include "marker.h" -#include "board.h" namespace aruco { class ARUCO_EXPORTS FiducidalMarkers { @@ -80,7 +79,7 @@ public: * @param gridSize grid layout (numer of sqaures in x and Y) * @param MarkerSize size of markers sides in pixels * @param MarkerDistance distance between the markers - * @param TInfo output + * @param TInfo output * @param excludedIds set of ids excluded from the board */ static cv::Mat createBoardImage( cv::Size gridSize,int MarkerSize,int MarkerDistance, BoardConfiguration& TInfo ,vector *excludedIds=NULL ) throw (cv::Exception); @@ -89,24 +88,24 @@ public: /**Creates a printable image of a board in chessboard_like manner * @param gridSize grid layout (numer of sqaures in x and Y) * @param MarkerSize size of markers sides in pixels - * @param TInfo output + * @param TInfo output * @param setDataCentered indicates if the center is set at the center of the board. Otherwise it is the left-upper corner - * + * */ static cv::Mat createBoardImage_ChessBoard( cv::Size gridSize,int MarkerSize, BoardConfiguration& TInfo ,bool setDataCentered=true ,vector *excludedIds=NULL) throw (cv::Exception); - /**Creates a printable image of a board in a frame fashion + /**Creates a printable image of a board in a frame fashion * @param gridSize grid layout (numer of sqaures in x and Y) * @param MarkerSize size of markers sides in pixels * @param MarkerDistance distance between the markers - * @param TInfo output + * @param TInfo output * @param setDataCentered indicates if the center is set at the center of the board. Otherwise it is the left-upper corner - * + * */ static cv::Mat createBoardImage_Frame( cv::Size gridSize,int MarkerSize,int MarkerDistance, BoardConfiguration& TInfo ,bool setDataCentered=true,vector *excludedIds=NULL ) throw (cv::Exception); private: - + static vector getListOfValidMarkersIds_random(int nMarkers,vector *excluded) throw (cv::Exception); static cv::Mat rotate(const cv::Mat & in); static int hammDistMarker(cv::Mat bits); diff --git a/ftnoir_tracker_aruco/include/board.h b/ftnoir_tracker_aruco/include/board.h deleted file mode 100644 index c1d792925..000000000 --- a/ftnoir_tracker_aruco/include/board.h +++ /dev/null @@ -1,168 +0,0 @@ -/***************************** -Copyright 2011 Rafael Muñoz Salinas. All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, this list - of conditions and the following disclaimer in the documentation and/or other materials - provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The views and conclusions contained in the software and documentation are those of the -authors and should not be interpreted as representing official policies, either expressed -or implied, of Rafael Muñoz Salinas. -********************************/ -#ifndef _Aruco_board_h -#define _Aruco_board_h -#include -#include -#include -#include "exports.h" -#include "marker.h" -using namespace std; -namespace aruco { -/** - * 3d representation of a marker - */ -struct ARUCO_EXPORTS MarkerInfo:public vector { - MarkerInfo() {} - MarkerInfo(int _id) {id=_id; } - MarkerInfo(const MarkerInfo&MI): vector(MI){id=MI.id; } - MarkerInfo & operator=(const MarkerInfo&MI){ - vector ::operator=(MI); - id=MI.id; - return *this; - } - int id;//maker id -}; - -/**\brief This class defines a board with several markers. - * A Board contains several markers so that they are more robustly detected. - * - * In general, a board is a set of markers. So BoardConfiguration is only a list - * of the id of the markers along with the position of their corners. - * - * The position of the corners can be specified either in pixels (in a non-specific size) or in meters. - * The first is the typical case in which you generate the image of board and the print it. Since you do not know in advance the real - * size of the markers, their corners are specified in pixels, and then, the translation to meters can be made once you know the real size. - * - * On the other hand, you may want to have the information of your boards in meters. The BoardConfiguration allows you to do so. - * - * The point is in the mInfoType variable. It can be either PIX or METERS according to your needs. - * -*/ - - -class ARUCO_EXPORTS BoardConfiguration: public vector -{ - friend class Board; -public: - enum MarkerInfoType {NONE=-1,PIX=0,METERS=1};//indicates if the data in MakersInfo is expressed in meters or in pixels so as to do conversion internally - //variable indicates if the data in MakersInfo is expressed in meters or in pixels so as to do conversion internally - int mInfoType; - /** - */ - BoardConfiguration(); - - /** - */ - BoardConfiguration(const BoardConfiguration &T); - - /** - */ - BoardConfiguration & operator=(const BoardConfiguration &T); - /**Saves the board info to a file - */ - void saveToFile(string sfile)throw (cv::Exception); - /**Reads board info from a file - */ - void readFromFile(string sfile)throw (cv::Exception); - /**Indicates if the corners are expressed in meters - */ - bool isExpressedInMeters()const { - return mInfoType==METERS; - } - /**Indicates if the corners are expressed in meters - */ - bool isExpressedInPixels()const { - return mInfoType==PIX; - } - /**Returns the index of the marker with id indicated, if is in the list - */ - int getIndexOfMarkerId(int id)const; - /**Returns the Info of the marker with id specified. If not in the set, throws exception - */ - const MarkerInfo& getMarkerInfo(int id)const throw (cv::Exception); - /**Set in the list passed the set of the ids - */ - void getIdList(vector &ids,bool append=true)const; -private: - /**Saves the board info to a file - */ - void saveToFile(cv::FileStorage &fs)throw (cv::Exception); - /**Reads board info from a file - */ - void readFromFile(cv::FileStorage &fs)throw (cv::Exception); -}; - -/** -*/ -class ARUCO_EXPORTS Board:public vector -{ - -public: - BoardConfiguration conf; - //matrices of rotation and translation respect to the camera - cv::Mat Rvec,Tvec; - /** - */ - Board() - { - Rvec.create(3,1,CV_32FC1); - Tvec.create(3,1,CV_32FC1); - for (int i=0;i<3;i++) - Tvec.at(i,0)=Rvec.at(i,0)=-999999; - } - - /**Given the extrinsic camera parameters returns the GL_MODELVIEW matrix for opengl. - * Setting this matrix, the reference corrdinate system will be set in this board - */ - void glGetModelViewMatrix(double modelview_matrix[16])throw(cv::Exception); - - /** - * Returns position vector and orientation quaternion for an Ogre scene node or entity. - * Use: - * ... - * Ogre::Vector3 ogrePos (position[0], position[1], position[2]); - * Ogre::Quaternion ogreOrient (orientation[0], orientation[1], orientation[2], orientation[3]); - * mySceneNode->setPosition( ogrePos ); - * mySceneNode->setOrientation( ogreOrient ); - * ... - */ - void OgreGetPoseParameters( double position[3], double orientation[4] )throw(cv::Exception); - - - /**Save this from a file - */ - void saveToFile(string filePath)throw(cv::Exception); - /**Read this from a file - */ - void readFromFile(string filePath)throw(cv::Exception); - -}; -} - -#endif diff --git a/ftnoir_tracker_aruco/include/boarddetector.h b/ftnoir_tracker_aruco/include/boarddetector.h deleted file mode 100644 index 4770b5c9f..000000000 --- a/ftnoir_tracker_aruco/include/boarddetector.h +++ /dev/null @@ -1,139 +0,0 @@ -/***************************** -Copyright 2011 Rafael Muñoz Salinas. All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, this list - of conditions and the following disclaimer in the documentation and/or other materials - provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The views and conclusions contained in the software and documentation are those of the -authors and should not be interpreted as representing official policies, either expressed -or implied, of Rafael Muñoz Salinas. -********************************/ -#ifndef _Aruco_BoardDetector_H -#define _Aruco_BoardDetector_H -#include -#include "exports.h" -#include "board.h" -#include "cameraparameters.h" -#include "markerdetector.h" -using namespace std; - -namespace aruco -{ - -/**\brief This class detects AR boards - * Version 1.2 - * There are two modes for board detection. - * First, the old way. (You first detect markers with MarkerDetector and then call to detect in this class. - * - * Second: New mode, marker detection is included in the class - * \code - - CameraParameters CP; - CP.readFromFile(path_cp) - BoardConfiguration BC; - BC.readFromFile(path_bc); - BoardDetector BD; - BD.setParams(BC,CP); //or only BD.setParams(BC) - //capture image - cv::Mat im; - capture_image(im); - - float prob=BD.detect(im); - if (prob>0.3) - CvDrawingUtils::draw3DAxis(im,BD.getDetectedBoard(),CP); - - \endcode - * -*/ -class ARUCO_EXPORTS BoardDetector -{ -public: - /** See discussion in @see enableRotateXAxis. - * Do not change unless you know what you are doing - */ - BoardDetector(bool setYPerperdicular=true); - - - /** - * Use if you plan to let this class to perform marker detection too - */ - void setParams(const BoardConfiguration &bc,const CameraParameters &cp, float markerSizeMeters=-1); - void setParams(const BoardConfiguration &bc); - /** - * Detect markers, and then, look for the board indicated in setParams() - * @return value indicating the likelihood of having found the marker - */ - float detect(const cv::Mat &im)throw (cv::Exception); - /**Returns a reference to the board detected - */ - Board & getDetectedBoard(){return _boardDetected;} - /**Returns a reference to the internal marker detector - */ - MarkerDetector &getMarkerDetector(){return _mdetector;} - /**Returns the vector of markers detected - */ - vector &getDetectedMarkers(){return _vmarkers;} - - - //ALTERNATIVE DETECTION METHOD, BASED ON MARKERS PREVIOUSLY DETECTED - - /** Given the markers detected, determines if there is the board passed - * @param detectedMarkers result provided by aruco::ArMarkerDetector - * @param BConf the board you want to see if is present - * @param Bdetected output information of the detected board - * @param camMatrix camera matrix with intrinsics - * @param distCoeff camera distorsion coeff - * @param camMatrix intrinsic camera information. - * @param distCoeff camera distorsion coefficient. If set Mat() if is assumed no camera distorion - * @param markerSizeMeters size of the marker sides expressed in meters - * @return value indicating the likelihood of having found the marker - */ - float detect(const vector &detectedMarkers,const BoardConfiguration &BConf, Board &Bdetected, cv::Mat camMatrix=cv::Mat(),cv::Mat distCoeff=cv::Mat(), float markerSizeMeters=-1 )throw (cv::Exception); - float detect(const vector &detectedMarkers,const BoardConfiguration &BConf, Board &Bdetected,const CameraParameters &cp, float markerSizeMeters=-1 )throw (cv::Exception); - - - /** - * By default, the Y axis is set to point up. However this is not the default - * operation mode of opencv, which produces the Z axis pointing up instead. - * So, to achieve this change, we have to rotate the X axis. - */ - void setYPerperdicular(bool enable){_setYPerperdicular=enable;} - - - - -private: - void rotateXAxis(cv::Mat &rotation); - bool _setYPerperdicular; - - //-- Functionality to detect markers inside - bool _areParamsSet; - BoardConfiguration _bconf; - Board _boardDetected; - float _markerSize; - CameraParameters _camParams; - MarkerDetector _mdetector;//internal markerdetector - vector _vmarkers;//markers detected in the call to : float detect(const cv::Mat &im); - -}; - -} -#endif - diff --git a/ftnoir_tracker_aruco/include/cameraparameters.h b/ftnoir_tracker_aruco/include/cameraparameters.h index c3381a74a..a419afbe0 100644 --- a/ftnoir_tracker_aruco/include/cameraparameters.h +++ b/ftnoir_tracker_aruco/include/cameraparameters.h @@ -28,7 +28,7 @@ or implied, of Rafael Muñoz Salinas. #ifndef _Aruco_CameraParameters_H #define _Aruco_CameraParameters_H #include "exports.h" -#include +#include #include using namespace std; namespace aruco @@ -105,7 +105,7 @@ public: * @param invert: indicates if the output projection matrix has to yield a horizontally inverted image because image data has not been stored in the order of glDrawPixels: bottom-to-top. */ void glGetProjectionMatrix( cv::Size orgImgSize, cv::Size size,double proj_matrix[16],double gnear,double gfar,bool invert=false )throw(cv::Exception); - + /** * setup camera for an Ogre project. * Use: @@ -117,7 +117,7 @@ public: * As in OpenGL, it assumes no camera distorsion */ void OgreGetProjectionMatrix( cv::Size orgImgSize, cv::Size size,double proj_matrix[16],double gnear,double gfar,bool invert=false )throw(cv::Exception); - + private: //GL routines diff --git a/ftnoir_tracker_aruco/include/cvdrawingutils.h b/ftnoir_tracker_aruco/include/cvdrawingutils.h index 38e9986e7..24bfe6301 100644 --- a/ftnoir_tracker_aruco/include/cvdrawingutils.h +++ b/ftnoir_tracker_aruco/include/cvdrawingutils.h @@ -33,19 +33,12 @@ namespace aruco { /**\brief A set of functions to draw in opencv images */ - class ARUCO_EXPORTS CvDrawingUtils - { - public: - - static void draw3dAxis(cv::Mat &Image,Marker &m,const CameraParameters &CP); - - static void draw3dCube(cv::Mat &Image,Marker &m,const CameraParameters &CP); - - static void draw3dAxis(cv::Mat &Image,Board &m,const CameraParameters &CP); - - static void draw3dCube(cv::Mat &Image,Board &m,const CameraParameters &CP); - - }; + class ARUCO_EXPORTS CvDrawingUtils + { + public: + static void draw3dAxis(cv::Mat &Image,Marker &m,const CameraParameters &CP); + static void draw3dCube(cv::Mat &Image,Marker &m,const CameraParameters &CP); + }; } #endif diff --git a/ftnoir_tracker_aruco/include/exports.h b/ftnoir_tracker_aruco/include/exports.h index 154605ec2..044a13678 100644 --- a/ftnoir_tracker_aruco/include/exports.h +++ b/ftnoir_tracker_aruco/include/exports.h @@ -25,7 +25,7 @@ The views and conclusions contained in the software and documentation are those authors and should not be interpreted as representing official policies, either expressed or implied, of Rafael Muñoz Salinas. ********************************/ - + #ifndef __OPENARUCO_CORE_TYPES_H__ @@ -37,9 +37,9 @@ or implied, of Rafael Muñoz Salinas. #if (defined WIN32 || defined _WIN32 || defined WINCE) && defined DSO_EXPORTS - #define ARUCO_EXPORTS __declspec(dllexport) + #define ARUCO_EXPORTS __declspec(dllexport) __attribute__((visibility ("default"))) #else - #define ARUCO_EXPORTS + #define ARUCO_EXPORTS __attribute__((visibility ("default"))) #endif diff --git a/ftnoir_tracker_aruco/include/marker.h b/ftnoir_tracker_aruco/include/marker.h index dc6bb28cd..899610028 100644 --- a/ftnoir_tracker_aruco/include/marker.h +++ b/ftnoir_tracker_aruco/include/marker.h @@ -29,7 +29,7 @@ or implied, of Rafael Muñoz Salinas. #define _Aruco_Marker_H #include #include -#include +#include #include "exports.h" #include "cameraparameters.h" using namespace std; @@ -81,12 +81,12 @@ public: * @param setYPerperdicular If set the Y axis will be perpendicular to the surface. Otherwise, it will be the Z axis */ void calculateExtrinsics(float markerSize,cv::Mat CameraMatrix,cv::Mat Distorsion=cv::Mat(),bool setYPerperdicular=true)throw(cv::Exception); - + /**Given the extrinsic camera parameters returns the GL_MODELVIEW matrix for opengl. * Setting this matrix, the reference coordinate system will be set in this marker */ void glGetModelViewMatrix( double modelview_matrix[16])throw(cv::Exception); - + /** * Returns position vector and orientation quaternion for an Ogre scene node or entity. * Use: @@ -97,8 +97,8 @@ public: * mySceneNode->setOrientation( ogreOrient ); * ... */ - void OgreGetPoseParameters( double position[3], double orientation[4] )throw(cv::Exception); - + void OgreGetPoseParameters( double position[3], double orientation[4] )throw(cv::Exception); + /**Returns the centroid of the marker */ cv::Point2f getCenter()const; @@ -132,11 +132,11 @@ public: return str; } - - + + private: void rotateXAxis(cv::Mat &rotation); - + }; } diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h index 4d6e7b904..a4656527a 100644 --- a/ftnoir_tracker_aruco/include/markerdetector.h +++ b/ftnoir_tracker_aruco/include/markerdetector.h @@ -27,7 +27,7 @@ or implied, of Rafael Muñoz Salinas. ********************************/ #ifndef _ARUCO_MarkerDetector_H #define _ARUCO_MarkerDetector_H -#include +#include #include #include #include "cameraparameters.h" @@ -47,7 +47,7 @@ class ARUCO_EXPORTS MarkerDetector class MarkerCandidate: public Marker{ public: MarkerCandidate(){} - MarkerCandidate(const Marker &M): Marker(M){} + MarkerCandidate(const Marker &M): Marker(M){} MarkerCandidate(const MarkerCandidate &M): Marker(M){ contour=M.contour; idx=M.idx; @@ -60,20 +60,20 @@ class ARUCO_EXPORTS MarkerDetector idx=M.idx; return M; } - + vector contour;//all the points of its contour int idx;//index position in the global contour list }; public: /** - * See + * See */ - MarkerDetector(); + MarkerDetector() {} /** */ - ~MarkerDetector(); + ~MarkerDetector() {} /**Detects the markers in the image passed * @@ -161,17 +161,17 @@ public: * of cols and rows. * @param min size of the contour to consider a possible marker as valid (0,1] * @param max size of the contour to consider a possible marker as valid [0,1) - * + * */ void setMinMaxSize(float min=0.03,float max=0.5)throw(cv::Exception); - + /**reads the min and max sizes employed * @param min output size of the contour to consider a possible marker as valid (0,1] * @param max output size of the contour to consider a possible marker as valid [0,1) - * + * */ void getMinMaxSize(float &min,float &max){min=_minSize;max=_maxSize;} - + /**Enables/Disables erosion process that is REQUIRED for chessboard like boards. * By default, this property is enabled */ @@ -210,10 +210,10 @@ public: markerIdDetector_ptrfunc=markerdetector_func; } - /** Use an smaller version of the input image for marker detection. + /** Use an smaller version of the input image for marker detection. * If your marker is small enough, you can employ an smaller image to perform the detection without noticeable reduction in the precision. * Internally, we are performing a pyrdown operation - * + * * @param level number of times the image size is divided by 2. Internally, we are performing a pyrdown. */ void pyrDown(unsigned int level){pyrdown_level=level;} @@ -247,17 +247,17 @@ public: * @return true if the operation succeed */ bool warp(cv::Mat &in,cv::Mat &out,cv::Size size, std::vector points)throw (cv::Exception); - - - + + + /** Refine MarkerCandidate Corner using LINES method * @param candidate candidate to refine corners */ - void refineCandidateLines(MarkerCandidate &candidate); - - + void refineCandidateLines(MarkerCandidate &candidate); + + /**DEPRECATED!!! Use the member function in CameraParameters - * + * * Given the intrinsic camera parameters returns the GL_PROJECTION matrix for opengl. * PLease NOTE that when using OpenGL, it is assumed no camera distorsion! So, if it is not true, you should have * undistor image @@ -308,26 +308,26 @@ private: */ int perimeter(std::vector &a); - + // //GL routines -// +// // static void argConvGLcpara2( double cparam[3][4], int width, int height, double gnear, double gfar, double m[16], bool invert )throw(cv::Exception); // static int arParamDecompMat( double source[3][4], double cpara[3][4], double trans[3][4] )throw(cv::Exception); // static double norm( double a, double b, double c ); // static double dot( double a1, double a2, double a3, // double b1, double b2, double b3 ); -// +// //detection of the void findBestCornerInRegion_harris(const cv::Mat & grey,vector & Corners,int blockSize); - - + + // auxiliar functions to perform LINES refinement void interpolate2Dline( const vector< cv::Point > &inPoints, cv::Point3f &outLine); - cv::Point2f getCrossPoint(const cv::Point3f& line1, const cv::Point3f& line2); - - - /**Given a vector vinout with elements and a boolean vector indicating the lements from it to remove, + cv::Point2f getCrossPoint(const cv::Point3f& line1, const cv::Point3f& line2); + + + /**Given a vector vinout with elements and a boolean vector indicating the lements from it to remove, * this function remove the elements * @param vinout * @param toRemove diff --git a/ftnoir_tracker_aruco/trans_calib.h b/ftnoir_tracker_aruco/trans_calib.h index 5c321b2c9..c2c02b381 100644 --- a/ftnoir_tracker_aruco/trans_calib.h +++ b/ftnoir_tracker_aruco/trans_calib.h @@ -8,7 +8,7 @@ #ifndef TRANSCALIB_H #define TRANSCALIB_H -#include +#include //----------------------------------------------------------------------------- // Calibrates the translation from head to model = t_MH diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h index 7ebbcb67e..889bf2d3e 100644 --- a/ftnoir_tracker_pt/camera.h +++ b/ftnoir_tracker_pt/camera.h @@ -8,7 +8,7 @@ #ifndef CAMERA_H #define CAMERA_H -#include +#include #ifndef OPENTRACK_API # include #else diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h index 5bcfd37d0..fff8d4ab9 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #ifndef OPENTRACK_API # include @@ -36,53 +36,53 @@ class Tracker : public ITracker, protected QThread { public: - Tracker(); + Tracker(); ~Tracker() override; void StartTracker(QFrame* parent_window) override; void GetHeadPoseData(double* data) override; void apply(settings& s); - void apply_inner(); - void center(); - void reset(); // reset the trackers internal state variables + void apply_inner(); + void center(); + void reset(); // reset the trackers internal state variables - void get_pose(FrameTrafo* X_CM) { QMutexLocker lock(&mutex); *X_CM = point_tracker.get_pose(); } - int get_n_points() { QMutexLocker lock(&mutex); return point_extractor.get_points().size(); } - void get_cam_info(CamInfo* info) { QMutexLocker lock(&mutex); *info = camera.get_info(); } + void get_pose(FrameTrafo* X_CM) { QMutexLocker lock(&mutex); *X_CM = point_tracker.get_pose(); } + int get_n_points() { QMutexLocker lock(&mutex); return point_extractor.get_points().size(); } + void get_cam_info(CamInfo* info) { QMutexLocker lock(&mutex); *info = camera.get_info(); } protected: void run() override; private: - QMutex mutex; - // thread commands - enum Command { - ABORT = 1<<0 - }; - void set_command(Command command); - void reset_command(Command command); + QMutex mutex; + // thread commands + enum Command { + ABORT = 1<<0 + }; + void set_command(Command command); + void reset_command(Command command); volatile int commands; CVCamera camera; - FrameRotation frame_rotation; - PointExtractor point_extractor; - PointTracker point_tracker; + FrameRotation frame_rotation; + PointExtractor point_extractor; + PointTracker point_tracker; - FrameTrafo X_GH_0; // for centering - cv::Vec3f t_MH; // translation from model frame to head frame - cv::Matx33f R_GC; // rotation from opengl reference frame to camera frame + FrameTrafo X_GH_0; // for centering + cv::Vec3f t_MH; // translation from model frame to head frame + cv::Matx33f R_GC; // rotation from opengl reference frame to camera frame - // --- ui --- - cv::Mat frame; // the output frame for display + // --- ui --- + cv::Mat frame; // the output frame for display PTVideoWidget* video_widget; - QFrame* video_frame; - + QFrame* video_frame; + settings s; std::atomic new_settings; Timer time; - + static constexpr double rad2deg = 180.0/3.14159265; static constexpr double deg2rad = 3.14159265/180.0; - + PointModel model; }; diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index 6cd6135cb..3af7b5605 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #ifndef OPENTRACK_API # include #else @@ -25,14 +25,14 @@ TrackerDialog::TrackerDialog() timer(this), trans_calib_running(false) { - ui.setupUi( this ); + ui.setupUi( this ); vector device_names; - get_camera_device_names(device_names); + get_camera_device_names(device_names); for (vector::iterator iter = device_names.begin(); iter != device_names.end(); ++iter) - { - ui.camdevice_combo->addItem(iter->c_str()); - } + { + ui.camdevice_combo->addItem(iter->c_str()); + } ui.camroll_combo->addItem("-90"); ui.camroll_combo->addItem("0"); @@ -82,7 +82,7 @@ TrackerDialog::TrackerDialog() connect(ui.model_tabs, SIGNAL(currentChanged(int)), this, SLOT(set_model(int))); connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); - timer.start(100); + timer.start(100); connect(ui.buttonBox_2, SIGNAL(clicked(QAbstractButton*)), this, SLOT(do_apply_without_saving(QAbstractButton*))); } @@ -96,7 +96,7 @@ void TrackerDialog::set_model_clip() s.m02_y = -static_cast(s.clip_by); s.m02_z = -static_cast(s.clip_bz); - settings_changed(); + settings_changed(); } void TrackerDialog::set_model_cap() @@ -108,12 +108,12 @@ void TrackerDialog::set_model_cap() s.m02_y = -static_cast(s.cap_y); s.m02_z = -static_cast(s.cap_z); - settings_changed(); + settings_changed(); } void TrackerDialog::set_model_custom() { - settings_changed(); + settings_changed(); } void TrackerDialog::set_model(int val) @@ -123,38 +123,38 @@ void TrackerDialog::set_model(int val) void TrackerDialog::startstop_trans_calib(bool start) { - if (start) - { - qDebug()<<"TrackerDialog:: Starting translation calibration"; - trans_calib.reset(); - trans_calib_running = true; - } - else - { - qDebug()<<"TrackerDialog:: Stoppping translation calibration"; - trans_calib_running = false; + if (start) + { + qDebug()<<"TrackerDialog:: Starting translation calibration"; + trans_calib.reset(); + trans_calib_running = true; + } + else + { + qDebug()<<"TrackerDialog:: Stoppping translation calibration"; + trans_calib_running = false; { auto tmp = trans_calib.get_estimate(); s.t_MH_x = tmp[0]; s.t_MH_y = tmp[1]; s.t_MH_z = tmp[2]; } - settings_changed(); - } + settings_changed(); + } } void TrackerDialog::poll_tracker_info() { if (tracker) - { + { QString to_print; - + // display caminfo CamInfo info; tracker->get_cam_info(&info); to_print = QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS"; ui.caminfo_label->setText(to_print); - + // display pointinfo int n_points = tracker->get_n_points(); to_print = QString::number(n_points); @@ -163,7 +163,7 @@ void TrackerDialog::poll_tracker_info() else to_print += " BAD!"; ui.pointinfo_label->setText(to_print); - + // update calibration if (trans_calib_running) trans_calib_step(); } @@ -177,16 +177,16 @@ void TrackerDialog::poll_tracker_info() void TrackerDialog::trans_calib_step() { - if (tracker) - { - FrameTrafo X_CM; - tracker->get_pose(&X_CM); - trans_calib.update(X_CM.R, X_CM.t); - cv::Vec3f t_MH = trans_calib.get_estimate(); + if (tracker) + { + FrameTrafo X_CM; + tracker->get_pose(&X_CM); + trans_calib.update(X_CM.R, X_CM.t); + cv::Vec3f t_MH = trans_calib.get_estimate(); s.t_MH_x = t_MH[0]; s.t_MH_y = t_MH[1]; s.t_MH_z = t_MH[2]; - } + } } void TrackerDialog::settings_changed() @@ -203,7 +203,7 @@ void TrackerDialog::save() void TrackerDialog::doOK() { save(); - close(); + close(); } void TrackerDialog::do_apply_without_saving(QAbstractButton*) @@ -225,7 +225,7 @@ void TrackerDialog::do_apply_without_saving(QAbstractButton*) void TrackerDialog::doApply() { - save(); + save(); } void TrackerDialog::doCancel() @@ -236,23 +236,23 @@ void TrackerDialog::doCancel() void TrackerDialog::registerTracker(ITracker *t) { - qDebug()<<"TrackerDialog:: Tracker registered"; - tracker = static_cast(t); + qDebug()<<"TrackerDialog:: Tracker registered"; + tracker = static_cast(t); if (isVisible() & s.b->modifiedp()) tracker->apply(s); - ui.tcalib_button->setEnabled(true); - //ui.center_button->setEnabled(true); + ui.tcalib_button->setEnabled(true); + //ui.center_button->setEnabled(true); } void TrackerDialog::unRegisterTracker() { - qDebug()<<"TrackerDialog:: Tracker un-registered"; - tracker = NULL; - ui.tcalib_button->setEnabled(false); - //ui.center_button->setEnabled(false); + qDebug()<<"TrackerDialog:: Tracker un-registered"; + tracker = NULL; + ui.tcalib_button->setEnabled(false); + //ui.center_button->setEnabled(false); } extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog( ) { - return new TrackerDialog; + return new TrackerDialog; } diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index 365776e43..e8cac6798 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -8,7 +8,7 @@ #ifndef FTNOIR_TRACKER_PT_SETTINGS_H #define FTNOIR_TRACKER_PT_SETTINGS_H -#include +#include #include "point_tracker.h" #include "facetracknoir/options.h" @@ -36,7 +36,7 @@ struct settings value clip_ty, clip_tz, clip_by, clip_bz; value active_model_panel, cap_x, cap_y, cap_z; - + // XXX todo red channel only, good for crapola CCD sensors -sh 20140922 settings() : diff --git a/ftnoir_tracker_pt/point_extractor.h b/ftnoir_tracker_pt/point_extractor.h index 3ef829005..5252b68df 100644 --- a/ftnoir_tracker_pt/point_extractor.h +++ b/ftnoir_tracker_pt/point_extractor.h @@ -8,8 +8,8 @@ #ifndef POINTEXTRACTOR_H #define POINTEXTRACTOR_H -#include -#include +#include +#include // ---------------------------------------------------------------------------- // Extracts points from an opencv image diff --git a/ftnoir_tracker_pt/point_tracker.h b/ftnoir_tracker_pt/point_tracker.h index c82125382..d65494a46 100644 --- a/ftnoir_tracker_pt/point_tracker.h +++ b/ftnoir_tracker_pt/point_tracker.h @@ -8,7 +8,7 @@ #ifndef POINTTRACKER_H #define POINTTRACKER_H -#include +#include #ifndef OPENTRACK_API # include #else @@ -21,31 +21,31 @@ class FrameTrafo { public: - FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {} - FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {} + FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {} + FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {} - cv::Matx33f R; - cv::Vec3f t; + cv::Matx33f R; + cv::Vec3f t; }; inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) { - return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); + return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); } inline FrameTrafo operator*(const cv::Matx33f& X, const FrameTrafo& Y) { - return FrameTrafo(X*Y.R, X*Y.t); + return FrameTrafo(X*Y.R, X*Y.t); } inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33f& Y) { - return FrameTrafo(X.R*Y, X.t); + return FrameTrafo(X.R*Y, X.t); } inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) { - return X.R*v + X.t; + return X.R*v + X.t; } @@ -55,28 +55,28 @@ inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) // [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] class PointModel { - friend class PointTracker; + friend class PointTracker; public: - static constexpr int N_POINTS = 3; + static constexpr int N_POINTS = 3; - PointModel(cv::Vec3f M01, cv::Vec3f M02); + PointModel(cv::Vec3f M01, cv::Vec3f M02); PointModel(); - inline const cv::Vec3f& get_M01() const { return M01; } - inline const cv::Vec3f& get_M02() const { return M02; } + inline const cv::Vec3f& get_M01() const { return M01; } + inline const cv::Vec3f& get_M02() const { return M02; } private: - cv::Vec3f M01; // M01 in model frame - cv::Vec3f M02; // M02 in model frame + cv::Vec3f M01; // M01 in model frame + cv::Vec3f M02; // M02 in model frame - cv::Vec3f u; // unit vector perpendicular to M01,M02-plane + cv::Vec3f u; // unit vector perpendicular to M01,M02-plane - cv::Matx22f P; + cv::Matx22f P; - cv::Vec2f d; // determinant vector for point correspondence - int d_order[3]; // sorting of projected model points with respect to d scalar product + cv::Vec2f d; // determinant vector for point correspondence + int d_order[3]; // sorting of projected model points with respect to d scalar product - void get_d_order(const std::vector& points, int d_order[]) const; + void get_d_order(const std::vector& points, int d_order[]) const; }; // ---------------------------------------------------------------------------- @@ -86,29 +86,29 @@ private: class PointTracker { public: - PointTracker(); - // track the pose using the set of normalized point coordinates (x pos in range -0.5:0.5) - // f : (focal length)/(sensor width) - // dt : time since last call - void track(const std::vector& projected_points, const PointModel& model); - FrameTrafo get_pose() const { return X_CM; } - void reset(); + PointTracker(); + // track the pose using the set of normalized point coordinates (x pos in range -0.5:0.5) + // f : (focal length)/(sensor width) + // dt : time since last call + void track(const std::vector& projected_points, const PointModel& model); + FrameTrafo get_pose() const { return X_CM; } + void reset(); private: // the points in model order typedef struct { cv::Vec2f points[PointModel::N_POINTS]; } PointOrder; - static constexpr float focal_length = 1.0f; - - inline cv::Vec2f project(const cv::Vec3f& v_M) - { - cv::Vec3f v_C = X_CM * v_M; - return cv::Vec2f(focal_length*v_C[0]/v_C[2], focal_length*v_C[1]/v_C[2]); - } + static constexpr float focal_length = 1.0f; + + inline cv::Vec2f project(const cv::Vec3f& v_M) + { + cv::Vec3f v_C = X_CM * v_M; + return cv::Vec2f(focal_length*v_C[0]/v_C[2], focal_length*v_C[1]/v_C[2]); + } PointOrder find_correspondences(const std::vector& projected_points, const PointModel &model); int POSIT(const PointModel& point_model, const PointOrder& order); // The POSIT algorithm, returns the number of iterations - - FrameTrafo X_CM; // trafo from model to camera + + FrameTrafo X_CM; // trafo from model to camera }; #endif //POINTTRACKER_H diff --git a/ftnoir_tracker_pt/pt_video_widget.h b/ftnoir_tracker_pt/pt_video_widget.h index de2c7efb1..f2b41d637 100644 --- a/ftnoir_tracker_pt/pt_video_widget.h +++ b/ftnoir_tracker_pt/pt_video_widget.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #ifndef OPENTRACK_API # include # include diff --git a/ftnoir_tracker_pt/trans_calib.h b/ftnoir_tracker_pt/trans_calib.h index 5c321b2c9..c2c02b381 100644 --- a/ftnoir_tracker_pt/trans_calib.h +++ b/ftnoir_tracker_pt/trans_calib.h @@ -8,7 +8,7 @@ #ifndef TRANSCALIB_H #define TRANSCALIB_H -#include +#include //----------------------------------------------------------------------------- // Calibrates the translation from head to model = t_MH -- cgit v1.2.3 From f4754d23984126de847279f4abad4ae713d9e386 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Oct 2014 19:55:05 +0200 Subject: flush and push --- .../README-CREDIT.txt | 6 - .../ft_tester/Makefile.am | 54 --- .../ft_tester/Makefile.in | 491 -------------------- .../ft_tester/fttester.rc.in | 67 --- .../ft_tester/main.cpp | 211 --------- .../ft_tester/resource.h | 27 -- .../important-stuff/NPClient.h | 17 - .../important-stuff/NPClient.spec | 23 - .../important-stuff/NPClient_dll.h | 58 --- .../important-stuff/NPClient_main.c | 444 ------------------ .../important-stuff/game_data.c | 149 ------ .../important-stuff/game_data.h | 17 - .../tester/Makefile.am | 78 ---- .../tester/Makefile.in | 512 --------------------- .../tester/main.cpp | 100 ---- .../tester/npifc.c | 302 ------------ .../tester/npifc.h | 66 --- .../tester/npview.rc.in | 49 -- .../tester/resource.h | 23 - .../tester/rest.c | 1 - .../tester/rest.h | 1 - facetracknoir/clientfiles/make-csv.pl | 72 +++ .../very-important-source-code/README-CREDIT.txt | 6 + .../ft_tester/Makefile.am | 54 +++ .../ft_tester/Makefile.in | 491 ++++++++++++++++++++ .../ft_tester/fttester.rc.in | 67 +++ .../very-important-source-code/ft_tester/main.cpp | 211 +++++++++ .../ft_tester/resource.h | 27 ++ .../important-stuff/NPClient.h | 17 + .../important-stuff/NPClient.spec | 23 + .../important-stuff/NPClient_dll.h | 58 +++ .../important-stuff/NPClient_main.c | 444 ++++++++++++++++++ .../important-stuff/game_data.c | 150 ++++++ .../important-stuff/game_data.h | 17 + .../very-important-source-code/tester/Makefile.am | 78 ++++ .../very-important-source-code/tester/Makefile.in | 512 +++++++++++++++++++++ .../very-important-source-code/tester/main.cpp | 100 ++++ .../very-important-source-code/tester/npifc.c | 302 ++++++++++++ .../very-important-source-code/tester/npifc.h | 66 +++ .../very-important-source-code/tester/npview.rc.in | 49 ++ .../very-important-source-code/tester/resource.h | 23 + .../very-important-source-code/tester/rest.c | 1 + .../very-important-source-code/tester/rest.h | 1 + facetracknoir/plugin-qt-api.hpp | 1 - facetracknoir/pose.hpp | 66 +++ facetracknoir/quat.hpp | 26 +- facetracknoir/tracker.cpp | 40 +- facetracknoir/tracker.h | 9 +- facetracknoir/tracker_types.h | 66 --- freetrackclient/build-msvc.sh | 33 ++ freetrackclient/freetrackclient.c | 4 + ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 11 +- ftnoir_tracker_aruco/include/aruco.h | 29 +- ftnoir_tracker_aruco/include/arucofidmarkers.h | 15 +- ftnoir_tracker_aruco/include/board.h | 168 +++++++ ftnoir_tracker_aruco/include/boarddetector.h | 139 ++++++ ftnoir_tracker_aruco/include/cvdrawingutils.h | 21 +- ftnoir_tracker_aruco/include/exports.h | 4 +- ftnoir_tracker_aruco/include/markerdetector.h | 16 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 19 +- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 33 +- 61 files changed, 3289 insertions(+), 2876 deletions(-) delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/README-CREDIT.txt delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.am delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.in delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/fttester.rc.in delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/main.cpp delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/resource.h delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/NPClient.h delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/NPClient.spec delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/NPClient_dll.h delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/NPClient_main.c delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.c delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.h delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.am delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.in delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/main.cpp delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.c delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.h delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npview.rc.in delete mode 100644 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/resource.h delete mode 120000 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.c delete mode 120000 facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.h create mode 100755 facetracknoir/clientfiles/make-csv.pl create mode 100644 facetracknoir/clientfiles/very-important-source-code/README-CREDIT.txt create mode 100644 facetracknoir/clientfiles/very-important-source-code/ft_tester/Makefile.am create mode 100644 facetracknoir/clientfiles/very-important-source-code/ft_tester/Makefile.in create mode 100644 facetracknoir/clientfiles/very-important-source-code/ft_tester/fttester.rc.in create mode 100644 facetracknoir/clientfiles/very-important-source-code/ft_tester/main.cpp create mode 100644 facetracknoir/clientfiles/very-important-source-code/ft_tester/resource.h create mode 100644 facetracknoir/clientfiles/very-important-source-code/important-stuff/NPClient.h create mode 100644 facetracknoir/clientfiles/very-important-source-code/important-stuff/NPClient.spec create mode 100644 facetracknoir/clientfiles/very-important-source-code/important-stuff/NPClient_dll.h create mode 100644 facetracknoir/clientfiles/very-important-source-code/important-stuff/NPClient_main.c create mode 100644 facetracknoir/clientfiles/very-important-source-code/important-stuff/game_data.c create mode 100644 facetracknoir/clientfiles/very-important-source-code/important-stuff/game_data.h create mode 100644 facetracknoir/clientfiles/very-important-source-code/tester/Makefile.am create mode 100644 facetracknoir/clientfiles/very-important-source-code/tester/Makefile.in create mode 100644 facetracknoir/clientfiles/very-important-source-code/tester/main.cpp create mode 100644 facetracknoir/clientfiles/very-important-source-code/tester/npifc.c create mode 100644 facetracknoir/clientfiles/very-important-source-code/tester/npifc.h create mode 100644 facetracknoir/clientfiles/very-important-source-code/tester/npview.rc.in create mode 100644 facetracknoir/clientfiles/very-important-source-code/tester/resource.h create mode 120000 facetracknoir/clientfiles/very-important-source-code/tester/rest.c create mode 120000 facetracknoir/clientfiles/very-important-source-code/tester/rest.h create mode 100644 facetracknoir/pose.hpp delete mode 100644 facetracknoir/tracker_types.h create mode 100644 freetrackclient/build-msvc.sh create mode 100644 ftnoir_tracker_aruco/include/board.h create mode 100644 ftnoir_tracker_aruco/include/boarddetector.h (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/README-CREDIT.txt b/facetracknoir/clientfiles/important-source-code-really-important-really-really/README-CREDIT.txt deleted file mode 100644 index 822141393..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/README-CREDIT.txt +++ /dev/null @@ -1,6 +0,0 @@ -The contents of the directory written by one and only, uglyDwarf. - -Obtained at epoch time 1412397452 from the mithril-mine's shaft, where -the elite dwarves reside. - -For the latest happenings, visit diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.am b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.am deleted file mode 100644 index 02747edb4..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.am +++ /dev/null @@ -1,54 +0,0 @@ -noinst_SCRIPTS = -if WINE_PLUGIN - noinst_SCRIPTS += ftc.exe.so -endif #WINE_PLUGIN - -if DARWIN - LDFLAGS += -Wl,-no_arch_warnings -else - LDFLAGS += -Wl,--no-warn-search-mismatch -endif - -CC = winegcc - -CXX = wineg++ - -SUFFIXES = .o .cpp .c .rc - -.cpp.o : - $(CXX) -c $(CXXFLAGS_PRE) $(CXXFLAGS) $(CPPFLAGS) -m32 -o $@ $< - -.c.o : - $(CC) -c $(CFLAGS_PRE) $(CFLAGS) $(CPPFLAGS) -m32 -o $@ $< - -.rc.o : - wrc -o $@ $(RCFLAGS) $< - -CXXFLAGS_PRE = -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@ -CFLAGS_PRE = -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@ -RCFLAGS = -I @srcdir@ -#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ -vpath %.h @srcdir@/../.. -vpath %.h @top_builddir@ -vpath %.c @srcdir@ -vpath %.c @srcdir@/../.. - -ftc.exe.so : main.o fttester.o - wineg++ -g -o $@ -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ - -fttester.o : fttester.rc resource.h config.h - -main.o : main.cpp - -clean-local: clean-local-check -.PHONY: clean-local-check -clean-local-check: - rm -f *.exe* *.dll* *.sh *.o - -distclean-local: distclean-local-check -.PHONY: distclean-local-check -distclean-local-check: - rm -f *.exe* *.dll* *.sh *.o - -EXTRA_DIST = resource.h fttester.rc main.cpp - diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.in b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.in deleted file mode 100644 index d1fff34d1..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/Makefile.in +++ /dev/null @@ -1,491 +0,0 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2013 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@WINE_PLUGIN_TRUE@am__append_1 = ftc.exe.so -@DARWIN_TRUE@am__append_2 = -Wl,-no_arch_warnings -@DARWIN_FALSE@am__append_3 = -Wl,--no-warn-search-mismatch -subdir = src/wine_bridge/ft_tester -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/fttester.rc.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = fttester.rc -CONFIG_CLEAN_VPATH_FILES = -SCRIPTS = $(noinst_SCRIPTS) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -depcomp = -am__depfiles_maybe = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BISON = @BISON@ -CC = winegcc -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = wineg++ -CXXCPP = @CXXCPP@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ $(am__append_2) $(am__append_3) -LEX = @LEX@ -LEXLIB = @LEXLIB@ -LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -LIB32DIR = @LIB32DIR@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJC = @OBJC@ -OBJCFLAGS = @OBJCFLAGS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OPENCV_CFLAGS = @OPENCV_CFLAGS@ -OPENCV_LIBS = @OPENCV_LIBS@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -QMAKE_PATH = @QMAKE_PATH@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -WINE64_LIBS = @WINE64_LIBS@ -WINE_LIBS = @WINE_LIBS@ -XPL_CPPFLAGS = @XPL_CPPFLAGS@ -YACC = @YACC@ -YFLAGS = @YFLAGS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_OBJC = @ac_ct_OBJC@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_makensis = @with_makensis@ -with_wine64 = @with_wine64@ -noinst_SCRIPTS = $(am__append_1) -SUFFIXES = .o .cpp .c .rc -CXXFLAGS_PRE = -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@ -CFLAGS_PRE = -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@ -RCFLAGS = -I @srcdir@ -EXTRA_DIST = resource.h fttester.rc main.cpp -all: all-am - -.SUFFIXES: -.SUFFIXES: .o .cpp .c .rc -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/ft_tester/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/ft_tester/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -fttester.rc: $(top_builddir)/config.status $(srcdir)/fttester.rc.in - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -tags TAGS: - -ctags CTAGS: - -cscope cscopelist: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(SCRIPTS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-local mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-local - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - clean-local cscopelist-am ctags-am distclean distclean-generic \ - distclean-libtool distclean-local distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ - uninstall-am - - -.cpp.o : - $(CXX) -c $(CXXFLAGS_PRE) $(CXXFLAGS) $(CPPFLAGS) -m32 -o $@ $< - -.c.o : - $(CC) -c $(CFLAGS_PRE) $(CFLAGS) $(CPPFLAGS) -m32 -o $@ $< - -.rc.o : - wrc -o $@ $(RCFLAGS) $< -#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ -vpath %.h @srcdir@/../.. -vpath %.h @top_builddir@ -vpath %.c @srcdir@ -vpath %.c @srcdir@/../.. - -ftc.exe.so : main.o fttester.o - wineg++ -g -o $@ -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ - -fttester.o : fttester.rc resource.h config.h - -main.o : main.cpp - -clean-local: clean-local-check -.PHONY: clean-local-check -clean-local-check: - rm -f *.exe* *.dll* *.sh *.o - -distclean-local: distclean-local-check -.PHONY: distclean-local-check -distclean-local-check: - rm -f *.exe* *.dll* *.sh *.o - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/fttester.rc.in b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/fttester.rc.in deleted file mode 100644 index 332f3c73c..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/fttester.rc.in +++ /dev/null @@ -1,67 +0,0 @@ -// Generated by ResEdit 1.5.9 -// Copyright (C) 2006-2011 -// http://www.resedit.net - -#include -#include -#include -#include "resource.h" - -#ifdef HAVE_CONFIG_H - #include "../../../config.h" -#endif - - - - -// -// Dialog resources -// -//LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -IDD_DIALOG1 DIALOGEX 0, 0, 333, 183 -STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU -CAPTION "FreeTrack client test utility v@PACKAGE_VERSION@" -FONT 8, "Ms Shell Dlg", 400, 0, 1 -{ - DEFPUSHBUTTON "Quit", IDQUIT, 262, 153, 50, 14 - PUSHBUTTON "Start", IDC_START, 199, 153, 50, 14 - EDITTEXT IDC_YAW, 38, 15, 48, 14, ES_AUTOHSCROLL - RTEXT "Yaw", IDC_STATIC, 12, 17, 21, 14, SS_RIGHT - EDITTEXT IDC_PITCH, 38, 38, 48, 14, ES_AUTOHSCROLL - RTEXT "Pitch", IDC_STATIC, 16, 40, 17, 14, SS_RIGHT - EDITTEXT IDC_ROLL, 38, 61, 48, 14, ES_AUTOHSCROLL - RTEXT "Roll", IDC_STATIC, 20, 63, 13, 14, SS_RIGHT - EDITTEXT IDC_X, 38, 84, 48, 14, ES_AUTOHSCROLL - RTEXT "X", IDC_STATIC, 27, 86, 6, 14, SS_RIGHT - EDITTEXT IDC_Y, 38, 107, 48, 14, ES_AUTOHSCROLL - RTEXT "Y", IDC_STATIC, 27, 109, 6, 14, SS_RIGHT - EDITTEXT IDC_Z, 38, 130, 48, 14, ES_AUTOHSCROLL - RTEXT "Z", IDC_STATIC, 27, 132, 6, 14, SS_RIGHT - EDITTEXT IDC_RYAW, 137, 15, 48, 14, ES_AUTOHSCROLL - RTEXT "Raw Yaw", IDC_STATIC, 101, 17, 32, 8, SS_RIGHT - EDITTEXT IDC_RPITCH, 137, 38, 48, 14, ES_AUTOHSCROLL - RTEXT "Raw Pitch", IDC_STATIC, 99, 40, 34, 8, SS_RIGHT - EDITTEXT IDC_RROLL, 137, 61, 48, 14, ES_AUTOHSCROLL - RTEXT "Raw Roll", IDC_STATIC, 103, 63, 30, 8, SS_RIGHT - EDITTEXT IDC_RX, 137, 84, 48, 14, ES_AUTOHSCROLL - RTEXT "Raw X", IDC_STATIC, 111, 86, 22, 8, SS_RIGHT - EDITTEXT IDC_RY, 137, 107, 48, 14, ES_AUTOHSCROLL - RTEXT "Raw Y", IDC_STATIC, 111, 109, 22, 8, SS_RIGHT - EDITTEXT IDC_RZ, 137, 130, 48, 14, ES_AUTOHSCROLL - RTEXT "Raw Z", IDC_STATIC, 111, 132, 22, 8, SS_RIGHT - EDITTEXT IDC_NUM, 264, 15, 48, 14, ES_AUTOHSCROLL - RTEXT "Frame Number", IDC_STATIC, 212, 17, 47, 8, SS_RIGHT - EDITTEXT IDC_RES, 264, 38, 48, 14, ES_AUTOHSCROLL - RTEXT "Camera Resolution", IDC_STATIC, 199, 40, 60, 8, SS_RIGHT - EDITTEXT IDC_PT0, 227, 61, 85, 14, ES_AUTOHSCROLL - RTEXT "Point 1", IDC_STATIC, 199, 63, 23, 8, SS_RIGHT - EDITTEXT IDC_PT1, 227, 84, 85, 14, ES_AUTOHSCROLL - RTEXT "Point 2", IDC_STATIC, 199, 86, 23, 8, SS_RIGHT - EDITTEXT IDC_PT2, 227, 107, 85, 14, ES_AUTOHSCROLL - RTEXT "Point 3", IDC_STATIC, 199, 109, 23, 8, SS_RIGHT - EDITTEXT IDC_PT3, 227, 130, 85, 14, ES_AUTOHSCROLL - RTEXT "Point 4", IDC_STATIC, 199, 132, 23, 8, SS_RIGHT - EDITTEXT IDC_TITLE, 38, 153, 147, 14, ES_AUTOHSCROLL - RTEXT "Title", IDC_STATIC, 19, 155, 14, 8, SS_RIGHT -} - diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/main.cpp b/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/main.cpp deleted file mode 100644 index a737f88f5..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/ft_tester/main.cpp +++ /dev/null @@ -1,211 +0,0 @@ -#define WIN32_LEAN_AND_MEAN - -#include -#include -#include -#include -#include -#include - -#include "resource.h" - -HINSTANCE hInst; -UINT_PTR timer = 0; - -HMODULE ftclient; - -typedef struct -{ - unsigned int dataID; - int res_x; int res_y; - float yaw; // positive yaw to the left - float pitch;// positive pitch up - float roll;// positive roll to the left - float x; - float y; - float z; - // raw pose with no smoothing, sensitivity, response curve etc. - float ryaw; - float rpitch; - float rroll; - float rx; - float ry; - float rz; - // raw points, sorted by Y, origin top left corner - float x0, y0; - float x1, y1; - float x2, y2; - float x3, y3; -}FreeTrackData; - - -typedef bool (WINAPI *importGetData)(FreeTrackData * data); -typedef char *(WINAPI *importGetDllVersion)(void); -typedef void (WINAPI *importReportName)(char *name); -typedef char *(WINAPI *importProvider)(void); - -importGetData getData; -importGetDllVersion getDllVersion; -importReportName reportName; -importProvider provider; - - -char *client_path() -{ - HKEY hkey = 0; - RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Freetrack\\FreetrackClient", 0, - KEY_QUERY_VALUE, &hkey); - if(!hkey){ - printf("Can't open registry key\n"); - return NULL; - } - - BYTE path[1024]; - DWORD buf_len = 1024; - LONG result = RegQueryValueEx(hkey, "Path", NULL, NULL, path, &buf_len); - char *full_path = (char *)malloc(2048); - if(result == ERROR_SUCCESS && buf_len > 0){ - sprintf(full_path, "%s\\FreeTrackClient.dll", path); - } - RegCloseKey(hkey); - return full_path; -} - - -bool start(HWND hwnd) -{ - char *libname = client_path(); - if(libname == NULL){ - printf("Freetrack client not found!\n"); - return false; - } - ftclient = LoadLibrary(libname); - if(ftclient == NULL){ - printf("Couldn't load Freetrack client library '%s'!\n", libname); - return false; - } - printf("Freetrack client library %s loaded.\n", client_path()); - - - getData = (importGetData)GetProcAddress(ftclient, "FTGetData"); - getDllVersion = (importGetDllVersion)GetProcAddress(ftclient, "FTGetDllVersion"); - reportName = (importReportName)GetProcAddress(ftclient, "FTReportName"); - provider = (importProvider)GetProcAddress(ftclient, "FTProvider"); - - if((getData == NULL) || (getDllVersion == NULL) || (reportName == NULL) || (provider == NULL)){ - printf("Couldn't load Freetrack client functions!\n"); - FreeLibrary(ftclient); - return false; - } - - printf("Dll version: %s\n", getDllVersion()); - printf("Provider: %s\n", provider()); - char title[1024]; - GetDlgItemText(hwnd, IDC_TITLE, title, 1020); - reportName(title); - return true; -} - -void reportError(std::string msg) -{ - MessageBoxA(0, "FreeTrack client test", msg.c_str(), 0); -} -VOID CALLBACK TimerProcedure(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) -{ - (void) uMsg; - (void) idEvent; - (void) dwTime; - FreeTrackData d; - getData(&d); - SetDlgItemInt(hwnd, IDC_PITCH, d.pitch, true); - SetDlgItemInt(hwnd, IDC_ROLL, d.roll, true); - SetDlgItemInt(hwnd, IDC_YAW, d.yaw, true); - - SetDlgItemInt(hwnd, IDC_X, d.x, true); - SetDlgItemInt(hwnd, IDC_Y, d.y, true); - SetDlgItemInt(hwnd, IDC_Z, d.z, true); - - SetDlgItemInt(hwnd, IDC_RPITCH, d.rpitch, true); - SetDlgItemInt(hwnd, IDC_RROLL, d.rroll, true); - SetDlgItemInt(hwnd, IDC_RYAW, d.ryaw, true); - - SetDlgItemInt(hwnd, IDC_RX, d.rx, true); - SetDlgItemInt(hwnd, IDC_RY, d.ry, true); - SetDlgItemInt(hwnd, IDC_RZ, d.rz, true); - - std::ostringstream s; - s.str(std::string()); - s<<"("< -#include "rest.h" -//#include "config.h" -#define __WINESRC__ - -#include -#include -#include -#include -#include -#include -#include "windef.h" -#include "winbase.h" -#include "NPClient_dll.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(NPClient); - -bool crypted = false; -static unsigned char table[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static int dbg_flag; - -static void dbg_report(const char *msg,...) -{ - static FILE *f = NULL; - if(dbg_flag){ - if(f == NULL){ - f = fopen("NPClient.log", "w"); - } - va_list ap; - va_start(ap,msg); - vfprintf(f, msg, ap); - fflush(f); - va_end(ap); - } -} - - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); - - switch (fdwReason) - { - case DLL_WINE_PREATTACH: - return TRUE; - case DLL_PROCESS_ATTACH: - DisableThreadLibraryCalls(hinstDLL); - dbg_flag = getDebugFlag('w'); - dbg_report("Attach request\n"); - break; - case DLL_PROCESS_DETACH: - linuxtrack_shutdown(); - break; - } - - return TRUE; -} -/****************************************************************** - * NPPriv_ClientNotify (NPCLIENT.1) - * - * - */ -#if 0 -__stdcall NPCLIENT_NPPriv_ClientNotify() -{ - /* @stub in .spec */ -} -#endif -/****************************************************************** - * NPPriv_GetLastError (NPCLIENT.2) - * - * - */ -#if 0 -__stdcall NPCLIENT_NPPriv_GetLastError() -{ - /* @stub in .spec */ -} -#endif -/****************************************************************** - * NPPriv_SetData (NPCLIENT.3) - * - * - */ -#if 0 -__stdcall NPCLIENT_NPPriv_SetData() -{ - /* @stub in .spec */ -} -#endif -/****************************************************************** - * NPPriv_SetLastError (NPCLIENT.4) - * - * - */ -#if 0 -__stdcall NPCLIENT_NPPriv_SetLastError() -{ - /* @stub in .spec */ -} -#endif -/****************************************************************** - * NPPriv_SetParameter (NPCLIENT.5) - * - * - */ -#if 0 -__stdcall NPCLIENT_NPPriv_SetParameter() -{ - /* @stub in .spec */ -} -#endif -/****************************************************************** - * NPPriv_SetSignature (NPCLIENT.6) - * - * - */ -#if 0 -__stdcall NPCLIENT_NPPriv_SetSignature() -{ - /* @stub in .spec */ -} -#endif -/****************************************************************** - * NPPriv_SetVersion (NPCLIENT.7) - * - * - */ -#if 0 -__stdcall NPCLIENT_NPPriv_SetVersion() -{ - /* @stub in .spec */ -} -#endif - -static float limit_num(float min, float val, float max) -{ - if(val < min) return min; - if(val > max) return max; - return val; -} - -static unsigned int cksum(unsigned char buf[], unsigned int size) -{ - if((size == 0) || (buf == NULL)){ - return 0; - } - - int rounds = size >> 2; - int rem = size % 4; - - int c = size; - int a0, a2; -// printf("Orig: "); -//for(a0 = 0; a0 < (int)size; ++a0) -//{ -// printf("%02X", buf[a0]); -//} -//printf("\n"); - while(rounds != 0){ - a0 = *(short int*)buf; - a2 = *(short int*)(buf+2); - buf += 4; - c += a0; - a2 ^= (c << 5); - a2 <<= 11; - c ^= a2; - c += (c >> 11); - --rounds; - } - switch(rem){ - case 3: - a0 = *(short int*)buf; - a2 = *(signed char*)(buf+2); - c += a0; - a2 = (a2 << 2) ^ c; - c ^= (a2 << 16); - a2 = (c >> 11); - break; - case 2: - a2 = *(short int*)buf; - c += a2; - c ^= (c << 11); - a2 = (c >> 17); - break; - case 1: - a2 = *(signed char*)(buf); - c += a2; - c ^= (c << 10); - a2 = (c >> 1); - break; - default: - break; - } - if(rem != 0){ - c+=a2; - } - - c ^= (c << 3); - c += (c >> 5); - c ^= (c << 4); - c += (c >> 17); - c ^= (c << 25); - c += (c >> 6); - - return (unsigned int)c; -} - -static void enhance(unsigned char buf[], unsigned int size, - unsigned char codetable[], unsigned int table_size) -{ - unsigned int table_ptr = 0; - unsigned char var = 0x88; - unsigned char tmp; - if((size <= 0) || (table_size <= 0) || - (buf == NULL) || (codetable == NULL)){ - return; - } - do{ - tmp = buf[--size]; - buf[size] = tmp ^ codetable[table_ptr] ^ var; - var += size + tmp; - ++table_ptr; - if(table_ptr >= table_size){ - table_ptr -= table_size; - } - }while(size != 0); -} - - -/****************************************************************** - * NP_GetData (NPCLIENT.8) - * - * - */ -int __stdcall NPCLIENT_NP_GetData(tir_data_t * data) -{ - float r, p, y, tx, ty, tz; - unsigned int frame; - int res = linuxtrack_get_pose(&y, &p, &r, &tx, &ty, &tz, &frame); - memset((char *)data, 0, sizeof(tir_data_t)); - data->status = (linuxtrack_get_tracking_state() == RUNNING) ? 0 : 1; - data->frame = frame & 0xFFFF; - data->cksum = 0; - data->roll = r / 180.0 * 16383; - data->pitch = -p / 180.0 * 16383; - data->yaw = y / 180.0 * 16383; - data->tx = -limit_num(-16383.0, 15 * tx, 16383); - data->ty = limit_num(-16383.0, 15 * ty, 16383); - data->tz = limit_num(-16383.0, 15 * tz, 16383); - data->cksum = cksum((unsigned char*)data, sizeof(tir_data_t)); - //printf("Cksum: %04X\n", data->cksum); - if(crypted){ - enhance((unsigned char*)data, sizeof(tir_data_t), table, sizeof(table)); - } - return (res >= 0) ? 0: 1; -} -/****************************************************************** - * NP_GetParameter (NPCLIENT.9) - * - * - */ -int __stdcall NPCLIENT_NP_GetParameter(int arg0, int arg1) -{ - dbg_report("GetParameter request: %d %d\n", arg0, arg1); - TRACE("(void): stub\n"); - return (int) 0; -} - -/****************************************************************** - * NP_GetSignature (NPCLIENT.10) - * - * - */ -int __stdcall NPCLIENT_NP_GetSignature(tir_signature_t * sig) -{ - dbg_report("GetSignature request\n"); - if(getSomeSeriousPoetry(sig->DllSignature, sig->AppSignature)){ - printf("Signature result: OK\n"); - return 0; - }else{ - printf("Signature result: NOT OK!\n"); - return 1; - } -} -/****************************************************************** - * NP_QueryVersion (NPCLIENT.11) - * - * - */ -int __stdcall NPCLIENT_NP_QueryVersion(unsigned short * version) -{ - dbg_report("QueryVersion request\n"); - *version=0x0500; - return 0; -} -/****************************************************************** - * NP_ReCenter (NPCLIENT.12) - * - * - */ -int __stdcall NPCLIENT_NP_ReCenter(void) -{ - dbg_report("ReCenter request\n"); - linuxtrack_recenter(); - return 0; -} - -/****************************************************************** - * NP_RegisterProgramProfileID (NPCLIENT.13) - * - * - */ -int __stdcall NPCLIENT_NP_RegisterProgramProfileID(unsigned short id) -{ - dbg_report("RegisterProgramProfileID request: %d\n", id); - game_desc_t gd; - if(game_data_get_desc(id, &gd)){ - printf("Application ID: %d - %s!!!\n", id, gd.name); - if(game_data_get_desc(id, &gd)){ - crypted = gd.encrypted; - if(gd.encrypted){ - printf("Table: %02X %02X %02X %02X %02X %02X %02X %02X\n", table[0],table[1],table[2],table[3],table[4], - table[5], table[6], table[7]); - table[0] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; - table[1] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; - table[2] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; - table[3] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; - table[4] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; - table[5] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; - table[6] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; - table[7] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; - } - } - if(linuxtrack_init(gd.name) != 0){ - return 1; - } - }else{ - if(!linuxtrack_init("Default")){ - return 1; - } - } - linuxtrack_suspend(); - return 0; -} -/****************************************************************** - * NP_RegisterWindowHandle (NPCLIENT.14) - * - * - */ -int __stdcall NPCLIENT_NP_RegisterWindowHandle(HWND hwnd) -{ - dbg_report("RegisterWindowHandle request: 0x%X\n", hwnd); - TRACE("((HWND)%p): stub\n",hwnd); - return (int) 0; -} -/****************************************************************** - * NP_RequestData (NPCLIENT.15) - * - * - */ -int __stdcall NPCLIENT_NP_RequestData(unsigned short req) -{ - dbg_report("RequestData request: %d\n", req); - TRACE("((unsigned short)%d): stub\n",req); - return (int) 0; -} -/****************************************************************** - * NP_SetParameter (NPCLIENT.16) - * - * - */ -int __stdcall NPCLIENT_NP_SetParameter(int arg0, int arg1) -{ - dbg_report("SetParameter request: %d %d\n", arg0, arg1); - TRACE("(void): stub\n"); - return (int) 0; -} -/****************************************************************** - * NP_StartCursor (NPCLIENT.17) - * - * - */ -int __stdcall NPCLIENT_NP_StartCursor(void) -{ - dbg_report("StartCursor request\n"); - TRACE("(void): stub\n"); - return (int) 0; -} -/****************************************************************** - * NP_StartDataTransmission (NPCLIENT.18) - * - * - */ -int __stdcall NPCLIENT_NP_StartDataTransmission(void) -{ - dbg_report("StartDataTransmission request\n"); - linuxtrack_wakeup(); - return 0; -} -/****************************************************************** - * NP_StopCursor (NPCLIENT.19) - * - * - */ -int __stdcall NPCLIENT_NP_StopCursor(void) -{ - dbg_report("StopCursor request\n"); - TRACE("(void): stub\n"); - return (int) 0; -} -/****************************************************************** - * NP_StopDataTransmission (NPCLIENT.20) - * - * - */ -int __stdcall NPCLIENT_NP_StopDataTransmission(void) -{ - dbg_report("StopDataTransmission request\n"); - linuxtrack_suspend(); - return 0; -} -/****************************************************************** - * NP_UnregisterWindowHandle (NPCLIENT.21) - * - * - */ -int __stdcall NPCLIENT_NP_UnregisterWindowHandle(void) -{ - dbg_report("UnregisterWindowHandle request\n"); - TRACE("(void): stub\n"); - return (int) 0; -} - diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.c b/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.c deleted file mode 100644 index 3197ba379..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.c +++ /dev/null @@ -1,149 +0,0 @@ -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include - - -//First 5 bytes is MD5 hash of "NaturalPoint" -static uint8_t secret_key[] = {0x0e, 0x9a, 0x63, 0x71, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static uint8_t S[256] = {0}; - -static char *decoded = NULL; - -static mxml_node_t *xml = NULL; -static mxml_node_t *tree = NULL; - -static void ksa(uint8_t key[], size_t len) -{ - unsigned int i, j; - for(i = 0; i < 256; ++i){ - S[i] = i; - } - j = 0; - for(i = 0; i < 256; ++i){ - j = (j + S[i] + key[i % len]) % 256; - uint8_t tmp = S[i]; - S[i] = S[j]; - S[j] = tmp; - } -} - -static uint8_t rc4() -{ - static uint8_t i = 0; - static uint8_t j = 0; - - i += 1; - j += S[i]; - uint8_t tmp = S[i]; - S[i] = S[j]; - S[j] = tmp; - return S[(S[i] + S[j]) % 256]; -} - -static bool decrypt_file(const char *fname, bool from_update) -{ - uint32_t header[5]; - size_t datlen; - ksa(secret_key, 16); - FILE *inp; - struct stat fst; - - if((inp = fopen(fname, "rb")) == NULL){ - printf("Can't open input file '%s'", fname); - return false; - } - - if(fstat(fileno(inp), &fst) != 0){ - fclose(inp); - printf("Cannot stat file '%s'\n", fname); - return false; - } - - if(from_update){ - if(fread(&header, sizeof(uint32_t), 5, inp) != 5){ - fclose(inp); - printf("Can't read the header - file '%s' is less than 20 bytes long?\n", fname); - return false; - } - datlen = header[4]; - }else{ - datlen = fst.st_size; - } - if((decoded = (char *)malloc(datlen+1)) == NULL){ - printf("malloc failed!\n"); - return false; - } - memset(decoded, 0, datlen+1); - size_t i; - size_t len = fread(decoded, 1, datlen, inp); - (void) len; - for(i = 0; i < datlen; ++i) decoded[i] ^= rc4(); - fclose(inp); - - //inp = fopen("tmp.dump", "w"); - //fwrite(decoded, 1, datlen, inp); - //fclose(inp); - - return true; -} - -static bool game_data_init(const char *fname, bool from_update) -{ - static bool initialized = false; - if(initialized){ - return true; - } - if(!decrypt_file(fname, from_update)){ - printf("Error decrypting file!\n"); - return false; - } - xml = mxmlNewXML("1.0"); - tree = mxmlLoadString(xml, decoded, MXML_TEXT_CALLBACK); - return (tree != NULL); -} - -static void game_data_close() -{ - mxmlDelete(tree); - free(decoded); -} - -bool get_game_data(const char *input_fname, const char *output_fname, bool from_update) -{ - FILE *outfile = NULL; - if((outfile = fopen(output_fname, "w")) == NULL){ - ltr_int_log_message("Can't open the output file '%s'!\n", output_fname); - return false; - } - if(!game_data_init(input_fname, from_update)){ - ltr_int_log_message("Can't process the data file '%s'!\n", input_fname); - return false; - } - - mxml_node_t *game; - const char *name; - const char *id; - for(game = mxmlFindElement(tree, tree, "Game", NULL, NULL, MXML_DESCEND); - game != NULL; - game = mxmlFindElement(game, tree, "Game", NULL, NULL, MXML_DESCEND)){ - name = mxmlElementGetAttr(game, "Name"); - id = mxmlElementGetAttr(game, "Id"); - - mxml_node_t *appid = mxmlFindElement(game, game, "ApplicationID", NULL, NULL, MXML_DESCEND); - if(appid == NULL){ - fprintf(outfile, "%s \"%s\"\n", id, name); - }else{ - fprintf(outfile, "%s \"%s\" (%s)\n", id, name, appid->child->value.text.string); - } - } - fclose(outfile); - game_data_close(); - return true; -} - diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.h b/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.h deleted file mode 100644 index b71f7a15d..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/important-stuff/game_data.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef GAME_DATA__H -#define GAME_DATA__H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -bool get_game_data(const char *input_fname, const char *output_fname, bool from_update); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.am b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.am deleted file mode 100644 index e025209a2..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.am +++ /dev/null @@ -1,78 +0,0 @@ -noinst_SCRIPTS = -if WINE_PLUGIN - noinst_SCRIPTS += Tester.exe -if WINE64 - noinst_SCRIPTS += Tester64.exe -endif #WINE64 -endif #WINE_PLUGIN - -if DARWIN - LDFLAGS += -Wl,-no_arch_warnings -else - LDFLAGS += -Wl,--no-warn-search-mismatch -endif - -CC = winegcc - -CXX = wineg++ - -SUFFIXES = .o .cpp .c .rc 64.o - -.cpp.o : - $(CXX) -c $(CXXFLAGS) -m32 -o $@ $< - -.c.o : - $(CC) -c $(CFLAGS) -m32 -o $@ $< - -.cpp64.o : - $(CXX) -c $(CXXFLAGS) -o $@ $< - -.c64.o : - $(CC) -c $(CFLAGS) -o $@ $< - -.rc.o : - wrc -o $@ $(RCFLAGS) $< - -CXXFLAGS += -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@ -CFLAGS += -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@ -RCFLAGS = -I @srcdir@ -#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ -vpath %.h @srcdir@/../.. -vpath %.h @top_builddir@ -vpath %.c @srcdir@ -vpath %.c @srcdir@/../.. - - -Tester64.exe : main64.o rest64.o npifc64.o npview.o - wineg++ -g -o Tester64 -L. $(WINE64_LIBS) $(LDFLAGS) -Wall -Wextra $^ - -Tester.exe : main.o npview.o rest.o npifc.o - wineg++ -g -o Tester -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ - -main.o : main.cpp Makefile - -main64.o : main.cpp Makefile - -npview.o : npview.rc - -rest.o : rest.c rest.h Makefile - -rest64.o : rest.c rest.h Makefile - -npifc.o : npifc.c npifc.h Makefile - -npifc64.o : CFLAGS+="-DFOR_WIN64=1" -npifc64.o : npifc.c npifc.h Makefile - -clean-local: clean-local-check -.PHONY: clean-local-check -clean-local-check: - rm -f *.exe* *.dll* *.sh *.o - -distclean-local: distclean-local-check -.PHONY: distclean-local-check -distclean-local-check: - rm -f *.exe* *.dll* *.sh *.o - -EXTRA_DIST = main.cpp npifc.c npifc.h resource.h rest.c rest.h - diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.in b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.in deleted file mode 100644 index cc49d7542..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/Makefile.in +++ /dev/null @@ -1,512 +0,0 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2013 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@WINE_PLUGIN_TRUE@am__append_1 = Tester.exe -@WINE64_TRUE@@WINE_PLUGIN_TRUE@am__append_2 = Tester64.exe -@DARWIN_TRUE@am__append_3 = -Wl,-no_arch_warnings -@DARWIN_FALSE@am__append_4 = -Wl,--no-warn-search-mismatch -subdir = src/wine_bridge/tester -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/npview.rc.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = npview.rc -CONFIG_CLEAN_VPATH_FILES = -SCRIPTS = $(noinst_SCRIPTS) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -depcomp = -am__depfiles_maybe = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BISON = @BISON@ -CC = winegcc -CFLAGS = @CFLAGS@ -g -I../.. -I../../.. -DHAVE_CONFIG_H \ - -I@srcdir@/../.. -I@top_builddir@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = wineg++ -CXXCPP = @CXXCPP@ -CXXFLAGS = @CXXFLAGS@ -g -DHAVE_CONFIG_H -I../../.. -I. \ - -I@srcdir@/../.. -I@top_builddir@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ $(am__append_3) $(am__append_4) -LEX = @LEX@ -LEXLIB = @LEXLIB@ -LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -LIB32DIR = @LIB32DIR@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJC = @OBJC@ -OBJCFLAGS = @OBJCFLAGS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OPENCV_CFLAGS = @OPENCV_CFLAGS@ -OPENCV_LIBS = @OPENCV_LIBS@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -QMAKE_PATH = @QMAKE_PATH@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -WINE64_LIBS = @WINE64_LIBS@ -WINE_LIBS = @WINE_LIBS@ -XPL_CPPFLAGS = @XPL_CPPFLAGS@ -YACC = @YACC@ -YFLAGS = @YFLAGS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_OBJC = @ac_ct_OBJC@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_makensis = @with_makensis@ -with_wine64 = @with_wine64@ -noinst_SCRIPTS = $(am__append_1) $(am__append_2) -SUFFIXES = .o .cpp .c .rc 64.o -RCFLAGS = -I @srcdir@ -EXTRA_DIST = main.cpp npifc.c npifc.h resource.h rest.c rest.h -all: all-am - -.SUFFIXES: -.SUFFIXES: .o .cpp .c .rc 64.o -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/tester/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/tester/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -npview.rc: $(top_builddir)/config.status $(srcdir)/npview.rc.in - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -tags TAGS: - -ctags CTAGS: - -cscope cscopelist: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(SCRIPTS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-local mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-local - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - clean-local cscopelist-am ctags-am distclean distclean-generic \ - distclean-libtool distclean-local distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ - uninstall-am - - -.cpp.o : - $(CXX) -c $(CXXFLAGS) -m32 -o $@ $< - -.c.o : - $(CC) -c $(CFLAGS) -m32 -o $@ $< - -.cpp64.o : - $(CXX) -c $(CXXFLAGS) -o $@ $< - -.c64.o : - $(CC) -c $(CFLAGS) -o $@ $< - -.rc.o : - wrc -o $@ $(RCFLAGS) $< -#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ -vpath %.h @srcdir@/../.. -vpath %.h @top_builddir@ -vpath %.c @srcdir@ -vpath %.c @srcdir@/../.. - -Tester64.exe : main64.o rest64.o npifc64.o npview.o - wineg++ -g -o Tester64 -L. $(WINE64_LIBS) $(LDFLAGS) -Wall -Wextra $^ - -Tester.exe : main.o npview.o rest.o npifc.o - wineg++ -g -o Tester -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ - -main.o : main.cpp Makefile - -main64.o : main.cpp Makefile - -npview.o : npview.rc - -rest.o : rest.c rest.h Makefile - -rest64.o : rest.c rest.h Makefile - -npifc.o : npifc.c npifc.h Makefile - -npifc64.o : CFLAGS+="-DFOR_WIN64=1" -npifc64.o : npifc.c npifc.h Makefile - -clean-local: clean-local-check -.PHONY: clean-local-check -clean-local-check: - rm -f *.exe* *.dll* *.sh *.o - -distclean-local: distclean-local-check -.PHONY: distclean-local-check -distclean-local-check: - rm -f *.exe* *.dll* *.sh *.o - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/main.cpp b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/main.cpp deleted file mode 100644 index 95ca0d9b3..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/main.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#define WIN32_LEAN_AND_MEAN - -#include -#include -#include -#include "resource.h" -#include "rest.h" -#include "npifc.h" - -HINSTANCE hInst; -UINT_PTR timer = 0; - -VOID CALLBACK TimerProcedure(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) -{ - (void) uMsg; - (void) idEvent; - (void) dwTime; - tir_data_t td; - npifc_getdata(&td); - SetDlgItemInt(hwnd, IDC_PITCH, td.pitch, true); - SetDlgItemInt(hwnd, IDC_ROLL, td.roll, true); - SetDlgItemInt(hwnd, IDC_YAW, td.yaw, true); - - SetDlgItemInt(hwnd, IDC_X1, td.tx, true); - SetDlgItemInt(hwnd, IDC_Y1, td.ty, true); - SetDlgItemInt(hwnd, IDC_Z1, td.tz, true); - - SetDlgItemInt(hwnd, IDC_X2, td.padding[0], true); - SetDlgItemInt(hwnd, IDC_Y2, td.padding[1], true); - SetDlgItemInt(hwnd, IDC_Z2, td.padding[2], true); - SetDlgItemInt(hwnd, IDC_X3, td.padding[3], true); - SetDlgItemInt(hwnd, IDC_Y3, td.padding[4], true); - SetDlgItemInt(hwnd, IDC_Z3, td.padding[5], true); - SetDlgItemInt(hwnd, IDC_S, td.status, true); - SetDlgItemInt(hwnd, IDC_F, td.frame, true); -} - -BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - (void) lParam; - switch(uMsg) - { - case WM_INITDIALOG: - SetDlgItemInt(hwndDlg, IDC_APPID, 2307, true); - return TRUE; - - case WM_CLOSE: - EndDialog(hwndDlg, 0); - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - /* - * TODO: Add more control ID's, when needed. - */ - case IDQUIT: - npifc_close(); - EndDialog(hwndDlg, 0); - return TRUE; - case IDSTART: - int ok; - int num = GetDlgItemInt(hwndDlg, IDC_APPID, (BOOL*)&ok, false); - if(!ok){ - num = 2307; - } - game_desc_t gd; - if(timer != 0){ - KillTimer(hwndDlg, timer); - timer = 0; - } - if(game_data_get_desc(num, &gd)){ - printf("Application ID: %d - %s\n", num, gd.name); - if(npifc_init(hwndDlg, num)){ - timer = SetTimer(hwndDlg, 0, 50, TimerProcedure); - } - }else{ - printf("Unknown Application ID: %d\n", num); - } - break; - - } - } - - return FALSE; -} - - -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) -{ - (void) hPrevInstance; - (void) lpCmdLine; - (void) nShowCmd; - hInst = hInstance; - - // The user interface is a modal dialog box - return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DialogProc); -} - - diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.c b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.c deleted file mode 100644 index b036464ec..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.c +++ /dev/null @@ -1,302 +0,0 @@ -#define _GNU_SOURCE -#include -#include -#define WIN32_LEAN_AND_MEAN -#include -#include "npifc.h" -#include "rest.h" - - -tir_signature_t ts; -HMODULE npclient; -/* -typedef int (*NP_RegisterWindowHandle_t)(HWND hwnd); -typedef int (*NP_UnregisterWindowHandle_t)(void); -typedef int (*NP_RegisterProgramProfileID_t)(unsigned short id); -typedef int (*NP_QueryVersion_t)(unsigned short *version); -typedef int (*NP_RequestData_t)(unsigned short req); -typedef int (*NP_GetSignature_t)(tir_signature_t *sig); -typedef int (*NP_GetData_t)(tir_data_t *data); -typedef int (*NP_GetParameter_t)(void); -typedef int (*NP_SetParameter_t)(void); -typedef int (*NP_StartCursor_t)(void); -typedef int (*NP_StopCursor_t)(void); -typedef int (*NP_ReCenter_t)(void); -typedef int (*NP_StartDataTransmission_t)(void); -typedef int (*NP_StopDataTransmission_t)(void); -*/ -NP_RegisterWindowHandle_t NP_RegisterWindowHandle = NULL; -NP_UnregisterWindowHandle_t NP_UnregisterWindowHandle = NULL; -NP_RegisterProgramProfileID_t NP_RegisterProgramProfileID = NULL; -NP_QueryVersion_t NP_QueryVersion = NULL; -NP_RequestData_t NP_RequestData = NULL; -NP_GetSignature_t NP_GetSignature = NULL; -NP_GetData_t NP_GetData = NULL; -NP_GetParameter_t NP_GetParameter = NULL; -NP_SetParameter_t NP_SetParameter = NULL; -NP_StartCursor_t NP_StartCursor = NULL; -NP_StopCursor_t NP_StopCursor = NULL; -NP_ReCenter_t NP_ReCenter = NULL; -NP_StartDataTransmission_t NP_StartDataTransmission = NULL; -NP_StopDataTransmission_t NP_StopDataTransmission = NULL; - -bool crypted = false; - - - -unsigned char table[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -char *client_path() -{ - HKEY hkey = 0; - RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\NaturalPoint\\NATURALPOINT\\NPClient Location", 0, - KEY_QUERY_VALUE, &hkey); - if(!hkey){ - printf("Can't open registry key\n"); - return NULL; - } - - BYTE path[1024]; - DWORD buf_len = 1024; - LONG result = RegQueryValueEx(hkey, "Path", NULL, NULL, path, &buf_len); - char *full_path = NULL; - int res = -1; - if(result == ERROR_SUCCESS && buf_len > 0){ -#ifdef FOR_WIN64 - res = asprintf(&full_path, "%s/NPClient64.dll", path); -#else - res = asprintf(&full_path, "%s/NPClient.dll", path); -#endif - } - RegCloseKey(hkey); - if(res > 0){ - return full_path; - }else{ - return NULL; - } -} - -bool initialized = false; - -bool npifc_init(HWND wnd, int id) -{ - //table[] = {0xb3, 0x16, 0x36, 0xeb, 0xb9, 0x05, 0x4f, 0xa4}; - game_desc_t gd; - if(game_data_get_desc(id, &gd)){ - crypted = gd.encrypted; - if(gd.encrypted){ - table[0] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; - table[1] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; - table[2] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; - table[3] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; - table[4] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; - table[5] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; - table[6] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; - table[7] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; - } - } - printf("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", - table[0], table[1], table[2], table[3], - table[4], table[5], table[6], table[7]); - - char *client = client_path(); - if(client == NULL){ - printf("Couldn't obtain client path!\n"); - return false; - } - npclient = LoadLibrary(client); - if(!npclient){ - printf("Can't load client %s\n", client); - return false; - } - - NP_RegisterWindowHandle = (NP_RegisterWindowHandle_t)GetProcAddress(npclient, "NP_RegisterWindowHandle"); - NP_UnregisterWindowHandle = (NP_UnregisterWindowHandle_t)GetProcAddress(npclient, "NP_UnregisterWindowHandle"); - NP_RegisterProgramProfileID = (NP_RegisterProgramProfileID_t)GetProcAddress(npclient, "NP_RegisterProgramProfileID"); - NP_QueryVersion = (NP_QueryVersion_t)GetProcAddress(npclient, "NP_QueryVersion"); - NP_RequestData = (NP_RequestData_t)GetProcAddress(npclient, "NP_RequestData"); - NP_GetSignature = (NP_GetSignature_t)GetProcAddress(npclient, "NP_GetSignature"); - NP_GetData = (NP_GetData_t)GetProcAddress(npclient, "NP_GetData"); - NP_GetParameter = (NP_GetParameter_t)GetProcAddress(npclient, "NP_GetParameter"); - NP_SetParameter = (NP_SetParameter_t)GetProcAddress(npclient, "NP_SetParameter"); - NP_StartCursor = (NP_StartCursor_t)GetProcAddress(npclient, "NP_StartCursor"); - NP_StopCursor = (NP_StopCursor_t)GetProcAddress(npclient, "NP_StopCursor"); - NP_ReCenter = (NP_ReCenter_t)GetProcAddress(npclient, "NP_ReCenter"); - NP_StartDataTransmission = (NP_StartDataTransmission_t)GetProcAddress(npclient, "NP_StartDataTransmission"); - NP_StopDataTransmission = (NP_StopDataTransmission_t)GetProcAddress(npclient, "NP_StopDataTransmission"); - if((NP_RegisterWindowHandle == NULL) || (NP_UnregisterWindowHandle == NULL) - || (NP_RegisterProgramProfileID == NULL) || (NP_QueryVersion == NULL) || (NP_RequestData == NULL) - || (NP_GetSignature == NULL) || (NP_GetData == NULL) || (NP_GetParameter == NULL) - || (NP_SetParameter == NULL) || (NP_StartCursor == NULL) || (NP_StopCursor == NULL) - || (NP_ReCenter == NULL) || (NP_StartDataTransmission == NULL) || (NP_StopDataTransmission == NULL)){ - printf("Couldn't bind all necessary functions!\n"); - return false; - } - tir_signature_t sig; - int res; - if((res = NP_GetSignature(&sig)) != 0){ - printf("Error retrieving signature! %d\n", res); - return false; - } - printf("Dll Sig:%s\nApp Sig2:%s\n", sig.DllSignature, sig.AppSignature); - NP_RegisterWindowHandle(wnd); - if(NP_RegisterProgramProfileID(id) != 0){ - printf("Couldn't register profile id!\n"); - return false; - } - printf("Program profile registered!\n"); - NP_RequestData(65535); - NP_StopCursor(); - NP_StartDataTransmission(); - initialized = true; - return true; -} - -void npifc_close() -{ - if(initialized){ - NP_StopDataTransmission(); - NP_StartCursor(); - NP_UnregisterWindowHandle(); - } - initialized = false; -} - -void c_encrypt(unsigned char buf[], unsigned int size, - unsigned char code_table[], unsigned int table_size) -{ - unsigned int table_ptr = 0; - unsigned char var = 0x88; - unsigned char tmp; - if((size <= 0) || (table_size <= 0) || - (buf == NULL) || (code_table == NULL)) - return; - do{ - tmp = buf[--size]; - buf[size] = tmp ^ code_table[table_ptr] ^ var; - var += size + tmp; - ++table_ptr; - if(table_ptr >= table_size){ - table_ptr -= table_size; - } - }while(size != 0); -} - - - -void decrypt(unsigned char buf[], unsigned int size, - unsigned char code_table[], unsigned int table_size) -{ - unsigned int table_ptr = 0; - unsigned char var = 0x88; - unsigned char tmp; - if((size <= 0) || (table_size <= 0) || - (buf == NULL) || (code_table == NULL)){ - return; - } - do{ - tmp = buf[--size]; - buf[size] = tmp ^ code_table[table_ptr] ^ var; - var += size + buf[size]; - ++table_ptr; - if(table_ptr >= table_size){ - table_ptr -= table_size; - } - }while(size != 0); -} - -unsigned int cksum(unsigned char buf[], unsigned int size) -{ - if((size == 0) || (buf == NULL)){ - return 0; - } - int rounds = size >> 2; - int rem = size % 4; - - int c = size; - int a0 = 0; - int a2 = 0; - - while(rounds != 0){ - a0 = *(short int*)buf; - a2 = *(short int*)(buf+2); - buf += 4; - c += a0; - a2 ^= (c << 5); - a2 <<= 11; - c ^= a2; - c += (c >> 11); - --rounds; - } - switch(rem){ - case 3: - a0 = *(short int*)buf; - a2 = *(signed char*)(buf+2); - c += a0; - a2 = (a2 << 2) ^ c; - c ^= (a2 << 16); - a2 = (c >> 11); - break; - case 2: - a2 = *(short int*)buf; - c += a2; - c ^= (c << 11); - a2 = (c >> 17); - break; - case 1: - a2 = *(signed char*)(buf); - c += a2; - c ^= (c << 10); - a2 = (c >> 1); - break; - default: - break; - } - if(rem != 0){ - c+=a2; - } - - c ^= (c << 3); - c += (c >> 5); - c ^= (c << 4); - c += (c >> 17); - c ^= (c << 25); - c += (c >> 6); - - return (unsigned int)c; -} - -int decode_frame(tir_data_t *td) -{ - //printf("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", - // table[0], table[1], table[2], table[3], - // table[4], table[5], table[6], table[7]); - unsigned int csum; - decrypt((unsigned char*)td, sizeof(*td), table, sizeof(table)); - csum = td->cksum; - td->cksum = 0; - if(csum != cksum((unsigned char*)td, sizeof(*td))){ - printf("Problem with frame!\n"); - //int a0; - //printf("Dec: "); - //for(a0 = 0; a0 < (int)sizeof(tir_data_t); ++a0) - //{ - // printf("%02X", ((unsigned char *)td)[a0]); - //} - //printf("\n"); - //printf("Cksum: %04X vs computed: %04X\n", csum, cksum((unsigned char*)td, sizeof(*td))); - return -1; - } - //printf("Frame OK!\n"); - return 0; -} - -int npifc_getdata(tir_data_t *data) -{ - int res = NP_GetData(data); - if(crypted){ - decode_frame(data); - } - return res; -} - diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.h b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.h deleted file mode 100644 index d580e16d6..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npifc.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef NPIFC__H -#define NPIFC__H - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - bool npifc_init(HWND wnd, int id); - void npifc_close(); - -#pragma pack(1) -typedef struct tir_data{ - short status; - short frame; - unsigned int cksum; - float roll, pitch, yaw; - float tx, ty, tz; - float padding[9]; -} tir_data_t; - -typedef struct tir_signature{ - char DllSignature[200]; - char AppSignature[200]; -} tir_signature_t; -#pragma pack(0) - -int npifc_getdata(tir_data_t *data); - -typedef int __stdcall (*NP_RegisterWindowHandle_t)(HWND hwnd); -typedef int __stdcall (*NP_UnregisterWindowHandle_t)(void); -typedef int __stdcall (*NP_RegisterProgramProfileID_t)(unsigned short id); -typedef int __stdcall (*NP_QueryVersion_t)(unsigned short *version); -typedef int __stdcall (*NP_RequestData_t)(unsigned short req); -typedef int __stdcall (*NP_GetSignature_t)(tir_signature_t *sig); -typedef int __stdcall (*NP_GetData_t)(tir_data_t *data); -typedef int __stdcall (*NP_GetParameter_t)(void); -typedef int __stdcall (*NP_SetParameter_t)(void); -typedef int __stdcall (*NP_StartCursor_t)(void); -typedef int __stdcall (*NP_StopCursor_t)(void); -typedef int __stdcall (*NP_ReCenter_t)(void); -typedef int __stdcall (*NP_StartDataTransmission_t)(void); -typedef int __stdcall (*NP_StopDataTransmission_t)(void); - -extern NP_RegisterWindowHandle_t NP_RegisterWindowHandle; -extern NP_UnregisterWindowHandle_t NP_UnregisterWindowHandle; -extern NP_RegisterProgramProfileID_t NP_RegisterProgramProfileID; -extern NP_QueryVersion_t NP_QueryVersion; -extern NP_RequestData_t NP_RequestData; -extern NP_GetSignature_t NP_GetSignature; -extern NP_GetData_t NP_GetData; -extern NP_GetParameter_t NP_GetParameter; -extern NP_SetParameter_t NP_SetParameter; -extern NP_StartCursor_t NP_StartCursor; -extern NP_StopCursor_t NP_StopCursor; -extern NP_ReCenter_t NP_ReCenter; -extern NP_StartDataTransmission_t NP_StartDataTransmission; -extern NP_StopDataTransmission_t NP_StopDataTransmission; - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npview.rc.in b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npview.rc.in deleted file mode 100644 index 231002f18..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/npview.rc.in +++ /dev/null @@ -1,49 +0,0 @@ -// Generated by ResEdit 1.5.9 -// Copyright (C) 2006-2011 -// http://www.resedit.net - -#include -#include -#include -#include "resource.h" - -#ifdef HAVE_CONFIG_H - #include "../../../config.h" -#endif - - - -// -// Dialog resources -// -//LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -IDD_DIALOG1 DIALOGEX 0, 0, 379, 124 -STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU -CAPTION "NPTest v@PACKAGE_VERSION@" -FONT 8, "Ms Shell Dlg", 400, 0, 1 -{ - DEFPUSHBUTTON "Quit", IDQUIT, 262, 102, 50, 14 - DEFPUSHBUTTON "Start", IDSTART, 7, 102, 50, 14 - EDITTEXT IDC_PITCH, 32, 32, 51, 14, ES_AUTOHSCROLL - LTEXT "Pitch", IDC_STATIC, 11, 34, 20, 8, SS_LEFT - LTEXT "Yaw", IDC_STATIC, 11, 59, 20, 8, SS_LEFT - EDITTEXT IDC_YAW, 32, 57, 51, 14, ES_AUTOHSCROLL - LTEXT "Roll", IDC_STATIC, 11, 84, 20, 8, SS_LEFT - EDITTEXT IDC_ROLL, 32, 82, 51, 14, ES_AUTOHSCROLL - LTEXT "X", IDC_STATIC, 101, 35, 6, 8, SS_LEFT - EDITTEXT IDC_X1, 112, 32, 51, 14, ES_AUTOHSCROLL - LTEXT "Y", IDC_STATIC, 101, 60, 6, 8, SS_LEFT - EDITTEXT IDC_Y1, 112, 57, 51, 14, ES_AUTOHSCROLL - LTEXT "Z", IDC_STATIC, 101, 85, 6, 8, SS_LEFT - EDITTEXT IDC_Z1, 112, 82, 51, 14, ES_AUTOHSCROLL - EDITTEXT IDC_X2, 172, 32, 51, 14, ES_AUTOHSCROLL - EDITTEXT IDC_Y2, 172, 57, 51, 14, ES_AUTOHSCROLL - EDITTEXT IDC_Z2, 172, 82, 51, 14, ES_AUTOHSCROLL - EDITTEXT IDC_X3, 232, 32, 51, 14, ES_AUTOHSCROLL - EDITTEXT IDC_Y3, 232, 57, 51, 14, ES_AUTOHSCROLL - EDITTEXT IDC_Z3, 232, 82, 51, 14, ES_AUTOHSCROLL - EDITTEXT IDC_S, 292, 32, 51, 14, ES_AUTOHSCROLL - EDITTEXT IDC_F, 292, 57, 51, 14, ES_AUTOHSCROLL - EDITTEXT IDC_APPID, 32, 12, 51, 12, ES_AUTOHSCROLL - LTEXT "ID", IDC_STATIC, 17, 14, 8, 8, SS_LEFT -} diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/resource.h b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/resource.h deleted file mode 100644 index 328d9cb78..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/resource.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef IDC_STATIC -#define IDC_STATIC (-1) -#endif - -#define IDD_DIALOG1 100 -#define IDQUIT 1002 -#define IDSTART 1003 -#define IDC_APPID 1016 -#define IDC_PITCH 1017 -#define IDC_YAW 1018 -#define IDC_ROLL 1019 -#define IDC_X1 1020 -#define IDC_X2 1021 -#define IDC_X3 1022 -#define IDC_Y1 1023 -#define IDC_Y2 1024 -#define IDC_Y3 1025 -#define IDC_Z1 1026 -#define IDC_Z2 1027 -#define IDC_Z3 1028 -#define IDC_S 1029 -#define IDC_F 1030 - diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.c b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.c deleted file mode 120000 index 663c21a99..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.c +++ /dev/null @@ -1 +0,0 @@ -../client/rest.c \ No newline at end of file diff --git a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.h b/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.h deleted file mode 120000 index 6dca182ae..000000000 --- a/facetracknoir/clientfiles/important-source-code-really-important-really-really/tester/rest.h +++ /dev/null @@ -1 +0,0 @@ -../client/rest.h \ No newline at end of file diff --git a/facetracknoir/clientfiles/make-csv.pl b/facetracknoir/clientfiles/make-csv.pl new file mode 100755 index 000000000..ee60364e7 --- /dev/null +++ b/facetracknoir/clientfiles/make-csv.pl @@ -0,0 +1,72 @@ +#!/usr/bin/env perl + +use strict; +use List::Util qw'reduce'; + +sub get_games_1 { + my @games; + + open my $fd, "<", $ARGV[1] or die "open: $!"; + <$fd>; + + while (defined(my $line = <$fd>)) { + chomp $line; + if ($line !~ /^(\d+)\s+"([^"]+)"(?:\s+\(([0-9A-F]{16})\))?$/) { + warn "Broken line"; + next; + } + push @games, +{ id => $1, name => $2, key => defined $3 ? (sprintf "%04X", $1) . $3 . '00' : undef}; + } + + [@games]; +} + +sub get_games_2 { + open my $fd, "<", $ARGV[0] or die "open: $!"; + <$fd>; + my @games; + while (defined(my $line = <$fd>)) { + chomp $line; + my @line = split/;/, $line; + if (@line != 8) { + warn "Broken line"; + next; + } + my @cols = qw'no name proto since verified by id key'; + push @games, +{ map { $cols[$_] => $line[$_] } 0..$#cols }; + } + [@games]; +} + +sub merge { + my ($new_games, $old_games) = @_; + my $no = (reduce { $a->{no} > $b->{no} ? $a : $b } +{id=>0}, @$old_games)->{no} + 1; + my %game_hash = map { $_->{name} => $_ } @$old_games; + my %ids = map { $_->{id} => 1 } @$old_games; + for my $g (@$new_games) { + if (!exists $game_hash{$g->{name}} && !exists $ids{$g->{id}}) { + $game_hash{$g->{name}} = +{ + no => $no++, + name => $g->{name}, + proto => 'FreeTrack20', + since => (defined $g->{key} ? 'V170' : 'V160'), + verified => '', + by => '', + id => $g->{id}, + key => $g->{key} + }; + } + } + print "No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID\n"; + for (sort { lc($a->{name}) cmp lc($b->{name}) } values %game_hash) { + my $g = {%$_}; + if (!defined $g->{key}) { + $g->{key} = (sprintf "%04X", $g->{no}) . (join"", map { sprintf "%02X", int rand 256 } 0 .. 7) . '00'; + } + my @cols = qw'no name proto since verified by id key'; + print join";", map { $g->{$_} } @cols; + print "\n"; + } +} + +merge(get_games_1(), get_games_2()); diff --git a/facetracknoir/clientfiles/very-important-source-code/README-CREDIT.txt b/facetracknoir/clientfiles/very-important-source-code/README-CREDIT.txt new file mode 100644 index 000000000..822141393 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/README-CREDIT.txt @@ -0,0 +1,6 @@ +The contents of the directory written by one and only, uglyDwarf. + +Obtained at epoch time 1412397452 from the mithril-mine's shaft, where +the elite dwarves reside. + +For the latest happenings, visit diff --git a/facetracknoir/clientfiles/very-important-source-code/ft_tester/Makefile.am b/facetracknoir/clientfiles/very-important-source-code/ft_tester/Makefile.am new file mode 100644 index 000000000..02747edb4 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/ft_tester/Makefile.am @@ -0,0 +1,54 @@ +noinst_SCRIPTS = +if WINE_PLUGIN + noinst_SCRIPTS += ftc.exe.so +endif #WINE_PLUGIN + +if DARWIN + LDFLAGS += -Wl,-no_arch_warnings +else + LDFLAGS += -Wl,--no-warn-search-mismatch +endif + +CC = winegcc + +CXX = wineg++ + +SUFFIXES = .o .cpp .c .rc + +.cpp.o : + $(CXX) -c $(CXXFLAGS_PRE) $(CXXFLAGS) $(CPPFLAGS) -m32 -o $@ $< + +.c.o : + $(CC) -c $(CFLAGS_PRE) $(CFLAGS) $(CPPFLAGS) -m32 -o $@ $< + +.rc.o : + wrc -o $@ $(RCFLAGS) $< + +CXXFLAGS_PRE = -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@ +CFLAGS_PRE = -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@ +RCFLAGS = -I @srcdir@ +#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ +vpath %.h @srcdir@/../.. +vpath %.h @top_builddir@ +vpath %.c @srcdir@ +vpath %.c @srcdir@/../.. + +ftc.exe.so : main.o fttester.o + wineg++ -g -o $@ -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ + +fttester.o : fttester.rc resource.h config.h + +main.o : main.cpp + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +distclean-local: distclean-local-check +.PHONY: distclean-local-check +distclean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +EXTRA_DIST = resource.h fttester.rc main.cpp + diff --git a/facetracknoir/clientfiles/very-important-source-code/ft_tester/Makefile.in b/facetracknoir/clientfiles/very-important-source-code/ft_tester/Makefile.in new file mode 100644 index 000000000..d1fff34d1 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/ft_tester/Makefile.in @@ -0,0 +1,491 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@WINE_PLUGIN_TRUE@am__append_1 = ftc.exe.so +@DARWIN_TRUE@am__append_2 = -Wl,-no_arch_warnings +@DARWIN_FALSE@am__append_3 = -Wl,--no-warn-search-mismatch +subdir = src/wine_bridge/ft_tester +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(srcdir)/fttester.rc.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = fttester.rc +CONFIG_CLEAN_VPATH_FILES = +SCRIPTS = $(noinst_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +depcomp = +am__depfiles_maybe = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BISON = @BISON@ +CC = winegcc +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = wineg++ +CXXCPP = @CXXCPP@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ $(am__append_2) $(am__append_3) +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIB32DIR = @LIB32DIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCFLAGS = @OBJCFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENCV_CFLAGS = @OPENCV_CFLAGS@ +OPENCV_LIBS = @OPENCV_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +QMAKE_PATH = @QMAKE_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +WINE64_LIBS = @WINE64_LIBS@ +WINE_LIBS = @WINE_LIBS@ +XPL_CPPFLAGS = @XPL_CPPFLAGS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_OBJC = @ac_ct_OBJC@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +with_makensis = @with_makensis@ +with_wine64 = @with_wine64@ +noinst_SCRIPTS = $(am__append_1) +SUFFIXES = .o .cpp .c .rc +CXXFLAGS_PRE = -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@ +CFLAGS_PRE = -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@ +RCFLAGS = -I @srcdir@ +EXTRA_DIST = resource.h fttester.rc main.cpp +all: all-am + +.SUFFIXES: +.SUFFIXES: .o .cpp .c .rc +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/ft_tester/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/ft_tester/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +fttester.rc: $(top_builddir)/config.status $(srcdir)/fttester.rc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-local mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-local + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + clean-local cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distclean-local distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am + + +.cpp.o : + $(CXX) -c $(CXXFLAGS_PRE) $(CXXFLAGS) $(CPPFLAGS) -m32 -o $@ $< + +.c.o : + $(CC) -c $(CFLAGS_PRE) $(CFLAGS) $(CPPFLAGS) -m32 -o $@ $< + +.rc.o : + wrc -o $@ $(RCFLAGS) $< +#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ +vpath %.h @srcdir@/../.. +vpath %.h @top_builddir@ +vpath %.c @srcdir@ +vpath %.c @srcdir@/../.. + +ftc.exe.so : main.o fttester.o + wineg++ -g -o $@ -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ + +fttester.o : fttester.rc resource.h config.h + +main.o : main.cpp + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +distclean-local: distclean-local-check +.PHONY: distclean-local-check +distclean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/facetracknoir/clientfiles/very-important-source-code/ft_tester/fttester.rc.in b/facetracknoir/clientfiles/very-important-source-code/ft_tester/fttester.rc.in new file mode 100644 index 000000000..332f3c73c --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/ft_tester/fttester.rc.in @@ -0,0 +1,67 @@ +// Generated by ResEdit 1.5.9 +// Copyright (C) 2006-2011 +// http://www.resedit.net + +#include +#include +#include +#include "resource.h" + +#ifdef HAVE_CONFIG_H + #include "../../../config.h" +#endif + + + + +// +// Dialog resources +// +//LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +IDD_DIALOG1 DIALOGEX 0, 0, 333, 183 +STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU +CAPTION "FreeTrack client test utility v@PACKAGE_VERSION@" +FONT 8, "Ms Shell Dlg", 400, 0, 1 +{ + DEFPUSHBUTTON "Quit", IDQUIT, 262, 153, 50, 14 + PUSHBUTTON "Start", IDC_START, 199, 153, 50, 14 + EDITTEXT IDC_YAW, 38, 15, 48, 14, ES_AUTOHSCROLL + RTEXT "Yaw", IDC_STATIC, 12, 17, 21, 14, SS_RIGHT + EDITTEXT IDC_PITCH, 38, 38, 48, 14, ES_AUTOHSCROLL + RTEXT "Pitch", IDC_STATIC, 16, 40, 17, 14, SS_RIGHT + EDITTEXT IDC_ROLL, 38, 61, 48, 14, ES_AUTOHSCROLL + RTEXT "Roll", IDC_STATIC, 20, 63, 13, 14, SS_RIGHT + EDITTEXT IDC_X, 38, 84, 48, 14, ES_AUTOHSCROLL + RTEXT "X", IDC_STATIC, 27, 86, 6, 14, SS_RIGHT + EDITTEXT IDC_Y, 38, 107, 48, 14, ES_AUTOHSCROLL + RTEXT "Y", IDC_STATIC, 27, 109, 6, 14, SS_RIGHT + EDITTEXT IDC_Z, 38, 130, 48, 14, ES_AUTOHSCROLL + RTEXT "Z", IDC_STATIC, 27, 132, 6, 14, SS_RIGHT + EDITTEXT IDC_RYAW, 137, 15, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Yaw", IDC_STATIC, 101, 17, 32, 8, SS_RIGHT + EDITTEXT IDC_RPITCH, 137, 38, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Pitch", IDC_STATIC, 99, 40, 34, 8, SS_RIGHT + EDITTEXT IDC_RROLL, 137, 61, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Roll", IDC_STATIC, 103, 63, 30, 8, SS_RIGHT + EDITTEXT IDC_RX, 137, 84, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw X", IDC_STATIC, 111, 86, 22, 8, SS_RIGHT + EDITTEXT IDC_RY, 137, 107, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Y", IDC_STATIC, 111, 109, 22, 8, SS_RIGHT + EDITTEXT IDC_RZ, 137, 130, 48, 14, ES_AUTOHSCROLL + RTEXT "Raw Z", IDC_STATIC, 111, 132, 22, 8, SS_RIGHT + EDITTEXT IDC_NUM, 264, 15, 48, 14, ES_AUTOHSCROLL + RTEXT "Frame Number", IDC_STATIC, 212, 17, 47, 8, SS_RIGHT + EDITTEXT IDC_RES, 264, 38, 48, 14, ES_AUTOHSCROLL + RTEXT "Camera Resolution", IDC_STATIC, 199, 40, 60, 8, SS_RIGHT + EDITTEXT IDC_PT0, 227, 61, 85, 14, ES_AUTOHSCROLL + RTEXT "Point 1", IDC_STATIC, 199, 63, 23, 8, SS_RIGHT + EDITTEXT IDC_PT1, 227, 84, 85, 14, ES_AUTOHSCROLL + RTEXT "Point 2", IDC_STATIC, 199, 86, 23, 8, SS_RIGHT + EDITTEXT IDC_PT2, 227, 107, 85, 14, ES_AUTOHSCROLL + RTEXT "Point 3", IDC_STATIC, 199, 109, 23, 8, SS_RIGHT + EDITTEXT IDC_PT3, 227, 130, 85, 14, ES_AUTOHSCROLL + RTEXT "Point 4", IDC_STATIC, 199, 132, 23, 8, SS_RIGHT + EDITTEXT IDC_TITLE, 38, 153, 147, 14, ES_AUTOHSCROLL + RTEXT "Title", IDC_STATIC, 19, 155, 14, 8, SS_RIGHT +} + diff --git a/facetracknoir/clientfiles/very-important-source-code/ft_tester/main.cpp b/facetracknoir/clientfiles/very-important-source-code/ft_tester/main.cpp new file mode 100644 index 000000000..a737f88f5 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/ft_tester/main.cpp @@ -0,0 +1,211 @@ +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include +#include +#include +#include + +#include "resource.h" + +HINSTANCE hInst; +UINT_PTR timer = 0; + +HMODULE ftclient; + +typedef struct +{ + unsigned int dataID; + int res_x; int res_y; + float yaw; // positive yaw to the left + float pitch;// positive pitch up + float roll;// positive roll to the left + float x; + float y; + float z; + // raw pose with no smoothing, sensitivity, response curve etc. + float ryaw; + float rpitch; + float rroll; + float rx; + float ry; + float rz; + // raw points, sorted by Y, origin top left corner + float x0, y0; + float x1, y1; + float x2, y2; + float x3, y3; +}FreeTrackData; + + +typedef bool (WINAPI *importGetData)(FreeTrackData * data); +typedef char *(WINAPI *importGetDllVersion)(void); +typedef void (WINAPI *importReportName)(char *name); +typedef char *(WINAPI *importProvider)(void); + +importGetData getData; +importGetDllVersion getDllVersion; +importReportName reportName; +importProvider provider; + + +char *client_path() +{ + HKEY hkey = 0; + RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Freetrack\\FreetrackClient", 0, + KEY_QUERY_VALUE, &hkey); + if(!hkey){ + printf("Can't open registry key\n"); + return NULL; + } + + BYTE path[1024]; + DWORD buf_len = 1024; + LONG result = RegQueryValueEx(hkey, "Path", NULL, NULL, path, &buf_len); + char *full_path = (char *)malloc(2048); + if(result == ERROR_SUCCESS && buf_len > 0){ + sprintf(full_path, "%s\\FreeTrackClient.dll", path); + } + RegCloseKey(hkey); + return full_path; +} + + +bool start(HWND hwnd) +{ + char *libname = client_path(); + if(libname == NULL){ + printf("Freetrack client not found!\n"); + return false; + } + ftclient = LoadLibrary(libname); + if(ftclient == NULL){ + printf("Couldn't load Freetrack client library '%s'!\n", libname); + return false; + } + printf("Freetrack client library %s loaded.\n", client_path()); + + + getData = (importGetData)GetProcAddress(ftclient, "FTGetData"); + getDllVersion = (importGetDllVersion)GetProcAddress(ftclient, "FTGetDllVersion"); + reportName = (importReportName)GetProcAddress(ftclient, "FTReportName"); + provider = (importProvider)GetProcAddress(ftclient, "FTProvider"); + + if((getData == NULL) || (getDllVersion == NULL) || (reportName == NULL) || (provider == NULL)){ + printf("Couldn't load Freetrack client functions!\n"); + FreeLibrary(ftclient); + return false; + } + + printf("Dll version: %s\n", getDllVersion()); + printf("Provider: %s\n", provider()); + char title[1024]; + GetDlgItemText(hwnd, IDC_TITLE, title, 1020); + reportName(title); + return true; +} + +void reportError(std::string msg) +{ + MessageBoxA(0, "FreeTrack client test", msg.c_str(), 0); +} +VOID CALLBACK TimerProcedure(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + (void) uMsg; + (void) idEvent; + (void) dwTime; + FreeTrackData d; + getData(&d); + SetDlgItemInt(hwnd, IDC_PITCH, d.pitch, true); + SetDlgItemInt(hwnd, IDC_ROLL, d.roll, true); + SetDlgItemInt(hwnd, IDC_YAW, d.yaw, true); + + SetDlgItemInt(hwnd, IDC_X, d.x, true); + SetDlgItemInt(hwnd, IDC_Y, d.y, true); + SetDlgItemInt(hwnd, IDC_Z, d.z, true); + + SetDlgItemInt(hwnd, IDC_RPITCH, d.rpitch, true); + SetDlgItemInt(hwnd, IDC_RROLL, d.rroll, true); + SetDlgItemInt(hwnd, IDC_RYAW, d.ryaw, true); + + SetDlgItemInt(hwnd, IDC_RX, d.rx, true); + SetDlgItemInt(hwnd, IDC_RY, d.ry, true); + SetDlgItemInt(hwnd, IDC_RZ, d.rz, true); + + std::ostringstream s; + s.str(std::string()); + s<<"("< +#include "rest.h" +//#include "config.h" +#define __WINESRC__ + +#include +#include +#include +#include +#include +#include +#include "windef.h" +#include "winbase.h" +#include "NPClient_dll.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(NPClient); + +bool crypted = false; +static unsigned char table[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static int dbg_flag; + +static void dbg_report(const char *msg,...) +{ + static FILE *f = NULL; + if(dbg_flag){ + if(f == NULL){ + f = fopen("NPClient.log", "w"); + } + va_list ap; + va_start(ap,msg); + vfprintf(f, msg, ap); + fflush(f); + va_end(ap); + } +} + + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); + + switch (fdwReason) + { + case DLL_WINE_PREATTACH: + return TRUE; + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + dbg_flag = getDebugFlag('w'); + dbg_report("Attach request\n"); + break; + case DLL_PROCESS_DETACH: + linuxtrack_shutdown(); + break; + } + + return TRUE; +} +/****************************************************************** + * NPPriv_ClientNotify (NPCLIENT.1) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_ClientNotify() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_GetLastError (NPCLIENT.2) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_GetLastError() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetData (NPCLIENT.3) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetData() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetLastError (NPCLIENT.4) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetLastError() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetParameter (NPCLIENT.5) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetParameter() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetSignature (NPCLIENT.6) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetSignature() +{ + /* @stub in .spec */ +} +#endif +/****************************************************************** + * NPPriv_SetVersion (NPCLIENT.7) + * + * + */ +#if 0 +__stdcall NPCLIENT_NPPriv_SetVersion() +{ + /* @stub in .spec */ +} +#endif + +static float limit_num(float min, float val, float max) +{ + if(val < min) return min; + if(val > max) return max; + return val; +} + +static unsigned int cksum(unsigned char buf[], unsigned int size) +{ + if((size == 0) || (buf == NULL)){ + return 0; + } + + int rounds = size >> 2; + int rem = size % 4; + + int c = size; + int a0, a2; +// printf("Orig: "); +//for(a0 = 0; a0 < (int)size; ++a0) +//{ +// printf("%02X", buf[a0]); +//} +//printf("\n"); + while(rounds != 0){ + a0 = *(short int*)buf; + a2 = *(short int*)(buf+2); + buf += 4; + c += a0; + a2 ^= (c << 5); + a2 <<= 11; + c ^= a2; + c += (c >> 11); + --rounds; + } + switch(rem){ + case 3: + a0 = *(short int*)buf; + a2 = *(signed char*)(buf+2); + c += a0; + a2 = (a2 << 2) ^ c; + c ^= (a2 << 16); + a2 = (c >> 11); + break; + case 2: + a2 = *(short int*)buf; + c += a2; + c ^= (c << 11); + a2 = (c >> 17); + break; + case 1: + a2 = *(signed char*)(buf); + c += a2; + c ^= (c << 10); + a2 = (c >> 1); + break; + default: + break; + } + if(rem != 0){ + c+=a2; + } + + c ^= (c << 3); + c += (c >> 5); + c ^= (c << 4); + c += (c >> 17); + c ^= (c << 25); + c += (c >> 6); + + return (unsigned int)c; +} + +static void enhance(unsigned char buf[], unsigned int size, + unsigned char codetable[], unsigned int table_size) +{ + unsigned int table_ptr = 0; + unsigned char var = 0x88; + unsigned char tmp; + if((size <= 0) || (table_size <= 0) || + (buf == NULL) || (codetable == NULL)){ + return; + } + do{ + tmp = buf[--size]; + buf[size] = tmp ^ codetable[table_ptr] ^ var; + var += size + tmp; + ++table_ptr; + if(table_ptr >= table_size){ + table_ptr -= table_size; + } + }while(size != 0); +} + + +/****************************************************************** + * NP_GetData (NPCLIENT.8) + * + * + */ +int __stdcall NPCLIENT_NP_GetData(tir_data_t * data) +{ + float r, p, y, tx, ty, tz; + unsigned int frame; + int res = linuxtrack_get_pose(&y, &p, &r, &tx, &ty, &tz, &frame); + memset((char *)data, 0, sizeof(tir_data_t)); + data->status = (linuxtrack_get_tracking_state() == RUNNING) ? 0 : 1; + data->frame = frame & 0xFFFF; + data->cksum = 0; + data->roll = r / 180.0 * 16383; + data->pitch = -p / 180.0 * 16383; + data->yaw = y / 180.0 * 16383; + data->tx = -limit_num(-16383.0, 15 * tx, 16383); + data->ty = limit_num(-16383.0, 15 * ty, 16383); + data->tz = limit_num(-16383.0, 15 * tz, 16383); + data->cksum = cksum((unsigned char*)data, sizeof(tir_data_t)); + //printf("Cksum: %04X\n", data->cksum); + if(crypted){ + enhance((unsigned char*)data, sizeof(tir_data_t), table, sizeof(table)); + } + return (res >= 0) ? 0: 1; +} +/****************************************************************** + * NP_GetParameter (NPCLIENT.9) + * + * + */ +int __stdcall NPCLIENT_NP_GetParameter(int arg0, int arg1) +{ + dbg_report("GetParameter request: %d %d\n", arg0, arg1); + TRACE("(void): stub\n"); + return (int) 0; +} + +/****************************************************************** + * NP_GetSignature (NPCLIENT.10) + * + * + */ +int __stdcall NPCLIENT_NP_GetSignature(tir_signature_t * sig) +{ + dbg_report("GetSignature request\n"); + if(getSomeSeriousPoetry(sig->DllSignature, sig->AppSignature)){ + printf("Signature result: OK\n"); + return 0; + }else{ + printf("Signature result: NOT OK!\n"); + return 1; + } +} +/****************************************************************** + * NP_QueryVersion (NPCLIENT.11) + * + * + */ +int __stdcall NPCLIENT_NP_QueryVersion(unsigned short * version) +{ + dbg_report("QueryVersion request\n"); + *version=0x0500; + return 0; +} +/****************************************************************** + * NP_ReCenter (NPCLIENT.12) + * + * + */ +int __stdcall NPCLIENT_NP_ReCenter(void) +{ + dbg_report("ReCenter request\n"); + linuxtrack_recenter(); + return 0; +} + +/****************************************************************** + * NP_RegisterProgramProfileID (NPCLIENT.13) + * + * + */ +int __stdcall NPCLIENT_NP_RegisterProgramProfileID(unsigned short id) +{ + dbg_report("RegisterProgramProfileID request: %d\n", id); + game_desc_t gd; + if(game_data_get_desc(id, &gd)){ + printf("Application ID: %d - %s!!!\n", id, gd.name); + if(game_data_get_desc(id, &gd)){ + crypted = gd.encrypted; + if(gd.encrypted){ + printf("Table: %02X %02X %02X %02X %02X %02X %02X %02X\n", table[0],table[1],table[2],table[3],table[4], + table[5], table[6], table[7]); + table[0] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[1] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[2] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[3] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[4] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[5] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[6] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[7] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + } + } + if(linuxtrack_init(gd.name) != 0){ + return 1; + } + }else{ + if(!linuxtrack_init("Default")){ + return 1; + } + } + linuxtrack_suspend(); + return 0; +} +/****************************************************************** + * NP_RegisterWindowHandle (NPCLIENT.14) + * + * + */ +int __stdcall NPCLIENT_NP_RegisterWindowHandle(HWND hwnd) +{ + dbg_report("RegisterWindowHandle request: 0x%X\n", hwnd); + TRACE("((HWND)%p): stub\n",hwnd); + return (int) 0; +} +/****************************************************************** + * NP_RequestData (NPCLIENT.15) + * + * + */ +int __stdcall NPCLIENT_NP_RequestData(unsigned short req) +{ + dbg_report("RequestData request: %d\n", req); + TRACE("((unsigned short)%d): stub\n",req); + return (int) 0; +} +/****************************************************************** + * NP_SetParameter (NPCLIENT.16) + * + * + */ +int __stdcall NPCLIENT_NP_SetParameter(int arg0, int arg1) +{ + dbg_report("SetParameter request: %d %d\n", arg0, arg1); + TRACE("(void): stub\n"); + return (int) 0; +} +/****************************************************************** + * NP_StartCursor (NPCLIENT.17) + * + * + */ +int __stdcall NPCLIENT_NP_StartCursor(void) +{ + dbg_report("StartCursor request\n"); + TRACE("(void): stub\n"); + return (int) 0; +} +/****************************************************************** + * NP_StartDataTransmission (NPCLIENT.18) + * + * + */ +int __stdcall NPCLIENT_NP_StartDataTransmission(void) +{ + dbg_report("StartDataTransmission request\n"); + linuxtrack_wakeup(); + return 0; +} +/****************************************************************** + * NP_StopCursor (NPCLIENT.19) + * + * + */ +int __stdcall NPCLIENT_NP_StopCursor(void) +{ + dbg_report("StopCursor request\n"); + TRACE("(void): stub\n"); + return (int) 0; +} +/****************************************************************** + * NP_StopDataTransmission (NPCLIENT.20) + * + * + */ +int __stdcall NPCLIENT_NP_StopDataTransmission(void) +{ + dbg_report("StopDataTransmission request\n"); + linuxtrack_suspend(); + return 0; +} +/****************************************************************** + * NP_UnregisterWindowHandle (NPCLIENT.21) + * + * + */ +int __stdcall NPCLIENT_NP_UnregisterWindowHandle(void) +{ + dbg_report("UnregisterWindowHandle request\n"); + TRACE("(void): stub\n"); + return (int) 0; +} + diff --git a/facetracknoir/clientfiles/very-important-source-code/important-stuff/game_data.c b/facetracknoir/clientfiles/very-important-source-code/important-stuff/game_data.c new file mode 100644 index 000000000..f80a7d44d --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/important-stuff/game_data.c @@ -0,0 +1,150 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +//First 5 bytes is MD5 hash of "NaturalPoint" +static uint8_t secret_key[] = {0x0e, 0x9a, 0x63, 0x71, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static uint8_t S[256] = {0}; + +static char *decoded = NULL; + +static mxml_node_t *xml = NULL; +static mxml_node_t *tree = NULL; + +static void ksa(uint8_t key[], size_t len) +{ + unsigned int i, j; + for(i = 0; i < 256; ++i){ + S[i] = i; + } + j = 0; + for(i = 0; i < 256; ++i){ + j = (j + S[i] + key[i % len]) % 256; + uint8_t tmp = S[i]; + S[i] = S[j]; + S[j] = tmp; + } +} + +static uint8_t rc4() +{ + static uint8_t i = 0; + static uint8_t j = 0; + + i += 1; + j += S[i]; + uint8_t tmp = S[i]; + S[i] = S[j]; + S[j] = tmp; + return S[(S[i] + S[j]) % 256]; +} + +static bool decrypt_file(const char *fname, bool from_update) +{ + uint32_t header[5]; + size_t datlen; + ksa(secret_key, 16); + FILE *inp; + struct stat fst; + + if((inp = fopen(fname, "rb")) == NULL){ + printf("Can't open input file '%s'", fname); + return false; + } + + if(fstat(fileno(inp), &fst) != 0){ + fclose(inp); + printf("Cannot stat file '%s'\n", fname); + return false; + } + + if(from_update){ + if(fread(&header, sizeof(uint32_t), 5, inp) != 5){ + fclose(inp); + printf("Can't read the header - file '%s' is less than 20 bytes long?\n", fname); + return false; + } + datlen = header[4]; + }else{ + datlen = fst.st_size; + } + if((decoded = (char *)malloc(datlen+1)) == NULL){ + printf("malloc failed!\n"); + return false; + } + memset(decoded, 0, datlen+1); + size_t i; + size_t len = fread(decoded, 1, datlen, inp); + (void) len; + for(i = 0; i < datlen; ++i) decoded[i] ^= rc4(); + fclose(inp); + + //inp = fopen("tmp.dump", "w"); + //fwrite(decoded, 1, datlen, inp); + //fclose(inp); + + return true; +} + +static bool game_data_init(const char *fname, bool from_update) +{ + static bool initialized = false; + if(initialized){ + return true; + } + if(!decrypt_file(fname, from_update)){ + printf("Error decrypting file!\n"); + return false; + } + xml = mxmlNewXML("1.0"); + tree = mxmlLoadString(xml, decoded, MXML_TEXT_CALLBACK); + return (tree != NULL); +} + +static void game_data_close() +{ + mxmlDelete(tree); + free(decoded); +} + +#define ltr_int_log_message(...) fprintf(stderr, __VA_ARGS__) + +bool get_game_data(const char *input_fname, const char *output_fname, bool from_update) +{ + FILE *outfile = NULL; + if((outfile = (output_fname ? fopen(output_fname, "w") : stdout)) == NULL){ + ltr_int_log_message("Can't open the output file '%s'!\n", output_fname); + return false; + } + if(!game_data_init(input_fname, from_update)){ + ltr_int_log_message("Can't process the data file '%s'!\n", input_fname); + return false; + } + + mxml_node_t *game; + const char *name; + const char *id; + for(game = mxmlFindElement(tree, tree, "Game", NULL, NULL, MXML_DESCEND); + game != NULL; + game = mxmlFindElement(game, tree, "Game", NULL, NULL, MXML_DESCEND)){ + name = mxmlElementGetAttr(game, "Name"); + id = mxmlElementGetAttr(game, "Id"); + + mxml_node_t *appid = mxmlFindElement(game, game, "ApplicationID", NULL, NULL, MXML_DESCEND); + if(appid == NULL){ + fprintf(outfile, "%s \"%s\"\n", id, name); + }else{ + fprintf(outfile, "%s \"%s\" (%s)\n", id, name, appid->child->value.text.string); + } + } + fclose(outfile); + game_data_close(); + return true; +} + +int main(int argc, char** argv) { return argc > 1 && get_game_data(argv[1], NULL, false); } diff --git a/facetracknoir/clientfiles/very-important-source-code/important-stuff/game_data.h b/facetracknoir/clientfiles/very-important-source-code/important-stuff/game_data.h new file mode 100644 index 000000000..b71f7a15d --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/important-stuff/game_data.h @@ -0,0 +1,17 @@ +#ifndef GAME_DATA__H +#define GAME_DATA__H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +bool get_game_data(const char *input_fname, const char *output_fname, bool from_update); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/facetracknoir/clientfiles/very-important-source-code/tester/Makefile.am b/facetracknoir/clientfiles/very-important-source-code/tester/Makefile.am new file mode 100644 index 000000000..e025209a2 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/tester/Makefile.am @@ -0,0 +1,78 @@ +noinst_SCRIPTS = +if WINE_PLUGIN + noinst_SCRIPTS += Tester.exe +if WINE64 + noinst_SCRIPTS += Tester64.exe +endif #WINE64 +endif #WINE_PLUGIN + +if DARWIN + LDFLAGS += -Wl,-no_arch_warnings +else + LDFLAGS += -Wl,--no-warn-search-mismatch +endif + +CC = winegcc + +CXX = wineg++ + +SUFFIXES = .o .cpp .c .rc 64.o + +.cpp.o : + $(CXX) -c $(CXXFLAGS) -m32 -o $@ $< + +.c.o : + $(CC) -c $(CFLAGS) -m32 -o $@ $< + +.cpp64.o : + $(CXX) -c $(CXXFLAGS) -o $@ $< + +.c64.o : + $(CC) -c $(CFLAGS) -o $@ $< + +.rc.o : + wrc -o $@ $(RCFLAGS) $< + +CXXFLAGS += -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@ +CFLAGS += -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@ +RCFLAGS = -I @srcdir@ +#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ +vpath %.h @srcdir@/../.. +vpath %.h @top_builddir@ +vpath %.c @srcdir@ +vpath %.c @srcdir@/../.. + + +Tester64.exe : main64.o rest64.o npifc64.o npview.o + wineg++ -g -o Tester64 -L. $(WINE64_LIBS) $(LDFLAGS) -Wall -Wextra $^ + +Tester.exe : main.o npview.o rest.o npifc.o + wineg++ -g -o Tester -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ + +main.o : main.cpp Makefile + +main64.o : main.cpp Makefile + +npview.o : npview.rc + +rest.o : rest.c rest.h Makefile + +rest64.o : rest.c rest.h Makefile + +npifc.o : npifc.c npifc.h Makefile + +npifc64.o : CFLAGS+="-DFOR_WIN64=1" +npifc64.o : npifc.c npifc.h Makefile + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +distclean-local: distclean-local-check +.PHONY: distclean-local-check +distclean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +EXTRA_DIST = main.cpp npifc.c npifc.h resource.h rest.c rest.h + diff --git a/facetracknoir/clientfiles/very-important-source-code/tester/Makefile.in b/facetracknoir/clientfiles/very-important-source-code/tester/Makefile.in new file mode 100644 index 000000000..cc49d7542 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/tester/Makefile.in @@ -0,0 +1,512 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@WINE_PLUGIN_TRUE@am__append_1 = Tester.exe +@WINE64_TRUE@@WINE_PLUGIN_TRUE@am__append_2 = Tester64.exe +@DARWIN_TRUE@am__append_3 = -Wl,-no_arch_warnings +@DARWIN_FALSE@am__append_4 = -Wl,--no-warn-search-mismatch +subdir = src/wine_bridge/tester +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(srcdir)/npview.rc.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = npview.rc +CONFIG_CLEAN_VPATH_FILES = +SCRIPTS = $(noinst_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +depcomp = +am__depfiles_maybe = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BISON = @BISON@ +CC = winegcc +CFLAGS = @CFLAGS@ -g -I../.. -I../../.. -DHAVE_CONFIG_H \ + -I@srcdir@/../.. -I@top_builddir@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = wineg++ +CXXCPP = @CXXCPP@ +CXXFLAGS = @CXXFLAGS@ -g -DHAVE_CONFIG_H -I../../.. -I. \ + -I@srcdir@/../.. -I@top_builddir@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ $(am__append_3) $(am__append_4) +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIB32DIR = @LIB32DIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCFLAGS = @OBJCFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENCV_CFLAGS = @OPENCV_CFLAGS@ +OPENCV_LIBS = @OPENCV_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +QMAKE_PATH = @QMAKE_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +WINE64_LIBS = @WINE64_LIBS@ +WINE_LIBS = @WINE_LIBS@ +XPL_CPPFLAGS = @XPL_CPPFLAGS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_OBJC = @ac_ct_OBJC@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +with_makensis = @with_makensis@ +with_wine64 = @with_wine64@ +noinst_SCRIPTS = $(am__append_1) $(am__append_2) +SUFFIXES = .o .cpp .c .rc 64.o +RCFLAGS = -I @srcdir@ +EXTRA_DIST = main.cpp npifc.c npifc.h resource.h rest.c rest.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .o .cpp .c .rc 64.o +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/tester/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/tester/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +npview.rc: $(top_builddir)/config.status $(srcdir)/npview.rc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-local mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-local + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + clean-local cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distclean-local distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am + + +.cpp.o : + $(CXX) -c $(CXXFLAGS) -m32 -o $@ $< + +.c.o : + $(CC) -c $(CFLAGS) -m32 -o $@ $< + +.cpp64.o : + $(CXX) -c $(CXXFLAGS) -o $@ $< + +.c64.o : + $(CC) -c $(CFLAGS) -o $@ $< + +.rc.o : + wrc -o $@ $(RCFLAGS) $< +#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@ +vpath %.h @srcdir@/../.. +vpath %.h @top_builddir@ +vpath %.c @srcdir@ +vpath %.c @srcdir@/../.. + +Tester64.exe : main64.o rest64.o npifc64.o npview.o + wineg++ -g -o Tester64 -L. $(WINE64_LIBS) $(LDFLAGS) -Wall -Wextra $^ + +Tester.exe : main.o npview.o rest.o npifc.o + wineg++ -g -o Tester -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^ + +main.o : main.cpp Makefile + +main64.o : main.cpp Makefile + +npview.o : npview.rc + +rest.o : rest.c rest.h Makefile + +rest64.o : rest.c rest.h Makefile + +npifc.o : npifc.c npifc.h Makefile + +npifc64.o : CFLAGS+="-DFOR_WIN64=1" +npifc64.o : npifc.c npifc.h Makefile + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +distclean-local: distclean-local-check +.PHONY: distclean-local-check +distclean-local-check: + rm -f *.exe* *.dll* *.sh *.o + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/facetracknoir/clientfiles/very-important-source-code/tester/main.cpp b/facetracknoir/clientfiles/very-important-source-code/tester/main.cpp new file mode 100644 index 000000000..95ca0d9b3 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/tester/main.cpp @@ -0,0 +1,100 @@ +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include +#include "resource.h" +#include "rest.h" +#include "npifc.h" + +HINSTANCE hInst; +UINT_PTR timer = 0; + +VOID CALLBACK TimerProcedure(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + (void) uMsg; + (void) idEvent; + (void) dwTime; + tir_data_t td; + npifc_getdata(&td); + SetDlgItemInt(hwnd, IDC_PITCH, td.pitch, true); + SetDlgItemInt(hwnd, IDC_ROLL, td.roll, true); + SetDlgItemInt(hwnd, IDC_YAW, td.yaw, true); + + SetDlgItemInt(hwnd, IDC_X1, td.tx, true); + SetDlgItemInt(hwnd, IDC_Y1, td.ty, true); + SetDlgItemInt(hwnd, IDC_Z1, td.tz, true); + + SetDlgItemInt(hwnd, IDC_X2, td.padding[0], true); + SetDlgItemInt(hwnd, IDC_Y2, td.padding[1], true); + SetDlgItemInt(hwnd, IDC_Z2, td.padding[2], true); + SetDlgItemInt(hwnd, IDC_X3, td.padding[3], true); + SetDlgItemInt(hwnd, IDC_Y3, td.padding[4], true); + SetDlgItemInt(hwnd, IDC_Z3, td.padding[5], true); + SetDlgItemInt(hwnd, IDC_S, td.status, true); + SetDlgItemInt(hwnd, IDC_F, td.frame, true); +} + +BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + (void) lParam; + switch(uMsg) + { + case WM_INITDIALOG: + SetDlgItemInt(hwndDlg, IDC_APPID, 2307, true); + return TRUE; + + case WM_CLOSE: + EndDialog(hwndDlg, 0); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + /* + * TODO: Add more control ID's, when needed. + */ + case IDQUIT: + npifc_close(); + EndDialog(hwndDlg, 0); + return TRUE; + case IDSTART: + int ok; + int num = GetDlgItemInt(hwndDlg, IDC_APPID, (BOOL*)&ok, false); + if(!ok){ + num = 2307; + } + game_desc_t gd; + if(timer != 0){ + KillTimer(hwndDlg, timer); + timer = 0; + } + if(game_data_get_desc(num, &gd)){ + printf("Application ID: %d - %s\n", num, gd.name); + if(npifc_init(hwndDlg, num)){ + timer = SetTimer(hwndDlg, 0, 50, TimerProcedure); + } + }else{ + printf("Unknown Application ID: %d\n", num); + } + break; + + } + } + + return FALSE; +} + + +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) +{ + (void) hPrevInstance; + (void) lpCmdLine; + (void) nShowCmd; + hInst = hInstance; + + // The user interface is a modal dialog box + return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DialogProc); +} + + diff --git a/facetracknoir/clientfiles/very-important-source-code/tester/npifc.c b/facetracknoir/clientfiles/very-important-source-code/tester/npifc.c new file mode 100644 index 000000000..b036464ec --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/tester/npifc.c @@ -0,0 +1,302 @@ +#define _GNU_SOURCE +#include +#include +#define WIN32_LEAN_AND_MEAN +#include +#include "npifc.h" +#include "rest.h" + + +tir_signature_t ts; +HMODULE npclient; +/* +typedef int (*NP_RegisterWindowHandle_t)(HWND hwnd); +typedef int (*NP_UnregisterWindowHandle_t)(void); +typedef int (*NP_RegisterProgramProfileID_t)(unsigned short id); +typedef int (*NP_QueryVersion_t)(unsigned short *version); +typedef int (*NP_RequestData_t)(unsigned short req); +typedef int (*NP_GetSignature_t)(tir_signature_t *sig); +typedef int (*NP_GetData_t)(tir_data_t *data); +typedef int (*NP_GetParameter_t)(void); +typedef int (*NP_SetParameter_t)(void); +typedef int (*NP_StartCursor_t)(void); +typedef int (*NP_StopCursor_t)(void); +typedef int (*NP_ReCenter_t)(void); +typedef int (*NP_StartDataTransmission_t)(void); +typedef int (*NP_StopDataTransmission_t)(void); +*/ +NP_RegisterWindowHandle_t NP_RegisterWindowHandle = NULL; +NP_UnregisterWindowHandle_t NP_UnregisterWindowHandle = NULL; +NP_RegisterProgramProfileID_t NP_RegisterProgramProfileID = NULL; +NP_QueryVersion_t NP_QueryVersion = NULL; +NP_RequestData_t NP_RequestData = NULL; +NP_GetSignature_t NP_GetSignature = NULL; +NP_GetData_t NP_GetData = NULL; +NP_GetParameter_t NP_GetParameter = NULL; +NP_SetParameter_t NP_SetParameter = NULL; +NP_StartCursor_t NP_StartCursor = NULL; +NP_StopCursor_t NP_StopCursor = NULL; +NP_ReCenter_t NP_ReCenter = NULL; +NP_StartDataTransmission_t NP_StartDataTransmission = NULL; +NP_StopDataTransmission_t NP_StopDataTransmission = NULL; + +bool crypted = false; + + + +unsigned char table[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +char *client_path() +{ + HKEY hkey = 0; + RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\NaturalPoint\\NATURALPOINT\\NPClient Location", 0, + KEY_QUERY_VALUE, &hkey); + if(!hkey){ + printf("Can't open registry key\n"); + return NULL; + } + + BYTE path[1024]; + DWORD buf_len = 1024; + LONG result = RegQueryValueEx(hkey, "Path", NULL, NULL, path, &buf_len); + char *full_path = NULL; + int res = -1; + if(result == ERROR_SUCCESS && buf_len > 0){ +#ifdef FOR_WIN64 + res = asprintf(&full_path, "%s/NPClient64.dll", path); +#else + res = asprintf(&full_path, "%s/NPClient.dll", path); +#endif + } + RegCloseKey(hkey); + if(res > 0){ + return full_path; + }else{ + return NULL; + } +} + +bool initialized = false; + +bool npifc_init(HWND wnd, int id) +{ + //table[] = {0xb3, 0x16, 0x36, 0xeb, 0xb9, 0x05, 0x4f, 0xa4}; + game_desc_t gd; + if(game_data_get_desc(id, &gd)){ + crypted = gd.encrypted; + if(gd.encrypted){ + table[0] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[1] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[2] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[3] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8; + table[4] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[5] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[6] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + table[7] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8; + } + } + printf("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", + table[0], table[1], table[2], table[3], + table[4], table[5], table[6], table[7]); + + char *client = client_path(); + if(client == NULL){ + printf("Couldn't obtain client path!\n"); + return false; + } + npclient = LoadLibrary(client); + if(!npclient){ + printf("Can't load client %s\n", client); + return false; + } + + NP_RegisterWindowHandle = (NP_RegisterWindowHandle_t)GetProcAddress(npclient, "NP_RegisterWindowHandle"); + NP_UnregisterWindowHandle = (NP_UnregisterWindowHandle_t)GetProcAddress(npclient, "NP_UnregisterWindowHandle"); + NP_RegisterProgramProfileID = (NP_RegisterProgramProfileID_t)GetProcAddress(npclient, "NP_RegisterProgramProfileID"); + NP_QueryVersion = (NP_QueryVersion_t)GetProcAddress(npclient, "NP_QueryVersion"); + NP_RequestData = (NP_RequestData_t)GetProcAddress(npclient, "NP_RequestData"); + NP_GetSignature = (NP_GetSignature_t)GetProcAddress(npclient, "NP_GetSignature"); + NP_GetData = (NP_GetData_t)GetProcAddress(npclient, "NP_GetData"); + NP_GetParameter = (NP_GetParameter_t)GetProcAddress(npclient, "NP_GetParameter"); + NP_SetParameter = (NP_SetParameter_t)GetProcAddress(npclient, "NP_SetParameter"); + NP_StartCursor = (NP_StartCursor_t)GetProcAddress(npclient, "NP_StartCursor"); + NP_StopCursor = (NP_StopCursor_t)GetProcAddress(npclient, "NP_StopCursor"); + NP_ReCenter = (NP_ReCenter_t)GetProcAddress(npclient, "NP_ReCenter"); + NP_StartDataTransmission = (NP_StartDataTransmission_t)GetProcAddress(npclient, "NP_StartDataTransmission"); + NP_StopDataTransmission = (NP_StopDataTransmission_t)GetProcAddress(npclient, "NP_StopDataTransmission"); + if((NP_RegisterWindowHandle == NULL) || (NP_UnregisterWindowHandle == NULL) + || (NP_RegisterProgramProfileID == NULL) || (NP_QueryVersion == NULL) || (NP_RequestData == NULL) + || (NP_GetSignature == NULL) || (NP_GetData == NULL) || (NP_GetParameter == NULL) + || (NP_SetParameter == NULL) || (NP_StartCursor == NULL) || (NP_StopCursor == NULL) + || (NP_ReCenter == NULL) || (NP_StartDataTransmission == NULL) || (NP_StopDataTransmission == NULL)){ + printf("Couldn't bind all necessary functions!\n"); + return false; + } + tir_signature_t sig; + int res; + if((res = NP_GetSignature(&sig)) != 0){ + printf("Error retrieving signature! %d\n", res); + return false; + } + printf("Dll Sig:%s\nApp Sig2:%s\n", sig.DllSignature, sig.AppSignature); + NP_RegisterWindowHandle(wnd); + if(NP_RegisterProgramProfileID(id) != 0){ + printf("Couldn't register profile id!\n"); + return false; + } + printf("Program profile registered!\n"); + NP_RequestData(65535); + NP_StopCursor(); + NP_StartDataTransmission(); + initialized = true; + return true; +} + +void npifc_close() +{ + if(initialized){ + NP_StopDataTransmission(); + NP_StartCursor(); + NP_UnregisterWindowHandle(); + } + initialized = false; +} + +void c_encrypt(unsigned char buf[], unsigned int size, + unsigned char code_table[], unsigned int table_size) +{ + unsigned int table_ptr = 0; + unsigned char var = 0x88; + unsigned char tmp; + if((size <= 0) || (table_size <= 0) || + (buf == NULL) || (code_table == NULL)) + return; + do{ + tmp = buf[--size]; + buf[size] = tmp ^ code_table[table_ptr] ^ var; + var += size + tmp; + ++table_ptr; + if(table_ptr >= table_size){ + table_ptr -= table_size; + } + }while(size != 0); +} + + + +void decrypt(unsigned char buf[], unsigned int size, + unsigned char code_table[], unsigned int table_size) +{ + unsigned int table_ptr = 0; + unsigned char var = 0x88; + unsigned char tmp; + if((size <= 0) || (table_size <= 0) || + (buf == NULL) || (code_table == NULL)){ + return; + } + do{ + tmp = buf[--size]; + buf[size] = tmp ^ code_table[table_ptr] ^ var; + var += size + buf[size]; + ++table_ptr; + if(table_ptr >= table_size){ + table_ptr -= table_size; + } + }while(size != 0); +} + +unsigned int cksum(unsigned char buf[], unsigned int size) +{ + if((size == 0) || (buf == NULL)){ + return 0; + } + int rounds = size >> 2; + int rem = size % 4; + + int c = size; + int a0 = 0; + int a2 = 0; + + while(rounds != 0){ + a0 = *(short int*)buf; + a2 = *(short int*)(buf+2); + buf += 4; + c += a0; + a2 ^= (c << 5); + a2 <<= 11; + c ^= a2; + c += (c >> 11); + --rounds; + } + switch(rem){ + case 3: + a0 = *(short int*)buf; + a2 = *(signed char*)(buf+2); + c += a0; + a2 = (a2 << 2) ^ c; + c ^= (a2 << 16); + a2 = (c >> 11); + break; + case 2: + a2 = *(short int*)buf; + c += a2; + c ^= (c << 11); + a2 = (c >> 17); + break; + case 1: + a2 = *(signed char*)(buf); + c += a2; + c ^= (c << 10); + a2 = (c >> 1); + break; + default: + break; + } + if(rem != 0){ + c+=a2; + } + + c ^= (c << 3); + c += (c >> 5); + c ^= (c << 4); + c += (c >> 17); + c ^= (c << 25); + c += (c >> 6); + + return (unsigned int)c; +} + +int decode_frame(tir_data_t *td) +{ + //printf("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", + // table[0], table[1], table[2], table[3], + // table[4], table[5], table[6], table[7]); + unsigned int csum; + decrypt((unsigned char*)td, sizeof(*td), table, sizeof(table)); + csum = td->cksum; + td->cksum = 0; + if(csum != cksum((unsigned char*)td, sizeof(*td))){ + printf("Problem with frame!\n"); + //int a0; + //printf("Dec: "); + //for(a0 = 0; a0 < (int)sizeof(tir_data_t); ++a0) + //{ + // printf("%02X", ((unsigned char *)td)[a0]); + //} + //printf("\n"); + //printf("Cksum: %04X vs computed: %04X\n", csum, cksum((unsigned char*)td, sizeof(*td))); + return -1; + } + //printf("Frame OK!\n"); + return 0; +} + +int npifc_getdata(tir_data_t *data) +{ + int res = NP_GetData(data); + if(crypted){ + decode_frame(data); + } + return res; +} + diff --git a/facetracknoir/clientfiles/very-important-source-code/tester/npifc.h b/facetracknoir/clientfiles/very-important-source-code/tester/npifc.h new file mode 100644 index 000000000..d580e16d6 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/tester/npifc.h @@ -0,0 +1,66 @@ +#ifndef NPIFC__H +#define NPIFC__H + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + bool npifc_init(HWND wnd, int id); + void npifc_close(); + +#pragma pack(1) +typedef struct tir_data{ + short status; + short frame; + unsigned int cksum; + float roll, pitch, yaw; + float tx, ty, tz; + float padding[9]; +} tir_data_t; + +typedef struct tir_signature{ + char DllSignature[200]; + char AppSignature[200]; +} tir_signature_t; +#pragma pack(0) + +int npifc_getdata(tir_data_t *data); + +typedef int __stdcall (*NP_RegisterWindowHandle_t)(HWND hwnd); +typedef int __stdcall (*NP_UnregisterWindowHandle_t)(void); +typedef int __stdcall (*NP_RegisterProgramProfileID_t)(unsigned short id); +typedef int __stdcall (*NP_QueryVersion_t)(unsigned short *version); +typedef int __stdcall (*NP_RequestData_t)(unsigned short req); +typedef int __stdcall (*NP_GetSignature_t)(tir_signature_t *sig); +typedef int __stdcall (*NP_GetData_t)(tir_data_t *data); +typedef int __stdcall (*NP_GetParameter_t)(void); +typedef int __stdcall (*NP_SetParameter_t)(void); +typedef int __stdcall (*NP_StartCursor_t)(void); +typedef int __stdcall (*NP_StopCursor_t)(void); +typedef int __stdcall (*NP_ReCenter_t)(void); +typedef int __stdcall (*NP_StartDataTransmission_t)(void); +typedef int __stdcall (*NP_StopDataTransmission_t)(void); + +extern NP_RegisterWindowHandle_t NP_RegisterWindowHandle; +extern NP_UnregisterWindowHandle_t NP_UnregisterWindowHandle; +extern NP_RegisterProgramProfileID_t NP_RegisterProgramProfileID; +extern NP_QueryVersion_t NP_QueryVersion; +extern NP_RequestData_t NP_RequestData; +extern NP_GetSignature_t NP_GetSignature; +extern NP_GetData_t NP_GetData; +extern NP_GetParameter_t NP_GetParameter; +extern NP_SetParameter_t NP_SetParameter; +extern NP_StartCursor_t NP_StartCursor; +extern NP_StopCursor_t NP_StopCursor; +extern NP_ReCenter_t NP_ReCenter; +extern NP_StartDataTransmission_t NP_StartDataTransmission; +extern NP_StopDataTransmission_t NP_StopDataTransmission; + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/facetracknoir/clientfiles/very-important-source-code/tester/npview.rc.in b/facetracknoir/clientfiles/very-important-source-code/tester/npview.rc.in new file mode 100644 index 000000000..231002f18 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/tester/npview.rc.in @@ -0,0 +1,49 @@ +// Generated by ResEdit 1.5.9 +// Copyright (C) 2006-2011 +// http://www.resedit.net + +#include +#include +#include +#include "resource.h" + +#ifdef HAVE_CONFIG_H + #include "../../../config.h" +#endif + + + +// +// Dialog resources +// +//LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +IDD_DIALOG1 DIALOGEX 0, 0, 379, 124 +STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU +CAPTION "NPTest v@PACKAGE_VERSION@" +FONT 8, "Ms Shell Dlg", 400, 0, 1 +{ + DEFPUSHBUTTON "Quit", IDQUIT, 262, 102, 50, 14 + DEFPUSHBUTTON "Start", IDSTART, 7, 102, 50, 14 + EDITTEXT IDC_PITCH, 32, 32, 51, 14, ES_AUTOHSCROLL + LTEXT "Pitch", IDC_STATIC, 11, 34, 20, 8, SS_LEFT + LTEXT "Yaw", IDC_STATIC, 11, 59, 20, 8, SS_LEFT + EDITTEXT IDC_YAW, 32, 57, 51, 14, ES_AUTOHSCROLL + LTEXT "Roll", IDC_STATIC, 11, 84, 20, 8, SS_LEFT + EDITTEXT IDC_ROLL, 32, 82, 51, 14, ES_AUTOHSCROLL + LTEXT "X", IDC_STATIC, 101, 35, 6, 8, SS_LEFT + EDITTEXT IDC_X1, 112, 32, 51, 14, ES_AUTOHSCROLL + LTEXT "Y", IDC_STATIC, 101, 60, 6, 8, SS_LEFT + EDITTEXT IDC_Y1, 112, 57, 51, 14, ES_AUTOHSCROLL + LTEXT "Z", IDC_STATIC, 101, 85, 6, 8, SS_LEFT + EDITTEXT IDC_Z1, 112, 82, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_X2, 172, 32, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_Y2, 172, 57, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_Z2, 172, 82, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_X3, 232, 32, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_Y3, 232, 57, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_Z3, 232, 82, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_S, 292, 32, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_F, 292, 57, 51, 14, ES_AUTOHSCROLL + EDITTEXT IDC_APPID, 32, 12, 51, 12, ES_AUTOHSCROLL + LTEXT "ID", IDC_STATIC, 17, 14, 8, 8, SS_LEFT +} diff --git a/facetracknoir/clientfiles/very-important-source-code/tester/resource.h b/facetracknoir/clientfiles/very-important-source-code/tester/resource.h new file mode 100644 index 000000000..328d9cb78 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/tester/resource.h @@ -0,0 +1,23 @@ +#ifndef IDC_STATIC +#define IDC_STATIC (-1) +#endif + +#define IDD_DIALOG1 100 +#define IDQUIT 1002 +#define IDSTART 1003 +#define IDC_APPID 1016 +#define IDC_PITCH 1017 +#define IDC_YAW 1018 +#define IDC_ROLL 1019 +#define IDC_X1 1020 +#define IDC_X2 1021 +#define IDC_X3 1022 +#define IDC_Y1 1023 +#define IDC_Y2 1024 +#define IDC_Y3 1025 +#define IDC_Z1 1026 +#define IDC_Z2 1027 +#define IDC_Z3 1028 +#define IDC_S 1029 +#define IDC_F 1030 + diff --git a/facetracknoir/clientfiles/very-important-source-code/tester/rest.c b/facetracknoir/clientfiles/very-important-source-code/tester/rest.c new file mode 120000 index 000000000..663c21a99 --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/tester/rest.c @@ -0,0 +1 @@ +../client/rest.c \ No newline at end of file diff --git a/facetracknoir/clientfiles/very-important-source-code/tester/rest.h b/facetracknoir/clientfiles/very-important-source-code/tester/rest.h new file mode 120000 index 000000000..6dca182ae --- /dev/null +++ b/facetracknoir/clientfiles/very-important-source-code/tester/rest.h @@ -0,0 +1 @@ +../client/rest.h \ No newline at end of file diff --git a/facetracknoir/plugin-qt-api.hpp b/facetracknoir/plugin-qt-api.hpp index 0e2e3c32e..1697d8e7d 100644 --- a/facetracknoir/plugin-qt-api.hpp +++ b/facetracknoir/plugin-qt-api.hpp @@ -56,7 +56,6 @@ struct ITracker virtual ~ITracker() = 0; virtual void StartTracker( QFrame* frame ) = 0; virtual void GetHeadPoseData(double *data) = 0; - virtual int preferredHz() { return 200; } }; inline ITracker::~ITracker() {} diff --git a/facetracknoir/pose.hpp b/facetracknoir/pose.hpp new file mode 100644 index 000000000..ec9faaa3e --- /dev/null +++ b/facetracknoir/pose.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include +#include +#include "./quat.hpp" +#include "./plugin-api.hpp" + +class Pose { +private: + static constexpr double pi = 3.141592653; + static constexpr double d2r = pi/180.0; + static constexpr double r2d = 180./pi; + + double axes[6]; +public: + Pose() : axes {0,0,0, 0,0,0 } {} + + inline operator double*() { return axes; } + inline operator const double*() const { return axes; } + + inline double& operator()(int i) { return axes[i]; } + inline double operator()(int i) const { return axes[i]; } + + Quat quat() const + { + return Quat(axes[Yaw]*d2r, axes[Pitch]*d2r, axes[Roll]*d2r); + } + + static Pose fromQuat(const Quat& q) + { + Pose ret; + q.to_euler_degrees(ret(Yaw), ret(Pitch), ret(Roll)); + return ret; + } + + Pose operator-(const Pose& B) const + { + const Quat q = (quat() * B.quat().inv()); + Pose ret = fromQuat(q); + for (int i = TX; i < Yaw; i++) + ret(i) = B(i); + return ret; + } + + Pose operator+(const Pose& B) const + { + const Quat q = (quat() * B.quat().inv()); + Pose ret = fromQuat(q); + for (int i = TX; i < Yaw; i++) + ret(i) = B(i); + return ret; + } + + Pose operator|(const Pose& replacement) const + { + Pose ret = *this; + for (int i = 0; i < 6; i++) + { + static constexpr double eps = 1e-5; + // NB replace zero-valued elements with argument's + if (std::abs(ret(i)) < eps) + ret(i) = replacement(i); + } + return ret; + } +}; diff --git a/facetracknoir/quat.hpp b/facetracknoir/quat.hpp index 1e2689630..6d777b283 100644 --- a/facetracknoir/quat.hpp +++ b/facetracknoir/quat.hpp @@ -14,7 +14,7 @@ private: static constexpr double r2d = 180./pi; double a,b,c,d; // quaternion coefficients public: - Quat() : a(1.0),b(0.0),c(0.0),d(0.0) {} + Quat() : a(1.),b(0.),c(0.),d(0.) {} Quat(double yaw, double pitch, double roll) { from_euler_rads(yaw, pitch, roll); } Quat(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} @@ -27,12 +27,12 @@ public: void from_euler_rads(double yaw, double pitch, double roll) { - double sin_phi = sin(roll/2.0); - double cos_phi = cos(roll/2.0); - double sin_the = sin(pitch/2.0); - double cos_the = cos(pitch/2.0); - double sin_psi = sin(yaw/2.0); - double cos_psi = cos(yaw/2.0); + const double sin_phi = sin(roll/2.); + const double cos_phi = cos(roll/2.); + const double sin_the = sin(pitch/2.); + const double cos_the = cos(pitch/2.); + const double sin_psi = sin(yaw/2.); + const double cos_psi = cos(yaw/2.); a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; @@ -42,9 +42,9 @@ public: void to_euler_rads(double& yaw, double& pitch, double& roll) const { - roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); - pitch = asin(2.0*(a*c - b*d)); - yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); + roll = atan2(2.*(a*b + c*d), 1. - 2.*(b*b + c*c)); + pitch = asin(2.*(a*c - b*d)); + yaw = atan2(2.*(a*d + b*c), 1. - 2.*(c*c + d*d)); } void to_euler_degrees(double& yaw, double& pitch, double& roll) const @@ -59,8 +59,8 @@ public: { const Quat& A = *this; return Quat(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication - A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, - A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, - A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); + A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, + A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, + A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); } }; diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 0c2d289f4..e1f86294e 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -12,8 +12,7 @@ * originally written by Wim Vriend. */ -#include "tracker.h" -#include "facetracknoir.h" +#include "./tracker.h" #include #include #include @@ -49,9 +48,10 @@ void Tracker::get_curve(double pos, double& out, Mapping& axis) { static void t_compensate(double* input, double* output, bool rz) { - const auto H = input[Yaw] * M_PI / -180; - const auto P = input[Pitch] * M_PI / -180; - const auto B = input[Roll] * M_PI / 180; + static constexpr double pi = 3.141592653; + const auto H = input[Yaw] * pi / -180; + const auto P = input[Pitch] * pi / -180; + const auto B = input[Roll] * pi / 180; const auto cosH = cos(H); const auto sinH = sin(H); @@ -83,15 +83,10 @@ static void t_compensate(double* input, double* output, bool rz) } void Tracker::run() { - T6DOF pose_offset, unstopped_pose; + Pose pose_offset, unstopped_pose; double newpose[6] = {0}; - int sleep_ms = 15; - - if (Libraries->pTracker) - sleep_ms = std::min(sleep_ms, 1000 / Libraries->pTracker->preferredHz()); - - qDebug() << "tracker Hz:" << 1000 / sleep_ms; + const int sleep_ms = 3; #if defined(_WIN32) (void) timeBeginPeriod(1); @@ -104,9 +99,7 @@ void Tracker::run() { if (should_quit) break; - if (Libraries->pTracker) { - Libraries->pTracker->GetHeadPoseData(newpose); - } + Libraries->pTracker->GetHeadPoseData(newpose); { QMutexLocker foo(&mtx); @@ -130,15 +123,12 @@ void Tracker::run() { if (enabledp) unstopped_pose = raw_6dof; - { + if (Libraries->pFilter) + Libraries->pFilter->FilterHeadPoseData(unstopped_pose, output_pose); + else + output_pose = unstopped_pose; - if (Libraries->pFilter) - Libraries->pFilter->FilterHeadPoseData(unstopped_pose, output_pose); - else - output_pose = unstopped_pose; - - output_pose = output_pose - pose_offset; - } + output_pose = output_pose - pose_offset; for (int i = 0; i < 6; i++) get_curve(output_pose(i), output_pose(i), m(i)); @@ -147,9 +137,7 @@ void Tracker::run() { if (s.tcomp_p) t_compensate(output_pose, output_pose, s.tcomp_tz); - if (Libraries->pProtocol) { - Libraries->pProtocol->sendHeadposeToGame(output_pose); - } + Libraries->pProtocol->sendHeadposeToGame(output_pose); } const long q = std::max(0L, sleep_ms * 1000L - std::max(0L, t.elapsed())); diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 3d9a3858c..8a4ecb1f5 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -10,14 +10,15 @@ #include #include #include -#include "plugin-support.h" -#include "mappings.hpp" +#include "./plugin-support.h" +#include "./mappings.hpp" +#include "./pose.hpp" #include #include #include -#include "tracker_types.h" +#include "./quat.hpp" #include "facetracknoir/main-settings.hpp" #include "facetracknoir/options.h" #include "facetracknoir/timer.hpp" @@ -30,7 +31,7 @@ private: // XXX can be const-cast when functionconfig const-correct -sh 20141004 Mappings& m; Timer t; - T6DOF output_pose, raw_6dof; + Pose output_pose, raw_6dof; std::atomic centerp; std::atomic enabledp; std::atomic should_quit; diff --git a/facetracknoir/tracker_types.h b/facetracknoir/tracker_types.h deleted file mode 100644 index 02aacdcf6..000000000 --- a/facetracknoir/tracker_types.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include -#include -#include "./quat.hpp" -#include "./plugin-api.hpp" - -struct T6DOF { -private: - static constexpr double pi = 3.141592653; - static constexpr double d2r = pi/180.0; - static constexpr double r2d = 180./pi; - - double axes[6]; -public: - T6DOF() : axes {0,0,0, 0,0,0 } {} - - inline operator double*() { return axes; } - inline operator const double*() const { return axes; } - - inline double& operator()(int i) { return axes[i]; } - inline double operator()(int i) const { return axes[i]; } - - Quat quat() const - { - return Quat(axes[Yaw]*d2r, axes[Pitch]*d2r, axes[Roll]*d2r); - } - - static T6DOF fromQuat(const Quat& q) - { - T6DOF ret; - q.to_euler_rads(ret(Yaw), ret(Pitch), ret(Roll)); - return ret; - } - - T6DOF operator-(const T6DOF& B) const - { - const Quat q = (quat() * B.quat().inv()); - T6DOF ret = fromQuat(q); - for (int i = TX; i < Yaw; i++) - ret(i) = B(i); - return ret; - } - - T6DOF operator+(const T6DOF& B) const - { - const Quat q = (quat() * B.quat().inv()); - T6DOF ret = fromQuat(q); - for (int i = TX; i < Yaw; i++) - ret(i) = B(i); - return ret; - } - - T6DOF operator|(const T6DOF& replacement) const - { - T6DOF ret = *this; - for (int i = 0; i < 6; i++) - { - static constexpr double eps = 1e-5; - // NB replace zero-valued elements with argument's - if (std::abs(ret(i)) < eps) - ret(i) = replacement(i); - } - return ret; - } -}; diff --git a/freetrackclient/build-msvc.sh b/freetrackclient/build-msvc.sh new file mode 100644 index 000000000..4fd303a0c --- /dev/null +++ b/freetrackclient/build-msvc.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +export PATH="/bin:/usr/bin:$PATH" + +case "$(uname -s 2>/dev/null)" in +*CYG*|*MING*|'') wrap= ;; +*) wrap=wine ;; +esac + +c_src=".\\freetrackclient.c" +c_bin="..\\facetracknoir\\clientfiles\\freetrackclient.dll" +opt_link="-nologo -LTCG -SAFESEH:NO -OPT:REF,ICF" +opt_cl=" +-nologo -arch:SSE2 -fp:fast -EHc -EH- -GL -GR- -GS- -Gw -LD -MT -O1 +-Ob2 -Og -Oi -Ot -Oy -QIfist -volatile:iso -Ze -Fe\"${c_bin}\" +" + +MSVC="VS140COMNTOOLS" + +test -z "$MSVC" && { + echo "uh-oh, no MSVC" >&2 + exit 1 +} + +sep="\&" + +cd "$(dirname "$0")" + +$wrap cmd.exe /C $(echo " + del /F /Q $c_bin $sep + call %${MSVC}%/vsvars32.bat 2>nul >nul $sep + cl $opt_cl $c_src -link $opt_link + " | tr '\n' ' ') diff --git a/freetrackclient/freetrackclient.c b/freetrackclient/freetrackclient.c index 200242b9b..4bc39d67e 100644 --- a/freetrackclient/freetrackclient.c +++ b/freetrackclient/freetrackclient.c @@ -18,6 +18,10 @@ * * created by the FreeTrack developers. * */ +#ifndef _MSC_VER +# warning "expect misnamed symbols" +#endif + #pragma GCC diagnostic ignored "-Wvariadic-macros" #pragma GCC diagnostic ignored "-Wunused-parameter" diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index a1e15721f..1787ef2bc 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -5,16 +5,15 @@ * copyright notice and this permission notice appear in all copies. */ +#include +#include +#include +#include +#include "./include/markerdetector.h" #include "ftnoir_tracker_aruco.h" -#include "ui_aruco-trackercontrols.h" #include "facetracknoir/plugin-api.hpp" -#include -#include "include/markerdetector.h" #include #include -#include -#include -#include #if defined(_WIN32) # undef NOMINMAX diff --git a/ftnoir_tracker_aruco/include/aruco.h b/ftnoir_tracker_aruco/include/aruco.h index 8ea583a8b..569b95fb8 100644 --- a/ftnoir_tracker_aruco/include/aruco.h +++ b/ftnoir_tracker_aruco/include/aruco.h @@ -26,12 +26,12 @@ The views and conclusions contained in the software and documentation are those authors and should not be interpreted as representing official policies, either expressed or implied, of Rafael Muñoz Salinas. - - + + \mainpage ArUco: Augmented Reality library from the University of Cordoba -ArUco is a minimal C++ library for detection of Augmented Reality markers based on OpenCv exclusively. +ArUco is a minimal C++ library for detection of Augmented Reality markers based on OpenCv exclusively. It is an educational project to show student how to detect augmented reality markers and it is provided under BSD license. @@ -54,11 +54,11 @@ Aruco allows the possibility to employ board. Boards are markers composed by an The library comes with five applications that will help you to learn how to use the library: - aruco_create_marker: which creates marker and saves it in a jpg file you can print. - - aruco_simple : simple test aplication that detects the markers in a image + - aruco_simple : simple test aplication that detects the markers in a image - aruco_test: this is the main application for detection. It reads images either from the camera of from a video and detect markers. Additionally, if you provide the intrinsics of the camera(obtained by OpenCv calibration) and the size of the marker in meters, the library calculates the marker intrinsics so that you can easily create your AR applications. - aruco_test_gl: shows how to use the library AR applications using OpenGL for rendering - aruco_create_board: application that helps you to create a board - - aruco_simple_board: simple test aplication that detects a board of markers in a image + - aruco_simple_board: simple test aplication that detects a board of markers in a image - aruco_test_board: application that detects boards - aruco_test_board_gl: application that detects boards and uses OpenGL to draw @@ -66,7 +66,7 @@ The library comes with five applications that will help you to learn how to use The ArUco library contents are divided in two main directories. The src directory, which contains the library itself. And the utils directory which contains the applications. -The library main classes are: +The library main classes are: - aruco::CameraParameters: represent the information of the camera that captures the images. Here you must set the calibration info. - aruco::Marker: which represent a marker detected in the image - aruco::MarkerDetector: that is in charge of deteting the markers in a image Detection is done by simple calling the member funcion ArMarkerDetector::detect(). Additionally, the classes contain members to create the required matrices for rendering using OpenGL. See aruco_test_gl for details @@ -101,33 +101,34 @@ The library has been compiled using MinGW and codeblocks. Below I describe the b -# Download the source code and compile it using cmake and codeblocks. Note: install the library in C:\ if you want it to be easily detected by cmake afterwards - step 4) aruco -# Download and decompress. - -# Open cmake gui application and set the path to the main library directory and also set a path where the project is going to be built. + -# Open cmake gui application and set the path to the main library directory and also set a path where the project is going to be built. -# Generate the codeblock project. -# Open the project with codeblock and compile then, install. The programs will be probably generated into the bin directory OpenGL: by default, the mingw version installed has not the glut library. So, the opengl programs are not compiled. If you want to compile with OpenGL support, you must install glut, or prefereably freeglut. -Thus, - - Download the library (http://www.martinpayne.me.uk/software/development/GLUT/freeglut-MinGW.zip) for mingw. - - Decompress in a directory X. +Thus, + - Download the library (http://www.martinpayne.me.uk/software/development/GLUT/freeglut-MinGW.zip) for mingw. + - Decompress in a directory X. - Then, rerun cmake setting the variable GLU_PATH to that directory (>cmake .. -DGLUT_PATH="C:\X") - Finally, recompile and test. Indeed, you should move the freeglut.dll to the directory with the binaries or to any other place in the PATH. CONCLUSION: Move to Linux, things are simpler :P - -\section Testing + +\section Testing For testing the applications, the library provides videos and the corresponding camera parameters of these videos. Into the directories you will find information on how to run the examples. - + \section Final Notes - REQUIREMENTS: OpenCv >= 2.1.0. and OpenGL for (aruco_test_gl and aruco_test_board_gl) - CONTACT: Rafael Munoz-Salinas: rmsalinas@uco.es - This libary is free software and come with no guaratee! - + */ #include "markerdetector.h" +#include "boarddetector.h" #include "cvdrawingutils.h" diff --git a/ftnoir_tracker_aruco/include/arucofidmarkers.h b/ftnoir_tracker_aruco/include/arucofidmarkers.h index 15eb8e4c7..7dad46728 100644 --- a/ftnoir_tracker_aruco/include/arucofidmarkers.h +++ b/ftnoir_tracker_aruco/include/arucofidmarkers.h @@ -31,6 +31,7 @@ or implied, of Rafael Muñoz Salinas. #include #include "exports.h" #include "marker.h" +#include "board.h" namespace aruco { class ARUCO_EXPORTS FiducidalMarkers { @@ -79,7 +80,7 @@ public: * @param gridSize grid layout (numer of sqaures in x and Y) * @param MarkerSize size of markers sides in pixels * @param MarkerDistance distance between the markers - * @param TInfo output + * @param TInfo output * @param excludedIds set of ids excluded from the board */ static cv::Mat createBoardImage( cv::Size gridSize,int MarkerSize,int MarkerDistance, BoardConfiguration& TInfo ,vector *excludedIds=NULL ) throw (cv::Exception); @@ -88,24 +89,24 @@ public: /**Creates a printable image of a board in chessboard_like manner * @param gridSize grid layout (numer of sqaures in x and Y) * @param MarkerSize size of markers sides in pixels - * @param TInfo output + * @param TInfo output * @param setDataCentered indicates if the center is set at the center of the board. Otherwise it is the left-upper corner - * + * */ static cv::Mat createBoardImage_ChessBoard( cv::Size gridSize,int MarkerSize, BoardConfiguration& TInfo ,bool setDataCentered=true ,vector *excludedIds=NULL) throw (cv::Exception); - /**Creates a printable image of a board in a frame fashion + /**Creates a printable image of a board in a frame fashion * @param gridSize grid layout (numer of sqaures in x and Y) * @param MarkerSize size of markers sides in pixels * @param MarkerDistance distance between the markers - * @param TInfo output + * @param TInfo output * @param setDataCentered indicates if the center is set at the center of the board. Otherwise it is the left-upper corner - * + * */ static cv::Mat createBoardImage_Frame( cv::Size gridSize,int MarkerSize,int MarkerDistance, BoardConfiguration& TInfo ,bool setDataCentered=true,vector *excludedIds=NULL ) throw (cv::Exception); private: - + static vector getListOfValidMarkersIds_random(int nMarkers,vector *excluded) throw (cv::Exception); static cv::Mat rotate(const cv::Mat & in); static int hammDistMarker(cv::Mat bits); diff --git a/ftnoir_tracker_aruco/include/board.h b/ftnoir_tracker_aruco/include/board.h new file mode 100644 index 000000000..c1d792925 --- /dev/null +++ b/ftnoir_tracker_aruco/include/board.h @@ -0,0 +1,168 @@ +/***************************** +Copyright 2011 Rafael Muñoz Salinas. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of + conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, this list + of conditions and the following disclaimer in the documentation and/or other materials + provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those of the +authors and should not be interpreted as representing official policies, either expressed +or implied, of Rafael Muñoz Salinas. +********************************/ +#ifndef _Aruco_board_h +#define _Aruco_board_h +#include +#include +#include +#include "exports.h" +#include "marker.h" +using namespace std; +namespace aruco { +/** + * 3d representation of a marker + */ +struct ARUCO_EXPORTS MarkerInfo:public vector { + MarkerInfo() {} + MarkerInfo(int _id) {id=_id; } + MarkerInfo(const MarkerInfo&MI): vector(MI){id=MI.id; } + MarkerInfo & operator=(const MarkerInfo&MI){ + vector ::operator=(MI); + id=MI.id; + return *this; + } + int id;//maker id +}; + +/**\brief This class defines a board with several markers. + * A Board contains several markers so that they are more robustly detected. + * + * In general, a board is a set of markers. So BoardConfiguration is only a list + * of the id of the markers along with the position of their corners. + * + * The position of the corners can be specified either in pixels (in a non-specific size) or in meters. + * The first is the typical case in which you generate the image of board and the print it. Since you do not know in advance the real + * size of the markers, their corners are specified in pixels, and then, the translation to meters can be made once you know the real size. + * + * On the other hand, you may want to have the information of your boards in meters. The BoardConfiguration allows you to do so. + * + * The point is in the mInfoType variable. It can be either PIX or METERS according to your needs. + * +*/ + + +class ARUCO_EXPORTS BoardConfiguration: public vector +{ + friend class Board; +public: + enum MarkerInfoType {NONE=-1,PIX=0,METERS=1};//indicates if the data in MakersInfo is expressed in meters or in pixels so as to do conversion internally + //variable indicates if the data in MakersInfo is expressed in meters or in pixels so as to do conversion internally + int mInfoType; + /** + */ + BoardConfiguration(); + + /** + */ + BoardConfiguration(const BoardConfiguration &T); + + /** + */ + BoardConfiguration & operator=(const BoardConfiguration &T); + /**Saves the board info to a file + */ + void saveToFile(string sfile)throw (cv::Exception); + /**Reads board info from a file + */ + void readFromFile(string sfile)throw (cv::Exception); + /**Indicates if the corners are expressed in meters + */ + bool isExpressedInMeters()const { + return mInfoType==METERS; + } + /**Indicates if the corners are expressed in meters + */ + bool isExpressedInPixels()const { + return mInfoType==PIX; + } + /**Returns the index of the marker with id indicated, if is in the list + */ + int getIndexOfMarkerId(int id)const; + /**Returns the Info of the marker with id specified. If not in the set, throws exception + */ + const MarkerInfo& getMarkerInfo(int id)const throw (cv::Exception); + /**Set in the list passed the set of the ids + */ + void getIdList(vector &ids,bool append=true)const; +private: + /**Saves the board info to a file + */ + void saveToFile(cv::FileStorage &fs)throw (cv::Exception); + /**Reads board info from a file + */ + void readFromFile(cv::FileStorage &fs)throw (cv::Exception); +}; + +/** +*/ +class ARUCO_EXPORTS Board:public vector +{ + +public: + BoardConfiguration conf; + //matrices of rotation and translation respect to the camera + cv::Mat Rvec,Tvec; + /** + */ + Board() + { + Rvec.create(3,1,CV_32FC1); + Tvec.create(3,1,CV_32FC1); + for (int i=0;i<3;i++) + Tvec.at(i,0)=Rvec.at(i,0)=-999999; + } + + /**Given the extrinsic camera parameters returns the GL_MODELVIEW matrix for opengl. + * Setting this matrix, the reference corrdinate system will be set in this board + */ + void glGetModelViewMatrix(double modelview_matrix[16])throw(cv::Exception); + + /** + * Returns position vector and orientation quaternion for an Ogre scene node or entity. + * Use: + * ... + * Ogre::Vector3 ogrePos (position[0], position[1], position[2]); + * Ogre::Quaternion ogreOrient (orientation[0], orientation[1], orientation[2], orientation[3]); + * mySceneNode->setPosition( ogrePos ); + * mySceneNode->setOrientation( ogreOrient ); + * ... + */ + void OgreGetPoseParameters( double position[3], double orientation[4] )throw(cv::Exception); + + + /**Save this from a file + */ + void saveToFile(string filePath)throw(cv::Exception); + /**Read this from a file + */ + void readFromFile(string filePath)throw(cv::Exception); + +}; +} + +#endif diff --git a/ftnoir_tracker_aruco/include/boarddetector.h b/ftnoir_tracker_aruco/include/boarddetector.h new file mode 100644 index 000000000..a0ee2361a --- /dev/null +++ b/ftnoir_tracker_aruco/include/boarddetector.h @@ -0,0 +1,139 @@ +/***************************** +Copyright 2011 Rafael Muñoz Salinas. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of + conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, this list + of conditions and the following disclaimer in the documentation and/or other materials + provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those of the +authors and should not be interpreted as representing official policies, either expressed +or implied, of Rafael Muñoz Salinas. +********************************/ +#ifndef _Aruco_BoardDetector_H +#define _Aruco_BoardDetector_H +#include +#include "exports.h" +#include "board.h" +#include "cameraparameters.h" +#include "markerdetector.h" +using namespace std; + +namespace aruco +{ + +/**\brief This class detects AR boards + * Version 1.2 + * There are two modes for board detection. + * First, the old way. (You first detect markers with MarkerDetector and then call to detect in this class. + * + * Second: New mode, marker detection is included in the class + * \code + + CameraParameters CP; + CP.readFromFile(path_cp) + BoardConfiguration BC; + BC.readFromFile(path_bc); + BoardDetector BD; + BD.setParams(BC,CP); //or only BD.setParams(BC) + //capture image + cv::Mat im; + capture_image(im); + + float prob=BD.detect(im); + if (prob>0.3) + CvDrawingUtils::draw3DAxis(im,BD.getDetectedBoard(),CP); + + \endcode + * +*/ +class ARUCO_EXPORTS BoardDetector +{ +public: + /** See discussion in @see enableRotateXAxis. + * Do not change unless you know what you are doing + */ + BoardDetector(bool setYPerperdicular=true); + + + /** + * Use if you plan to let this class to perform marker detection too + */ + void setParams(const BoardConfiguration &bc,const CameraParameters &cp, float markerSizeMeters=-1); + void setParams(const BoardConfiguration &bc); + /** + * Detect markers, and then, look for the board indicated in setParams() + * @return value indicating the likelihood of having found the marker + */ + float detect(const cv::Mat &im)throw (cv::Exception); + /**Returns a reference to the board detected + */ + Board & getDetectedBoard(){return _boardDetected;} + /**Returns a reference to the internal marker detector + */ + MarkerDetector &getMarkerDetector(){return _mdetector;} + /**Returns the vector of markers detected + */ + vector &getDetectedMarkers(){return _vmarkers;} + + + //ALTERNATIVE DETECTION METHOD, BASED ON MARKERS PREVIOUSLY DETECTED + + /** Given the markers detected, determines if there is the board passed + * @param detectedMarkers result provided by aruco::ArMarkerDetector + * @param BConf the board you want to see if is present + * @param Bdetected output information of the detected board + * @param camMatrix camera matrix with intrinsics + * @param distCoeff camera distorsion coeff + * @param camMatrix intrinsic camera information. + * @param distCoeff camera distorsion coefficient. If set Mat() if is assumed no camera distorion + * @param markerSizeMeters size of the marker sides expressed in meters + * @return value indicating the likelihood of having found the marker + */ + float detect(const vector &detectedMarkers,const BoardConfiguration &BConf, Board &Bdetected, cv::Mat camMatrix=cv::Mat(),cv::Mat distCoeff=cv::Mat(), float markerSizeMeters=-1 )throw (cv::Exception); + float detect(const vector &detectedMarkers,const BoardConfiguration &BConf, Board &Bdetected,const CameraParameters &cp, float markerSizeMeters=-1 )throw (cv::Exception); + + + /** + * By default, the Y axis is set to point up. However this is not the default + * operation mode of opencv, which produces the Z axis pointing up instead. + * So, to achieve this change, we have to rotate the X axis. + */ + void setYPerperdicular(bool enable){_setYPerperdicular=enable;} + + + + +private: + void rotateXAxis(cv::Mat &rotation); + bool _setYPerperdicular; + + //-- Functionality to detect markers inside + bool _areParamsSet; + BoardConfiguration _bconf; + Board _boardDetected; + float _markerSize; + CameraParameters _camParams; + MarkerDetector _mdetector;//internal markerdetector + vector _vmarkers;//markers detected in the call to : float detect(const cv::Mat &im); + +}; + +}; +#endif + diff --git a/ftnoir_tracker_aruco/include/cvdrawingutils.h b/ftnoir_tracker_aruco/include/cvdrawingutils.h index 24bfe6301..ff67242f3 100644 --- a/ftnoir_tracker_aruco/include/cvdrawingutils.h +++ b/ftnoir_tracker_aruco/include/cvdrawingutils.h @@ -33,13 +33,20 @@ namespace aruco { /**\brief A set of functions to draw in opencv images */ - class ARUCO_EXPORTS CvDrawingUtils - { - public: - static void draw3dAxis(cv::Mat &Image,Marker &m,const CameraParameters &CP); - static void draw3dCube(cv::Mat &Image,Marker &m,const CameraParameters &CP); - }; -} + class ARUCO_EXPORTS CvDrawingUtils + { + public: + + static void draw3dAxis(cv::Mat &Image,Marker &m,const CameraParameters &CP); + + static void draw3dCube(cv::Mat &Image,Marker &m,const CameraParameters &CP); + + static void draw3dAxis(cv::Mat &Image,Board &m,const CameraParameters &CP); + + static void draw3dCube(cv::Mat &Image,Board &m,const CameraParameters &CP); + + }; +}; #endif diff --git a/ftnoir_tracker_aruco/include/exports.h b/ftnoir_tracker_aruco/include/exports.h index 044a13678..aaeb94e49 100644 --- a/ftnoir_tracker_aruco/include/exports.h +++ b/ftnoir_tracker_aruco/include/exports.h @@ -37,9 +37,9 @@ or implied, of Rafael Muñoz Salinas. #if (defined WIN32 || defined _WIN32 || defined WINCE) && defined DSO_EXPORTS - #define ARUCO_EXPORTS __declspec(dllexport) __attribute__((visibility ("default"))) + #define ARUCO_EXPORTS __declspec(dllexport) #else - #define ARUCO_EXPORTS __attribute__((visibility ("default"))) + #define ARUCO_EXPORTS __attribute__ ((visibility ("default"))) #endif diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h index a4656527a..6f489c34e 100644 --- a/ftnoir_tracker_aruco/include/markerdetector.h +++ b/ftnoir_tracker_aruco/include/markerdetector.h @@ -52,13 +52,11 @@ class ARUCO_EXPORTS MarkerDetector contour=M.contour; idx=M.idx; } - MarkerCandidate operator=(const MarkerCandidate &M){ - if (this == &M) - return *this; + MarkerCandidate & operator=(const MarkerCandidate &M){ (*(Marker*)this)=(*(Marker*)&M); contour=M.contour; idx=M.idx; - return M; + return *this; } vector contour;//all the points of its contour @@ -69,11 +67,11 @@ public: /** * See */ - MarkerDetector() {} + MarkerDetector(); /** */ - ~MarkerDetector() {} + ~MarkerDetector(); /**Detects the markers in the image passed * @@ -353,5 +351,9 @@ private: void draw(cv::Mat out,const std::vector &markers ); }; -} + + + + +}; #endif diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 1e4c6683a..672efa289 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -13,11 +13,10 @@ struct settings { class Hydra_Tracker : public ITracker { public: - Hydra_Tracker(); + Hydra_Tracker(); ~Hydra_Tracker(); void StartTracker(QFrame *) override; void GetHeadPoseData(double *data) override; - int preferredHz() override { return 250; } volatile bool should_quit; private: settings s; @@ -28,23 +27,23 @@ class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); + explicit TrackerControls(); void registerTracker(ITracker *) {} void unRegisterTracker() {} private: settings s; - Ui::UIHydraControls ui; + Ui::UIHydraControls ui; private slots: - void doOK(); - void doCancel(); + void doOK(); + void doCancel(); }; class FTNoIR_TrackerDll : public Metadata { public: - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); }; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index eb21f7bc6..158229a65 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -25,15 +25,14 @@ struct settings { class Rift_Tracker : public ITracker { public: - Rift_Tracker(); + Rift_Tracker(); ~Rift_Tracker() override; void StartTracker(QFrame *) override; void GetHeadPoseData(double *data) override; - int preferredHz() override { return 250; } volatile bool should_quit; protected: - void run(); // qthread override run method + void run(); // qthread override run method private: double old_yaw; @@ -45,32 +44,32 @@ class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); + explicit TrackerControls(); void registerTracker(ITracker *) {} - void unRegisterTracker() {} + void unRegisterTracker() {} private: - Ui::UIRiftControls ui; + Ui::UIRiftControls ui; settings s; private slots: - void doOK(); - void doCancel(); + void doOK(); + void doCancel(); }; class FTNoIR_TrackerDll : public Metadata { public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); + FTNoIR_TrackerDll(); + ~FTNoIR_TrackerDll(); + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); private: - QString trackerFullName; // Trackers' name and description - QString trackerShortName; - QString trackerDescription; + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; }; -- cgit v1.2.3 From 2b3cb1d774812ea0a1a1dae1edfc9b5717095ce3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Oct 2014 20:58:54 +0200 Subject: allow for 180 pitch --- facetracknoir/ftnoir_curves.ui | 138 ----------------------------------------- facetracknoir/mappings.hpp | 2 +- 2 files changed, 1 insertion(+), 139 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 7d6671aaf..07e7b6ca3 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -54,15 +54,6 @@ 260 - - 180 - - - 180 - - - 5 - 255 @@ -100,15 +91,6 @@ 260 - - 180 - - - 180 - - - 5 - 255 @@ -138,18 +120,6 @@ 260 - - 90 - - - 90 - - - 10 - - - 2 - 0 @@ -187,18 +157,6 @@ 260 - - 90 - - - 90 - - - 10 - - - 2 - 0 @@ -228,18 +186,6 @@ 260 - - 180 - - - 180 - - - 5 - - - 1 - 0 @@ -277,18 +223,6 @@ 260 - - 180 - - - 180 - - - 5 - - - 1 - 0 @@ -318,18 +252,6 @@ 260 - - 100 - - - 100 - - - 28 - - - 2 - 255 @@ -367,18 +289,6 @@ 260 - - 100 - - - 100 - - - 28 - - - 2 - 255 @@ -408,18 +318,6 @@ 260 - - 100 - - - 100 - - - 28 - - - 2 - 255 @@ -457,18 +355,6 @@ 260 - - 100 - - - 100 - - - 28 - - - 2 - 255 @@ -498,18 +384,6 @@ 260 - - 100 - - - 100 - - - 28 - - - 2 - 0 @@ -547,18 +421,6 @@ 260 - - 100 - - - 100 - - - 28 - - - 2 - 0 diff --git a/facetracknoir/mappings.hpp b/facetracknoir/mappings.hpp index 4dae7a908..a3e534506 100644 --- a/facetracknoir/mappings.hpp +++ b/facetracknoir/mappings.hpp @@ -44,7 +44,7 @@ public: Mapping("ty","ty_alt", 100, 100, 100, 100, *opts[TY]), Mapping("tz","tz_alt", 100, 100, 100, 100, *opts[TZ]), Mapping("rx", "rx_alt", 180, 180, 180, 180, *opts[Yaw]), - Mapping("ry", "ry_alt", 90, 90, 90, 90, *opts[Pitch]), + Mapping("ry", "ry_alt", 180, 180, 180, 180, *opts[Pitch]), Mapping("rz", "rz_alt", 180, 180, 180, 180, *opts[Roll]) } {} -- cgit v1.2.3 From 613baa7e9473ced982ac7933f4007349d41d79d7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Oct 2014 21:02:29 +0200 Subject: fix typo --- facetracknoir/pose.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/pose.hpp b/facetracknoir/pose.hpp index ec9faaa3e..d925c0a89 100644 --- a/facetracknoir/pose.hpp +++ b/facetracknoir/pose.hpp @@ -44,7 +44,7 @@ public: Pose operator+(const Pose& B) const { - const Quat q = (quat() * B.quat().inv()); + const Quat q = quat() * B.quat(); Pose ret = fromQuat(q); for (int i = TX; i < Yaw; i++) ret(i) = B(i); @@ -56,7 +56,7 @@ public: Pose ret = *this; for (int i = 0; i < 6; i++) { - static constexpr double eps = 1e-5; + static constexpr double eps = 1e-3; // NB replace zero-valued elements with argument's if (std::abs(ret(i)) < eps) ret(i) = replacement(i); -- cgit v1.2.3 From 1956932bbf0f26c2bdbf89abfe44cc3e00ff7e7a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Oct 2014 21:37:57 +0200 Subject: tracker: cleanup --- facetracknoir/tracker.cpp | 89 ++++++++++++++++++++++++----------------------- facetracknoir/tracker.h | 1 + 2 files changed, 46 insertions(+), 44 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index e1f86294e..504cd003a 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -46,7 +46,7 @@ void Tracker::get_curve(double pos, double& out, Mapping& axis) { out += axis.opts.zero; } -static void t_compensate(double* input, double* output, bool rz) +void Tracker::t_compensate(const double* input, double* output, bool rz) { static constexpr double pi = 3.141592653; const auto H = input[Yaw] * pi / -180; @@ -72,14 +72,14 @@ static void t_compensate(double* input, double* output, bool rz) cosH * cosP, }; - cv::Mat rmat(3, 3, CV_64F, foo); - const cv::Mat tvec(3, 1, CV_64F, input); - cv::Mat ret = rmat * tvec; + const cv::Matx33d rmat(foo); + const cv::Vec3d tvec(input); + const cv::Vec3d ret = rmat * tvec; const int max = !rz ? 3 : 2; for (int i = 0; i < max; i++) - output[i] = ret.at(i); + output[i] = ret(i); } void Tracker::run() { @@ -92,58 +92,59 @@ void Tracker::run() { (void) timeBeginPeriod(1); #endif - for (;;) + while (!should_quit) { t.start(); - if (should_quit) - break; - Libraries->pTracker->GetHeadPoseData(newpose); + Pose final_raw, final_mapped; + + for (int i = 0; i < 6; i++) { - QMutexLocker foo(&mtx); + auto& axis = m(i); + int k = axis.opts.src; + if (k < 0 || k >= 6) + continue; + // not really raw, after axis remap -sh + final_raw(i) = newpose[k]; + } + + if (centerp) { + centerp = false; + pose_offset = final_raw; + } + + { + if (enabledp) + unstopped_pose = final_raw; + + if (Libraries->pFilter) + Libraries->pFilter->FilterHeadPoseData(unstopped_pose, final_mapped); + else + final_mapped = unstopped_pose; + + final_mapped = final_mapped - pose_offset; for (int i = 0; i < 6; i++) - { - auto& axis = m(i); - int k = axis.opts.src; - if (k < 0 || k >= 6) - continue; - // not really raw, after axis remap -sh - raw_6dof(i) = newpose[k]; - } - - if (centerp) { - centerp = false; - pose_offset = raw_6dof; - } - - { - if (enabledp) - unstopped_pose = raw_6dof; - - if (Libraries->pFilter) - Libraries->pFilter->FilterHeadPoseData(unstopped_pose, output_pose); - else - output_pose = unstopped_pose; - - output_pose = output_pose - pose_offset; - - for (int i = 0; i < 6; i++) - get_curve(output_pose(i), output_pose(i), m(i)); - } - - if (s.tcomp_p) - t_compensate(output_pose, output_pose, s.tcomp_tz); - - Libraries->pProtocol->sendHeadposeToGame(output_pose); + get_curve(final_mapped(i), final_mapped(i), m(i)); } - const long q = std::max(0L, sleep_ms * 1000L - std::max(0L, t.elapsed())); + if (s.tcomp_p) + t_compensate(final_mapped, final_mapped, s.tcomp_tz); + + Libraries->pProtocol->sendHeadposeToGame(final_mapped); + + { + QMutexLocker foo(&mtx); + output_pose = final_mapped; + raw_6dof = final_raw; + } + const long q = 1000L * std::max(0L, sleep_ms - t.elapsed_ms()); usleep(q); } + #if defined(_WIN32) (void) timeEndPeriod(1); #endif diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 8a4ecb1f5..5f9639b25 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -37,6 +37,7 @@ private: std::atomic should_quit; static void get_curve(double pos, double& out, Mapping& axis); + static void t_compensate(const double* input, double* output, bool rz); protected: void run() override; public: -- cgit v1.2.3 From e8f28d843af7b181593e58eaaea16816699b8d76 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Oct 2014 20:26:34 +0200 Subject: cleanup includes --- facetracknoir/tracker.h | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 5f9639b25..d65e1cf16 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -1,27 +1,19 @@ -#ifndef __TRACKER_H__ -#define __TRACKER_H__ +#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include "./timer.hpp" #include "./plugin-support.h" #include "./mappings.hpp" #include "./pose.hpp" -#include -#include +#include "../qfunctionconfigurator/functionconfig.h" +#include "./main-settings.hpp" +#include "./options.h" -#include -#include "./quat.hpp" -#include "facetracknoir/main-settings.hpp" -#include "facetracknoir/options.h" -#include "facetracknoir/timer.hpp" +#include +#include class Tracker : protected QThread { Q_OBJECT @@ -46,7 +38,6 @@ public: void get_raw_and_mapped_poses(double* mapped, double* raw) const; void start() { QThread::start(); } - void center() { centerp.store(true); } void toggle_enabled() { enabledp.store(!enabledp.load()); } + void center() { centerp.store(!centerp.load()); } }; -#endif -- cgit v1.2.3 From 3f6e60abec9285e803b0e2b380e3fea490b6e392 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Oct 2014 20:26:54 +0200 Subject: time.h -> ctime --- facetracknoir/timer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp index 8eb6b943b..35ccd4cc0 100644 --- a/facetracknoir/timer.hpp +++ b/facetracknoir/timer.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #if defined (_WIN32) # include static inline void opentrack_clock_gettime(int, struct timespec* ts) -- cgit v1.2.3 From f50ef9ca768f676c38fb7f24c15d38e2f72126fb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Oct 2014 00:29:05 +0200 Subject: simplify, rename infix operator --- facetracknoir/pose.hpp | 30 ++++-------------------------- facetracknoir/tracker.cpp | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 39 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/pose.hpp b/facetracknoir/pose.hpp index d925c0a89..41e984f56 100644 --- a/facetracknoir/pose.hpp +++ b/facetracknoir/pose.hpp @@ -33,34 +33,12 @@ public: return ret; } - Pose operator-(const Pose& B) const + Pose operator&(const Pose& B) const { - const Quat q = (quat() * B.quat().inv()); + const Quat q = quat() * B.quat().inv(); Pose ret = fromQuat(q); - for (int i = TX; i < Yaw; i++) - ret(i) = B(i); - return ret; - } - - Pose operator+(const Pose& B) const - { - const Quat q = quat() * B.quat(); - Pose ret = fromQuat(q); - for (int i = TX; i < Yaw; i++) - ret(i) = B(i); - return ret; - } - - Pose operator|(const Pose& replacement) const - { - Pose ret = *this; - for (int i = 0; i < 6; i++) - { - static constexpr double eps = 1e-3; - // NB replace zero-valued elements with argument's - if (std::abs(ret(i)) < eps) - ret(i) = replacement(i); - } + for (int i = TX; i < TX + 3; i++) + ret(i) = axes[i] - B.axes[i]; return ret; } }; diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 504cd003a..4a80c7229 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -98,7 +98,7 @@ void Tracker::run() { Libraries->pTracker->GetHeadPoseData(newpose); - Pose final_raw, final_mapped; + Pose final_raw, filtered; for (int i = 0; i < 6; i++) { @@ -110,34 +110,34 @@ void Tracker::run() { final_raw(i) = newpose[k]; } - if (centerp) { - centerp = false; - pose_offset = final_raw; - } - { if (enabledp) unstopped_pose = final_raw; if (Libraries->pFilter) - Libraries->pFilter->FilterHeadPoseData(unstopped_pose, final_mapped); + Libraries->pFilter->FilterHeadPoseData(unstopped_pose, filtered); else - final_mapped = unstopped_pose; + filtered = unstopped_pose; + + if (centerp) { + centerp = false; + pose_offset = filtered; + } - final_mapped = final_mapped - pose_offset; + filtered = filtered & pose_offset; for (int i = 0; i < 6; i++) - get_curve(final_mapped(i), final_mapped(i), m(i)); + get_curve(filtered(i), filtered(i), m(i)); } if (s.tcomp_p) - t_compensate(final_mapped, final_mapped, s.tcomp_tz); + t_compensate(filtered, filtered, s.tcomp_tz); - Libraries->pProtocol->sendHeadposeToGame(final_mapped); + Libraries->pProtocol->sendHeadposeToGame(filtered); { QMutexLocker foo(&mtx); - output_pose = final_mapped; + output_pose = filtered; raw_6dof = final_raw; } -- cgit v1.2.3 From 88f985ca34275fc1cc014c5b8fa618ca95233db7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Oct 2014 00:30:13 +0200 Subject: spline editor needs discard changes on cancel --- facetracknoir/curve-config.cpp | 15 ++-- facetracknoir/curve-config.h | 5 +- facetracknoir/facetracknoir.cpp | 8 +- facetracknoir/facetracknoir.h | 2 +- facetracknoir/facetracknoir.ui | 12 --- facetracknoir/mappings.hpp | 9 +++ qfunctionconfigurator/functionconfig.cpp | 97 ++++++++++++++----------- qfunctionconfigurator/functionconfig.h | 12 ++- qfunctionconfigurator/qfunctionconfigurator.cpp | 71 ++++++++++-------- qfunctionconfigurator/qfunctionconfigurator.h | 16 +--- 10 files changed, 128 insertions(+), 119 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 886e40fad..57cea7a41 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -1,7 +1,8 @@ #include "./facetracknoir.h" #include "./curve-config.h" #include "./main-settings.hpp" -CurveConfigurationDialog::CurveConfigurationDialog(Mappings& m, main_settings& s, QWidget *parent) : QWidget(parent, Qt::Dialog), +MapWidget::MapWidget(Mappings& m, main_settings& s, QWidget *parent) : + QWidget(parent, Qt::Dialog), m(m) { ui.setupUi( this ); @@ -82,16 +83,12 @@ CurveConfigurationDialog::CurveConfigurationDialog(Mappings& m, main_settings& s tie_setting(s.a_z.src, ui.src_z); } -void CurveConfigurationDialog::doOK() { - save(); +void MapWidget::doOK() { + m.save_mappings(); this->close(); } -void CurveConfigurationDialog::doCancel() { - m.load_mappings(); +void MapWidget::doCancel() { + m.invalidate_unsaved(); this->close(); } - -void CurveConfigurationDialog::save() { - m.save_mappings(); -} diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index 67a588e22..d485c4ff0 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -3,15 +3,14 @@ #include "./mappings.hpp" #include "ui_ftnoir_curves.h" -class CurveConfigurationDialog: public QWidget +class MapWidget: public QWidget { Q_OBJECT public: - CurveConfigurationDialog(Mappings &m, main_settings &s, QWidget *parent ); + MapWidget(Mappings &m, main_settings &s, QWidget *parent ); private: Ui::UICCurveConfigurationDialog ui; Mappings& m; - void save(); private slots: void doOK(); void doCancel(); diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index af76f09b3..f689cb5fb 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -91,7 +91,7 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : QMainWindow(parent), pProtocolDialog(nullptr), pFilterDialog(nullptr), shortcuts_widget(nullptr), - mapping_widget(new CurveConfigurationDialog(pose, s, this)), + mapping_widget(nullptr), kbd_quit(QKeySequence("Ctrl+Q"), this), looping(0), video_frame_layout(new QVBoxLayout()), @@ -444,8 +444,10 @@ void FaceTrackNoIR::showKeyboardShortcuts() { shortcuts_widget->raise(); } void FaceTrackNoIR::showCurveConfiguration() { - if (!mapping_widget) - mapping_widget = new CurveConfigurationDialog(pose, s, this); + if (mapping_widget) + delete mapping_widget; + + mapping_widget = new MapWidget(pose, s, this); mapping_widget->show(); mapping_widget->raise(); diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 09f96147c..d4c3a3697 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -100,7 +100,7 @@ private: IFilterDialog* pFilterDialog; QWidget *shortcuts_widget; - CurveConfigurationDialog* mapping_widget; + MapWidget* mapping_widget; void createIconGroupBox(); void loadSettings(); diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 1d769f0d0..41c6abc90 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -435,12 +435,6 @@ - - - 0 - 0 - - Mapping @@ -458,12 +452,6 @@ - - - 0 - 0 - - Keys diff --git a/facetracknoir/mappings.hpp b/facetracknoir/mappings.hpp index a3e534506..5953ed1e3 100644 --- a/facetracknoir/mappings.hpp +++ b/facetracknoir/mappings.hpp @@ -76,4 +76,13 @@ public: axes[i].curveAlt.saveSettings(iniFile, axes[i].name2); } } + + void invalidate_unsaved() + { + for (int i = 0; i < 6; i++) + { + axes[i].curve.invalidate_unsaved_settings(); + axes[i].curveAlt.invalidate_unsaved_settings(); + } + } }; diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 4c52b6ebd..0d37156e5 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -24,7 +24,6 @@ void Map::setTrackingActive(bool blnActive) Map::Map() : _mutex(QMutex::Recursive), - data(0), activep(false), max_x(0), max_y(0) @@ -48,13 +47,13 @@ bool Map::getLastPoint(QPointF& point ) { float Map::getValueInternal(int x) { float sign = x < 0 ? -1 : 1; - x = std::abs((double) x); + x = std::abs(x); float ret; - int sz = data.size(); + int sz = cur.data.size(); if (sz == 0) ret = 0; else - ret = data[std::max(std::min(x, sz-1), 0)]; + ret = cur.data[std::max(std::min(x, sz-1), 0)]; return ret * sign; } @@ -72,91 +71,99 @@ static bool sortFn(const QPointF& one, const QPointF& two) { } void Map::reload() { - if (input.size()) - qStableSort(input.begin(), input.end(), sortFn); - - if (input.size()) + if (cur.input.size()) { + auto& input = cur.input; + auto& data = cur.data; + + qStableSort(input.begin(), input.end(), sortFn); data = std::vector(MEMOIZE_PRECISION * input[input.size() - 1].x()); - + const int sz = data.size(); - + for (int i = 0; i < sz; i++) - data[i] = -1; - - for (int k = 0; k < input[0].x() * MEMOIZE_PRECISION; k++) { + data[i] = -1; + + for (int k = 0; k < input[0].x() * MEMOIZE_PRECISION; k++) { if (k < sz) data[k] = input[0].y() * k / (input[0].x() * MEMOIZE_PRECISION); } - - for (int i = 0; i < sz; i++) { + + for (int i = 0; i < sz; i++) { QPointF p0 = ensureInBounds(input, i - 1); QPointF p1 = ensureInBounds(input, i); QPointF p2 = ensureInBounds(input, i + 1); QPointF p3 = ensureInBounds(input, i + 2); - + int end = std::min(sz, p2.x() * MEMOIZE_PRECISION); int start = p1.x() * MEMOIZE_PRECISION; - + for (int j = start; j < end; j++) { double t = (j - start) / (double) (end - start); double t2 = t*t; double t3 = t*t*t; - + int x = .5 * ((2. * p1.x()) + (-p0.x() + p2.x()) * t + (2. * p0.x() - 5. * p1.x() + 4. * p2.x() - p3.x()) * t2 + (-p0.x() + 3. * p1.x() - 3. * p2.x() + p3.x()) * t3) * MEMOIZE_PRECISION; - + float y = .5 * ((2. * p1.y()) + - (-p0.y() + p2.y()) * t + - (2. * p0.y() - 5. * p1.y() + 4. * p2.y() - p3.y()) * t2 + - (-p0.y() + 3. * p1.y() - 3. * p2.y() + p3.y()) * t3); - + (-p0.y() + p2.y()) * t + + (2. * p0.y() - 5. * p1.y() + 4. * p2.y() - p3.y()) * t2 + + (-p0.y() + 3. * p1.y() - 3. * p2.y() + p3.y()) * t3); + if (x >= 0 && x < sz) data[x] = y; } - } - - float last = 0; - for (int i = 0; i < sz; i++) - { - if (data[i] <= 0) - data[i] = last; - last = data[i]; - } + } + + float last = 0; + for (int i = 0; i < sz; i++) + { + if (data[i] <= 0) + data[i] = last; + last = data[i]; + } } + else + cur.data.clear(); } void Map::removePoint(int i) { QMutexLocker foo(&_mutex); - if (i >= 0 && i < input.size()) + if (i >= 0 && i < cur.input.size()) { - input.removeAt(i); + cur.input.removeAt(i); reload(); } } void Map::addPoint(QPointF pt) { QMutexLocker foo(&_mutex); - input.append(pt); + cur.input.append(pt); reload(); } void Map::movePoint(int idx, QPointF pt) { QMutexLocker foo(&_mutex); - if (idx >= 0 && idx < input.size()) + if (idx >= 0 && idx < cur.input.size()) { - input[idx] = pt; + cur.input[idx] = pt; reload(); } } const QList Map::getPoints() { QMutexLocker foo(&_mutex); - // NB can't pass by reference - return input; + return cur.input; +} + +void Map::invalidate_unsaved_settings() +{ + cur = saved; + reload(); } void Map::loadSettings(QSettings& settings, const QString& title) { @@ -180,19 +187,20 @@ void Map::loadSettings(QSettings& settings, const QString& title) { } settings.endGroup(); - input = points; + cur.input = points; reload(); + saved = cur; } void Map::saveSettings(QSettings& settings, const QString& title) { QMutexLocker foo(&_mutex); settings.beginGroup(QString("Curves-%1").arg(title)); - int max = input.size(); + int max = cur.input.size(); settings.setValue("point-count", max); for (int i = 0; i < max; i++) { - settings.setValue(QString("point-%1-x").arg(i), input[i].x()); - settings.setValue(QString("point-%1-y").arg(i), input[i].y()); + settings.setValue(QString("point-%1-x").arg(i), cur.input[i].x()); + settings.setValue(QString("point-%1-y").arg(i), cur.input[i].y()); } for (int i = max; true; i++) @@ -203,5 +211,8 @@ void Map::saveSettings(QSettings& settings, const QString& title) { settings.remove(x); settings.remove(QString("point-%1-y").arg(i)); } + + saved = cur; + settings.endGroup(); } diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 7d21fd63e..e24f54cf2 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -20,17 +20,22 @@ class OPENTRACK_EXPORT Map { private: + struct State { + QList input; + std::vector data; + }; + static constexpr long MEMOIZE_PRECISION = 25; void reload(); float getValueInternal(int x); MyMutex _mutex; - QList input; - std::vector data; QPointF last_input_value; volatile bool activep; int max_x; int max_y; + + State cur, saved; public: int maxInput() const { return max_x; } int maxOutput() const { return max_y; } @@ -46,7 +51,7 @@ public: void removePoint(int i); void removeAllPoints() { QMutexLocker foo(&_mutex); - input.clear(); + cur.input.clear(); reload(); } @@ -62,6 +67,7 @@ public: void saveSettings(QSettings& settings, const QString& title); void loadSettings(QSettings& settings, const QString& title); + void invalidate_unsaved_settings(); void setTrackingActive(bool blnActive); }; diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 57d1500ac..b15f308e8 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -10,20 +10,11 @@ #include "qfunctionconfigurator/qfunctionconfigurator.h" #include #include -#include -#include -#include -#include #include -#include -#include #include #include -#include #include -#include -#include -#include +#include static const int pointSize = 5; @@ -57,8 +48,7 @@ void QFunctionConfigurator::drawBackground() QPainter painter(&_background); painter.fillRect(rect(), QColor::fromRgb(204, 204, 204)); - painter.setRenderHint(QPainter::Antialiasing); - + QColor bg_color(112, 154, 209); painter.fillRect(pixel_bounds, bg_color); @@ -140,8 +130,6 @@ void QFunctionConfigurator::drawFunction() _function = QPixmap(_background); QPainter painter(&_function); - - painter.save(); painter.setRenderHint(QPainter::Antialiasing, true); QList points = _config->getPoints(); @@ -164,13 +152,11 @@ void QFunctionConfigurator::drawFunction() drawLine(&painter, prev, cur, pen); prev = cur; } - painter.restore(); } void QFunctionConfigurator::paintEvent(QPaintEvent *e) { QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); if (_background.isNull()) drawBackground(); @@ -179,6 +165,7 @@ void QFunctionConfigurator::paintEvent(QPaintEvent *e) _draw_function = false; drawFunction(); } + p.drawPixmap(e->rect(), _function); if (_config) { @@ -246,10 +233,9 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) moving_control_point_idx = -1; if (_config) { for (int i = 0; i < points.size(); i++) { - if ( point_within_pixel(points[i], e->pos() ) ) { + if (point_within_pixel(points[i], e->pos())) { bTouchingPoint = true; moving_control_point_idx = i; - timer.restart(); break; } } @@ -263,7 +249,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) if (_config) { int found_pt = -1; for (int i = 0; i < points.size(); i++) { - if ( point_within_pixel(points[i], e->pos() ) ) { + if (point_within_pixel(points[i], e->pos())) { found_pt = i; break; } @@ -284,21 +270,31 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) if (!_config) return; - static constexpr int min_refresh_delay = 25; + static constexpr int min_refresh_delay = 12; if (timer.isValid() && timer.elapsed() < min_refresh_delay) return; - static constexpr int refresh_delay = 50; + static constexpr int refresh_delay = 17; QList points = _config->getPoints(); - if (moving_control_point_idx >= 0 && moving_control_point_idx < points.size()) { + if (moving_control_point_idx != -1 && moving_control_point_idx < points.size()) { setCursor(Qt::ClosedHandCursor); - - if (timer.isValid() && timer.elapsed() > refresh_delay) + + bool overlap = false; + + QPointF new_pt = pixel_coord_to_point(e->pos()); + + if (moving_control_point_idx + 1 < points.size()) + overlap |= new_pt.x() > points[moving_control_point_idx+1].x(); + if (moving_control_point_idx != 0) + overlap |= new_pt.x() < points[moving_control_point_idx-1].x(); + + if (overlap) + moving_control_point_idx = -1; + else if (timer.isValid() && timer.elapsed() > refresh_delay) { timer.restart(); - QPointF new_pt = pixel_coord_to_point(e->pos()); points[moving_control_point_idx] = new_pt; _config->movePoint(moving_control_point_idx, new_pt); _draw_function = true; @@ -326,11 +322,9 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) { if (!_config) return; - - QList points = _config->getPoints(); if (e->button() == Qt::LeftButton) { - timer.invalidate(); + QList points = _config->getPoints(); if (moving_control_point_idx >= 0 && moving_control_point_idx < points.size()) { if (_config) { _config->movePoint(moving_control_point_idx, pixel_coord_to_point(e->pos())); @@ -338,10 +332,27 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) } setCursor(Qt::ArrowCursor); moving_control_point_idx = -1; + + _draw_function = true; + update(); } +} +void QFunctionConfigurator::update_range() +{ + if (!_config) + return; + + const double w = width(), h = height(); + const double mwl = 40, mhl = 20; + const double mwr = 15, mhr = 35; + + pixel_bounds = QRectF(mwl, mhl, (w - mwl - mwr), (h - mhl - mhr)); + c = QPointF(pixel_bounds.width() / _config->maxInput(), pixel_bounds.height() / _config->maxOutput()); _draw_function = true; - update(); + + _background = QPixmap(); + _function = QPixmap(); } bool QFunctionConfigurator::point_within_pixel(const QPointF &pt, const QPointF &pixel) @@ -382,5 +393,5 @@ QPointF QFunctionConfigurator::point_to_pixel(const QPointF& point) void QFunctionConfigurator::resizeEvent(QResizeEvent *) { update_range(); - repaint(); + update(); } diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index e35d0bc38..25d8f8bc7 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -46,21 +46,7 @@ private: protected: virtual void resizeEvent(QResizeEvent *); private: - void update_range() { - if (!_config) - return; - - const double w = width(), h = height(); - const double mwl = 40, mhl = 20; - const double mwr = 15, mhr = 35; - - pixel_bounds = QRectF(mwl, mhl, (w - mwl - mwr), (h - mhl - mhr)); - c = QPointF(pixel_bounds.width() / _config->maxInput(), pixel_bounds.height() / _config->maxOutput()); - _draw_function = true; - - _background = QPixmap(); - _function = QPixmap(); - } + void update_range(); QPointF pixel_coord_to_point (const QPointF& point); QPointF point_to_pixel (const QPointF& point); -- cgit v1.2.3 From a4262fce4a33053438fb94d32331aa27d44056c2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Oct 2014 16:07:38 +0200 Subject: comments only --- facetracknoir/gain-control.hpp | 5 ++++- facetracknoir/plugin-support.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/gain-control.hpp b/facetracknoir/gain-control.hpp index 5958e945d..081d4b6f1 100644 --- a/facetracknoir/gain-control.hpp +++ b/facetracknoir/gain-control.hpp @@ -1,5 +1,7 @@ #pragma once +/* still WIP, not usable yet! -sh 20141012 */ + #include #undef NDEBUG #include @@ -163,7 +165,7 @@ public: if (history_timer.elapsed_ms() > GAIN_HISTORY_EVERY_MS) { - const double cov = get_covariance(frame, last_frame); + //const double cov = get_covariance(frame, last_frame); history_timer.start(); last_frame = frame.clone(); @@ -174,6 +176,7 @@ public: if (debug_timer.elapsed_ms() > 1000) { const double mu = mean(frame); + // XXX move to HSL/HSV color space for it to work! -sh 20141012 const double var = get_variance(frame, mu); debug_timer.start(); diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h index c3914cfb7..b539d1521 100644 --- a/facetracknoir/plugin-support.h +++ b/facetracknoir/plugin-support.h @@ -45,7 +45,7 @@ private: }; -// TODO it can die if running tracker state separated into class -sh 20141004 +// XXX TODO it can die if running tracker state separated into class -sh 20141004 class IDynamicLibraryProvider { public: virtual DynamicLibrary* current_tracker1() = 0; -- cgit v1.2.3 From a24ef3d12230f739fefea85c14a7587aeb43b4d2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Oct 2014 16:10:41 +0200 Subject: opt: cleanup some nonsense --- facetracknoir/options.h | 151 +++++++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 80 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 291ac0719..37377b55b 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -28,10 +28,10 @@ #include namespace options { - template + template // don't elide usages of the function, qvariant default implicit // conversion results in nonsensical runtime behavior -sh - inline T qcruft_to_t (const QVariant& t); + inline t qcruft_to_t (const QVariant& datum); template<> inline int qcruft_to_t(const QVariant& t) @@ -84,6 +84,7 @@ namespace options { conf.endGroup(); } static constexpr const char* org = "opentrack"; + void save() { QSettings s(ini_pathname(), QSettings::IniFormat); s.beginGroup(name); @@ -91,9 +92,9 @@ namespace options { s.setValue(k, map[k]); s.endGroup(); } - template - T get(const QString& k) { - return qcruft_to_t(map.value(k)); + template + t get(const QString& k) { + return qcruft_to_t(map.value(k)); } void put(const QString& s, const QVariant& d) { @@ -105,7 +106,8 @@ namespace options { } }; - class impl_bundle { + class impl_bundle : public QObject { + Q_OBJECT private: QMutex mtx; const QString group_name; @@ -114,7 +116,8 @@ namespace options { impl_bundle(const impl_bundle&) = delete; impl_bundle& operator=(const impl_bundle&) = delete; bool modified; - long priv_cookie; + signals: + void changed(); public: impl_bundle(const QString& group_name) : mtx(QMutex::Recursive), @@ -128,18 +131,20 @@ namespace options { QMutexLocker l(&mtx); saved = group(group_name); transient = saved; - priv_cookie++; } - void store(const QString& name, const QVariant& datum) + void store_kv(const QString& name, const QVariant& datum) { QMutexLocker l(&mtx); - if (!transient.contains(name) || datum != transient.get(name)) + auto old = transient.get(name); + if (!transient.contains(name) || datum != old) { if (!modified) - qDebug() << "bundle" << group_name << "modified due to" << name << transient.get(name) << datum << "->" << datum; + qDebug() << "bundle" << group_name << + "modified due to" << name << + transient.get(name) << + old << "->" << datum; modified = true; transient.put(name, datum); - priv_cookie++; } } bool contains(const QString& name) @@ -147,10 +152,10 @@ namespace options { QMutexLocker l(&mtx); return transient.contains(name); } - template - T get(const QString& name) { + template + t get(const QString& name) { QMutexLocker l(&mtx); - return transient.get(name); + return transient.get(name); } void save() { @@ -158,100 +163,85 @@ namespace options { modified = false; saved = transient; transient.save(); + emit changed(); } void revert() { QMutexLocker l(&mtx); modified = false; transient = saved; - priv_cookie++; + emit changed(); } bool modifiedp() { QMutexLocker l(&mtx); return modified; } - long cookie() const { - return priv_cookie; - } }; using pbundle = std::shared_ptr; class base_value : public QObject { Q_OBJECT +#define DEFINE_SLOT(t) void setValue(t datum) { store(datum); } +#define DEFINE_SIGNAL(t) void valueChanged(t); public: - base_value(pbundle b, const QString& name) : b(b), self_name(name), cookie_snap(0) {} - virtual QVariant operator=(const QVariant& datum) = 0; - template - QVariant operator=(const T& datum) - { - return this->operator =(qVariantFromValue(datum)); - } - protected: - pbundle b; - QString self_name; - template - QVariant store(const T& datum) - { - b->store(self_name, qVariantFromValue(datum)); - emit valueChanged(datum); - return datum; - } - void maybe_lazy_change() - { - long cookie = b->cookie(); - if (cookie_snap != cookie) - { - cookie_snap = cookie; - this->operator=(b->get(self_name)); - } - } - private: - long cookie_snap; + base_value(pbundle b, const QString& name) : b(b), self_name(name) {} public slots: -#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(qVariantFromValue(datum)); } DEFINE_SLOT(double) DEFINE_SLOT(int) DEFINE_SLOT(QString) DEFINE_SLOT(bool) signals: -#define DEFINE_SIGNAL(t) void valueChanged(t); - DEFINE_SIGNAL(double) - DEFINE_SIGNAL(int) - DEFINE_SIGNAL(QString) - DEFINE_SIGNAL(bool) + DEFINE_SIGNAL(double); + DEFINE_SIGNAL(int); + DEFINE_SIGNAL(bool); + DEFINE_SIGNAL(QString); + // Qt5 moc really insists on that one -sh 20141012 + DEFINE_SIGNAL(QVariant); + protected: + pbundle b; + QString self_name; + + template + void store(const t& datum) + { + b->store_kv(self_name, datum); + emit valueChanged(static_cast(datum)); + } }; - template + template class value : public base_value { public: - QVariant operator=(const QVariant& datum) { - return store(qcruft_to_t(datum)); + t operator=(const t& datum) + { + store(qVariantFromValue(datum)); + return datum; } - static constexpr const Qt::ConnectionType QT_CONNTYPE = Qt::UniqueConnection; - static constexpr const Qt::ConnectionType OPT_CONNTYPE = Qt::UniqueConnection; - value(pbundle b, const QString& name, T def) : base_value(b, name) + static constexpr const Qt::ConnectionType DIRECT_CONNTYPE = Qt::DirectConnection; + static constexpr const Qt::ConnectionType SAFE_CONNTYPE = Qt::AutoConnection; + value(pbundle b, const QString& name, t def) : base_value(b, name) { if (!b->contains(name) || b->get(name).type() == QVariant::Invalid) - this->operator=(qVariantFromValue(def)); + *this = def; } - operator T() + operator t() { - maybe_lazy_change(); - return b->get(self_name); + return b->get(self_name); } }; - template - inline void tie_setting(value&, Q*); + template + inline void tie_setting(value&, q*); template<> inline void tie_setting(value& v, QComboBox* cb) { cb->setCurrentIndex(v); - base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.QT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.OPT_CONNTYPE); + v = cb->currentIndex(); + base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE); } template<> @@ -259,55 +249,56 @@ namespace options { { cb->setCurrentText(v); v = cb->currentText(); - base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.QT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.OPT_CONNTYPE); + base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.DIRECT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.SAFE_CONNTYPE); } template<> inline void tie_setting(value& v, QCheckBox* cb) { cb->setChecked(v); - base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.QT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.OPT_CONNTYPE); + base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.DIRECT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.SAFE_CONNTYPE); } template<> inline void tie_setting(value& v, QDoubleSpinBox* dsb) { dsb->setValue(v); - base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.QT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.OPT_CONNTYPE); + base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.DIRECT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.SAFE_CONNTYPE); } template<> inline void tie_setting(value& v, QSpinBox* sb) { sb->setValue(v); - base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.QT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.OPT_CONNTYPE); + base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.SAFE_CONNTYPE); } template<> inline void tie_setting(value& v, QSlider* sl) { sl->setValue(v); - base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.QT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.OPT_CONNTYPE); + v = sl->value(); + base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.SAFE_CONNTYPE); } template<> inline void tie_setting(value& v, QLineEdit* le) { le->setText(v); - base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.QT_CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.OPT_CONNTYPE); + base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.DIRECT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.SAFE_CONNTYPE); } template<> inline void tie_setting(value& v, QLabel* lb) { lb->setText(v); - base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.OPT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.SAFE_CONNTYPE); } inline pbundle bundle(const QString& group) { -- cgit v1.2.3 From d478332561caf3d35f6615b6246f6ad4cdaac89f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 14:05:05 +0200 Subject: use layout for whole main window fixes too small widgets inside of it --- facetracknoir/facetracknoir.ui | 2147 ++++++++++++++++++++-------------------- 1 file changed, 1048 insertions(+), 1099 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 41c6abc90..32aea889e 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -12,7 +12,7 @@ - + 0 0 @@ -27,1137 +27,1086 @@ - - - - 10 - 225 - 655 - 505 - - - - Video preview - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - + + + + + + 0 + 0 + + + + Tracking preview + + + + 0 - - - 640 - 480 - + + 0 - - - 640 - 480 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 640 - 480 - - - - - 640 - 480 - - - - - - - - - - - - - - - - 675 - 225 - 271 - 505 - - - - - - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Connected game + + 0 - - - 6 - - - 6 - - - 3 - - - - - Not connected - - - - - - - - - - - 0 - 0 - + + 0 - - Profile + + + + + 0 + 120 + + + + + + + + + + + + + + + 10 - - - 6 - - - 6 - - - 3 - - - - - true - - - - 0 - 0 - - - - Save - - - - - - - - 0 - 0 - - - - Load - - - - - - - - 0 - 0 - - - - 10 - - - - - - - true - - - - 0 - 0 - - - - Save As ... - - - - - - - - - - - 0 - 0 - + + 0 - - Tracker + + 0 - - - 6 - - - 6 - - - 3 - - - - - - 0 - 0 - - - - - - - - true - - - - 0 - 0 - - - - Settings - - - - - - - - - - - 0 - 0 - + + 0 - - Filter + + 0 - - - 6 - - - 6 - - - 3 - - - - - - 0 - 0 - - - - - - - - true - - - - 0 - 0 - - - - Settings - - - - - - - - - - - 0 - 0 - + + + + Raw pose + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + 3 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + 3 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + pitch + + + + + + + + 0 + 0 + + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + 3 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + 3 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + false + + + TZ + + + + + + + true + + + + 0 + 0 + + + + false + + + TY + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + 3 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + yaw + + + + + + + + 0 + 0 + + + + roll + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + 3 + + + QLCDNumber::Outline + + + + + + + + + + Game data + + + + + + + 0 + 0 + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 3 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 3 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 3 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TZ + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 3 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TY + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + yaw + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 3 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + true + + + 3 + + + QLCDNumber::Flat + + + + + + + + + + + + + Video preview + + + + 0 - - Protocol + + 0 - - - 6 - - - 6 - - - 3 - - - - - true - - - - 0 - 0 - - - - Settings - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - + + 0 - - Settings + + 0 - - - 6 - - - 6 - - - 3 - - - - - Mapping - - - - :/uielements/curves.png:/uielements/curves.png - - - - 91 - 20 - - - - - - - - Keys - - - - :/uielements/tools.png:/uielements/tools.png - - - - 98 - 24 - - - - - - - - - - - - 0 - 0 - + + 0 - - - 0 - 0 - + + 0 - - - 65536 - 65536 - + + + + + 0 + 0 + + + + + 640 + 480 + + + + + 640 + 480 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 640 + 480 + + + + + 640 + 480 + + + + + + + + + + + + + + + + + + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + + 3 - - Controls + + 0 - - - 6 - - - 6 - - - 3 - - - - - false - - - - 0 - 0 - - - - Stop - - - - - - - - 0 - 0 - - - - Start - - - - - - - - - - - - 185 - 10 - 761 - 211 - - - - - - - - 10 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Raw pose + + 0 - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - 3 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - 3 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - pitch - - - - - - - - 0 - 0 - - - - TX - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - 3 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - 3 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - false - - - TZ - - - - - - - true - - - - 0 - 0 - - - - false - - - TY - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - 3 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - yaw - - - - - - - - 0 - 0 - - - - roll - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - 3 - - - QLCDNumber::Outline - - - - - - - - - - Game data + + 0 - - - - - - 0 - 0 - - - - - NoAntialias - false - - - - QFrame::Raised - - - TX - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - + + 0 + + + + + Connected game + + + + 6 + + + 6 + + 3 - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - + + + + Not connected + + + + + + + + + + + 0 + 0 + + + + Profile + + + + 6 + + + 6 + + 3 - - QLCDNumber::Flat - - - - - - - - 0 - 0 - - - - - NoAntialias - false - - - - QFrame::Raised - - - pitch - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - + + + + true + + + + 0 + 0 + + + + Save + + + + + + + + 0 + 0 + + + + Load + + + + + + + + 0 + 0 + + + + 10 + + + + + + + true + + + + 0 + 0 + + + + Save As ... + + + + + + + + + + + 0 + 0 + + + + Tracker + + + + 6 + + + 6 + + 3 - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - - NoAntialias - false - - - - false - - - QFrame::Raised - - - TZ - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - + + + + + 0 + 0 + + + + + + + + true + + + + 0 + 0 + + + + Settings + + + + + + + + + + + 0 + 0 + + + + Filter + + + + 6 + + + 6 + + 3 - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - - NoAntialias - false - - - - false - - - QFrame::Raised - - - TY - - - - - - - - 0 - 0 - - - - - NoAntialias - false - - - - QFrame::Raised - - - yaw - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - + + + + + 0 + 0 + + + + + + + + true + + + + 0 + 0 + + + + Settings + + + + + + + + + + + 0 + 0 + + + + Protocol + + + + 6 + + + 6 + + 3 - - QLCDNumber::Flat - - - - - - - - 0 - 0 - - - - - NoAntialias - false - - - - QFrame::Raised - - - roll - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - true - - + + + + true + + + + 0 + 0 + + + + Settings + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Settings + + + + 6 + + + 6 + + 3 - - QLCDNumber::Flat + + + + Mapping + + + + :/uielements/curves.png:/uielements/curves.png + + + + 91 + 20 + + + + + + + + Keys + + + + :/uielements/tools.png:/uielements/tools.png + + + + 98 + 24 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + Controls + + + + 6 + + + 6 + + + 3 - - - - - - - - - - - 10 - 10 - 166 - 211 - - - - - 0 - 0 - - - - Tracking preview - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - + + + + false + + + + 0 + 0 + + + + Stop + + + + + + + + 0 + 0 + + + + Start + + + + + + + + + + -- cgit v1.2.3 From ffa06a093c0ca6a1024db9b013fe52d87bb2553f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 14:05:48 +0200 Subject: fix several instances of same group not refreshing --- facetracknoir/options.h | 144 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 95 insertions(+), 49 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 37377b55b..b4b1f0f78 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -8,9 +8,11 @@ #pragma once #include +#include +#include + #include #include -#include #include #include #include @@ -25,9 +27,14 @@ #include #include +#include + #include namespace options { + template + using map = std::map; + template // don't elide usages of the function, qvariant default implicit // conversion results in nonsensical runtime behavior -sh @@ -66,7 +73,7 @@ namespace options { // snapshot of qsettings group at given time class group { private: - QMap map; + map map; QString name; static const QString ini_pathname() { @@ -85,39 +92,42 @@ namespace options { } static constexpr const char* org = "opentrack"; - void save() { + void save() + { QSettings s(ini_pathname(), QSettings::IniFormat); s.beginGroup(name); - for (auto& k : map.keys()) - s.setValue(k, map[k]); + for (auto& i : map) + s.setValue(i.first, map[i.first]); s.endGroup(); } + template - t get(const QString& k) { - return qcruft_to_t(map.value(k)); + t get(const QString& k) + { + return qcruft_to_t(map[k]); } + void put(const QString& s, const QVariant& d) { map[s] = d; } + bool contains(const QString& s) { - return map.contains(s); + return map.count(s) != 0; } }; class impl_bundle : public QObject { Q_OBJECT - private: + protected: QMutex mtx; const QString group_name; group saved; group transient; + bool modified; impl_bundle(const impl_bundle&) = delete; impl_bundle& operator=(const impl_bundle&) = delete; - bool modified; - signals: - void changed(); public: impl_bundle(const QString& group_name) : mtx(QMutex::Recursive), @@ -127,25 +137,32 @@ namespace options { modified(false) { } + + QString name() { return group_name; } + void reload() { QMutexLocker l(&mtx); saved = group(group_name); transient = saved; + modified = false; } - void store_kv(const QString& name, const QVariant& datum) + + bool store_kv(const QString& name, const QVariant& datum) { QMutexLocker l(&mtx); + auto old = transient.get(name); if (!transient.contains(name) || datum != old) { if (!modified) - qDebug() << "bundle" << group_name << - "modified due to" << name << - transient.get(name) << - old << "->" << datum; + qDebug() << "bundle" << (intptr_t)static_cast(this) << + "modified as per" << name << old << "->" << datum; + modified = true; transient.put(name, datum); + return true; } + return false; } bool contains(const QString& name) { @@ -153,7 +170,8 @@ namespace options { return transient.contains(name); } template - t get(const QString& name) { + t get(const QString& name) + { QMutexLocker l(&mtx); return transient.get(name); } @@ -163,14 +181,6 @@ namespace options { modified = false; saved = transient; transient.save(); - emit changed(); - } - void revert() - { - QMutexLocker l(&mtx); - modified = false; - transient = saved; - emit changed(); } bool modifiedp() { @@ -178,15 +188,64 @@ namespace options { return modified; } }; - - using pbundle = std::shared_ptr; + + class opt_bundle; + using pbundle = std::shared_ptr; + + namespace { + using tt = std::tuple; + + QMutex implsgl_mtx(QMutex::Recursive); + map implsgl_bundles; + } + + class opt_bundle : public impl_bundle + { + public: + opt_bundle() : impl_bundle("i-have-no-name") {} + opt_bundle(const QString& group_name) : impl_bundle(group_name) {} + + ~opt_bundle() + { + QMutexLocker l(&implsgl_mtx); + + if (--std::get<0>(implsgl_bundles[this->group_name]) == 0) + implsgl_bundles.erase(this->group_name); + } + }; + + inline pbundle bundle(const QString& group) { + QMutexLocker l(&implsgl_mtx); + + if (implsgl_bundles.count(group) != 0) + return std::get<1>(implsgl_bundles[group]); + + auto shr = std::make_shared(group); + implsgl_bundles[group] = tt(1,shr); + return shr; + } class base_value : public QObject { Q_OBJECT #define DEFINE_SLOT(t) void setValue(t datum) { store(datum); } -#define DEFINE_SIGNAL(t) void valueChanged(t); +#define DEFINE_SIGNAL(t) void valueChanged(const t&) public: - base_value(pbundle b, const QString& name) : b(b), self_name(name) {} + base_value(pbundle b, const QString& name) : b(b), self_name(name), reentrancy_count(0) {} + protected: + pbundle b; + QString self_name; + + template + void store(const t& datum) + { + reentrancy_count++; + if (b->store_kv(self_name, datum)) + if (reentrancy_count == 0) + emit valueChanged(datum); + reentrancy_count--; + } + private: + volatile char reentrancy_count; public slots: DEFINE_SLOT(double) DEFINE_SLOT(int) @@ -197,34 +256,25 @@ namespace options { DEFINE_SIGNAL(int); DEFINE_SIGNAL(bool); DEFINE_SIGNAL(QString); - // Qt5 moc really insists on that one -sh 20141012 - DEFINE_SIGNAL(QVariant); - protected: - pbundle b; - QString self_name; - - template - void store(const t& datum) - { - b->store_kv(self_name, datum); - emit valueChanged(static_cast(datum)); - } }; template class value : public base_value { public: - t operator=(const t& datum) + t operator=(const t datum) { - store(qVariantFromValue(datum)); + store(datum); return datum; } static constexpr const Qt::ConnectionType DIRECT_CONNTYPE = Qt::DirectConnection; - static constexpr const Qt::ConnectionType SAFE_CONNTYPE = Qt::AutoConnection; + static constexpr const Qt::ConnectionType SAFE_CONNTYPE = Qt::BlockingQueuedConnection; value(pbundle b, const QString& name, t def) : base_value(b, name) { if (!b->contains(name) || b->get(name).type() == QVariant::Invalid) + { + qDebug() << "new option" << *(t*)this; *this = def; + } } operator t() { @@ -300,8 +350,4 @@ namespace options { lb->setText(v); base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.SAFE_CONNTYPE); } - - inline pbundle bundle(const QString& group) { - return std::make_shared(group); - } } -- cgit v1.2.3 From 1fdd53b6f652419f0f63c6846660f80ec672853a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 14:06:14 +0200 Subject: update options api --- facetracknoir/shortcuts.cpp | 2 +- ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 2 +- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 2 +- ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 2 +- ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp | 2 +- ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp | 2 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 758617caa..94c46376c 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -40,7 +40,7 @@ void KeyboardShortcutDialog::doOK() { } void KeyboardShortcutDialog::doCancel() { - mainApp->b->revert(); + mainApp->s.b->reload(); close(); } diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 965cb3ea5..1520ad6e2 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -43,7 +43,7 @@ void FilterControls::doCancel() { void FilterControls::discard() { - s.b->revert(); + s.b->reload(); } void FilterControls::save() { diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index a32875b93..b6bde553e 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -33,7 +33,7 @@ void FilterControls::doOK() { } void FilterControls::doCancel() { - s.b->revert(); + s.b->reload(); this->close(); } diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index 1aa67b433..0074a64a0 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -59,7 +59,7 @@ void FGControls::doOK() { } void FGControls::doCancel() { - s.b->revert(); + s.b->reload(); this->close(); } diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index d2af714ff..ceabeabfe 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -42,7 +42,7 @@ void FSUIPCControls::doOK() { } void FSUIPCControls::doCancel() { - s.b->revert(); + s.b->reload(); close(); } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index 654f6c18c..9db3211c4 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -59,7 +59,7 @@ void FTControls::doOK() { } void FTControls::doCancel() { - s.b->revert(); + s.b->reload(); this->close(); } diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index cab5b4ba9..8af12ad76 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -52,7 +52,7 @@ void FTNControls::doOK() { // Cancel clicked on server-dialog // void FTNControls::doCancel() { - s.b->revert(); + s.b->reload(); this->close(); } diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index 4b12a4f0e..efac958ce 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -59,7 +59,7 @@ void MOUSEControls::doOK() { } void MOUSEControls::doCancel() { - s.b->revert(); + s.b->reload(); this->close(); } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index cd8c21f91..c3d64e9d7 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -44,7 +44,7 @@ void SCControls::doOK() { } void SCControls::doCancel() { - s.b->revert(); + s.b->reload(); close(); } diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp index 5a0cade45..6d6a951e4 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp @@ -17,7 +17,7 @@ void TrackerDialog::doOK() { } void TrackerDialog::doCancel() { - s.b->revert(); + s.b->reload(); this->close(); } diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 05eb116c4..a1cb33a5a 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -267,6 +267,6 @@ void TrackerControls::doOK() void TrackerControls::doCancel() { - s.b->revert(); + s.b->reload(); this->close(); } diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index dbd9981fa..c81ddce7d 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -17,7 +17,7 @@ void TrackerControls::doOK() { } void TrackerControls::doCancel() { - s.b->revert(); + s.b->reload(); close(); } diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 4ddbcb0c8..84e02fb01 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -49,7 +49,7 @@ void TrackerControls::doOK() { } void TrackerControls::doCancel() { - s.b->revert(); + s.b->reload(); this->close(); } diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index 3af7b5605..981cbea02 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -230,7 +230,7 @@ void TrackerDialog::doApply() void TrackerDialog::doCancel() { - s.b->revert(); + s.b->reload(); close(); } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index a66eb83b7..38c7457e2 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -21,7 +21,7 @@ void TrackerControls::doOK() { } void TrackerControls::doCancel() { - s.b->revert(); + s.b->reload(); close(); } diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index b0f40ee94..062b18995 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -18,7 +18,7 @@ void TrackerControls::doOK() { } void TrackerControls::doCancel() { - s.b->revert(); + s.b->reload(); this->close(); } -- cgit v1.2.3 From 8aff21e4e73aa2517dc433da12202fd8c6052783 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 19:19:13 +0200 Subject: merely nits --- facetracknoir/options.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index b4b1f0f78..27d7eed75 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -97,7 +97,7 @@ namespace options { QSettings s(ini_pathname(), QSettings::IniFormat); s.beginGroup(name); for (auto& i : map) - s.setValue(i.first, map[i.first]); + s.setValue(i.first, i.second); s.endGroup(); } @@ -210,7 +210,10 @@ namespace options { QMutexLocker l(&implsgl_mtx); if (--std::get<0>(implsgl_bundles[this->group_name]) == 0) + { + qDebug() << "bundle" << this->group_name << "not used anymore"; implsgl_bundles.erase(this->group_name); + } } }; -- cgit v1.2.3 From 7254de89f65817de879c2f04f53ec598b283cbab Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 19:46:49 +0200 Subject: nix debug printf --- facetracknoir/options.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 27d7eed75..de445e692 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -274,10 +274,7 @@ namespace options { value(pbundle b, const QString& name, t def) : base_value(b, name) { if (!b->contains(name) || b->get(name).type() == QVariant::Invalid) - { - qDebug() << "new option" << *(t*)this; *this = def; - } } operator t() { -- cgit v1.2.3 From 345b4bf257b805ea1d2903b921e95e4be20eded5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 19:47:28 +0200 Subject: octopii width, srs business so you don't hafta --- facetracknoir/facetracknoir.ui | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 32aea889e..ad968030d 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -40,26 +40,11 @@ Tracking preview - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - 0 + 90 120 -- cgit v1.2.3 From e79d33c5eeecf12d6777fe2d5619f1e5d6c782c2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 20:55:19 +0200 Subject: nix crash on exit, add more stl, less qt --- facetracknoir/options.h | 131 ++++++++++++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 48 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index de445e692..b55d2bf0a 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,7 @@ namespace options { template using map = std::map; + using std::string; template // don't elide usages of the function, qvariant default implicit @@ -73,8 +75,8 @@ namespace options { // snapshot of qsettings group at given time class group { private: - map map; - QString name; + map map; + string name; static const QString ini_pathname() { QSettings settings(group::org); @@ -82,12 +84,17 @@ namespace options { QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); } public: - group(const QString& name) : name(name) + group(const string& name) : name(name) { QSettings conf(ini_pathname(), QSettings::IniFormat); - conf.beginGroup(name); - for (auto& k : conf.childKeys()) - map[k] = conf.value(k); + auto q_name = QString::fromStdString(name); + conf.beginGroup(q_name); + for (auto& k_ : conf.childKeys()) + { + auto tmp = k_.toUtf8(); + string k(tmp); + map[k] = conf.value(k_); + } conf.endGroup(); } static constexpr const char* org = "opentrack"; @@ -95,24 +102,28 @@ namespace options { void save() { QSettings s(ini_pathname(), QSettings::IniFormat); - s.beginGroup(name); + auto q_name = QString::fromStdString(name); + s.beginGroup(q_name); for (auto& i : map) - s.setValue(i.first, i.second); + { + auto k = QString::fromStdString(i.first); + s.setValue(k, i.second); + } s.endGroup(); } template - t get(const QString& k) + t get(const string& k) { return qcruft_to_t(map[k]); } - void put(const QString& s, const QVariant& d) + void put(const string& s, const QVariant& d) { map[s] = d; } - bool contains(const QString& s) + bool contains(const string& s) { return map.count(s) != 0; } @@ -122,14 +133,14 @@ namespace options { Q_OBJECT protected: QMutex mtx; - const QString group_name; + const string group_name; group saved; group transient; bool modified; impl_bundle(const impl_bundle&) = delete; impl_bundle& operator=(const impl_bundle&) = delete; public: - impl_bundle(const QString& group_name) : + impl_bundle(const string& group_name) : mtx(QMutex::Recursive), group_name(group_name), saved(group_name), @@ -138,7 +149,7 @@ namespace options { { } - QString name() { return group_name; } + string name() { return group_name; } void reload() { QMutexLocker l(&mtx); @@ -147,30 +158,26 @@ namespace options { modified = false; } - bool store_kv(const QString& name, const QVariant& datum) + bool store_kv(const string& name, const QVariant& datum) { QMutexLocker l(&mtx); auto old = transient.get(name); if (!transient.contains(name) || datum != old) { - if (!modified) - qDebug() << "bundle" << (intptr_t)static_cast(this) << - "modified as per" << name << old << "->" << datum; - modified = true; transient.put(name, datum); return true; } return false; } - bool contains(const QString& name) + bool contains(const string& name) { QMutexLocker l(&mtx); return transient.contains(name); } template - t get(const QString& name) + t get(const string& name) { QMutexLocker l(&mtx); return transient.get(name); @@ -190,53 +197,72 @@ namespace options { }; class opt_bundle; - using pbundle = std::shared_ptr; - namespace { - using tt = std::tuple; + namespace + { + template + struct opt_singleton + { + public: + using pbundle = std::shared_ptr; + using tt = std::tuple; + private: + QMutex implsgl_mtx; + map implsgl_data; + public: + opt_singleton() : implsgl_mtx(QMutex::Recursive) {} + + pbundle bundle(const k& key) + { + QMutexLocker l(&implsgl_mtx); + + if (implsgl_data.count(key) != 0) + return std::get<1>(implsgl_data[key]); + + auto shr = std::make_shared(key); + implsgl_data[key] = tt(cnt(1), shr); + return shr; + } + + void bundle_decf(const k& key) + { + QMutexLocker l(&implsgl_mtx); + + if (--std::get<0>(implsgl_data[key]) == 0) + implsgl_data.erase(key); + } + + ~opt_singleton() { implsgl_data.clear(); } + }; - QMutex implsgl_mtx(QMutex::Recursive); - map implsgl_bundles; + using pbundle = std::shared_ptr; + using t_fact = opt_singleton; + static t_fact* opt_factory = new t_fact; } + + static inline t_fact::pbundle bundle(const string name) { return opt_factory->bundle(name); } class opt_bundle : public impl_bundle { public: opt_bundle() : impl_bundle("i-have-no-name") {} - opt_bundle(const QString& group_name) : impl_bundle(group_name) {} + opt_bundle(const string& group_name) : impl_bundle(group_name) {} ~opt_bundle() { - QMutexLocker l(&implsgl_mtx); - - if (--std::get<0>(implsgl_bundles[this->group_name]) == 0) - { - qDebug() << "bundle" << this->group_name << "not used anymore"; - implsgl_bundles.erase(this->group_name); - } + opt_factory->bundle_decf(this->group_name); } }; - - inline pbundle bundle(const QString& group) { - QMutexLocker l(&implsgl_mtx); - - if (implsgl_bundles.count(group) != 0) - return std::get<1>(implsgl_bundles[group]); - - auto shr = std::make_shared(group); - implsgl_bundles[group] = tt(1,shr); - return shr; - } class base_value : public QObject { Q_OBJECT #define DEFINE_SLOT(t) void setValue(t datum) { store(datum); } #define DEFINE_SIGNAL(t) void valueChanged(const t&) public: - base_value(pbundle b, const QString& name) : b(b), self_name(name), reentrancy_count(0) {} + base_value(pbundle b, const string& name) : b(b), self_name(name), reentrancy_count(0) {} protected: pbundle b; - QString self_name; + string self_name; template void store(const t& datum) @@ -260,6 +286,12 @@ namespace options { DEFINE_SIGNAL(bool); DEFINE_SIGNAL(QString); }; + + static inline string string_from_qstring(const QString& datum) + { + auto tmp = datum.toUtf8(); + return string(tmp.constData()); + } template class value : public base_value { @@ -271,11 +303,14 @@ namespace options { } static constexpr const Qt::ConnectionType DIRECT_CONNTYPE = Qt::DirectConnection; static constexpr const Qt::ConnectionType SAFE_CONNTYPE = Qt::BlockingQueuedConnection; - value(pbundle b, const QString& name, t def) : base_value(b, name) + value(pbundle b, const string& name, t def) : base_value(b, name) { if (!b->contains(name) || b->get(name).type() == QVariant::Invalid) *this = def; } + value(pbundle b, const QString& name, t def) : value(b, string_from_qstring(name), def) {} + value(pbundle b, const char* name, t def) : value(b, string(name), def) {} + operator t() { return b->get(self_name); -- cgit v1.2.3 From 26e9257cc97e7496912254c945943bdc69d14007 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 22:21:16 +0200 Subject: fix calibration dialog in aruco/pt --- facetracknoir/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index b55d2bf0a..ffabd7565 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -269,7 +269,7 @@ namespace options { { reentrancy_count++; if (b->store_kv(self_name, datum)) - if (reentrancy_count == 0) + if (reentrancy_count <= 3) emit valueChanged(datum); reentrancy_count--; } @@ -302,7 +302,7 @@ namespace options { return datum; } static constexpr const Qt::ConnectionType DIRECT_CONNTYPE = Qt::DirectConnection; - static constexpr const Qt::ConnectionType SAFE_CONNTYPE = Qt::BlockingQueuedConnection; + static constexpr const Qt::ConnectionType SAFE_CONNTYPE = Qt::UniqueConnection; value(pbundle b, const string& name, t def) : base_value(b, name) { if (!b->contains(name) || b->get(name).type() == QVariant::Invalid) -- cgit v1.2.3 From 2e79bf5e7c232aa8e09ea410083fce87330bbe3c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 22:57:34 +0200 Subject: drop guard, only relevant in direct/blockingqueued --- facetracknoir/options.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index ffabd7565..7833ea41a 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -259,7 +259,7 @@ namespace options { #define DEFINE_SLOT(t) void setValue(t datum) { store(datum); } #define DEFINE_SIGNAL(t) void valueChanged(const t&) public: - base_value(pbundle b, const string& name) : b(b), self_name(name), reentrancy_count(0) {} + base_value(pbundle b, const string& name) : b(b), self_name(name) {} protected: pbundle b; string self_name; @@ -267,14 +267,9 @@ namespace options { template void store(const t& datum) { - reentrancy_count++; if (b->store_kv(self_name, datum)) - if (reentrancy_count <= 3) - emit valueChanged(datum); - reentrancy_count--; + emit valueChanged(datum); } - private: - volatile char reentrancy_count; public slots: DEFINE_SLOT(double) DEFINE_SLOT(int) -- cgit v1.2.3