From f4b1e06604c74bb56a88c7e9284c77ffbd1acc78 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jul 2015 12:44:13 +0200 Subject: make "make_dylib_instance" part of public API For @gagagu. Issue: #151 --- opentrack/plugin-support.hpp | 9 +++++++++ opentrack/selected-libraries.cpp | 15 +++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index 627bce6a..32f79e0e 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -247,3 +247,12 @@ private: return ret; } }; + +template +mem make_dylib_instance(mem lib) +{ + mem ret; + if (lib != nullptr && lib->Constructor) + ret = mem(reinterpret_cast(reinterpret_cast(lib->Constructor)())); + return ret; +} diff --git a/opentrack/selected-libraries.cpp b/opentrack/selected-libraries.cpp index 7617ce90..c39ee3f5 100644 --- a/opentrack/selected-libraries.cpp +++ b/opentrack/selected-libraries.cpp @@ -5,22 +5,13 @@ SelectedLibraries::~SelectedLibraries() { } -template -static mem make_instance(mem lib) -{ - mem ret; - if (lib != nullptr && lib->Constructor) - ret = mem(reinterpret_cast(reinterpret_cast(lib->Constructor)())); - return ret; -} - SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) : pTracker(nullptr), pFilter(nullptr), pProtocol(nullptr), correct(false) { - pProtocol = make_instance(p); + pProtocol = make_dylib_instance(p); if (!pProtocol) { @@ -35,8 +26,8 @@ SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dyli return; } - pTracker = make_instance(t); - pFilter = make_instance(f); + pTracker = make_dylib_instance(t); + pFilter = make_dylib_instance(f); if (!pTracker) { -- cgit v1.2.3 From 03ba7a0bc6bc2465c6487d38b70c33e3690584be Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 06:39:57 +0200 Subject: remove --autostart option Author said he no longer needs it. --- facetracknoir/main.cpp | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 6d29e3b5..326b40ec 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -60,34 +60,14 @@ int main(int argc, char** argv) QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); - QCommandLineParser p; - p.setApplicationDescription("opentrack - Head tracking software for MS Windows, Linux, and Apple OSX"); - p.addHelpOption(); - QCommandLineOption autostartOption(QStringList() << "a" << "autostart", "Load and start tracking", "profile"); - p.addOption(autostartOption); - p.process(app); - - QString profile = p.value(autostartOption); - - bool use_profile = profile.endsWith(".ini") && QFileInfo(profile).exists() && QFileInfo(profile).isFile(); - if (!profile.isEmpty() && !use_profile) - QMessageBox::warning(nullptr, "Can't load profile", "Profile " + profile + " specified but can't be opened!", - QMessageBox::Ok, QMessageBox::NoButton); - - if (use_profile) - MainWindow::set_profile(profile); - auto w = std::make_shared(); - - if (use_profile) - w->startTracker(); - + w->show(); app.exec(); - // on MSVC crashes in atexit + // on MSVC crashes in atexit #ifdef _MSC_VER - TerminateProcess(GetCurrentProcess(), 0); + TerminateProcess(GetCurrentProcess(), 0); #endif return 0; } -- cgit v1.2.3 From 0e4dedcac5071cf29baf6130e0b54e3d3ae719bd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 06:43:25 +0200 Subject: ui: simplify dialog creation --- facetracknoir/ui.cpp | 105 +++++++++++++++++++-------------------------------- 1 file changed, 39 insertions(+), 66 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 10445182..416a619c 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -340,100 +340,73 @@ void MainWindow::showHeadPose() } template -mem mk_dialog(mem lib) +bool mk_dialog(mem lib, mem* orig) { + if (*orig && (*orig)->isVisible()) + { + (*orig)->show(); + (*orig)->raise(); + return false; + } + if (lib && lib->Dialog) { auto dialog = mem(reinterpret_cast(lib->Dialog())); dialog->setWindowFlags(Qt::Dialog); dialog->setFixedSize(dialog->size()); - return dialog; + + *orig = dialog; + dialog->show(); + dialog->raise(); + + return true; } - return nullptr; + return false; } void MainWindow::showTrackerSettings() { - if (pTrackerDialog && pTrackerDialog->isVisible()) - { - pTrackerDialog->show(); - pTrackerDialog->raise(); - } - else - { - auto dialog = mk_dialog(current_tracker()); - if (!dialog) return; - pTrackerDialog = dialog; - if (libs.pTracker != nullptr) - dialog->register_tracker(libs.pTracker.get()); - dialog->show(); - dialog->raise(); - } + if (mk_dialog(current_tracker(), &pTrackerDialog) && libs.pTracker) + pTrackerDialog->register_tracker(libs.pTracker.get()); } void MainWindow::showProtocolSettings() { - if (pProtocolDialog && pProtocolDialog->isVisible()) - { - pProtocolDialog->show(); - pProtocolDialog->raise(); - } else - { - auto dialog = mk_dialog(current_protocol()); - if (!dialog) return; - pProtocolDialog = dialog; - if (libs.pProtocol != nullptr) - dialog->register_protocol(libs.pProtocol.get()); - dialog->show(); - dialog->raise(); - } + if (mk_dialog(current_tracker(), &pProtocolDialog) && libs.pProtocol) + pProtocolDialog->register_protocol(libs.pProtocol.get()); } void MainWindow::showFilterSettings() { - if (pFilterDialog && pFilterDialog->isVisible()) - { - pFilterDialog->show(); - pFilterDialog->raise(); - } else - { - auto dialog = mk_dialog(current_filter()); - if (!dialog) return; - pFilterDialog = dialog; - if (libs.pFilter != nullptr) - dialog->register_filter(libs.pFilter.get()); - dialog->show(); - dialog->raise(); - } + if (mk_dialog(current_tracker(), &pFilterDialog) && libs.pFilter) + pFilterDialog->register_filter(libs.pFilter.get()); } -void MainWindow::showKeyboardShortcuts() { - if (shortcuts_widget && shortcuts_widget->isVisible()) +template +bool mk_window(mem* place, Args... params) +{ + if (*place && (*place)->isVisible()) { - shortcuts_widget->show(); - shortcuts_widget->raise(); + (*place)->show(); + (*place)->raise(); + return false; } else { - shortcuts_widget = std::make_shared(); - shortcuts_widget->setWindowFlags(Qt::Dialog); - connect(shortcuts_widget.get(), SIGNAL(reload()), this, SLOT(bindKeyboardShortcuts())); - shortcuts_widget->show(); - shortcuts_widget->raise(); + *place = std::make_shared(params...); + (*place)->setWindowFlags(Qt::Dialog); + (*place)->show(); + (*place)->raise(); + return true; } } +void MainWindow::showKeyboardShortcuts() { + if (mk_window(&shortcuts_widget)) + connect(shortcuts_widget.get(), SIGNAL(reload()), this, SLOT(bindKeyboardShortcuts())); +} + void MainWindow::showCurveConfiguration() { - if (mapping_widget && mapping_widget->isVisible()) - { - mapping_widget->show(); - mapping_widget->raise(); - } - else - { - mapping_widget = std::make_shared(pose, s); - mapping_widget->setWindowFlags(Qt::Dialog); - mapping_widget->show(); - } + mk_window(&mapping_widget, pose, s); } void MainWindow::exit() { -- cgit v1.2.3 From e6828869411281e089c7ec9d5d27dfa0d136daf2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 06:47:50 +0200 Subject: add credit for hatire authorship --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 85139930..4abcdf07 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Not to be confused with railway planning software <> - Relaying UDP via FreePIE-specific Android app - Joystick analog axes (Windows, Linux) - Windows Phone [tracker](http://www.windowsphone.com/en-us/store/app/opentrack-head-tracking/1c604f32-6d68-40ef-aa44-3163e30f547f) over opentrack UDP protocol +- Arduino with custom firmware # Output @@ -59,6 +60,7 @@ Don't be afraid to submit an issue/feature request if need arises. - Ryan Spicer (OSX tester, contributor) - Patrick Ruoff (PT tracker) - Ulf Schreiber (PT tracker) +- furax49 (hatire tracker) - Andrzej Czarnowski (quality assurance) - uglyDwarf (high CON) - Wim Vriend (historically) -- cgit v1.2.3 From 71b9202dbd592996478cb3ab67a84c23fd98368e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 07:45:35 +0200 Subject: opentrack-api: add copyright notices Code without a license defaults to having all rights reserved. --- opentrack/mappings.hpp | 7 +++++++ opentrack/options.hpp | 2 +- opentrack/plugin-support.hpp | 4 ++-- opentrack/selected-libraries.hpp | 8 ++++++++ opentrack/shortcuts.h | 8 ++++++++ opentrack/simple-mat.hpp | 8 ++++++++ opentrack/state.hpp | 8 ++++++++ opentrack/thread.hpp | 8 ++++++++ opentrack/timer.hpp | 8 ++++++++ opentrack/tracker.h | 8 ++++++++ opentrack/work.hpp | 8 ++++++++ 11 files changed, 74 insertions(+), 3 deletions(-) diff --git a/opentrack/mappings.hpp b/opentrack/mappings.hpp index 3336dcd8..650e6f99 100644 --- a/opentrack/mappings.hpp +++ b/opentrack/mappings.hpp @@ -1,3 +1,10 @@ +/* Copyright (c) 2014-2015 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. + */ + #pragma once #include diff --git a/opentrack/options.hpp b/opentrack/options.hpp index a10ba382..f4deb8a1 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2014 Stanislaw Halik +/* Copyright (c) 2013-2015 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 diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index 32f79e0e..ec8bb3c8 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -1,5 +1,3 @@ -#pragma once - /* Copyright (c) 2015 Stanislaw Halik * * Permission to use, copy, modify, and/or distribute this software for any @@ -7,6 +5,8 @@ * copyright notice and this permission notice appear in all copies. */ +#pragma once + #include "plugin-api.hpp" #include "options.hpp" diff --git a/opentrack/selected-libraries.hpp b/opentrack/selected-libraries.hpp index ffaf882c..2813cd27 100644 --- a/opentrack/selected-libraries.hpp +++ b/opentrack/selected-libraries.hpp @@ -1,3 +1,11 @@ +/* Copyright (c) 2014-2015, 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. + */ + #pragma once #include "opentrack/plugin-support.hpp" diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h index ee0d9777..520042f0 100644 --- a/opentrack/shortcuts.h +++ b/opentrack/shortcuts.h @@ -1,3 +1,11 @@ +/* Copyright (c) 2014-2015, 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. + */ + #pragma once #include #include diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index 1cea967e..e111305a 100644 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -1,3 +1,11 @@ +/* Copyright (c) 2014-2015, 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. + */ + #pragma once #include #include diff --git a/opentrack/state.hpp b/opentrack/state.hpp index bfbf113e..e4cb0f04 100644 --- a/opentrack/state.hpp +++ b/opentrack/state.hpp @@ -1,3 +1,11 @@ +/* Copyright (c) 2014-2015, 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. + */ + #pragma once #include diff --git a/opentrack/thread.hpp b/opentrack/thread.hpp index b1db9158..946f2972 100644 --- a/opentrack/thread.hpp +++ b/opentrack/thread.hpp @@ -1,3 +1,11 @@ +/* Copyright (c) 2014-2015, 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. + */ + #pragma once #include diff --git a/opentrack/timer.hpp b/opentrack/timer.hpp index eb956213..fd710499 100644 --- a/opentrack/timer.hpp +++ b/opentrack/timer.hpp @@ -1,3 +1,11 @@ +/* Copyright (c) 2014-2015, 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. + */ + #pragma once #include #if defined (_WIN32) diff --git a/opentrack/tracker.h b/opentrack/tracker.h index d4dc149f..8aeaf1c5 100644 --- a/opentrack/tracker.h +++ b/opentrack/tracker.h @@ -1,3 +1,11 @@ +/* Copyright (c) 2014-2015, 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. + */ + #pragma once #include diff --git a/opentrack/work.hpp b/opentrack/work.hpp index eb5bd4ff..39eb12fb 100644 --- a/opentrack/work.hpp +++ b/opentrack/work.hpp @@ -1,3 +1,11 @@ +/* Copyright (c) 2014-2015, 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. + */ + #pragma once #include "opentrack/main-settings.hpp" -- cgit v1.2.3 From 511e095fa3b944b2016560e6bb21e3f0413aa1a4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 11:24:40 +0200 Subject: includes relative to project top directory --- ftnoir_protocol_ft/ftnoir_protocol_ft.h | 2 +- opentrack/mappings.hpp | 2 +- opentrack/tracker.h | 2 +- qfunctionconfigurator/functionconfig.h | 2 +- qfunctionconfigurator/qfunctionconfigurator.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index ade6ac75..3fe9952d 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -38,7 +38,7 @@ #include #include "compat/compat.h" #include "opentrack/options.hpp" -#include "../freetrackclient/fttypes.h" +#include "freetrackclient/fttypes.h" using namespace options; struct settings : opts { diff --git a/opentrack/mappings.hpp b/opentrack/mappings.hpp index 650e6f99..85d9900c 100644 --- a/opentrack/mappings.hpp +++ b/opentrack/mappings.hpp @@ -10,7 +10,7 @@ #include #include "options.hpp" using namespace options; -#include "../qfunctionconfigurator/functionconfig.h" +#include "qfunctionconfigurator/functionconfig.h" #include "main-settings.hpp" class Mapping { diff --git a/opentrack/tracker.h b/opentrack/tracker.h index 8aeaf1c5..453357c4 100644 --- a/opentrack/tracker.h +++ b/opentrack/tracker.h @@ -17,7 +17,7 @@ #include "simple-mat.hpp" #include "selected-libraries.hpp" -#include "../qfunctionconfigurator/functionconfig.h" +#include "qfunctionconfigurator/functionconfig.h" #include "main-settings.hpp" #include "options.hpp" diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 4ce5efee..bd8be140 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -14,7 +14,7 @@ #include #include #include -#include "../opentrack/qcopyable-mutex.hpp" +#include "opentrack/qcopyable-mutex.hpp" class Map { private: diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index e1c40396..11eb8a71 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -1,4 +1,4 @@ -#include "../opentrack/options.hpp" +#include "opentrack/options.hpp" using namespace options; #include "qfunctionconfigurator/qfunctionconfigurator.h" #include -- cgit v1.2.3 From cdbe9e8ea3283dde4667098e8b35f09b94cbcfc4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 11:49:12 +0200 Subject: camera dialog: don't crash due to race condition We have no idea when the capture can be closed, so wait for three seconds instead. --- opentrack/opencv-camera-dialog.hpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/opentrack/opencv-camera-dialog.hpp b/opentrack/opencv-camera-dialog.hpp index 3b700a70..6218f125 100644 --- a/opentrack/opencv-camera-dialog.hpp +++ b/opentrack/opencv-camera-dialog.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -9,6 +10,14 @@ template class camera_dialog { cv::VideoCapture fake_capture; + QTimer t; + +private: + void delete_capture() + { + fake_capture.open(""); + } + public: void open_camera_settings(cv::VideoCapture* cap, const QString& camera_name, QMutex* camera_mtx) { @@ -23,10 +32,20 @@ public: } } + if (t.isActive()) + return; + + // don't hog the camera capture + if (!t.isSingleShot()) + QObject::connect(&t, &QTimer::timeout, [&]() -> void { delete_capture(); }); + + t.setSingleShot(true); + t.setInterval(3000); + fake_capture = cv::VideoCapture(camera_name_to_index(camera_name)); fake_capture.set(cv::CAP_PROP_SETTINGS, 1); - // don't hog the camera capture - fake_capture.open(""); + // HACK: we're not notified when it's safe to close the capture + t.start(); } }; -- cgit v1.2.3 From 80bac8b7583f1757d17bbc2ead69261b8b6347b5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 11:50:24 +0200 Subject: qfc: don't cancel moving if points come too close Instead, block moving but allow the user to move the other way. --- qfunctionconfigurator/qfunctionconfigurator.cpp | 59 ++++++++++++++++--------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 11eb8a71..a59b0f00 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -132,7 +132,7 @@ void QFunctionConfigurator::drawFunction() QPen pen(spline_color, 1.2, Qt::SolidLine); const double max = _config->maxInput(); - const double step = std::max(.1, max / 300.); + const double step = std::max(1e-2, max / 500.); QPointF prev = point_to_pixel(QPointF(0, 0)); for (double i = 0; i < max; i += step) { @@ -141,11 +141,6 @@ void QFunctionConfigurator::drawFunction() drawLine(&painter, prev, cur, pen); prev = cur; } - if (points.size()) - { - auto last = point_to_pixel(points[points.size()-1]); - drawLine(&painter, prev, last, pen); - } } void QFunctionConfigurator::paintEvent(QPaintEvent *e) @@ -259,16 +254,45 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) bool overlap = false; - QPointF new_pt = pixel_coord_to_point(e->pos()); + QPoint pix = e->pos(); + QPointF new_pt = pixel_coord_to_point(pix); - 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(); + static constexpr int limit = 8; - if (overlap) - moving_control_point_idx = -1; - else + for (int i = 0; i < 2; i++) + { + bool bad = false; + if (moving_control_point_idx + 1 < points.size()) + { + auto other = points[moving_control_point_idx+1]; + auto other_pix = point_to_pixel(other); + bad = pix.x() + limit > other_pix.x(); + if (i == 0 && bad) + { + pix.setX(other_pix.x() - limit - 1); + new_pt = pixel_coord_to_point(pix); + } + else + overlap |= bad; + } + if (moving_control_point_idx != 0) + { + auto other = points[moving_control_point_idx-1]; + auto other_pix = point_to_pixel(other); + bad = pix.x() - limit < other_pix.x(); + if (i == 0 && bad) + { + pix.setX(other_pix.x() + limit + 1); + new_pt = pixel_coord_to_point(pix); + } + else + overlap |= bad; + } + if (!bad) + break; + } + + if (!overlap) { points[moving_control_point_idx] = new_pt; _config->movePoint(moving_control_point_idx, new_pt); @@ -299,12 +323,7 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) return; if (e->button() == Qt::LeftButton) { - 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())); - } - } + mouseMoveEvent(e); setCursor(Qt::ArrowCursor); moving_control_point_idx = -1; -- cgit v1.2.3 From 87e7547b3b5ea10630f6f1238ce04c9e6e354b78 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 11:50:24 +0200 Subject: qfc: don't cancel moving if points come too close Instead, block moving but allow the user to move the other way. --- qfunctionconfigurator/qfunctionconfigurator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index a59b0f00..3d86216e 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -257,7 +257,7 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) QPoint pix = e->pos(); QPointF new_pt = pixel_coord_to_point(pix); - static constexpr int limit = 8; + static constexpr int limit = 16; for (int i = 0; i < 2; i++) { -- cgit v1.2.3 From 74c317a64c4aa152f1ba988d3e5d4d48d4a8e33e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 11:51:08 +0200 Subject: qfc: use same precision no matter the max x value --- qfunctionconfigurator/functionconfig.cpp | 37 ++++++++++++++++++++++---------- qfunctionconfigurator/functionconfig.h | 8 ++++--- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 70393246..e75e99b0 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -24,7 +24,7 @@ Map::Map() : float Map::getValue(float x) { QMutexLocker foo(&_mutex); - float q = x * MEMOIZE_PRECISION; + float q = x * precision(); int xi = (int)q; float yi = getValueInternal(xi); float yiplus1 = getValueInternal(xi+1); @@ -69,20 +69,28 @@ static bool sortFn(const QPointF& one, const QPointF& two) { void Map::reload() { if (cur.input.size()) { - auto& input = cur.input; + qStableSort(cur.input.begin(), cur.input.end(), sortFn); + + QList input = cur.input; auto& data = cur.data; - - qStableSort(input.begin(), input.end(), sortFn); - data = std::vector(MEMOIZE_PRECISION * input[input.size() - 1].x()); + + if (input.size() && input[0].x() > 1e-2) + input.prepend(QPointF(0, 0)); + + data = std::vector(value_count); + const int mult = precision(); 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++) { - if (k < sz) - data[k] = input[0].y() * k / (input[0].x() * MEMOIZE_PRECISION); + if (input.size() == 1) + { + for (int k = 0; k < input[0].x() * mult; k++) { + if (k < sz) + data[k] = input[0].y() * k / (input[0].x() * mult); + } } for (int i = 0; i < sz; i++) { @@ -91,8 +99,8 @@ void Map::reload() { 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; + int end = std::min(sz, p2.x() * mult); + int start = p1.x() * mult; for (int j = start; j < end; j++) { double t = (j - start) / (double) (end - start); @@ -103,7 +111,7 @@ void Map::reload() { (-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; + * mult; float y = .5 * ((2. * p1.y()) + (-p0.y() + p2.y()) * t + @@ -216,3 +224,10 @@ void Map::saveSettings(QSettings& settings, const QString& title) { settings.endGroup(); } + + +int Map::precision() const { + if (cur.input.size()) + return value_count / std::max(1.f, (cur.input[cur.input.size() - 1].x())); + return 1; +} diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index bd8be140..f7930cb2 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -22,8 +22,10 @@ private: QList input; std::vector data; }; - - static constexpr long MEMOIZE_PRECISION = 25; + + static constexpr int value_count = 9001; + + int precision() const; void reload(); float getValueInternal(int x); @@ -32,7 +34,7 @@ private: volatile bool activep; int max_x; int max_y; - + State cur, saved; public: int maxInput() const { return max_x; } -- cgit v1.2.3 From 7f18b823af6998b18e041fc01ef2d5ee3c189056 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 12:45:22 +0200 Subject: qfc: use float intermediates, and consistently --- qfunctionconfigurator/functionconfig.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index e75e99b0..6d1a48b4 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -98,25 +98,28 @@ void Map::reload() { QPointF p1 = ensureInBounds(input, i); QPointF p2 = ensureInBounds(input, i + 1); QPointF p3 = ensureInBounds(input, i + 2); + + const float p0_x = p0.x(), p1_x = p1.x(), p2_x = p2.x(), p3_x = p3.x(); + const float p0_y = p0.y(), p1_y = p1.y(), p2_y = p2.y(), p3_y = p3.y(); int end = std::min(sz, p2.x() * mult); int start = p1.x() * mult; 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) + float t = (j - start) / (float) (end - start); + float t2 = t*t; + float 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) * mult; - 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); + 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); if (x >= 0 && x < sz) data[x] = y; @@ -126,7 +129,7 @@ void Map::reload() { float last = 0; for (int i = 0; i < sz; i++) { - if (data[i] <= 0) + if (data[i] < 0) data[i] = last; last = data[i]; } -- cgit v1.2.3 From 4edcae8dd0092535485de12e8bcf3d4526ff99df Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 13:26:08 +0200 Subject: qfc: only prepend leading (0,0) if there's more than 1 point --- qfunctionconfigurator/functionconfig.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 6d1a48b4..7edbe0ef 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -74,9 +74,6 @@ void Map::reload() { QList input = cur.input; auto& data = cur.data; - if (input.size() && input[0].x() > 1e-2) - input.prepend(QPointF(0, 0)); - data = std::vector(value_count); const int mult = precision(); @@ -92,6 +89,8 @@ void Map::reload() { data[k] = input[0].y() * k / (input[0].x() * mult); } } + else if (input[0].x() > 1e-2) + input.prepend(QPointF(0, 0)); for (int i = 0; i < sz; i++) { QPointF p0 = ensureInBounds(input, i - 1); -- cgit v1.2.3 From 68fe8c1f09a2747ef816c688e1c957e39cf21664 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 13:48:16 +0200 Subject: typo: all dialogs were creating protocol dialog --- facetracknoir/ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 416a619c..7a412bdb 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -372,12 +372,12 @@ void MainWindow::showTrackerSettings() } void MainWindow::showProtocolSettings() { - if (mk_dialog(current_tracker(), &pProtocolDialog) && libs.pProtocol) + if (mk_dialog(current_protocol(), &pProtocolDialog) && libs.pProtocol) pProtocolDialog->register_protocol(libs.pProtocol.get()); } void MainWindow::showFilterSettings() { - if (mk_dialog(current_tracker(), &pFilterDialog) && libs.pFilter) + if (mk_dialog(current_filter(), &pFilterDialog) && libs.pFilter) pFilterDialog->register_filter(libs.pFilter.get()); } -- cgit v1.2.3 From daef1862f1ef7a1332253ee427b9726316ba6328 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jul 2015 13:59:49 +0200 Subject: tracker: camera angle affected translation twice --- opentrack/tracker.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index c124111f..0d4d8c2c 100644 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -106,7 +106,6 @@ void Tracker::logic() dmat<3, 1> t { value(0), value(1), value(2) }; r = cam * r; - t = cam * t; bool can_center = false; -- cgit v1.2.3 From ab47eac174db02710a7fa6c194e00c31cef755a4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 8 Jul 2015 05:38:47 +0200 Subject: try to fix FSX stutter while FSX has focus As reported in #174 FSX has issues with calldispatch in steam edition. Attempt setting high process priority. --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 7d4e09f9..52db14f8 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -41,6 +41,9 @@ FTNoIR_Protocol::~FTNoIR_Protocol() void FTNoIR_Protocol::run() { + (void) SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); + (void) SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); + HANDLE event = CreateEvent(NULL, FALSE, FALSE, nullptr); if (event == nullptr) -- cgit v1.2.3