summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--api/plugin-support.hpp11
-rw-r--r--cmake/msvc.cmake2
-rw-r--r--cmake/opentrack-boilerplate.cmake1
-rw-r--r--cmake/opentrack-platform.cmake3
-rw-r--r--cmake/opentrack-policy.cmake1
-rw-r--r--cmake/opentrack-qt.cmake4
-rw-r--r--compat/mutex.cpp33
-rw-r--r--compat/mutex.hpp24
-rw-r--r--csv/csv.cpp220
-rw-r--r--csv/csv.h24
-rw-r--r--gui/init.cpp5
-rw-r--r--gui/process_detector.cpp2
-rw-r--r--opentrack/new_file_dialog.h1
-rw-r--r--options/bundle.hpp8
-rw-r--r--options/connector.hpp4
-rw-r--r--options/globals.hpp4
-rw-r--r--options/metatype.cpp2
-rw-r--r--proto-ft/ftnoir_protocol_ft.cpp2
-rw-r--r--sdk-paths-sthalik@MSVC-windows.cmake4
-rw-r--r--spline/spline-widget.cpp20
-rw-r--r--spline/spline.cpp42
-rw-r--r--spline/spline.hpp13
-rw-r--r--tracker-hatire/thread.cpp8
-rw-r--r--tracker-s2bot/ftnoir_tracker_s2bot.cpp3
-rw-r--r--tracker-steamvr/steamvr.cpp4
-rw-r--r--tracker-steamvr/steamvr.hpp6
-rw-r--r--video-opencv/impl-camera.cpp5
-rw-r--r--video-ps3eye/module.cpp5
-rw-r--r--video/video-widget.hpp2
29 files changed, 184 insertions, 279 deletions
diff --git a/api/plugin-support.hpp b/api/plugin-support.hpp
index 9c0a3ae0..105b2c29 100644
--- a/api/plugin-support.hpp
+++ b/api/plugin-support.hpp
@@ -17,6 +17,7 @@
#include <QDebug>
#include <QString>
+#include <QStringView>
#include <QLibrary>
#include <QDir>
#include <QIcon>
@@ -132,9 +133,9 @@ private:
static QString trim_filename(const QString& in_)
{
- QStringRef in(&in_);
+ QString in(in_);
- const int idx = in.lastIndexOf("/");
+ const int idx = in.lastIndexOf('/');
if (idx != -1)
{
@@ -143,8 +144,8 @@ private:
if (in.startsWith(OPENTRACK_LIBRARY_PREFIX) &&
in.endsWith("." OPENTRACK_LIBRARY_EXTENSION))
{
- constexpr unsigned pfx_len = sizeof(OPENTRACK_LIBRARY_PREFIX) - 1;
- constexpr unsigned rst_len = sizeof("." OPENTRACK_LIBRARY_EXTENSION) - 1;
+ constexpr auto pfx_len = (qsizetype)sizeof(OPENTRACK_LIBRARY_PREFIX) - 1;
+ constexpr auto rst_len = (qsizetype)sizeof("." OPENTRACK_LIBRARY_EXTENSION) - 1;
in = in.mid(pfx_len);
in = in.left(in.size() - rst_len);
@@ -161,7 +162,7 @@ private:
for (auto name : names)
{
if (in.startsWith(name))
- return in.mid(std::strlen(name)).toString();
+ return in.mid((qsizetype)std::strlen(name));
}
}
}
diff --git a/cmake/msvc.cmake b/cmake/msvc.cmake
index cd967dd9..1e67948d 100644
--- a/cmake/msvc.cmake
+++ b/cmake/msvc.cmake
@@ -51,6 +51,8 @@ if(CMAKE_PROJECT_NAME STREQUAL "opencv")
endif()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+
+cmake_policy(SET CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
add_compile_options(-Zi -Zf -Zo -bigobj -cgthreads1 -vd0)
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake
index a78e0ed0..a3034b44 100644
--- a/cmake/opentrack-boilerplate.cmake
+++ b/cmake/opentrack-boilerplate.cmake
@@ -170,6 +170,7 @@ function(otr_module n_)
add_library(${n} ${link-mode} "${${n}-all}")
set_property(TARGET "${n}" PROPERTY PREFIX "")
endif()
+ set_property(TARGET "${n}" PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
if(NOT arg_NO-QT)
otr_qt2("${n}")
diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake
index 23f684f3..274a2189 100644
--- a/cmake/opentrack-platform.cmake
+++ b/cmake/opentrack-platform.cmake
@@ -146,8 +146,9 @@ if(MSVC)
#C4266 - no override available for virtual member function from base type, function is hidden
#C4928 - illegal copy-initialization, more than one user-defined conversion has been implicitly applied
#C4200: nonstandard extension used: zero-sized array in struct/union
+ #C4828: The file contains a character starting at offset 0x1433 that is illegal in the current source character set (codepage 65001).
- set(warns-disable 4530 4577 4789 4244 4702 4530 4244 4127 4458 4456 4251 4100 4702 4457 4200)
+ set(warns-disable 4530 4577 4789 4244 4702 4530 4244 4127 4458 4456 4251 4100 4702 4457 4200 4828)
foreach(i ${warns-disable})
add_compile_options(-wd${i})
diff --git a/cmake/opentrack-policy.cmake b/cmake/opentrack-policy.cmake
index 6426cf87..6eafd90c 100644
--- a/cmake/opentrack-policy.cmake
+++ b/cmake/opentrack-policy.cmake
@@ -14,6 +14,7 @@ set(_policies
CMP0069
CMP0063
CMP0082
+ CMP0069
)
foreach(k ${_policies})
if(POLICY ${k})
diff --git a/cmake/opentrack-qt.cmake b/cmake/opentrack-qt.cmake
index ab0b751b..274948f4 100644
--- a/cmake/opentrack-qt.cmake
+++ b/cmake/opentrack-qt.cmake
@@ -23,12 +23,12 @@ function(otr_install_qt_libs)
if(NOT TARGET "${i}")
continue()
endif()
- otr_install_lib(${i} "platforms")
+ otr_install_lib(${i} ".")
endforeach()
if(WIN32)
get_property(foo TARGET Qt6::Core PROPERTY IMPORTED_LOCATION)
get_filename_component(foo "${foo}" DIRECTORY)
- otr_install_lib("${foo}/../platforms/qwindows.dll" "platforms")
+ otr_install_lib("${foo}/../plugins/platforms/qwindows.dll" "platforms")
endif()
endfunction()
diff --git a/compat/mutex.cpp b/compat/mutex.cpp
deleted file mode 100644
index 664677ea..00000000
--- a/compat/mutex.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "mutex.hpp"
-#include <cstdlib>
-
-mutex& mutex::operator=(const mutex& rhs)
-{
- if (rhs->isRecursive() != inner.isRecursive())
- std::abort();
-
- return *this;
-}
-
-mutex::mutex(const mutex& datum) : mutex{datum.inner.isRecursive() ? Recursive : NonRecursive}
-{
-}
-
-mutex::mutex(RecursionMode m) : inner{m}
-{
-}
-
-QMutex* mutex::operator&() const noexcept
-{
- return &inner;
-}
-
-mutex::operator QMutex*() const noexcept
-{
- return &inner;
-}
-
-QMutex* mutex::operator->() const noexcept
-{
- return &inner;
-}
diff --git a/compat/mutex.hpp b/compat/mutex.hpp
deleted file mode 100644
index 54758a08..00000000
--- a/compat/mutex.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-
-#include <QMutex>
-
-#include "export.hpp"
-
-class OTR_COMPAT_EXPORT mutex
-{
- mutable QMutex inner;
-
-public:
- using RecursionMode = QMutex::RecursionMode;
- static constexpr RecursionMode Recursive = RecursionMode::Recursive;
- static constexpr RecursionMode NonRecursive = RecursionMode::NonRecursive;
-
- mutex& operator=(const mutex& datum);
- mutex(const mutex& datum);
- explicit mutex(RecursionMode m);
- mutex() : mutex{NonRecursive} {}
-
- QMutex* operator&() const noexcept;
- explicit operator QMutex*() const noexcept;
- QMutex* operator->() const noexcept;
-};
diff --git a/csv/csv.cpp b/csv/csv.cpp
index a1f62dc0..d465906b 100644
--- a/csv/csv.cpp
+++ b/csv/csv.cpp
@@ -10,85 +10,19 @@
*/
#include "csv.h"
+#include "compat/macros.hpp"
#include "compat/library-path.hpp"
-#include <QTextDecoder>
-#include <QFile>
-#include <QString>
-#include <QDebug>
-
-#include <utility>
-#include <algorithm>
-
-const QTextCodec* const CSV::m_codec = QTextCodec::codecForName("System");
-const QRegExp CSV::m_rx = QRegExp(QString("((?:(?:[^;\\n]*;?)|(?:\"[^\"]*\";?))*)?\\n?"));
-const QRegExp CSV::m_rx2 = QRegExp(QString("(?:\"([^\"]*)\";?)|(?:([^;]*);?)?"));
-
-CSV::CSV(QIODevice* device) :
- m_device(device),
- m_pos(0)
-{
- if (m_device && m_device->isReadable())
- {
- QTextDecoder dec(m_codec);
- m_string = dec.toUnicode(m_device->readAll());
- }
-}
-
-QString CSV::readLine()
-{
- QString line;
-
- if ((m_pos = m_rx.indexIn(m_string,m_pos)) != -1)
- {
- line = m_rx.cap(1);
- m_pos += m_rx.matchedLength();
- }
- else
- {
- const QChar lf(QChar::LineFeed);
-
- while (m_pos < m_string.length())
- if (m_string[m_pos++] == lf)
- break;
- }
- return line;
-}
-
-bool CSV::parseLine(QStringList& ret)
-{
- QString line(readLine());
-
- QStringList list;
- int pos2 = 0;
-
- if (line.size() == 0)
- {
- ret = QStringList();
- return m_device->size() > m_pos;
- }
- else
- {
- while (line.size() > pos2 && (pos2 = m_rx2.indexIn(line, pos2)) != -1)
- {
- QString col;
- if (m_rx2.cap(1).size() > 0)
- col = m_rx2.cap(1);
- else if (m_rx2.cap(2).size() > 0)
- col = m_rx2.cap(2);
- list << col;
+#include <ios>
+#include <fstream>
+#include <sstream>
+#include <vector>
- if (col.size())
- pos2 += m_rx2.matchedLength();
- else
- pos2++;
- }
- }
- ret = std::move(list);
- return true;
-}
+#include <QString>
+#include <QDebug>
-bool CSV::getGameData(int id, unsigned char* table, QString& gamename)
+static bool
+check_line(int id, unsigned char* table, QString& game_name, const std::vector<std::string>& fields, unsigned lineno)
{
for (int i = 0; i < 8; i++)
table[i] = 0;
@@ -96,76 +30,104 @@ bool CSV::getGameData(int id, unsigned char* table, QString& gamename)
if (id != 0)
qDebug() << "csv: lookup game id" << id;
- QString id_str(QString::number(id));
+ const auto id_str = std::to_string(id);
- static const QString csv_path(OPENTRACK_BASE_PATH +
- OPENTRACK_DOC_PATH "settings/facetracknoir supported games.csv");
+ unsigned tmp[8];
+ unsigned fuzz[3];
- QFile file(csv_path);
+ //qDebug() << "Column 0: " << gameLine.at(0); // No.
+ //qDebug() << "Column 1: " << gameLine.at(1); // Game Name
+ //qDebug() << "Column 2: " << gameLine.at(2); // Game Protocol
+ //qDebug() << "Column 3: " << gameLine.at(3); // Supported since version
+ //qDebug() << "Column 4: " << gameLine.at(4); // Verified
+ //qDebug() << "Column 5: " << gameLine.at(5); // By
+ //qDebug() << "Column 6: " << gameLine.at(6); // International ID
+ //qDebug() << "Column 7: " << gameLine.at(7); // FaceTrackNoIR ID
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ if (fields.size() == 8)
{
- qDebug() << "csv: can't open game list for freetrack protocol!";
- return false;
+ if (fields[6] == id_str)
+ {
+ const auto& proto = fields[3];
+ const auto& name = fields[1];
+
+ const auto& proto_id = fields[7];
+
+ auto do_scanf = [&]() {
+ return sscanf(proto_id.c_str(),
+ "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ fuzz + 2,
+ fuzz + 0,
+ tmp + 3, tmp + 2, tmp + 1, tmp + 0,
+ tmp + 7, tmp + 6, tmp + 5, tmp + 4,
+ fuzz + 1);
+ };
+
+ if (proto == "V160" || proto_id.size() != 22)
+ (void)0;
+ else if (proto_id.size() != 22 || do_scanf() != 11)
+ qDebug() << "scanf failed" << lineno;
+ else
+ for (int i = 0; i < 8; i++)
+ table[i] = (unsigned char)tmp[i];
+ game_name = QString::fromStdString(name);
+ return true;
+ }
}
+ else
+ eval_once(qDebug() << "malformed csv line" << lineno);
- CSV csv(&file);
-
- unsigned tmp[8];
- unsigned fuzz[3];
+ if (id)
+ qDebug() << "unknown game connected" << id;
- QStringList gameLine;
+ return false;
+}
- for (int lineno = 0; csv.parseLine(gameLine); lineno++)
+bool get_game_data(int id, unsigned char* table, QString& game_name)
+{
+ static const auto filename =
+ (OPENTRACK_BASE_PATH + OPENTRACK_DOC_PATH "settings/facetracknoir supported games.csv").toStdWString();
+ std::ifstream in;
+ in.exceptions(std::ifstream::badbit | std::ifstream::failbit);
+ in.open(filename);
+ try
{
- //qDebug() << "Column 0: " << gameLine.at(0); // No.
- //qDebug() << "Column 1: " << gameLine.at(1); // Game Name
- //qDebug() << "Column 2: " << gameLine.at(2); // Game Protocol
- //qDebug() << "Column 3: " << gameLine.at(3); // Supported since version
- //qDebug() << "Column 4: " << gameLine.at(4); // Verified
- //qDebug() << "Column 5: " << gameLine.at(5); // By
- //qDebug() << "Column 6: " << gameLine.at(6); // International ID
- //qDebug() << "Column 7: " << gameLine.at(7); // FaceTrackNoIR ID
-
- if (gameLine.count() == 8)
+ if (in.fail())
+ eval_once(qDebug() << "can't open csv file");
+
+ std::string line, field;
+ line.reserve(1024); field.reserve(1024);
+ std::vector<std::string> fields; fields.reserve(16);
+ unsigned lineno = 0;
+ try
{
- if (gameLine.at(6).compare(id_str, Qt::CaseInsensitive) == 0)
+ while (!in.eof())
{
- const QString& proto = gameLine[3];
- QString& name = gameLine[1];
-
- const QByteArray id_cstr = gameLine[7].toLatin1();
-
- auto do_scanf = [&]() {
- return sscanf(id_cstr.constData(),
- "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
- fuzz + 2,
- fuzz + 0,
- tmp + 3, tmp + 2, tmp + 1, tmp + 0,
- tmp + 7, tmp + 6, tmp + 5, tmp + 4,
- fuzz + 1);
- };
-
- if (proto == QStringLiteral("V160") || id_cstr.length() != 22)
- (void)0;
- else if (id_cstr.length() != 22 || do_scanf() != 11)
- qDebug() << "scanf failed" << lineno;
- else
+ line.clear();
+ std::getline(in, line);
+ std::stringstream s{line, std::ios_base::in};
+ fields.clear();
+ while (!s.eof())
{
- using uchar = unsigned char;
- for (int i = 0; i < 8; i++)
- table[i] = uchar(tmp[i]);
+ field.clear();
+ std::getline(s, field, ';');
+ fields.push_back(field);
}
- gamename = std::move(name);
- return true;
+ bool ret = check_line(id, table, game_name, fields, lineno);
+ if (ret)
+ return true;
+ lineno++;
}
}
- else
- qDebug() << "malformed csv line" << lineno;
+ catch (const std::ios::failure& e)
+ {
+ eval_once(qDebug() << "failed to read .csv file:" << e.what());
+ }
+ }
+ catch (const std::ios::failure& e)
+ {
+ eval_once(qDebug() << "can't open .csv file:" << e.what());
}
-
- if (id)
- qDebug() << "unknown game connected" << id;
return false;
}
diff --git a/csv/csv.h b/csv/csv.h
index 9e72b2bb..0e223fe1 100644
--- a/csv/csv.h
+++ b/csv/csv.h
@@ -1,26 +1,6 @@
#pragma once
-#include <QtGlobal>
-#include <QObject>
-#include <QStringList>
-#include <QIODevice>
-#include <QTextCodec>
-#include <QRegExp>
-#include <QtGlobal>
-class CSV
-{
-public:
- QString readLine();
- bool parseLine(QStringList& ret);
+class QString;
- static bool getGameData(int gameID, unsigned char* table, QString& gamename);
-private:
- CSV(QIODevice* device);
+bool get_game_data(int id, unsigned char* table, QString& game_name);
- QIODevice* m_device;
- QString m_string;
- int m_pos;
-
- static QTextCodec const* const m_codec;
- static const QRegExp m_rx, m_rx2;
-};
diff --git a/gui/init.cpp b/gui/init.cpp
index 2b7b01ad..246b7017 100644
--- a/gui/init.cpp
+++ b/gui/init.cpp
@@ -295,11 +295,6 @@ int otr_main(int argc, char** argv, std::function<std::unique_ptr<QWidget>()> co
enable_x11_threads();
#endif
- QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
- QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
-#endif
-
QApplication app(argc, argv);
#ifdef _WIN32
diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp
index 58ea4ca9..4dadd041 100644
--- a/gui/process_detector.cpp
+++ b/gui/process_detector.cpp
@@ -63,7 +63,7 @@ void proc_detector_settings::set_is_enabled(bool enabled)
QHash<QString, QString> proc_detector_settings::split_process_names()
{
QString str = get_game_list();
- QStringList pairs = str.split(RECORD_SEPARATOR, QString::SkipEmptyParts);
+ QStringList pairs = str.split(RECORD_SEPARATOR, Qt::SkipEmptyParts);
QHash<QString, QString> ret;
ret.reserve(pairs.size() * 2);
for (auto const& pair : pairs)
diff --git a/opentrack/new_file_dialog.h b/opentrack/new_file_dialog.h
index 7244e524..9e3c86a6 100644
--- a/opentrack/new_file_dialog.h
+++ b/opentrack/new_file_dialog.h
@@ -3,7 +3,6 @@
#include "ui_new_config.h"
#include "options/options.hpp"
#include <QFile>
-#include <QRegExp>
#include <QString>
#include <QMessageBox>
diff --git a/options/bundle.hpp b/options/bundle.hpp
index 158fcef9..58324e79 100644
--- a/options/bundle.hpp
+++ b/options/bundle.hpp
@@ -21,7 +21,7 @@
#include <QObject>
#include <QString>
#include <QVariant>
-#include <QMutex>
+#include <QRecursiveMutex>
#include <QDebug>
@@ -46,7 +46,7 @@ class OTR_OPTIONS_EXPORT bundle final : public QObject, public connector
friend struct bundler;
- mutable QMutex mtx { QMutex::Recursive };
+ mutable QRecursiveMutex mtx;
const QString group_name;
group saved;
group transient;
@@ -62,7 +62,7 @@ public:
bundle(const bundle&) = delete;
bundle& operator=(const bundle&) = delete;
- QMutex* get_mtx() const override { return &mtx; }
+ QRecursiveMutex* get_mtx() const override { return &mtx; }
QString name() const { return group_name; }
explicit bundle(const QString& group_name);
@@ -93,7 +93,7 @@ struct OTR_OPTIONS_EXPORT bundler final
static void reload();
private:
- QMutex implsgl_mtx { QMutex::Recursive };
+ mutable QRecursiveMutex implsgl_mtx;
std::unordered_map<k, weak> implsgl_data {};
void notify_();
diff --git a/options/connector.hpp b/options/connector.hpp
index 025efda2..bcac5676 100644
--- a/options/connector.hpp
+++ b/options/connector.hpp
@@ -14,7 +14,7 @@
#include <vector>
#include <QString>
-#include <QMutex>
+#include <QRecursiveMutex>
#include "export.hpp"
@@ -38,7 +38,7 @@ class OTR_OPTIONS_EXPORT connector
protected:
void notify_values(const QString& name) const;
void notify_all_values() const;
- virtual QMutex* get_mtx() const = 0;
+ virtual QRecursiveMutex* get_mtx() const = 0;
void set_all_to_default_();
public:
diff --git a/options/globals.hpp b/options/globals.hpp
index 7af6533d..e0146a43 100644
--- a/options/globals.hpp
+++ b/options/globals.hpp
@@ -7,7 +7,7 @@
#include <QString>
#include <QSettings>
-#include <QMutex>
+#include <QRecursiveMutex>
namespace options::globals::detail {
@@ -17,7 +17,7 @@ struct OTR_OPTIONS_EXPORT ini_ctx
{
std::optional<QSettings> qsettings { std::in_place };
QString pathname;
- QMutex mtx { QMutex::Recursive };
+ QRecursiveMutex mtx;
unsigned refcount = 0;
bool modifiedp = false;
diff --git a/options/metatype.cpp b/options/metatype.cpp
index 7962b81b..c444edc3 100644
--- a/options/metatype.cpp
+++ b/options/metatype.cpp
@@ -7,7 +7,7 @@ template<typename t>
void declare_metatype_for_type(const char* str)
{
qRegisterMetaType<t>(str);
- qRegisterMetaTypeStreamOperators<t>();
+ //qRegisterMetaTypeStreamOperators<t>();
}
} // ns options::detail
diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp
index c6259593..d437a13d 100644
--- a/proto-ft/ftnoir_protocol_ft.cpp
+++ b/proto-ft/ftnoir_protocol_ft.cpp
@@ -95,7 +95,7 @@ void freetrack::pose(const double* headpose, const double* raw)
t.ints[0] = 0; t.ints[1] = 0;
- (void)CSV::getGameData(id, t.table, gamename);
+ get_game_data(id, t.table, gamename);
{
// FTHeap pMemData happens to be aligned on a page boundary by virtue of
diff --git a/sdk-paths-sthalik@MSVC-windows.cmake b/sdk-paths-sthalik@MSVC-windows.cmake
index ad2ddb7e..b9776f07 100644
--- a/sdk-paths-sthalik@MSVC-windows.cmake
+++ b/sdk-paths-sthalik@MSVC-windows.cmake
@@ -23,7 +23,7 @@ set(opentrack_maintainer-mode TRUE CACHE INTERNAL "" FORCE)
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/../qt-msvc-6.1.0")
setq(EIGEN3_INCLUDE_DIR "eigen")
-setq(OpenCV_DIR "opencv/build")
+setq(OpenCV_DIR "../opencv/build")
setq(SDL2_DIR "SDL2-win32")
setq(SDK_ARUCO_LIBPATH "aruco/build/src/aruco.lib")
setq(SDK_FSUIPC "fsuipc")
@@ -32,7 +32,7 @@ setq(SDK_KINECT20 "Kinect-v2.0")
setq(SDK_LIBUSB "libusb-msvc-x86")
setq(SDK_PS3EYEDRIVER "PS3EYEDriver")
setq(SDK_REALSENSE "RSSDK-R3")
-setq(SDK_RIFT_140 "ovr_sdk_win_1.43.0/LibOVR")
+setq(SDK_RIFT_140 "ovr_sdk_win_23.0.0/LibOVR")
setq(SDK_VALVE_STEAMVR "steamvr")
setq(SDK_VJOYSTICK "vjoystick")
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index 7aeaf590..2120d0ae 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -345,7 +345,7 @@ void spline_widget::drawLine(QPainter& painter, const QPointF& start, const QPoi
void spline_widget::mousePressEvent(QMouseEvent *e)
{
- if (!config || !isEnabled() || !is_in_bounds(e->localPos()) || preview_only)
+ if (!config || !isEnabled() || !is_in_bounds(e->position()) || preview_only)
return;
const double min_dist = min_pt_distance();
@@ -360,7 +360,7 @@ void spline_widget::mousePressEvent(QMouseEvent *e)
for (int i = 0; i < points.size(); i++)
{
- if (point_within_pixel(points[i], e->localPos()))
+ if (point_within_pixel(points[i], e->position()))
{
is_touching_point = true;
moving_control_point_idx = i;
@@ -371,7 +371,7 @@ void spline_widget::mousePressEvent(QMouseEvent *e)
if (!is_touching_point)
{
bool too_close = false;
- const QPointF pos = pixel_to_point(e->localPos());
+ const QPointF pos = pixel_to_point(e->position());
for (QPointF const& point : points)
{
@@ -385,7 +385,7 @@ void spline_widget::mousePressEvent(QMouseEvent *e)
if (!too_close)
{
- config->add_point(pixel_to_point(e->localPos()));
+ config->add_point(pixel_to_point(e->position()));
show_tooltip(e->pos());
}
}
@@ -399,7 +399,7 @@ void spline_widget::mousePressEvent(QMouseEvent *e)
{
for (int i = 0; i < points.size(); i++)
{
- if (point_within_pixel(points[i], e->localPos()))
+ if (point_within_pixel(points[i], e->position()))
{
config->remove_point(i);
draw_function = true;
@@ -434,7 +434,7 @@ void spline_widget::mouseMoveEvent(QMouseEvent *e)
if (i >= 0 && i < sz)
{
const double min_dist = min_pt_distance();
- QPointF new_pt = pixel_to_point(e->localPos());
+ QPointF new_pt = pixel_to_point(e->position());
const bool has_prev = i > 0, has_next = i + 1 < points.size();
@@ -469,7 +469,7 @@ void spline_widget::mouseMoveEvent(QMouseEvent *e)
else if (sz)
{
int i;
- bool is_on_point = is_on_pt(e->localPos(), &i);
+ bool is_on_point = is_on_pt(e->position(), &i);
if (is_on_point)
{
@@ -479,7 +479,7 @@ void spline_widget::mouseMoveEvent(QMouseEvent *e)
else
{
setCursor(Qt::ArrowCursor);
- if (is_in_bounds(e->localPos()))
+ if (is_in_bounds(e->position()))
show_tooltip(e->pos());
else
QToolTip::hideText();
@@ -498,13 +498,13 @@ void spline_widget::mouseReleaseEvent(QMouseEvent *e)
if (e->button() == Qt::LeftButton)
{
{
- if (is_on_pt(e->localPos(), nullptr))
+ if (is_on_pt(e->position(), nullptr))
setCursor(Qt::CrossCursor);
else
setCursor(Qt::ArrowCursor);
}
- if (is_in_bounds(e->localPos()))
+ if (is_in_bounds(e->position()))
show_tooltip(e->pos());
else
QToolTip::hideText();
diff --git a/spline/spline.cpp b/spline/spline.cpp
index 21044b34..d5708476 100644
--- a/spline/spline.cpp
+++ b/spline/spline.cpp
@@ -31,7 +31,7 @@ spline::spline(const QString& name, const QString& axis_name, Axis axis)
spline::~spline()
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
disconnect_signals();
}
@@ -41,7 +41,7 @@ void spline::set_tracking_active(bool value) const
{
std::shared_ptr<settings> S;
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
S = s;
activep = value;
}
@@ -50,7 +50,7 @@ void spline::set_tracking_active(bool value) const
bundle spline::get_bundle()
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
return s->b;
}
@@ -58,7 +58,7 @@ void spline::clear()
{
std::shared_ptr<settings> S;
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
S = s;
s->points = {};
points = {};
@@ -69,7 +69,7 @@ void spline::clear()
double spline::get_value(double x) const
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
const double ret = get_value_no_save(x);
last_input_value = { std::fabs(x), std::fabs((double)ret) };
@@ -78,7 +78,7 @@ double spline::get_value(double x) const
double spline::get_value_no_save(double x) const
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
double q = x * bucket_size_coefficient(points);
int xi = (int)q;
@@ -91,7 +91,7 @@ double spline::get_value_no_save(double x) const
bool spline::get_last_value(QPointF& point)
{
- QMutexLocker foo(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
point = last_input_value;
return activep && point.y() >= 0;
}
@@ -129,7 +129,7 @@ void spline::ensure_in_bounds(const QList<QPointF>& points, int i, f& x, f& y)
int spline::element_count(const QList<QPointF>& points, double max_input)
{
- const unsigned sz = (unsigned)points.size();
+ const int sz = points.size();
for (int k = sz-1; k >= 0; k--)
{
const QPointF& pt = points[k];
@@ -248,14 +248,14 @@ void spline::remove_point(int i)
{
std::shared_ptr<settings> S;
{
- QMutexLocker foo(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
S = s;
const int sz = element_count(points, max_input());
if (i >= 0 && i < sz)
{
- points.erase(points.begin() + i);
+ points.erase(points.cbegin() + i);
s->points = points;
update_interp_data();
}
@@ -268,7 +268,7 @@ void spline::add_point(QPointF pt)
{
std::shared_ptr<settings> S;
{
- QMutexLocker foo(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
S = s;
points.push_back(pt);
std::stable_sort(points.begin(), points.end(), sort_fn);
@@ -287,7 +287,7 @@ void spline::move_point(int idx, QPointF pt)
{
std::shared_ptr<settings> S;
{
- QMutexLocker foo(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
S = s;
const int sz = element_count(points, max_input());
@@ -310,19 +310,19 @@ const points_t& spline::get_points() const
int spline::get_point_count() const
{
- QMutexLocker foo(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
return element_count(points, clamp_x);
}
void spline::reload()
{
- QMutexLocker foo(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
s->b->reload();
}
void spline::save()
{
- QMutexLocker foo(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
s->b->save();
}
@@ -338,7 +338,7 @@ void spline::invalidate_settings()
{
std::shared_ptr<settings> S;
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
S = s;
invalidate_settings_();
}
@@ -353,7 +353,7 @@ void spline::set_bundle(bundle b, const QString& axis_name, Axis axis)
std::shared_ptr<settings> S;
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
disconnect_signals();
s = std::make_shared<settings>(b, axis_name, axis);
@@ -373,7 +373,7 @@ void spline::set_bundle(bundle b, const QString& axis_name, Axis axis)
double spline::max_input() const
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
if (clamp_x == axis_opts::x1000)
return std::fmax(1, points.empty() ? 0 : points[points.size() - 1].x());
return std::fabs((double)clamp_x);
@@ -381,7 +381,7 @@ double spline::max_input() const
double spline::max_output() const
{
- QMutexLocker l(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
if (clamp_y == axis_opts::x1000 && !points.empty())
return std::fmax(1, points.empty() ? 0 : points[points.size() - 1].y());
return std::fabs((double)clamp_y);
@@ -446,13 +446,13 @@ void spline::ensure_valid(points_t& list) const
std::shared_ptr<base_settings> spline::get_settings()
{
- QMutexLocker foo(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
return std::static_pointer_cast<base_settings>(s);
}
std::shared_ptr<const base_settings> spline::get_settings() const
{
- QMutexLocker foo(&mtx);
+ [[maybe_unused]] QMutexLocker l(*mtx);
return std::static_pointer_cast<const base_settings>(s);
}
diff --git a/spline/spline.hpp b/spline/spline.hpp
index e4f64069..4aeaec2f 100644
--- a/spline/spline.hpp
+++ b/spline/spline.hpp
@@ -11,7 +11,6 @@
#include "options/options.hpp"
#include "axis-opts.hpp"
#include "export.hpp"
-#include "compat/mutex.hpp"
#include <cstddef>
#include <vector>
@@ -21,6 +20,7 @@
#include <QObject>
#include <QPointF>
#include <QString>
+#include <QRecursiveMutex>
#include <QMetaObject>
namespace spline_detail {
@@ -103,6 +103,15 @@ struct OTR_SPLINE_EXPORT base_spline : base_spline_, spline_modify_mixin, spline
~base_spline() override;
};
+struct mutex
+{
+ mutable QRecursiveMutex inner;
+ auto* operator*() { return &inner; }
+ auto* operator->() { return &inner; }
+ mutex() = default;
+ mutex(const mutex&) {}
+};
+
class OTR_SPLINE_EXPORT spline : public base_spline
{
using f = float;
@@ -118,12 +127,12 @@ class OTR_SPLINE_EXPORT spline : public base_spline
void disconnect_signals();
void invalidate_settings_();
- mutex mtx { mutex::Recursive };
std::shared_ptr<settings> s;
QMetaObject::Connection conn_points, conn_maxx, conn_maxy;
std::shared_ptr<QObject> ctx { std::make_shared<QObject>() };
+ mutable mutex mtx;
mutable QPointF last_input_value{-1, -1};
mutable std::vector<float> data = std::vector<float>(value_count, magic_fill_value);
mutable points_t points;
diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp
index 4938e77f..994d573f 100644
--- a/tracker-hatire/thread.cpp
+++ b/tracker-hatire/thread.cpp
@@ -120,7 +120,7 @@ void hatire_thread::teardown_serial()
{
msg.append("\r\n");
msg.append("SEND '");
- msg.append(s.CmdStop);
+ msg.append(s.CmdStop->toLatin1());
msg.append("'\r\n");
}
emit serial_debug_info(msg);
@@ -241,13 +241,13 @@ void hatire_thread::serial_info_impl()
if (com_port.isOpen())
{
msg.append("\r\n");
- msg.append(com_port.portName());
+ msg.append(com_port.portName().toLatin1());
msg.append("\r\n");
msg.append("BAUDRATE :");
- msg.append(QString::number(com_port.baudRate()));
+ msg.append(QString::number(com_port.baudRate()).toLatin1());
msg.append("\r\n");
msg.append("DataBits :");
- msg.append(QString::number(com_port.dataBits()));
+ msg.append(QString::number(com_port.dataBits()).toLatin1());
msg.append("\r\n");
msg.append("Parity :");
diff --git a/tracker-s2bot/ftnoir_tracker_s2bot.cpp b/tracker-s2bot/ftnoir_tracker_s2bot.cpp
index c9d684aa..1034447e 100644
--- a/tracker-s2bot/ftnoir_tracker_s2bot.cpp
+++ b/tracker-s2bot/ftnoir_tracker_s2bot.cpp
@@ -7,6 +7,7 @@
#include <cmath>
#include <QNetworkRequest>
#include <QNetworkReply>
+#include <QRegularExpression>
tracker_s2bot::tracker_s2bot() : pose { 0,0,0, 0,0,0 }, m_nam (std::make_unique<QNetworkAccessManager>())
{
@@ -48,7 +49,7 @@ void tracker_s2bot::run() {
return;
}
- const QStringList slist = QString::fromLatin1(reply->readAll()).split(QRegExp("[\r\n]+"), QString::SkipEmptyParts);
+ const QStringList slist = QString::fromLatin1(reply->readAll()).split(QRegularExpression{"[\r\n]+"}, Qt::SkipEmptyParts);
reply->close();
reply->deleteLater();
diff --git a/tracker-steamvr/steamvr.cpp b/tracker-steamvr/steamvr.cpp
index 3bcfcc25..eafbb946 100644
--- a/tracker-steamvr/steamvr.cpp
+++ b/tracker-steamvr/steamvr.cpp
@@ -26,7 +26,7 @@
#include <QMessageBox>
#include <QDebug>
-QMutex device_list::mtx(QMutex::Recursive);
+QRecursiveMutex device_list::mtx;
template<typename F>
auto with_vr_lock(F&& fun) -> decltype(fun(vr_t(), vr_error_t()))
@@ -285,7 +285,7 @@ steamvr_dialog::steamvr_dialog()
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
ui.device->clear();
- ui.device->addItem("First available", QVariant(QVariant::String));
+ ui.device->addItem("First available", QString{});
device_list list;
for (const device_spec& spec : list.devices())
diff --git a/tracker-steamvr/steamvr.hpp b/tracker-steamvr/steamvr.hpp
index 61da2e05..2e9c5391 100644
--- a/tracker-steamvr/steamvr.hpp
+++ b/tracker-steamvr/steamvr.hpp
@@ -8,7 +8,7 @@
#include <climits>
#include <QString>
-#include <QMutex>
+#include <QRecursiveMutex>
#include <QList>
#include <openvr.h>
@@ -27,7 +27,7 @@ struct settings : opts
value<QVariant> device_serial;
settings() :
opts("valve-steamvr"),
- device_serial(b, "serial", QVariant(QVariant::String))
+ device_serial(b, "serial", QString{})
{}
};
@@ -57,7 +57,7 @@ struct device_list final
private:
QList<device_spec> device_specs;
- static QMutex mtx;
+ static QRecursiveMutex mtx;
static tt vr_init_();
static void fill_device_specs(QList<device_spec>& list);
static tt vr_init();
diff --git a/video-opencv/impl-camera.cpp b/video-opencv/impl-camera.cpp
index 3f2a1b1a..0dc98a58 100644
--- a/video-opencv/impl-camera.cpp
+++ b/video-opencv/impl-camera.cpp
@@ -97,3 +97,8 @@ bool cam::show_dialog()
}
} // ns opencv_camera_impl
+
+#ifdef _MSC_VER
+// workaround bug in cmake. newest MSVC doesn't create dot.lib with no exported symbols
+extern "C" __declspec(dllexport) int _empty(void) { return 0; }
+#endif \ No newline at end of file
diff --git a/video-ps3eye/module.cpp b/video-ps3eye/module.cpp
index a7078180..84c65b90 100644
--- a/video-ps3eye/module.cpp
+++ b/video-ps3eye/module.cpp
@@ -281,3 +281,8 @@ void settings::set_exposure()
++ptr.in.settings_updated;
std::atomic_thread_fence(std::memory_order_seq_cst);
}
+
+#ifdef _MSC_VER
+// workaround bug in cmake. newest MSVC doesn't create dot.lib with no exported symbols
+extern "C" __declspec(dllexport) int _empty(void) { return 0; }
+#endif
diff --git a/video/video-widget.hpp b/video/video-widget.hpp
index bb218c69..461258f7 100644
--- a/video/video-widget.hpp
+++ b/video/video-widget.hpp
@@ -31,7 +31,7 @@ struct OTR_VIDEO_EXPORT video_widget : QWidget
void draw_image();
protected:
- mutable QMutex mtx { QMutex::NonRecursive };
+ mutable QMutex mtx;
QImage texture;
std::vector<unsigned char> vec;
bool fresh() const;