diff options
34 files changed, 1688 insertions, 160 deletions
diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake index 96d306fa..23f684f3 100644 --- a/cmake/opentrack-platform.cmake +++ b/cmake/opentrack-platform.cmake @@ -118,8 +118,8 @@ if(MSVC) add_definitions(-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1) add_definitions(-D_SCL_SECURE_NO_WARNINGS) - add_compile_options(-EHs-c-) - add_definitions(-D_HAS_EXCEPTIONS=0) + add_compile_options(-EHsc) + #add_definitions(-D_HAS_EXCEPTIONS=0) add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE) add_definitions(-D_ENABLE_ATOMIC_ALIGNMENT_FIX) diff --git a/compat/thread-name.cpp b/compat/thread-name.cpp index 504c6f19..08a7d628 100644 --- a/compat/thread-name.cpp +++ b/compat/thread-name.cpp @@ -20,12 +20,9 @@ struct THREADNAME_INFO }; static inline -void set_curthread_name_old(const QString& name_) +void set_curthread_name_old_(const char* name) { - QByteArray str = name_.toLocal8Bit(); - const char* name = str.constData(); HANDLE curthread = GetCurrentThread(); - THREADNAME_INFO info; // NOLINT(cppcoreguidelines-pro-type-member-init) info.dwType = 0x1000; info.szName = name; @@ -41,6 +38,15 @@ void set_curthread_name_old(const QString& name_) { } } + +static inline +void set_curthread_name_old(const QString& name_) +{ + QByteArray str = name_.toLocal8Bit(); + const char* name = str.constData(); + + set_curthread_name_old_(name); +} #else static inline void set_curthread_name_old(const QString&) {} diff --git a/filter-hamilton/hamilton-tools.cpp b/filter-hamilton/hamilton-tools.cpp index 4f9ad046..e18082a8 100644 --- a/filter-hamilton/hamilton-tools.cpp +++ b/filter-hamilton/hamilton-tools.cpp @@ -1,5 +1,3 @@ -#pragma once - #include "hamilton-tools.h" #include <cmath> diff --git a/gui/correlation-calibrator.ui b/gui/correlation-calibrator.ui index d351d5da..02fdf1d2 100644 --- a/gui/correlation-calibrator.ui +++ b/gui/correlation-calibrator.ui @@ -40,7 +40,7 @@ Press "clear calibration" to remove any calibration data pertaining to <enum>Qt::ScrollBarAlwaysOff</enum> </property> <property name="sizeAdjustPolicy"> - <enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum> + <enum>QAbstractScrollArea::AdjustToContents</enum> </property> <property name="autoScroll"> <bool>true</bool> diff --git a/gui/init.cpp b/gui/init.cpp index 3aae5772..2b7b01ad 100644 --- a/gui/init.cpp +++ b/gui/init.cpp @@ -159,6 +159,39 @@ static void qdebug_to_console(QtMsgType loglevel, const QMessageLogContext& ctx, #ifdef _WIN32 +static void apply_dark_windows_theme_if_needed() +{ + // On Windows apply dark theme if requested by user settings + QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", QSettings::NativeFormat); + if (settings.value("AppsUseLightTheme") == 0) { + qApp->setStyle(QStyleFactory::create("Dark")); + QPalette darkPalette; + QColor darkColor = QColor(45, 45, 45); + QColor disabledColor = QColor(127, 127, 127); + darkPalette.setColor(QPalette::Window, darkColor); + darkPalette.setColor(QPalette::WindowText, Qt::white); + darkPalette.setColor(QPalette::Base, QColor(18, 18, 18)); + darkPalette.setColor(QPalette::AlternateBase, darkColor); + darkPalette.setColor(QPalette::ToolTipBase, Qt::white); + darkPalette.setColor(QPalette::ToolTipText, Qt::white); + darkPalette.setColor(QPalette::Text, Qt::white); + darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor); + darkPalette.setColor(QPalette::Button, darkColor); + darkPalette.setColor(QPalette::ButtonText, Qt::white); + darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor); + darkPalette.setColor(QPalette::BrightText, Qt::red); + darkPalette.setColor(QPalette::Link, QColor(42, 130, 218)); + + darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218)); + darkPalette.setColor(QPalette::HighlightedText, Qt::black); + darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor); + + qApp->setPalette(darkPalette); + + qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }"); + } +} + static void add_win32_path() { // see https://software.intel.com/en-us/articles/limitation-to-the-length-of-the-system-path-variable @@ -270,6 +303,7 @@ int otr_main(int argc, char** argv, std::function<std::unique_ptr<QWidget>()> co QApplication app(argc, argv); #ifdef _WIN32 + apply_dark_windows_theme_if_needed(); add_win32_path(); attach_parent_console(); #endif diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp index 40737114..58ea4ca9 100644 --- a/gui/process_detector.cpp +++ b/gui/process_detector.cpp @@ -56,6 +56,10 @@ void proc_detector_settings::set_is_enabled(bool enabled) }); } +#ifdef __GNUG__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + QHash<QString, QString> proc_detector_settings::split_process_names() { QString str = get_game_list(); diff --git a/proto-wine/ftnoir_protocol_wine.cpp b/proto-wine/ftnoir_protocol_wine.cpp index 6652eb48..af53ff1f 100644 --- a/proto-wine/ftnoir_protocol_wine.cpp +++ b/proto-wine/ftnoir_protocol_wine.cpp @@ -80,7 +80,7 @@ module_status wine::initialize() if (!success) return error(error_string); } - + else { QString wineprefix = "~/.wine"; if (!s.wineprefix->isEmpty()) diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp index 3cb0a93e..52758f71 100644 --- a/qxt-mini/qxtglobalshortcut.cpp +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -36,6 +36,10 @@ #include <QtDebug> #include <QtGlobal> +#ifdef __GNUG__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + QHash<QPair<quint32, quint32>, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; void QxtGlobalShortcutPrivate::event_filter_installer::ensure_event_filter() diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp index 8a5612d8..7aeaf590 100644 --- a/spline/spline-widget.cpp +++ b/spline/spline-widget.cpp @@ -10,6 +10,7 @@ #include <QString> #include <QToolTip> #include <QtEvents> +#include <QPainterPath> #include <QDebug> diff --git a/tracker-easy/lang/nl_NL.ts b/tracker-easy/lang/nl_NL.ts index 9c4e1843..775ec4d9 100644 --- a/tracker-easy/lang/nl_NL.ts +++ b/tracker-easy/lang/nl_NL.ts @@ -4,17 +4,13 @@ <context> <name>EasyTracker::Metadata</name> <message> - <source>Easy Tracker 1.0</source> + <source>Easy Tracker 1.1</source> <translation type="unfinished"></translation> </message> </context> <context> <name>UICPTClientControls</name> <message> - <source>PointTracker Settings</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Camera</source> <translation type="unfinished"></translation> </message> @@ -151,79 +147,103 @@ <translation type="unfinished"></translation> </message> <message> - <source>Top Right</source> + <source><html><head/><body><p><span style=" font-size:12pt;">X</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Top</source> + <source><html><head/><body><p><span style=" font-size:12pt;">Y</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Top Left</source> + <source><html><head/><body><p><span style=" font-size:12pt;">Z</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Left</source> + <source>Auto center</source> <translation type="unfinished"></translation> </message> <message> - <source>Vertex count</source> + <source><html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Three vertices</source> + <source>Auto center timeout</source> <translation type="unfinished"></translation> </message> <message> - <source>Four vertices</source> + <source>If no valid pose can be determined after that much time the center pose will be used.</source> <translation type="unfinished"></translation> </message> <message> - <source>Five vertices</source> + <source> ms</source> <translation type="unfinished"></translation> </message> <message> - <source>Center</source> + <source>Easy Tracker Settings</source> <translation type="unfinished"></translation> </message> <message> - <source>Right</source> + <source>Model type:</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">X</span></p></body></html></source> + <source>Hat three vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">Y</span></p></body></html></source> + <source>Hat four vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">Z</span></p></body></html></source> + <source>Hat five vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></source> + <source>Clip three vertices</source> <translation type="unfinished"></translation> </message> <message> - <source>Auto center</source> + <source>Vertices: </source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html></source> + <source>Top:</source> <translation type="unfinished"></translation> </message> <message> - <source>Auto center timeout</source> + <source>Right:</source> <translation type="unfinished"></translation> </message> <message> - <source>If no valid pose can be determined after that much time the center pose will be used.</source> + <source>Left:</source> <translation type="unfinished"></translation> </message> <message> - <source> ms</source> + <source>Center:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Top right:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Top left:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip top:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip middle:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip bottom:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></source> <translation type="unfinished"></translation> </message> </context> diff --git a/tracker-easy/lang/ru_RU.ts b/tracker-easy/lang/ru_RU.ts index 6499415f..2ae262a5 100644 --- a/tracker-easy/lang/ru_RU.ts +++ b/tracker-easy/lang/ru_RU.ts @@ -4,17 +4,13 @@ <context> <name>EasyTracker::Metadata</name> <message> - <source>Easy Tracker 1.0</source> + <source>Easy Tracker 1.1</source> <translation type="unfinished"></translation> </message> </context> <context> <name>UICPTClientControls</name> <message> - <source>PointTracker Settings</source> - <translation>Настройки PointTracker</translation> - </message> - <message> <source>Camera</source> <translation>Камера</translation> </message> @@ -151,79 +147,103 @@ <translation type="unfinished"></translation> </message> <message> - <source>Top Right</source> + <source><html><head/><body><p><span style=" font-size:12pt;">X</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Top</source> + <source><html><head/><body><p><span style=" font-size:12pt;">Y</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Top Left</source> + <source><html><head/><body><p><span style=" font-size:12pt;">Z</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Left</source> + <source>Auto center</source> <translation type="unfinished"></translation> </message> <message> - <source>Vertex count</source> + <source><html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Three vertices</source> + <source>Auto center timeout</source> <translation type="unfinished"></translation> </message> <message> - <source>Four vertices</source> + <source>If no valid pose can be determined after that much time the center pose will be used.</source> <translation type="unfinished"></translation> </message> <message> - <source>Five vertices</source> + <source> ms</source> <translation type="unfinished"></translation> </message> <message> - <source>Center</source> + <source>Easy Tracker Settings</source> <translation type="unfinished"></translation> </message> <message> - <source>Right</source> + <source>Model type:</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">X</span></p></body></html></source> + <source>Hat three vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">Y</span></p></body></html></source> + <source>Hat four vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">Z</span></p></body></html></source> + <source>Hat five vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></source> + <source>Clip three vertices</source> <translation type="unfinished"></translation> </message> <message> - <source>Auto center</source> + <source>Vertices: </source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html></source> + <source>Top:</source> <translation type="unfinished"></translation> </message> <message> - <source>Auto center timeout</source> + <source>Right:</source> <translation type="unfinished"></translation> </message> <message> - <source>If no valid pose can be determined after that much time the center pose will be used.</source> + <source>Left:</source> <translation type="unfinished"></translation> </message> <message> - <source> ms</source> + <source>Center:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Top right:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Top left:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip top:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip middle:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip bottom:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></source> <translation type="unfinished"></translation> </message> </context> diff --git a/tracker-easy/lang/stub.ts b/tracker-easy/lang/stub.ts index 7b6facec..b10f5885 100644 --- a/tracker-easy/lang/stub.ts +++ b/tracker-easy/lang/stub.ts @@ -4,17 +4,13 @@ <context> <name>EasyTracker::Metadata</name> <message> - <source>Easy Tracker 1.0</source> + <source>Easy Tracker 1.1</source> <translation type="unfinished"></translation> </message> </context> <context> <name>UICPTClientControls</name> <message> - <source>PointTracker Settings</source> - <translation type="unfinished"></translation> - </message> - <message> <source>Camera</source> <translation type="unfinished"></translation> </message> @@ -151,79 +147,103 @@ <translation type="unfinished"></translation> </message> <message> - <source>Top Right</source> + <source><html><head/><body><p><span style=" font-size:12pt;">X</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Top</source> + <source><html><head/><body><p><span style=" font-size:12pt;">Y</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Top Left</source> + <source><html><head/><body><p><span style=" font-size:12pt;">Z</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Left</source> + <source>Auto center</source> <translation type="unfinished"></translation> </message> <message> - <source>Vertex count</source> + <source><html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Three vertices</source> + <source>Auto center timeout</source> <translation type="unfinished"></translation> </message> <message> - <source>Four vertices</source> + <source>If no valid pose can be determined after that much time the center pose will be used.</source> <translation type="unfinished"></translation> </message> <message> - <source>Five vertices</source> + <source> ms</source> <translation type="unfinished"></translation> </message> <message> - <source>Center</source> + <source>Easy Tracker Settings</source> <translation type="unfinished"></translation> </message> <message> - <source>Right</source> + <source>Model type:</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">X</span></p></body></html></source> + <source>Hat three vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">Y</span></p></body></html></source> + <source>Hat four vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">Z</span></p></body></html></source> + <source>Hat five vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></source> + <source>Clip three vertices</source> <translation type="unfinished"></translation> </message> <message> - <source>Auto center</source> + <source>Vertices: </source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html></source> + <source>Top:</source> <translation type="unfinished"></translation> </message> <message> - <source>Auto center timeout</source> + <source>Right:</source> <translation type="unfinished"></translation> </message> <message> - <source>If no valid pose can be determined after that much time the center pose will be used.</source> + <source>Left:</source> <translation type="unfinished"></translation> </message> <message> - <source> ms</source> + <source>Center:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Top right:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Top left:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip top:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip middle:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip bottom:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></source> <translation type="unfinished"></translation> </message> </context> diff --git a/tracker-easy/lang/zh_CN.ts b/tracker-easy/lang/zh_CN.ts index bbd8aff1..71fc6368 100644 --- a/tracker-easy/lang/zh_CN.ts +++ b/tracker-easy/lang/zh_CN.ts @@ -4,17 +4,13 @@ <context> <name>EasyTracker::Metadata</name> <message> - <source>Easy Tracker 1.0</source> + <source>Easy Tracker 1.1</source> <translation type="unfinished"></translation> </message> </context> <context> <name>UICPTClientControls</name> <message> - <source>PointTracker Settings</source> - <translation>PointTracker设置</translation> - </message> - <message> <source>Camera</source> <translation>摄像头</translation> </message> @@ -151,79 +147,103 @@ <translation type="unfinished"></translation> </message> <message> - <source>Top Right</source> + <source><html><head/><body><p><span style=" font-size:12pt;">X</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Top</source> + <source><html><head/><body><p><span style=" font-size:12pt;">Y</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Top Left</source> + <source><html><head/><body><p><span style=" font-size:12pt;">Z</span></p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Left</source> + <source>Auto center</source> <translation type="unfinished"></translation> </message> <message> - <source>Vertex count</source> + <source><html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html></source> <translation type="unfinished"></translation> </message> <message> - <source>Three vertices</source> + <source>Auto center timeout</source> <translation type="unfinished"></translation> </message> <message> - <source>Four vertices</source> + <source>If no valid pose can be determined after that much time the center pose will be used.</source> <translation type="unfinished"></translation> </message> <message> - <source>Five vertices</source> + <source> ms</source> <translation type="unfinished"></translation> </message> <message> - <source>Center</source> + <source>Easy Tracker Settings</source> <translation type="unfinished"></translation> </message> <message> - <source>Right</source> + <source>Model type:</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">X</span></p></body></html></source> + <source>Hat three vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">Y</span></p></body></html></source> + <source>Hat four vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-size:12pt;">Z</span></p></body></html></source> + <source>Hat five vertices</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></source> + <source>Clip three vertices</source> <translation type="unfinished"></translation> </message> <message> - <source>Auto center</source> + <source>Vertices: </source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html></source> + <source>Top:</source> <translation type="unfinished"></translation> </message> <message> - <source>Auto center timeout</source> + <source>Right:</source> <translation type="unfinished"></translation> </message> <message> - <source>If no valid pose can be determined after that much time the center pose will be used.</source> + <source>Left:</source> <translation type="unfinished"></translation> </message> <message> - <source> ms</source> + <source>Center:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Top right:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Top left:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip top:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip middle:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Clip bottom:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></source> <translation type="unfinished"></translation> </message> </context> diff --git a/tracker-easy/module.cpp b/tracker-easy/module.cpp index 3a9df22b..8fcfeae1 100644 --- a/tracker-easy/module.cpp +++ b/tracker-easy/module.cpp @@ -6,7 +6,7 @@ namespace EasyTracker { - QString Metadata::name() { return tr("Easy Tracker 1.0"); } + QString Metadata::name() { return tr("Easy Tracker 1.1"); } QIcon Metadata::icon() { return QIcon(":/Resources/easy-tracker-logo.png"); } } diff --git a/tracker-easy/settings.h b/tracker-easy/settings.h index b0f14417..4141ebe0 100644 --- a/tracker-easy/settings.h +++ b/tracker-easy/settings.h @@ -30,6 +30,7 @@ namespace EasyTracker { value<bool> iCustomModelThree{ b, "iCustomModelThree", true }; value<bool> iCustomModelFour{ b, "iCustomModelFour", false }; value<bool> iCustomModelFive{ b, "iCustomModelFive", false }; + value<bool> iClipModelThree{ b, "iClipModelThree", false }; // Custom model vertices value<int> iVertexTopX{ b, "iVertexTopX", 0 }, iVertexTopY{ b, "iVertexTopY", 0 }, iVertexTopZ{ b, "iVertexTopZ", 0 }; @@ -38,7 +39,10 @@ namespace EasyTracker { value<int> iVertexCenterX{ b, "iVertexCenterX", 0 }, iVertexCenterY{ b, "iVertexCenterY", 0 }, iVertexCenterZ{ b, "iVertexCenterZ", 0 }; value<int> iVertexTopRightX{ b, "iVertexTopRightX", 0 }, iVertexTopRightY{ b, "iVertexTopRightY", 0 }, iVertexTopRightZ{ b, "iVertexTopRightZ", 0 }; value<int> iVertexTopLeftX{ b, "iVertexTopLeftX", 0 }, iVertexTopLeftY{ b, "iVertexTopLeftY", 0 }, iVertexTopLeftZ{ b, "iVertexTopLeftZ", 0 }; - + // Clip model vertices + value<int> iVertexClipTopX{ b, "iVertexClipTopX", 0 }, iVertexClipTopY{ b, "iVertexClipTopY", 0 }, iVertexClipTopZ{ b, "iVertexClipTopZ", 0 }; + value<int> iVertexClipMiddleX{ b, "iVertexClipMiddleX", 0 }, iVertexClipMiddleY{ b, "iVertexClipMiddleY", 0 }, iVertexClipMiddleZ{ b, "iVertexClipMiddleZ", 0 }; + value<int> iVertexClipBottomX{ b, "iVertexClipBottomX", 0 }, iVertexClipBottomY{ b, "iVertexClipBottomY", 0 }, iVertexClipBottomZ{ b, "iVertexClipBottomZ", 0 }; value<int> fov{ b, "camera-fov", 56 }; diff --git a/tracker-easy/tracker-easy-dialog.cpp b/tracker-easy/tracker-easy-dialog.cpp index 4a49e194..b0870b50 100644 --- a/tracker-easy/tracker-easy-dialog.cpp +++ b/tracker-easy/tracker-easy-dialog.cpp @@ -68,6 +68,19 @@ namespace EasyTracker tie_setting(s.iVertexTopLeftY, ui.iSpinVertexTopLeftY); tie_setting(s.iVertexTopLeftZ, ui.iSpinVertexTopLeftZ); + // Clip model + tie_setting(s.iVertexClipTopX, ui.iSpinVertexClipTopX); + tie_setting(s.iVertexClipTopY, ui.iSpinVertexClipTopY); + tie_setting(s.iVertexClipTopZ, ui.iSpinVertexClipTopZ); + + tie_setting(s.iVertexClipMiddleX, ui.iSpinVertexClipMiddleX); + tie_setting(s.iVertexClipMiddleY, ui.iSpinVertexClipMiddleY); + tie_setting(s.iVertexClipMiddleZ, ui.iSpinVertexClipMiddleZ); + + tie_setting(s.iVertexClipBottomX, ui.iSpinVertexClipBottomX); + tie_setting(s.iVertexClipBottomY, ui.iSpinVertexClipBottomY); + tie_setting(s.iVertexClipBottomZ, ui.iSpinVertexClipBottomZ); + tie_setting(s.fov, ui.fov); tie_setting(s.debug, ui.debug); @@ -87,10 +100,12 @@ namespace EasyTracker connect(ui.iRadioButtonCustomModelThree, &QRadioButton::clicked, this, &Dialog::UpdateCustomModelControls); connect(ui.iRadioButtonCustomModelFour, &QRadioButton::clicked, this, &Dialog::UpdateCustomModelControls); connect(ui.iRadioButtonCustomModelFive, &QRadioButton::clicked, this, &Dialog::UpdateCustomModelControls); + connect(ui.iRadioButtonClipModelThree, &QRadioButton::clicked, this, &Dialog::UpdateCustomModelControls); tie_setting(s.iCustomModelThree, ui.iRadioButtonCustomModelThree); tie_setting(s.iCustomModelFour, ui.iRadioButtonCustomModelFour); tie_setting(s.iCustomModelFive, ui.iRadioButtonCustomModelFive); + tie_setting(s.iClipModelThree, ui.iRadioButtonClipModelThree); for (unsigned k = 0; k < cv::SOLVEPNP_MAX_COUNT; k++) @@ -111,20 +126,49 @@ namespace EasyTracker ui.iGroupBoxCenter->hide(); ui.iGroupBoxTopRight->hide(); ui.iGroupBoxTopLeft->hide(); + ui.iGroupBoxTop->show(); + ui.iGroupBoxRight->show(); + ui.iGroupBoxLeft->show(); + ui.iGroupBoxClipTop->hide(); + ui.iGroupBoxClipMiddle->hide(); + ui.iGroupBoxClipBottom->hide(); } else if (ui.iRadioButtonCustomModelFour->isChecked()) { ui.iGroupBoxCenter->show(); ui.iGroupBoxTopRight->hide(); ui.iGroupBoxTopLeft->hide(); + ui.iGroupBoxTop->show(); + ui.iGroupBoxRight->show(); + ui.iGroupBoxLeft->show(); + ui.iGroupBoxClipTop->hide(); + ui.iGroupBoxClipMiddle->hide(); + ui.iGroupBoxClipBottom->hide(); } else if (ui.iRadioButtonCustomModelFive->isChecked()) { ui.iGroupBoxCenter->hide(); ui.iGroupBoxTopRight->show(); ui.iGroupBoxTopLeft->show(); + ui.iGroupBoxTop->show(); + ui.iGroupBoxRight->show(); + ui.iGroupBoxLeft->show(); + ui.iGroupBoxClipTop->hide(); + ui.iGroupBoxClipMiddle->hide(); + ui.iGroupBoxClipBottom->hide(); + } + else if (ui.iRadioButtonClipModelThree->isChecked()) + { + ui.iGroupBoxTop->hide(); + ui.iGroupBoxRight->hide(); + ui.iGroupBoxLeft->hide(); + ui.iGroupBoxCenter->hide(); + ui.iGroupBoxTopRight->hide(); + ui.iGroupBoxTopLeft->hide(); + ui.iGroupBoxClipTop->show(); + ui.iGroupBoxClipMiddle->show(); + ui.iGroupBoxClipBottom->show(); } - } diff --git a/tracker-easy/tracker-easy-settings.ui b/tracker-easy/tracker-easy-settings.ui index 451b3e54..d6cc86b6 100644 --- a/tracker-easy/tracker-easy-settings.ui +++ b/tracker-easy/tracker-easy-settings.ui @@ -9,8 +9,8 @@ <rect> <x>0</x> <y>0</y> - <width>465</width> - <height>764</height> + <width>328</width> + <height>923</height> </rect> </property> <property name="sizePolicy"> @@ -20,7 +20,7 @@ </sizepolicy> </property> <property name="windowTitle"> - <string>PointTracker Settings</string> + <string>Easy Tracker Settings</string> </property> <property name="windowIcon"> <iconset> @@ -32,24 +32,8 @@ <property name="autoFillBackground"> <bool>false</bool> </property> - <layout class="QGridLayout" name="gridLayout_9"> - <property name="sizeConstraint"> - <enum>QLayout::SetFixedSize</enum> - </property> - <item row="7" column="0"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="0" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item alignment="Qt::AlignTop"> <widget class="QTabWidget" name="tabWidget"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> @@ -61,7 +45,7 @@ <locale language="English" country="UnitedStates"/> </property> <property name="currentIndex"> - <number>0</number> + <number>2</number> </property> <widget class="QWidget" name="tabTracker"> <attribute name="title"> @@ -548,13 +532,13 @@ <item> <widget class="QGroupBox" name="groupBoxCustomModelType"> <property name="title"> - <string>Vertex count</string> + <string>Model type:</string> </property> - <layout class="QHBoxLayout" name="horizontalLayout"> + <layout class="QVBoxLayout" name="verticalLayout_4"> <item> <widget class="QRadioButton" name="iRadioButtonCustomModelThree"> <property name="text"> - <string>Three vertices</string> + <string>Hat three vertices</string> </property> <property name="checked"> <bool>true</bool> @@ -564,14 +548,21 @@ <item> <widget class="QRadioButton" name="iRadioButtonCustomModelFour"> <property name="text"> - <string>Four vertices</string> + <string>Hat four vertices</string> </property> </widget> </item> <item> <widget class="QRadioButton" name="iRadioButtonCustomModelFive"> <property name="text"> - <string>Five vertices</string> + <string>Hat five vertices</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="iRadioButtonClipModelThree"> + <property name="text"> + <string>Clip three vertices</string> </property> </widget> </item> @@ -581,7 +572,7 @@ <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> - <string/> + <string>Vertices: </string> </property> <property name="flat"> <bool>false</bool> @@ -614,7 +605,7 @@ <item> <widget class="QGroupBox" name="iGroupBoxTop"> <property name="title"> - <string>Top</string> + <string>Top:</string> </property> <layout class="QHBoxLayout" name="horizontalLayout_2"> <property name="topMargin"> @@ -665,7 +656,7 @@ <item> <widget class="QGroupBox" name="iGroupBoxRight"> <property name="title"> - <string>Right</string> + <string>Right:</string> </property> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> @@ -713,7 +704,7 @@ <item> <widget class="QGroupBox" name="iGroupBoxLeft"> <property name="title"> - <string>Left</string> + <string>Left:</string> </property> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> @@ -761,7 +752,7 @@ <item> <widget class="QGroupBox" name="iGroupBoxCenter"> <property name="title"> - <string>Center</string> + <string>Center:</string> </property> <layout class="QHBoxLayout" name="horizontalLayout_5"> <item> @@ -809,7 +800,7 @@ <item> <widget class="QGroupBox" name="iGroupBoxTopRight"> <property name="title"> - <string>Top Right</string> + <string>Top right:</string> </property> <layout class="QHBoxLayout" name="horizontalLayout_6"> <item> @@ -857,7 +848,7 @@ <item> <widget class="QGroupBox" name="iGroupBoxTopLeft"> <property name="title"> - <string>Top Left</string> + <string>Top left:</string> </property> <layout class="QHBoxLayout" name="horizontalLayout_7"> <item> @@ -902,6 +893,159 @@ </layout> </widget> </item> + <item> + <widget class="QGroupBox" name="iGroupBoxClipTop"> + <property name="title"> + <string>Clip top:</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <property name="topMargin"> + <number>9</number> + </property> + <item> + <widget class="QSpinBox" name="iSpinVertexClipTopX"> + <property name="suffix"> + <string> mm</string> + </property> + <property name="minimum"> + <number>-65535</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="iSpinVertexClipTopY"> + <property name="suffix"> + <string> mm</string> + </property> + <property name="minimum"> + <number>-65535</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="iSpinVertexClipTopZ"> + <property name="suffix"> + <string> mm</string> + </property> + <property name="minimum"> + <number>-65535</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="iGroupBoxClipMiddle"> + <property name="title"> + <string>Clip middle:</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_9"> + <property name="topMargin"> + <number>9</number> + </property> + <item> + <widget class="QSpinBox" name="iSpinVertexClipMiddleX"> + <property name="suffix"> + <string> mm</string> + </property> + <property name="minimum"> + <number>-65535</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="iSpinVertexClipMiddleY"> + <property name="suffix"> + <string> mm</string> + </property> + <property name="minimum"> + <number>-65535</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="iSpinVertexClipMiddleZ"> + <property name="suffix"> + <string> mm</string> + </property> + <property name="minimum"> + <number>-65535</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="iGroupBoxClipBottom"> + <property name="title"> + <string>Clip bottom:</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_11"> + <property name="topMargin"> + <number>9</number> + </property> + <item> + <widget class="QSpinBox" name="iSpinVertexClipBottomX"> + <property name="suffix"> + <string> mm</string> + </property> + <property name="minimum"> + <number>-65535</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="iSpinVertexClipBottomY"> + <property name="suffix"> + <string> mm</string> + </property> + <property name="minimum"> + <number>-65535</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="iSpinVertexClipBottomZ"> + <property name="suffix"> + <string> mm</string> + </property> + <property name="minimum"> + <number>-65535</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> </layout> </widget> <widget class="QWidget" name="tab_3"> @@ -912,7 +1056,7 @@ <item row="0" column="0"> <widget class="QLabel" name="label_10"> <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></string> + <string><html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html></string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> @@ -939,10 +1083,22 @@ </widget> </widget> </item> + <item alignment="Qt::AlignBottom"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> </layout> </widget> <tabstops> - <tabstop>tabWidget</tabstop> <tabstop>camdevice_combo</tabstop> <tabstop>res_x_spin</tabstop> <tabstop>res_y_spin</tabstop> diff --git a/tracker-easy/tracker-easy.cpp b/tracker-easy/tracker-easy.cpp index 9fb41491..0487d031 100644 --- a/tracker-easy/tracker-easy.cpp +++ b/tracker-easy/tracker-easy.cpp @@ -154,8 +154,13 @@ namespace EasyTracker // 5 - Radial fourth order // 6 - Radial fifth order // 7 - Radial sixth order - for (unsigned k = 0; k < 8; k++) - iDistCoeffsMatrix(k) = (double)iCameraInfo.dist_c[k]; + // + // SL: Using distortion coefficients in this way is breaking our face tracking output. + // Just disable them for now until we invest time and effort to work it out. + // For our face tracking use case not having proper distortion coefficients ain't a big deal anyway + // See issues #1141 and #1020 + //for (unsigned k = 0; k < 8; k++) + // iDistCoeffsMatrix(k) = (double)iCameraInfo.dist_c[k]; } @@ -165,10 +170,15 @@ namespace EasyTracker { MatchFiveVertices(aTopIndex, aRightIndex, aLeftIndex, aTopRight, aTopLeft); } - else + else if (!iSettings.iClipModelThree) { MatchThreeOrFourVertices(aTopIndex, aRightIndex, aLeftIndex, aCenterIndex); } + else + { + // Clip model + MatchClipVertices(aTopIndex, aRightIndex, aLeftIndex); + } } @@ -337,7 +347,56 @@ namespace EasyTracker } } - + /** + */ + void Tracker::MatchClipVertices(int& aTopIndex, int& aMiddleIndex, int& aBottomIndex) + { + //Bitmap origin is top left + iTrackedPoints.clear(); + // Tracked points must match the order of the object model points. + // Find top most point, that's the one with min Y as we assume our guy's head is not up side down + int minY = std::numeric_limits<int>::max(); + for (int i = 0; i < (int)iPoints.size(); i++) + { + if (iPoints[i].y < minY) + { + minY = iPoints[i].y; + aTopIndex = i; + } + } + + + int maxY = 0; + + // Find bottom most point + for (int i = 0; i < (int)iPoints.size(); i++) + { + // Excluding top most point + if (i != aTopIndex && iPoints[i].y > maxY) + { + maxY = iPoints[i].y; + aBottomIndex = i; + } + } + + + // Find center point, the last one + for (int i = 0; i < (int)iPoints.size(); i++) + { + // Excluding the three points we already have + if (i != aTopIndex && i != aBottomIndex) + { + aMiddleIndex = i; + } + } + + // Order matters + iTrackedPoints.push_back(iPoints[aTopIndex]); + iTrackedPoints.push_back(iPoints[aMiddleIndex]); + iTrackedPoints.push_back(iPoints[aBottomIndex]); + } + + /// /// @@ -720,18 +779,29 @@ namespace EasyTracker // We are converting them from millimeters to centimeters. // TODO: Need to support clip too. That's cap only for now. iModel.clear(); - iModel.push_back(cv::Point3f(iSettings.iVertexTopX / 10.0, iSettings.iVertexTopY / 10.0, iSettings.iVertexTopZ / 10.0)); // Top - iModel.push_back(cv::Point3f(iSettings.iVertexRightX / 10.0, iSettings.iVertexRightY / 10.0, iSettings.iVertexRightZ / 10.0)); // Right - iModel.push_back(cv::Point3f(iSettings.iVertexLeftX / 10.0, iSettings.iVertexLeftY / 10.0, iSettings.iVertexLeftZ / 10.0)); // Left - if (iSettings.iCustomModelFour) + if (!iSettings.iClipModelThree) { - iModel.push_back(cv::Point3f(iSettings.iVertexCenterX / 10.0, iSettings.iVertexCenterY / 10.0, iSettings.iVertexCenterZ / 10.0)); // Center + iModel.push_back(cv::Point3f(iSettings.iVertexTopX / 10.0, iSettings.iVertexTopY / 10.0, iSettings.iVertexTopZ / 10.0)); // Top + iModel.push_back(cv::Point3f(iSettings.iVertexRightX / 10.0, iSettings.iVertexRightY / 10.0, iSettings.iVertexRightZ / 10.0)); // Right + iModel.push_back(cv::Point3f(iSettings.iVertexLeftX / 10.0, iSettings.iVertexLeftY / 10.0, iSettings.iVertexLeftZ / 10.0)); // Left + + if (iSettings.iCustomModelFour) + { + iModel.push_back(cv::Point3f(iSettings.iVertexCenterX / 10.0, iSettings.iVertexCenterY / 10.0, iSettings.iVertexCenterZ / 10.0)); // Center + } + else if (iSettings.iCustomModelFive) + { + iModel.push_back(cv::Point3f(iSettings.iVertexTopRightX / 10.0, iSettings.iVertexTopRightY / 10.0, iSettings.iVertexTopRightZ / 10.0)); // Top Right + iModel.push_back(cv::Point3f(iSettings.iVertexTopLeftX / 10.0, iSettings.iVertexTopLeftY / 10.0, iSettings.iVertexTopLeftZ / 10.0)); // Top Left + } } - else if (iSettings.iCustomModelFive) + else { - iModel.push_back(cv::Point3f(iSettings.iVertexTopRightX / 10.0, iSettings.iVertexTopRightY / 10.0, iSettings.iVertexTopRightZ / 10.0)); // Top Right - iModel.push_back(cv::Point3f(iSettings.iVertexTopLeftX / 10.0, iSettings.iVertexTopLeftY / 10.0, iSettings.iVertexTopLeftZ / 10.0)); // Top Left + // Clip model type + iModel.push_back(cv::Point3f(iSettings.iVertexClipTopX / 10.0, iSettings.iVertexClipTopY / 10.0, iSettings.iVertexClipTopZ / 10.0)); // Top + iModel.push_back(cv::Point3f(iSettings.iVertexClipMiddleX / 10.0, iSettings.iVertexClipMiddleY / 10.0, iSettings.iVertexClipMiddleZ / 10.0)); // Middle + iModel.push_back(cv::Point3f(iSettings.iVertexClipBottomX / 10.0, iSettings.iVertexClipBottomY / 10.0, iSettings.iVertexClipBottomZ / 10.0)); // Bottom } infout << "Update model - end"; diff --git a/tracker-easy/tracker-easy.h b/tracker-easy/tracker-easy.h index 0b51f9c7..4510fc7d 100644 --- a/tracker-easy/tracker-easy.h +++ b/tracker-easy/tracker-easy.h @@ -77,6 +77,7 @@ namespace EasyTracker void MatchVertices(int& aTopIndex, int& aRightIndex, int& aLeftIndex, int& aCenterIndex, int& aTopRight, int& aTopLeft); void MatchThreeOrFourVertices(int& aTopIndex, int& aRightIndex, int& aLeftIndex, int& aCenterIndex); void MatchFiveVertices(int& aTopIndex, int& aRightIndex, int& aLeftIndex, int& aTopRight, int& aTopLeft); + void MatchClipVertices(int& aTopIndex, int& aMiddleIndex, int& aBottomIndex); // diff --git a/tracker-hatire/ftnoir_hatcontrols.ui b/tracker-hatire/ftnoir_hatcontrols.ui index aa84758b..ca4cefbc 100644 --- a/tracker-hatire/ftnoir_hatcontrols.ui +++ b/tracker-hatire/ftnoir_hatcontrols.ui @@ -103,7 +103,7 @@ <bool>false</bool> </property> <property name="sizeAdjustPolicy"> - <enum>QComboBox::AdjustToMinimumContentsLength</enum> + <enum>QComboBox::AdjustToContents</enum> </property> <property name="modelColumn"> <number>0</number> diff --git a/tracker-linux-joystick/CMakeLists.txt b/tracker-linux-joystick/CMakeLists.txt new file mode 100644 index 00000000..4e821b01 --- /dev/null +++ b/tracker-linux-joystick/CMakeLists.txt @@ -0,0 +1,4 @@ +if(LINUX) + otr_module(tracker-linux-joystick) + target_link_libraries(opentrack-tracker-linux-joystick) +endif() diff --git a/tracker-linux-joystick/ftnoir_tracker_linux_joystick.cpp b/tracker-linux-joystick/ftnoir_tracker_linux_joystick.cpp new file mode 100644 index 00000000..8fa600e7 --- /dev/null +++ b/tracker-linux-joystick/ftnoir_tracker_linux_joystick.cpp @@ -0,0 +1,87 @@ +/* Copyright (c) 2013 Stanislaw Halik <sthalik@misaki.pl> + * + * 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_tracker_linux_joystick.h" +#include "api/plugin-api.hpp" +#include "compat/math.hpp" +#include <QMutexLocker> + +joystick::joystick() +{ + QString device = getJoystickDevice(s.guid); + joy_fd = open(device.toUtf8().data(), O_RDONLY | O_NONBLOCK); +} + + +joystick::~joystick() { + if (joy_fd > 0) close(joy_fd); +} + +module_status joystick::start_tracker(QFrame *) +{ + if (joy_fd == -1) return error("Couldn't open joystick"); + return status_ok(); +} + + +void joystick::data(double *data) +{ + int map[6] = { + s.joy_1 - 1, + s.joy_2 - 1, + s.joy_3 - 1, + s.joy_4 - 1, + s.joy_5 - 1, + s.joy_6 - 1, + }; + + const double limits[] = { + 100, + 100, + 100, + 180, + 180, + 180 + }; + + const QString guid = s.guid; + int axes[8]; + struct js_event event; + bool ret = true; + if (read(joy_fd, &event, sizeof(event)) > 0) + { + switch (event.type) + { + case JS_EVENT_AXIS: + if (event.number >= 8) break; + axes_state[event.number] = event.value; + + break; + default: + /* Ignore init/button events. */ + break; + } + } + + for (int i = 0; i < 6; i++) + { + axes[i] = axes_state[i]; + } + if (ret) + { + for (int i = 0; i < 6; i++) + { + int k = map[i]; + if (k < 0 || k >= 8) + data[i] = 0; + else + data[i] = clamp(axes[k] * limits[i] / AXIS_MAX, + -limits[i], limits[i]); + } + } +} + +OPENTRACK_DECLARE_TRACKER(joystick, dialog_joystick, joystickDll) diff --git a/tracker-linux-joystick/ftnoir_tracker_linux_joystick.h b/tracker-linux-joystick/ftnoir_tracker_linux_joystick.h new file mode 100644 index 00000000..6ddc4909 --- /dev/null +++ b/tracker-linux-joystick/ftnoir_tracker_linux_joystick.h @@ -0,0 +1,90 @@ +/* Copyright (c) 2013 Stanislaw Halik <sthalik@misaki.pl> + * + * 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 "ui_ftnoir_tracker_linux_joystick_controls.h" +#include <QComboBox> +#include <QCheckBox> +#include <QSpinBox> +#include <QMessageBox> +#include <QSettings> +#include <QList> +#include <QFrame> +#include <QStringList> +#include <cmath> +#include "api/plugin-api.hpp" + +#include <linux/joystick.h> +#include <fcntl.h> +#include <unistd.h> + +#include "options/options.hpp" +using namespace options; + +struct settings : opts { + value<QString> guid; + value<int> joy_1, joy_2, joy_3, joy_4, joy_5, joy_6; + settings() : + opts("tracker-linux-joystick"), + guid(b, "joy-guid", ""), + joy_1(b, "axis-map-1", 1), + joy_2(b, "axis-map-2", 2), + joy_3(b, "axis-map-3", 3), + joy_4(b, "axis-map-4", 4), + joy_5(b, "axis-map-5", 5), + joy_6(b, "axis-map-6", 6) + {} +}; + +struct linux_joystick { + QString name; + QString device_id; + QString dev; +}; +QList<linux_joystick> getJoysticks(); +QString getJoystickDevice(QString guid); + +class joystick : public ITracker +{ +public: + joystick(); + ~joystick(); + module_status start_tracker(QFrame *); + void data(double *data); + settings s; + QString guid; + static constexpr int AXIS_MAX = USHRT_MAX; + int axes_state[6] = {0}; + int joy_fd; +}; + +class dialog_joystick: public ITrackerDialog +{ + Q_OBJECT +public: + dialog_joystick(); + void register_tracker(ITracker *) {} + void unregister_tracker() {} + Ui::UILinuxJoystickControls ui; + joystick* tracker; + settings s; + struct joys { + QString name; + QString guid; + }; + QList<joys> joys_; +private slots: + void doOK(); + void doCancel(); +}; + +class joystickDll : public Metadata +{ + Q_OBJECT + + QString name() { return tr("Linux Joystick input"); } + QIcon icon() { return QIcon(":/images/opentrack.png"); } +}; diff --git a/tracker-linux-joystick/ftnoir_tracker_linux_joystick_controls.ui b/tracker-linux-joystick/ftnoir_tracker_linux_joystick_controls.ui new file mode 100644 index 00000000..2a54c74a --- /dev/null +++ b/tracker-linux-joystick/ftnoir_tracker_linux_joystick_controls.ui @@ -0,0 +1,492 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UILinuxJoystickControls</class> + <widget class="QWidget" name="UILinuxJoystickControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>498</width> + <height>334</height> + </rect> + </property> + <property name="windowTitle"> + <string>Tracker settings</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>../gui/images/opentrack.png</normaloff>../gui/images/opentrack.png</iconset> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>12</number> + </property> + <property name="topMargin"> + <number>6</number> + </property> + <property name="rightMargin"> + <number>12</number> + </property> + <property name="bottomMargin"> + <number>6</number> + </property> + <item> + <widget class="QFrame" name="frame"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Device</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="joylist"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Mapping</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <widget class="QComboBox" name="joy_1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>1</number> + </property> + <item> + <property name="text"> + <string>Disabled</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #1</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #2</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #3</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #4</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #5</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #6</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #7</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #8</string> + </property> + </item> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="joy_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>2</number> + </property> + <item> + <property name="text"> + <string>Disabled</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #1</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #2</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #3</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #4</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #5</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #6</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #7</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #8</string> + </property> + </item> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="joy_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>3</number> + </property> + <item> + <property name="text"> + <string>Disabled</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #1</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #2</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #3</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #4</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #5</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #6</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #7</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #8</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1"> + <widget class="QComboBox" name="joy_4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>4</number> + </property> + <item> + <property name="text"> + <string>Disabled</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #1</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #2</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #3</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #4</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #5</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #6</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #7</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #8</string> + </property> + </item> + </widget> + </item> + <item row="4" column="1"> + <widget class="QComboBox" name="joy_5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>5</number> + </property> + <item> + <property name="text"> + <string>Disabled</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #1</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #2</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #3</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #4</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #5</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #6</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #7</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #8</string> + </property> + </item> + </widget> + </item> + <item row="5" column="1"> + <widget class="QComboBox" name="joy_6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>6</number> + </property> + <item> + <property name="text"> + <string>Disabled</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #1</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #2</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #3</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #4</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #5</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #6</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #7</string> + </property> + </item> + <item> + <property name="text"> + <string>Joystick axis #8</string> + </property> + </item> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>X</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Y</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Z</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Yaw</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Pitch</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Roll</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>buttonBox</tabstop> + </tabstops> + <resources/> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> diff --git a/tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp b/tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp new file mode 100644 index 00000000..1cf75bc1 --- /dev/null +++ b/tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp @@ -0,0 +1,40 @@ +#include "ftnoir_tracker_linux_joystick.h" +#include "api/plugin-api.hpp" + +dialog_joystick::dialog_joystick() : tracker(nullptr) +{ + 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())); + + QList<::linux_joystick> joysticks = getJoysticks(); + + for (int i = 0; i < joysticks.size(); i++) { + ::linux_joystick joy = joysticks[i]; + joys_.push_back(joys { joy.name, joy.device_id}); + ui.joylist->addItem(QString("%1 | %2").arg(joy.dev).arg(joy.name)); + if (joysticks[i].device_id == s.guid) ui.joylist->setCurrentIndex(i); + } + + tie_setting(s.joy_1, ui.joy_1); + tie_setting(s.joy_2, ui.joy_2); + tie_setting(s.joy_3, ui.joy_3); + tie_setting(s.joy_4, ui.joy_4); + tie_setting(s.joy_5, ui.joy_5); + tie_setting(s.joy_6, ui.joy_6); +} + +void dialog_joystick::doOK() { + int idx = ui.joylist->currentIndex(); + static const joys def { {}, {} }; + auto val = joys_.value(idx, def); + s.guid = val.guid; + s.b->save(); + close(); +} + +void dialog_joystick::doCancel() { + close(); +} diff --git a/tracker-linux-joystick/lang/nl_NL.ts b/tracker-linux-joystick/lang/nl_NL.ts new file mode 100644 index 00000000..1c9b89d0 --- /dev/null +++ b/tracker-linux-joystick/lang/nl_NL.ts @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="nl_NL"> +<context> + <name>UILinuxJoystickControls</name> + <message> + <source>Tracker settings</source> + <translation type="unfinished">Tracker-instellingen</translation> + </message> + <message> + <source>Device</source> + <translation type="unfinished">Apparaat</translation> + </message> + <message> + <source>Mapping</source> + <translation type="unfinished">Verwijzing</translation> + </message> + <message> + <source>Disabled</source> + <translation type="unfinished">Uitgeschakeld</translation> + </message> + <message> + <source>Joystick axis #1</source> + <translation type="unfinished">Joystick-as #1</translation> + </message> + <message> + <source>Joystick axis #2</source> + <translation type="unfinished">Joystick-as #2</translation> + </message> + <message> + <source>Joystick axis #3</source> + <translation type="unfinished">Joystick-as #3</translation> + </message> + <message> + <source>Joystick axis #4</source> + <translation type="unfinished">Joystick-as #4</translation> + </message> + <message> + <source>Joystick axis #5</source> + <translation type="unfinished">Joystick-as #5</translation> + </message> + <message> + <source>Joystick axis #6</source> + <translation type="unfinished">Joystick-as #6</translation> + </message> + <message> + <source>Joystick axis #7</source> + <translation type="unfinished">Joystick-as #7</translation> + </message> + <message> + <source>Joystick axis #8</source> + <translation type="unfinished">Joystick-as #8</translation> + </message> + <message> + <source>X</source> + <translation type="unfinished">X</translation> + </message> + <message> + <source>Y</source> + <translation type="unfinished">Y</translation> + </message> + <message> + <source>Z</source> + <translation type="unfinished">Z</translation> + </message> + <message> + <source>Yaw</source> + <translation type="unfinished">Yaw</translation> + </message> + <message> + <source>Pitch</source> + <translation type="unfinished">Pitch</translation> + </message> + <message> + <source>Roll</source> + <translation type="unfinished">Rol</translation> + </message> +</context> +<context> + <name>joystickDll</name> + <message> + <source>Linux Joystick input</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tracker-linux-joystick/lang/ru_RU.ts b/tracker-linux-joystick/lang/ru_RU.ts new file mode 100644 index 00000000..34ed1089 --- /dev/null +++ b/tracker-linux-joystick/lang/ru_RU.ts @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="ru_RU"> +<context> + <name>UILinuxJoystickControls</name> + <message> + <source>Tracker settings</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Device</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Mapping</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Disabled</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #1</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #2</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #3</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #4</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #5</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #6</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #7</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #8</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>X</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Y</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Z</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Yaw</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Pitch</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Roll</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>joystickDll</name> + <message> + <source>Linux Joystick input</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tracker-linux-joystick/lang/stub.ts b/tracker-linux-joystick/lang/stub.ts new file mode 100644 index 00000000..12dc1400 --- /dev/null +++ b/tracker-linux-joystick/lang/stub.ts @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1"> +<context> + <name>UILinuxJoystickControls</name> + <message> + <source>Tracker settings</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Device</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Mapping</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Disabled</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #1</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #2</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #3</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #4</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #5</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #6</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #7</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #8</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>X</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Y</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Z</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Yaw</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Pitch</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Roll</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>joystickDll</name> + <message> + <source>Linux Joystick input</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tracker-linux-joystick/lang/zh_CN.ts b/tracker-linux-joystick/lang/zh_CN.ts new file mode 100644 index 00000000..12dc1400 --- /dev/null +++ b/tracker-linux-joystick/lang/zh_CN.ts @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1"> +<context> + <name>UILinuxJoystickControls</name> + <message> + <source>Tracker settings</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Device</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Mapping</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Disabled</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #1</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #2</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #3</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #4</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #5</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #6</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #7</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Joystick axis #8</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>X</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Y</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Z</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Yaw</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Pitch</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Roll</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>joystickDll</name> + <message> + <source>Linux Joystick input</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tracker-linux-joystick/linux_joystick.cpp b/tracker-linux-joystick/linux_joystick.cpp new file mode 100644 index 00000000..49718b52 --- /dev/null +++ b/tracker-linux-joystick/linux_joystick.cpp @@ -0,0 +1,65 @@ +#include "ftnoir_tracker_linux_joystick.h" + +#include <QDir> +#include <QFileInfo> +#include <QVariant> + +// Discovery is done by searching for devices in the sys file system. +// +// Given a path like this +// /sys/devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.2/0003:2341:8036.0170/input/input380/js0 +// we want to get this part of the string 2341:8036, it will allow us to +// identify the device in the future. +// alternative way of doing this https://stackoverflow.com/questions/21173988/linux-attempting-to-get-joystick-vendor-and-product-ids-via-ioctl-get-einval-i +std::tuple<QString, QString> sysfsDeviceToJsDev(QFileInfo device) { + using ret = std::tuple<QString, QString>; + QString symlink = device.symLinkTarget(); + QString js_dev = QString("/dev/input/%1").arg(device.fileName()); + + QRegExp sep(QString("[:.%1]").arg(QDir::separator())); + QString device_id = symlink.section(sep, -6, -5); + return ret(js_dev, device_id); +} + +QList<linux_joystick> getJoysticks() +{ + char name[128]; + QList<linux_joystick> joysticks; + + QDir dir("/sys/class/input/"); + dir.setNameFilters({ "js*" }); + QFileInfoList list = dir.entryInfoList(); + for (int i = 0; i < list.size(); ++i) + { + QFileInfo device = list.at(i); + auto [js_dev, device_id] = sysfsDeviceToJsDev(device); + int iFile = open(js_dev.toUtf8().data(), O_RDONLY | O_NONBLOCK); + if (iFile == -1) continue; + if (ioctl(iFile, JSIOCGNAME(sizeof(name)), &name) > 0) + { + linux_joystick j; + j.name = name; + j.dev = js_dev; + j.device_id = device_id; + joysticks.append(j); + } + close(iFile); + + } + + return joysticks; +} + +QString getJoystickDevice(QString guid) { + QDir dir("/sys/class/input/"); + dir.setNameFilters({ "js*" }); + QFileInfoList list = dir.entryInfoList(); + for (int i = 0; i < list.size(); ++i) + { + QFileInfo device = list.at(i); + auto [js_dev, device_id] = sysfsDeviceToJsDev(device); + if (device_id == guid) return js_dev; + } + + return {}; +} diff --git a/tracker-s2bot/ftnoir_tracker_s2bot.cpp b/tracker-s2bot/ftnoir_tracker_s2bot.cpp index c1cb7d9b..c9d684aa 100644 --- a/tracker-s2bot/ftnoir_tracker_s2bot.cpp +++ b/tracker-s2bot/ftnoir_tracker_s2bot.cpp @@ -27,6 +27,10 @@ static constexpr int add_cbx[] = -180, }; +#ifdef __GNUG__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + void tracker_s2bot::run() { int freq = s.freq; if (freq <= 0) diff --git a/video-ps3eye/CMakeLists.txt b/video-ps3eye/CMakeLists.txt index 3423901b..2f0bf50b 100644 --- a/video-ps3eye/CMakeLists.txt +++ b/video-ps3eye/CMakeLists.txt @@ -22,7 +22,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ps3eye-driver/CMakeLists.txt") endif() endif() -if(TARGET ps3eye-sdl) +if(TARGET ps3eye-sdl AND FALSE) install(TARGETS "ps3eye-sdl" DESTINATION "${opentrack-libexec}") if(WIN32) foreach(k ${SDL2_LIBRARIES}) diff --git a/video-ps3eye/module.cpp b/video-ps3eye/module.cpp index 1d4e43f1..a7078180 100644 --- a/video-ps3eye/module.cpp +++ b/video-ps3eye/module.cpp @@ -169,7 +169,7 @@ bool ps3eye_camera::start(info& args) ptr.in.gain = (uint8_t)s.gain; ptr.in.exposure = (uint8_t)s.exposure; - sleep_ms = (int)std::ceil(1000./std::max(1, (int)ptr.in.framerate)); + sleep_ms = std::clamp(int(std::floor(1000./ptr.in.framerate*2)), 1, 10); wrapper.start(); diff --git a/video-ps3eye/ps3eye-driver b/video-ps3eye/ps3eye-driver -Subproject 2cde6fbfbde7874daab634ca3b35b7ede14ed88 +Subproject ac056aa85dca83be3b1a14df7b20fd07104e052 |