From 18001ba72d8472697fafdcbd7fa8873e792d5f64 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 06:28:57 +0200 Subject: ui: fix close on save stopping the timer prevented maybe_save() from working --- facetracknoir/ui.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 0672d24a..ad3c4886 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -126,12 +126,11 @@ bool MainWindow::get_new_config_name_from_dialog(QString& ret) MainWindow::~MainWindow() { - save_timer.stop(); + maybe_save(); if (tray) tray->hide(); stopTracker(); - maybe_save(); } void MainWindow::set_working_directory() -- cgit v1.2.3 From 629875abd995f46f99b3cba3387faa7367a6f823 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 07:06:29 +0200 Subject: main, ui: fix sort order Sort order was applied only to combobox but not to tracker list. Reported-by: @nanospork cf. https://github.com/opentrack/opentrack/issues/231#issuecomment-145741998 --- facetracknoir/ui.cpp | 13 +++---------- opentrack/plugin-support.hpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index ad3c4886..d90fc762 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -19,13 +19,6 @@ # include #endif -template -static QList sorted(QList xs) -{ - std::sort(xs.begin(), xs.end(), [&](const t& a, const t& b) { return a->name.toLower() < b->name.toLower(); }); - return xs; -} - MainWindow::MainWindow() : pose_update_timer(this), kbd_quit(QKeySequence("Ctrl+Q"), this), @@ -47,13 +40,13 @@ MainWindow::MainWindow() : modules.filters().push_front(std::make_shared("", dylib::Filter)); - for (auto x : sorted(modules.trackers())) + for (auto x : modules.trackers()) ui.iconcomboTrackerSource->addItem(x->icon, x->name); - for (auto x : sorted(modules.protocols())) + for (auto x : modules.protocols()) ui.iconcomboProtocol->addItem(x->icon, x->name); - for (auto x : sorted(modules.filters())) + for (auto x : modules.filters()) ui.iconcomboFilter->addItem(x->icon, x->name); refresh_config_list(); diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index 8efda800..102d11c4 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -245,6 +246,12 @@ private: QList> filter_modules; QList> tracker_modules; QList> protocol_modules; + + template + static void sort(QList& xs) + { + std::sort(xs.begin(), xs.end(), [&](const t& a, const t& b) { return a->name.toLower() < b->name.toLower(); }); + } QList> filter(dylib::Type t) { @@ -252,6 +259,9 @@ private: for (auto x : module_list) if (x->type == t) ret.push_back(x); + + sort(ret); + return ret; } }; -- cgit v1.2.3 From c89ef2fe9cb1d681b1b3acdabee1786eabdf1051 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 07:07:10 +0200 Subject: csv: cleanup --- csv/csv.cpp | 15 ++++++++------- csv/csv.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/csv/csv.cpp b/csv/csv.cpp index 4c754542..1ae567a4 100644 --- a/csv/csv.cpp +++ b/csv/csv.cpp @@ -92,7 +92,7 @@ QStringList CSV::parseLine(QString line){ return list; } -void CSV::getGameData( const int id, unsigned char* table, QString& gamename) +bool CSV::getGameData( const int id, unsigned char* table, QString& gamename) { QString gameID = QString::number(id); @@ -104,12 +104,11 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) QFile file(QCoreApplication::applicationDirPath() + "/settings/facetracknoir supported games.csv"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - return; + return false; } CSV csv(&file); - gameLine = csv.parseLine(); - while (gameLine.count() > 2) { + while (gameLine = csv.parseLine(), gameLine.count() > 2) { //qDebug() << "Column 0: " << gameLine.at(0); // No. //qDebug() << "Column 1: " << gameLine.at(1); // Game Name //qDebug() << "Column 2: " << gameLine.at(2); // Game Protocol @@ -124,9 +123,11 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) QByteArray id = gameLine.at(7).toLatin1(); unsigned char tmp[8]; unsigned char fuzz[3]; + bool ret = true; if (gameLine.at(3) == QString("V160")) { qDebug() << "no table"; + ret = false; } else if (sscanf(id.constData(), "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx", @@ -143,6 +144,7 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) fuzz + 1) != 11) { qDebug() << "scanf failed" << fuzz[0] << fuzz[1] << fuzz[2]; + ret = false; } else for (int i = 0; i < 8; i++) @@ -150,13 +152,12 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) qDebug() << gameID << "game-id" << gameLine.at(7); gamename = gameLine.at(1); file.close(); - return; + return ret; } } - - gameLine = csv.parseLine(); } qDebug() << "Unknown game connected" << gameID; file.close(); + return false; } diff --git a/csv/csv.h b/csv/csv.h index 80fbcac4..a896a076 100644 --- a/csv/csv.h +++ b/csv/csv.h @@ -14,7 +14,7 @@ public: static QStringList parseLine(QString line); void setCodec(const char* codecName); - static void getGameData(const int gameID, unsigned char* table, QString& gamename); + static bool getGameData(const int gameID, unsigned char* table, QString& gamename); private: QIODevice *m_device; QTextCodec *m_codec; -- cgit v1.2.3 From a50d81c55c4364c7096fc8abcd19cfe6e25b1c07 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 07:08:25 +0200 Subject: ft: cleanup comments --- freetrackclient/fttypes.h | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 41 +++++++++++++++++-------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/freetrackclient/fttypes.h b/freetrackclient/fttypes.h index 8611017a..050ffc02 100644 --- a/freetrackclient/fttypes.h +++ b/freetrackclient/fttypes.h @@ -31,7 +31,7 @@ typedef __int32 int32_t; /* only 6 headpose floats and the data id are filled -sh */ typedef struct __FTData { - volatile int DataID; + volatile unsigned int DataID; volatile int CamWidth; volatile int CamHeight; /* virtual pose */ diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 97caaefc..6259029f 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -98,9 +98,8 @@ void FTNoIR_Protocol::pose(const double* headpose) { QString gamename; { unsigned char table[8]; - for (int i = 0; i < 8; i++) table[i] = pMemData->table[i]; - CSV::getGameData(id, table, gamename); - for (int i = 0; i < 8; i++) pMemData->table[i] = table[i]; + if (CSV::getGameData(id, table, gamename)) + for (int i = 0; i < 8; i++) pMemData->table[i] = table[i]; } ft->GameID2 = id; intGameID = id; @@ -148,8 +147,9 @@ void FTNoIR_Protocol::start_dummy() { bool FTNoIR_Protocol::correct() { - QSettings settings("Freetrack", "FreetrackClient"); // Registry settings (in HK_USER) - QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) + // Registry settings (in HK_USER) + QSettings settings("Freetrack", "FreetrackClient"); + QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); if (!shm.success()) return false; @@ -157,20 +157,23 @@ bool FTNoIR_Protocol::correct() QString aLocation = QCoreApplication::applicationDirPath() + "/"; switch (s.intUsedInterface) { - case 0: // Use both interfaces - settings.setValue( "Path" , aLocation ); - settingsTIR.setValue( "Path" , aLocation ); - break; - case 1: // Use FreeTrack, disable TrackIR - settings.setValue( "Path" , aLocation ); - settingsTIR.setValue( "Path" , "" ); - break; - case 2: // Use TrackIR, disable FreeTrack - settings.setValue( "Path" , "" ); - settingsTIR.setValue( "Path" , aLocation ); - break; - default: - break; + case 0: + // Use both interfaces + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , aLocation ); + break; + case 1: + // Use FreeTrack, disable TrackIR + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , "" ); + break; + case 2: + // Use TrackIR, disable FreeTrack + settings.setValue( "Path" , "" ); + settingsTIR.setValue( "Path" , aLocation ); + break; + default: + break; } if (s.useTIRViews) { -- cgit v1.2.3 From 58e93b106a637b9a3f9f9de90d93301f0215c8b9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 07:08:52 +0200 Subject: ft: try without locking this time --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 6259029f..d825afb1 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -66,8 +66,6 @@ void FTNoIR_Protocol::pose(const double* headpose) { FTHeap* ft = pMemData; FTData* data = &ft->data; - shm.lock(); - data->RawX = 0; data->RawY = 0; data->RawZ = 0; @@ -108,8 +106,6 @@ void FTNoIR_Protocol::pose(const double* headpose) { } data->DataID += 1; - - shm.unlock(); } void FTNoIR_Protocol::start_tirviews() { -- cgit v1.2.3 From d569546d6bee9a6942551ac5d71b4ce569f58448 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 07:29:59 +0200 Subject: accela: revert rot gains to rc15 --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 7f1d9d0a..acb196c8 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -12,11 +12,12 @@ #include "opentrack/plugin-api.hpp" static constexpr double rot_gains[][2] = { - { 2.66, 105 }, - { 2.0, 47 }, - { 1.66, 25 }, - { 1.33, 11 }, - { 1, 3.5 }, + { 2.66, 110 }, + { 2.33, 80 }, + { 2, 50 }, + { 1.66, 30 }, + { 1.33, 15 }, + { 1, 5 }, { .66, 1.4 }, { .33, .4 }, { 0, 0 }, -- cgit v1.2.3 From 82c3f7b913643a7f7512b0c6736e9d76bde883ae Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 07:30:08 +0200 Subject: shortcuts: sleep less, drop less keystrokes --- opentrack/shortcuts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentrack/shortcuts.cpp b/opentrack/shortcuts.cpp index e20fa1c0..a3c0773b 100644 --- a/opentrack/shortcuts.cpp +++ b/opentrack/shortcuts.cpp @@ -107,7 +107,7 @@ void KeybindingWorker::run() { } // keypresses get dropped with high values - Sleep(15); + Sleep(8); } } #endif -- cgit v1.2.3 From 7abfd9593409bb0c16f4ee6d19fea14d7e85c57d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 08:07:15 +0200 Subject: qfc: double the discrete value count --- qfunctionconfigurator/functionconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index d49a8f7b..d180928f 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -19,7 +19,7 @@ class Map { private: - static constexpr int value_count = 5000; + static constexpr int value_count = 10000; using num = double; using integral = std::uint16_t; static constexpr integral integral_max = std::numeric_limits::max(); -- cgit v1.2.3