diff options
35 files changed, 401 insertions, 239 deletions
diff --git a/compat/linkage-macros.hpp b/compat/linkage-macros.hpp index 460e7ee5..a4c4b351 100644 --- a/compat/linkage-macros.hpp +++ b/compat/linkage-macros.hpp @@ -7,3 +7,6 @@ # define OTR_GENERIC_EXPORT __attribute__ ((visibility ("default"))) # define OTR_GENERIC_IMPORT #endif + +#define OTR_TEMPLATE_EXPORT template class OTR_GENERIC_EXPORT +#define OTR_TEMPLATE_IMPORT extern template class OTR_GENERIC_IMPORT diff --git a/compat/math-imports.hpp b/compat/math-imports.hpp new file mode 100644 index 00000000..ad70f361 --- /dev/null +++ b/compat/math-imports.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include <cmath> +#include <cinttypes> + +namespace otr_math +{ + +using std::copysign; + +using std::sqrt; +using std::pow; + +using std::fabs; +using std::fmin; +using std::fmax; + +using std::atan; +using std::atan2; +using std::asin; +using std::acos; + +using std::sin; +using std::cos; +using std::tan; + +using std::round; +using std::fmod; + +using std::uintptr_t; +using std::intptr_t; + +using std::int64_t; +using std::int32_t; + +using std::uint64_t; +using std::uint32_t; + +template <typename T> +static inline constexpr auto signum(T x) +{ + return (T() < x) - (x < T()); +} + +} // ns otr_math diff --git a/cv/translation-calibrator.cpp b/cv/translation-calibrator.cpp index cdd573bc..fb150bf9 100644 --- a/cv/translation-calibrator.cpp +++ b/cv/translation-calibrator.cpp @@ -54,12 +54,10 @@ void TranslationCalibrator::update(const cv::Matx33d& R_CM_k, const cv::Vec3d& t y += H_k_T * t_CM_k; } -std::tuple<cv::Vec3f, unsigned> TranslationCalibrator::get_estimate() +std::tuple<cv::Vec3f, cv::Vec3i> TranslationCalibrator::get_estimate() { cv::Vec6f x = P.inv() * y; - qDebug() << "calibrator:" << nsamples << "samples total"; - unsigned values[3] {}; vec* in[] { &used_yaw_poses, &used_pitch_poses, &used_roll_poses }; @@ -71,12 +69,13 @@ std::tuple<cv::Vec3f, unsigned> TranslationCalibrator::get_estimate() values[k]++; } - qDebug() << "samples" + qDebug() << "samples total" << nsamples << "yaw" << values[0] << "pitch" << values[1] << "roll" << values[2]; - return std::make_tuple(cv::Vec3f(-x[0], -x[1], -x[2]), nsamples); + return std::make_tuple(cv::Vec3f(-x[0], -x[1], -x[2]), + cv::Vec3i(values[0], values[1], values[2])); } bool TranslationCalibrator::check_bucket(const cv::Matx33d& R_CM_k) diff --git a/cv/translation-calibrator.hpp b/cv/translation-calibrator.hpp index ae2ed844..d908496a 100644 --- a/cv/translation-calibrator.hpp +++ b/cv/translation-calibrator.hpp @@ -29,7 +29,7 @@ public: void update(const cv::Matx33d& R_CM_k, const cv::Vec3d& t_CM_k); // get the current estimate for t_MH - std::tuple<cv::Vec3f, unsigned> get_estimate(); + std::tuple<cv::Vec3f, cv::Vec3i> get_estimate(); private: bool check_bucket(const cv::Matx33d& R_CM_k); diff --git a/dinput/keybinding-worker.cpp b/dinput/keybinding-worker.cpp index 41fa3486..042f01a5 100644 --- a/dinput/keybinding-worker.cpp +++ b/dinput/keybinding-worker.cpp @@ -142,6 +142,8 @@ void KeybindingWorker::run() case DIK_RCONTROL: case DIK_RSHIFT: case DIK_RALT: + case DIK_LWIN: + case DIK_RWIN: break; default: k.shift = !!((keystate[DIK_LSHIFT] & 0x80) || (keystate[DIK_RSHIFT] & 0x80)); diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index a4095774..92b9e197 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -11,11 +11,9 @@ #include <QMutexLocker> #include "api/plugin-api.hpp" -using std::fabs; -using std::sqrt; -using std::pow; -using std::copysign; -using std::fmin; +#include "compat/math-imports.hpp" + +using namespace otr_math; constexpr settings_accela::gains settings_accela::rot_gains[16]; constexpr settings_accela::gains settings_accela::pos_gains[16]; @@ -25,12 +23,6 @@ accela::accela() : first_run(true) s.make_splines(spline_rot, spline_pos); } -template <typename T> -static inline constexpr T signum(T x) -{ - return T((T(0) < x) - (x < T(0))); -} - template<int N = 3, typename F> never_inline static void do_deltas(const double* deltas, double* output, double alpha, double& smoothed, F&& fun) @@ -44,7 +36,8 @@ static void do_deltas(const double* deltas, double* output, double alpha, double return sqrt(ret); ); - const double dist = smoothed = fmin(dist_, alpha*dist_ + (1-alpha)*smoothed); + const double dist = fmin(dist_, alpha*dist_ + (1-alpha)*smoothed); + smoothed = dist; const double value = double(fun(dist)); for (unsigned k = 0; k < N; k++) @@ -78,18 +71,26 @@ static void do_deltas(const double* deltas, double* output, double alpha, double void accela::filter(const double* input, double *output) { - if (first_run) + if (unlikely(first_run)) { + first_run = false; + for (int i = 0; i < 6; i++) { const double f = input[i]; output[i] = f; last_output[i] = f; } - first_run = false; + smoothed_input[0] = 0; smoothed_input[1] = 0; + t.start(); +#if defined DEBUG_ACCELA + debug_max = 0; + debug_timer.start(); +#endif + return; } @@ -132,6 +133,24 @@ void accela::filter(const double* input, double *output) do_deltas(&deltas[Yaw], &output[Yaw], alpha, smoothed_input[0], [this](double x) { return spline_rot.get_value_no_save(x); }); +#if defined DEBUG_ACCELA + var.input(smoothed_input[0]); + debug_max = fmax(debug_max, smoothed_input[0]); + + using time_units::secs_; + + if (debug_timer.is_elapsed(secs_(1))) + { + qDebug() << "accela:" + << "max" << debug_max + << "mean" << var.avg() + << "stddev" << var.stddev(); + + var.clear(); + debug_max = 0; + } +#endif + // pos for (unsigned i = 0; i < 3; i++) diff --git a/filter-accela/ftnoir_filter_accela.h b/filter-accela/ftnoir_filter_accela.h index bbe74b08..fa3c611f 100644 --- a/filter-accela/ftnoir_filter_accela.h +++ b/filter-accela/ftnoir_filter_accela.h @@ -11,11 +11,17 @@ #include "accela-settings.hpp" #include "api/plugin-api.hpp" #include "compat/timer.hpp" +#include "compat/variance.hpp" #include <atomic> #include <QMutex> #include <QTimer> +// ------------------------------------ +// debug knob +// ------------------------------------ +//#define DEBUG_ACCELA + class accela : public IFilter { public: @@ -25,13 +31,18 @@ public: spline spline_rot, spline_pos; private: settings_accela s; - bool first_run; double last_output[6], deltas[6]; double smoothed_input[2]; Timer t; +#if defined DEBUG_ACCELA + Timer debug_timer; + double debug_max; + variance var; +#endif + bool first_run; }; -class dialog_accela: public IFilterDialog +class dialog_accela : public IFilterDialog { Q_OBJECT public: diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index 1426300f..79c8fb29 100644 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -39,7 +39,6 @@ void KeyboardListener::keyPressEvent(QKeyEvent* event) case Qt::Key_Meta: case Qt::Key_Alt: case Qt::Key_AltGr: - case Qt::Key_CapsLock: case Qt::Key_NumLock: break; case Qt::Key_Escape: diff --git a/logic/win32-shortcuts.cpp b/logic/win32-shortcuts.cpp index 114bb46d..af50b949 100644 --- a/logic/win32-shortcuts.cpp +++ b/logic/win32-shortcuts.cpp @@ -18,130 +18,132 @@ #include <QDebug> QList<win_key> windows_key_mods = - QList<win_key>({ - win_key(DIK_LCONTROL, Qt::Key::Key_Control), - win_key(DIK_RCONTROL, Qt::Key::Key_Control), - win_key(DIK_LALT, Qt::Key::Key_Alt), - win_key(DIK_RALT, Qt::Key::Key_Alt), - win_key(DIK_LSHIFT, Qt::Key::Key_Shift), - win_key(DIK_RSHIFT, Qt::Key::Key_Shift), - win_key(DIK_LWIN, Qt::Key::Key_unknown), - win_key(DIK_RWIN, Qt::Key::Key_unknown) - }); + QList<win_key>{ + {DIK_LCONTROL, Qt::Key_Control}, + {DIK_RCONTROL, Qt::Key_Control}, + {DIK_LALT, Qt::Key_Alt}, + {DIK_RALT, Qt::Key_Alt}, + {DIK_LSHIFT, Qt::Key_Shift}, + {DIK_RSHIFT, Qt::Key_Shift}, + {DIK_LWIN, Qt::Key_Super_L}, + {DIK_RWIN, Qt::Key_Super_R}, + }; QList<win_key> windows_key_sequences = - QList<win_key>({ - win_key(DIK_F1, Qt::Key::Key_F1 ), - win_key(DIK_F2, Qt::Key::Key_F2 ), - win_key(DIK_F3, Qt::Key::Key_F3 ), - win_key(DIK_F4, Qt::Key::Key_F4 ), - win_key(DIK_F5, Qt::Key::Key_F5 ), - win_key(DIK_F6, Qt::Key::Key_F6 ), - win_key(DIK_F7, Qt::Key::Key_F7 ), - win_key(DIK_F8, Qt::Key::Key_F8 ), - win_key(DIK_F9, Qt::Key::Key_F9 ), - win_key(DIK_F10, Qt::Key::Key_F10 ), - win_key(DIK_F11, Qt::Key::Key_F11 ), - win_key(DIK_F12, Qt::Key::Key_F12 ), - win_key(DIK_LEFT, Qt::Key::Key_Left ), - win_key(DIK_RIGHT, Qt::Key::Key_Right ), - win_key(DIK_UP, Qt::Key::Key_Up ), - win_key(DIK_DOWN, Qt::Key::Key_Down ), - win_key(DIK_PRIOR, Qt::Key::Key_PageUp ), - win_key(DIK_NEXT, Qt::Key::Key_PageDown ), - win_key(DIK_HOME, Qt::Key::Key_Home ), - win_key(DIK_END, Qt::Key::Key_End ), - win_key(DIK_BACK, Qt::Key::Key_Backspace ), - win_key(DIK_COMMA, Qt::Key::Key_Comma ), - win_key(DIK_PERIOD, Qt::Key::Key_Period ), - win_key(DIK_LBRACKET, Qt::Key::Key_BracketLeft ), - win_key(DIK_RBRACKET, Qt::Key::Key_BracketRight ), - win_key(DIK_SEMICOLON, Qt::Key::Key_Semicolon ), - win_key(DIK_SLASH, Qt::Key::Key_Slash ), - win_key(DIK_BACKSLASH, Qt::Key::Key_Backslash ), - win_key(DIK_BACKSPACE, Qt::Key::Key_Backspace ), - win_key(DIK_APOSTROPHE, Qt::Key::Key_Apostrophe ), - win_key(DIK_GRAVE, Qt::Key::Key_QuoteLeft ), - win_key(DIK_MINUS, Qt::Key::Key_Minus ), - win_key(DIK_EQUALS, Qt::Key::Key_Equal ), - win_key(DIK_PERIOD, Qt::Key::Key_Period ), - win_key(DIK_F1, Qt::Key::Key_F1 ), - win_key(DIK_F2, Qt::Key::Key_F2 ), - win_key(DIK_F3, Qt::Key::Key_F3 ), - win_key(DIK_F4, Qt::Key::Key_F4 ), - win_key(DIK_F5, Qt::Key::Key_F5 ), - win_key(DIK_F6, Qt::Key::Key_F6 ), - win_key(DIK_F7, Qt::Key::Key_F7 ), - win_key(DIK_F8, Qt::Key::Key_F8 ), - win_key(DIK_F9, Qt::Key::Key_F9 ), - win_key(DIK_F10, Qt::Key::Key_F10 ), - win_key(DIK_F11, Qt::Key::Key_F11 ), - win_key(DIK_F12, Qt::Key::Key_F12 ), - win_key(DIK_0, Qt::Key::Key_0 ), - win_key(DIK_1, Qt::Key::Key_1 ), - win_key(DIK_2, Qt::Key::Key_2 ), - win_key(DIK_3, Qt::Key::Key_3 ), - win_key(DIK_4, Qt::Key::Key_4 ), - win_key(DIK_5, Qt::Key::Key_5 ), - win_key(DIK_6, Qt::Key::Key_6 ), - win_key(DIK_7, Qt::Key::Key_7 ), - win_key(DIK_8, Qt::Key::Key_8 ), - win_key(DIK_9, Qt::Key::Key_9 ), - win_key(DIK_A, Qt::Key::Key_A ), - win_key(DIK_B, Qt::Key::Key_B ), - win_key(DIK_C, Qt::Key::Key_C ), - win_key(DIK_D, Qt::Key::Key_D ), - win_key(DIK_E, Qt::Key::Key_E ), - win_key(DIK_F, Qt::Key::Key_F ), - win_key(DIK_G, Qt::Key::Key_G ), - win_key(DIK_H, Qt::Key::Key_H ), - win_key(DIK_I, Qt::Key::Key_I ), - win_key(DIK_J, Qt::Key::Key_J ), - win_key(DIK_K, Qt::Key::Key_K ), - win_key(DIK_L, Qt::Key::Key_L ), - win_key(DIK_M, Qt::Key::Key_M ), - win_key(DIK_N, Qt::Key::Key_N ), - win_key(DIK_O, Qt::Key::Key_O ), - win_key(DIK_P, Qt::Key::Key_P ), - win_key(DIK_Q, Qt::Key::Key_Q ), - win_key(DIK_R, Qt::Key::Key_R ), - win_key(DIK_S, Qt::Key::Key_S ), - win_key(DIK_T, Qt::Key::Key_T ), - win_key(DIK_U, Qt::Key::Key_U ), - win_key(DIK_V, Qt::Key::Key_V ), - win_key(DIK_W, Qt::Key::Key_W ), - win_key(DIK_X, Qt::Key::Key_X ), - win_key(DIK_Y, Qt::Key::Key_Y ), - win_key(DIK_Z, Qt::Key::Key_Z ), - win_key(DIK_RETURN, Qt::Key::Key_Return), - win_key(DIK_INSERT, Qt::Key::Key_Insert), - win_key(DIK_DELETE, Qt::Key::Key_Delete), - win_key(DIK_SPACE, Qt::Key::Key_Space), - win_key(DIK_SYSRQ, Qt::Key::Key_Print), - win_key(DIK_SCROLL, Qt::Key::Key_ScrollLock), - win_key(DIK_PAUSE, Qt::Key::Key_Pause), - win_key(DIK_NUMLOCK, Qt::Key::Key_NumLock), + QList<win_key>{ + {DIK_F1, Qt::Key_F1 }, + {DIK_F2, Qt::Key_F2 }, + {DIK_F3, Qt::Key_F3 }, + {DIK_F4, Qt::Key_F4 }, + {DIK_F5, Qt::Key_F5 }, + {DIK_F6, Qt::Key_F6 }, + {DIK_F7, Qt::Key_F7 }, + {DIK_F8, Qt::Key_F8 }, + {DIK_F9, Qt::Key_F9 }, + {DIK_F10, Qt::Key_F10 }, + {DIK_F11, Qt::Key_F11 }, + {DIK_F12, Qt::Key_F12 }, + {DIK_LEFT, Qt::Key_Left }, + {DIK_RIGHT, Qt::Key_Right }, + {DIK_UP, Qt::Key_Up }, + {DIK_DOWN, Qt::Key_Down }, + {DIK_PRIOR, Qt::Key_PageUp }, + {DIK_NEXT, Qt::Key_PageDown }, + {DIK_HOME, Qt::Key_Home }, + {DIK_END, Qt::Key_End }, + {DIK_BACK, Qt::Key_Backspace }, + {DIK_COMMA, Qt::Key_Comma }, + {DIK_PERIOD, Qt::Key_Period }, + {DIK_LBRACKET, Qt::Key_BracketLeft }, + {DIK_RBRACKET, Qt::Key_BracketRight }, + {DIK_SEMICOLON, Qt::Key_Semicolon }, + {DIK_SLASH, Qt::Key_Slash }, + {DIK_BACKSLASH, Qt::Key_Backslash }, + {DIK_BACKSPACE, Qt::Key_Backspace }, + {DIK_APOSTROPHE, Qt::Key_Apostrophe }, + {DIK_GRAVE, Qt::Key_QuoteLeft }, + {DIK_MINUS, Qt::Key_Minus }, + {DIK_EQUALS, Qt::Key_Equal }, + {DIK_PERIOD, Qt::Key_Period }, + {DIK_F1, Qt::Key_F1 }, + {DIK_F2, Qt::Key_F2 }, + {DIK_F3, Qt::Key_F3 }, + {DIK_F4, Qt::Key_F4 }, + {DIK_F5, Qt::Key_F5 }, + {DIK_F6, Qt::Key_F6 }, + {DIK_F7, Qt::Key_F7 }, + {DIK_F8, Qt::Key_F8 }, + {DIK_F9, Qt::Key_F9 }, + {DIK_F10, Qt::Key_F10 }, + {DIK_F11, Qt::Key_F11 }, + {DIK_F12, Qt::Key_F12 }, + {DIK_0, Qt::Key_0 }, + {DIK_1, Qt::Key_1 }, + {DIK_2, Qt::Key_2 }, + {DIK_3, Qt::Key_3 }, + {DIK_4, Qt::Key_4 }, + {DIK_5, Qt::Key_5 }, + {DIK_6, Qt::Key_6 }, + {DIK_7, Qt::Key_7 }, + {DIK_8, Qt::Key_8 }, + {DIK_9, Qt::Key_9 }, + {DIK_A, Qt::Key_A }, + {DIK_B, Qt::Key_B }, + {DIK_C, Qt::Key_C }, + {DIK_D, Qt::Key_D }, + {DIK_E, Qt::Key_E }, + {DIK_F, Qt::Key_F }, + {DIK_G, Qt::Key_G }, + {DIK_H, Qt::Key_H }, + {DIK_I, Qt::Key_I }, + {DIK_J, Qt::Key_J }, + {DIK_K, Qt::Key_K }, + {DIK_L, Qt::Key_L }, + {DIK_M, Qt::Key_M }, + {DIK_N, Qt::Key_N }, + {DIK_O, Qt::Key_O }, + {DIK_P, Qt::Key_P }, + {DIK_Q, Qt::Key_Q }, + {DIK_R, Qt::Key_R }, + {DIK_S, Qt::Key_S }, + {DIK_T, Qt::Key_T }, + {DIK_U, Qt::Key_U }, + {DIK_V, Qt::Key_V }, + {DIK_W, Qt::Key_W }, + {DIK_X, Qt::Key_X }, + {DIK_Y, Qt::Key_Y }, + {DIK_Z, Qt::Key_Z }, + {DIK_TAB, Qt::Key_Tab }, + {DIK_RETURN, Qt::Key_Return}, + {DIK_INSERT, Qt::Key_Insert}, + {DIK_DELETE, Qt::Key_Delete}, + {DIK_SPACE, Qt::Key_Space}, + {DIK_SYSRQ, Qt::Key_Print}, + {DIK_SCROLL, Qt::Key_ScrollLock}, + {DIK_PAUSE, Qt::Key_Pause}, + {DIK_NUMLOCK, Qt::Key_NumLock}, + {DIK_CAPSLOCK, Qt::Key_CapsLock}, #define mod(x, y) static_cast<Qt::Key>(x | y) - win_key(DIK_NUMPAD0, mod(Qt::Key::Key_0, Qt::KeypadModifier)), - win_key(DIK_NUMPAD0, mod(Qt::Key::Key_0, Qt::KeypadModifier)), - win_key(DIK_NUMPAD1, mod(Qt::Key::Key_1, Qt::KeypadModifier)), - win_key(DIK_NUMPAD2, mod(Qt::Key::Key_2, Qt::KeypadModifier)), - win_key(DIK_NUMPAD3, mod(Qt::Key::Key_3, Qt::KeypadModifier)), - win_key(DIK_NUMPAD4, mod(Qt::Key::Key_4, Qt::KeypadModifier)), - win_key(DIK_NUMPAD5, mod(Qt::Key::Key_5, Qt::KeypadModifier)), - win_key(DIK_NUMPAD6, mod(Qt::Key::Key_6, Qt::KeypadModifier)), - win_key(DIK_NUMPAD7, mod(Qt::Key::Key_7, Qt::KeypadModifier)), - win_key(DIK_NUMPAD8, mod(Qt::Key::Key_8, Qt::KeypadModifier)), - win_key(DIK_NUMPAD9, mod(Qt::Key::Key_9, Qt::KeypadModifier)), - win_key(DIK_NUMPADCOMMA, mod(Qt::Key::Key_Comma, Qt::KeypadModifier)), - win_key(DIK_NUMPADENTER, mod(Qt::Key::Key_Enter, Qt::KeypadModifier)), - win_key(DIK_NUMPADEQUALS, mod(Qt::Key::Key_Equal, Qt::KeypadModifier)), - win_key(DIK_NUMPADMINUS, mod(Qt::Key::Key_Minus, Qt::KeypadModifier)), - win_key(DIK_NUMPADPERIOD, mod(Qt::Key::Key_Period, Qt::KeypadModifier)), - win_key(DIK_NUMPADPLUS, mod(Qt::Key::Key_Plus, Qt::KeypadModifier)), - win_key(DIK_NUMPADSLASH, mod(Qt::Key::Key_Slash, Qt::KeypadModifier)), - win_key(DIK_NUMPADSTAR, mod(Qt::Key::Key_multiply, Qt::KeypadModifier)), - }); + {DIK_NUMPAD0, mod(Qt::Key_0, Qt::KeypadModifier)}, + {DIK_NUMPAD0, mod(Qt::Key_0, Qt::KeypadModifier)}, + {DIK_NUMPAD1, mod(Qt::Key_1, Qt::KeypadModifier)}, + {DIK_NUMPAD2, mod(Qt::Key_2, Qt::KeypadModifier)}, + {DIK_NUMPAD3, mod(Qt::Key_3, Qt::KeypadModifier)}, + {DIK_NUMPAD4, mod(Qt::Key_4, Qt::KeypadModifier)}, + {DIK_NUMPAD5, mod(Qt::Key_5, Qt::KeypadModifier)}, + {DIK_NUMPAD6, mod(Qt::Key_6, Qt::KeypadModifier)}, + {DIK_NUMPAD7, mod(Qt::Key_7, Qt::KeypadModifier)}, + {DIK_NUMPAD8, mod(Qt::Key_8, Qt::KeypadModifier)}, + {DIK_NUMPAD9, mod(Qt::Key_9, Qt::KeypadModifier)}, + {DIK_NUMPADCOMMA, mod(Qt::Key_Comma, Qt::KeypadModifier)}, + {DIK_NUMPADENTER, mod(Qt::Key_Enter, Qt::KeypadModifier)}, + {DIK_NUMPADEQUALS, mod(Qt::Key_Equal, Qt::KeypadModifier)}, + {DIK_NUMPADMINUS, mod(Qt::Key_Minus, Qt::KeypadModifier)}, + {DIK_NUMPADPERIOD, mod(Qt::Key_Period, Qt::KeypadModifier)}, + {DIK_NUMPADPLUS, mod(Qt::Key_Plus, Qt::KeypadModifier)}, + {DIK_NUMPADSLASH, mod(Qt::Key_Slash, Qt::KeypadModifier)}, + {DIK_NUMPADSTAR, mod(Qt::Key_multiply, Qt::KeypadModifier)}, + }; bool win_key::to_qt(const Key& k, QKeySequence& qt_, Qt::KeyboardModifiers &mods) { diff --git a/options/value.cpp b/options/value.cpp new file mode 100644 index 00000000..39bf0506 --- /dev/null +++ b/options/value.cpp @@ -0,0 +1,3 @@ +// instantiate the "template class" value<t> symbols +#define OTR_OPT_VALUE_TMPL_EXPORT +#include "value.hpp" diff --git a/options/value.hpp b/options/value.hpp index ba482cf7..be3e4be2 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -130,4 +130,27 @@ private: const t def; }; +#if defined OTR_OPT_VALUE_TMPL_EXPORT && defined BUILD_OPTIONS +# define OTR_OPT_VALUE OTR_TEMPLATE_EXPORT +#else +# define OTR_OPT_VALUE OTR_TEMPLATE_IMPORT +#endif + +OTR_OPT_VALUE value<double>; +OTR_OPT_VALUE value<float>; +OTR_OPT_VALUE value<int>; +OTR_OPT_VALUE value<bool>; +OTR_OPT_VALUE value<QString>; +OTR_OPT_VALUE value<slider_value>; +OTR_OPT_VALUE value<QPointF>; +OTR_OPT_VALUE value<QVariant>; + +OTR_OPT_VALUE value<QList<double>>; +OTR_OPT_VALUE value<QList<float>>; +OTR_OPT_VALUE value<QList<int>>; +OTR_OPT_VALUE value<QList<bool>>; +OTR_OPT_VALUE value<QList<QString>>; +OTR_OPT_VALUE value<QList<slider_value>>; +OTR_OPT_VALUE value<QList<QPointF>>; + } // ns options diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp index 8e5996d8..9b5113a6 100644 --- a/proto-ft/ftnoir_protocol_ft.cpp +++ b/proto-ft/ftnoir_protocol_ft.cpp @@ -7,6 +7,7 @@ */ #include "compat/ndebug-guard.hpp" +#include "compat/util.hpp" #include "ftnoir_protocol_ft.h" #include "csv/csv.h" diff --git a/proto-simconnect/scserver.manifest b/proto-simconnect/fsx_p3d_sp2_xpack.manifest index d342cfda..25a62765 100644 --- a/proto-simconnect/scserver.manifest +++ b/proto-simconnect/fsx_p3d_sp2_xpack.manifest @@ -5,9 +5,4 @@ <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='10.0.61259.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> </dependentAssembly> </dependency> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> - </dependentAssembly> - </dependency> </assembly> diff --git a/proto-simconnect/fsx_rtm.manifest b/proto-simconnect/fsx_rtm.manifest new file mode 100644 index 00000000..760de973 --- /dev/null +++ b/proto-simconnect/fsx_rtm.manifest @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='10.0.60905.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> + </dependentAssembly> + </dependency> +</assembly> diff --git a/proto-simconnect/fsx_sp1.manifest b/proto-simconnect/fsx_sp1.manifest new file mode 100644 index 00000000..ee746740 --- /dev/null +++ b/proto-simconnect/fsx_sp1.manifest @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='10.0.61242.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> + </dependentAssembly> + </dependency> +</assembly> diff --git a/proto-simconnect/fsx_sp2.manifest b/proto-simconnect/fsx_sp2.manifest new file mode 100644 index 00000000..25a62765 --- /dev/null +++ b/proto-simconnect/fsx_sp2.manifest @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='10.0.61259.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> + </dependentAssembly> + </dependency> +</assembly> diff --git a/proto-simconnect/fsx_steam_last.manifest b/proto-simconnect/fsx_steam_last.manifest new file mode 100644 index 00000000..b8cbaca4 --- /dev/null +++ b/proto-simconnect/fsx_steam_last.manifest @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='10.0.62615.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> + </dependentAssembly> + </dependency> +</assembly> diff --git a/proto-simconnect/fsx_steam_orig.manifest b/proto-simconnect/fsx_steam_orig.manifest new file mode 100644 index 00000000..f1b3314c --- /dev/null +++ b/proto-simconnect/fsx_steam_orig.manifest @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='10.0.62607.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> + </dependentAssembly> + </dependency> +</assembly> diff --git a/proto-simconnect/ftnoir-protocol-sc.rc b/proto-simconnect/ftnoir-protocol-sc.rc index c89eb9a7..5f47a5c9 100644 --- a/proto-simconnect/ftnoir-protocol-sc.rc +++ b/proto-simconnect/ftnoir-protocol-sc.rc @@ -1,4 +1,7 @@ #include <winuser.h> -142 RT_MANIFEST scserver.manifest -143 RT_MANIFEST scserver_sp2.manifest -144 RT_MANIFEST scserver_acceleration.manifest
\ No newline at end of file +142 RT_MANIFEST fsx_rtm.manifest +143 RT_MANIFEST fsx_sp1.manifest +144 RT_MANIFEST fsx_sp2.manifest +145 RT_MANIFEST fsx_p3d_sp2_xpack.manifest +146 RT_MANIFEST fsx_steam_orig.manifest +147 RT_MANIFEST fsx_steam_last.manifest diff --git a/proto-simconnect/ftnoir_protocol_sc.cpp b/proto-simconnect/ftnoir_protocol_sc.cpp index be0c23c4..cfe973a7 100644 --- a/proto-simconnect/ftnoir_protocol_sc.cpp +++ b/proto-simconnect/ftnoir_protocol_sc.cpp @@ -26,7 +26,7 @@ simconnect::~simconnect() void simconnect::run() { - HANDLE event = CreateEvent(NULL, FALSE, FALSE, nullptr); + HANDLE event = CreateEventA(NULL, FALSE, FALSE, nullptr); if (event == nullptr) { @@ -38,60 +38,57 @@ void simconnect::run() { HRESULT hr; - qDebug() << "simconnect: starting"; - if (SUCCEEDED(hr = simconnect_open(&hSimConnect, "opentrack", nullptr, 0, event, 0))) { if (!SUCCEEDED(hr = simconnect_subscribetosystemevent(hSimConnect, 0, "Frame"))) { qDebug() << "simconnect: can't subscribe to frame event:" << hr; - - should_reconnect = true; // will free simconnect handle and continue the loop } Timer tm; - int idle_seconds = 0; + should_reconnect = false; - while (!isInterruptionRequested()) - { - if (should_reconnect) + if (SUCCEEDED(hr)) + while (!isInterruptionRequested()) { - should_reconnect = false; - break; - } - - if (WaitForSingleObject(event, 10) == WAIT_OBJECT_0) - { - tm.start(); - idle_seconds = 0; + if (should_reconnect) + break; - if (!SUCCEEDED(hr = simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast<void*>(this)))) + if (WaitForSingleObject(event, 100) == WAIT_OBJECT_0) { - qDebug() << "simconnect: calldispatch failed:" << hr; - break; + tm.start(); + + if (!SUCCEEDED(hr = simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast<void*>(this)))) + { + qDebug() << "simconnect: calldispatch failed:" << hr; + break; + } } - } - else - { - if (int(tm.elapsed_seconds()) > idle_seconds) + else { - idle_seconds++; - qDebug() << "simconnect: can't process event for" << int(tm.elapsed_seconds()) << "seconds"; + const int idle_seconds = tm.elapsed_seconds(); + + static constexpr int max_idle_seconds = 2; + + if (idle_seconds >= max_idle_seconds) + { + qDebug() << "simconnect: reconnect"; + break; + } } } - } (void) simconnect_close(hSimConnect); } else - { qDebug() << "simconnect: can't open handle:" << hr; - } if (!isInterruptionRequested()) - Sleep(100); + Sleep(3000); } + qDebug() << "simconnect: exit"; + CloseHandle(event); } @@ -120,8 +117,8 @@ public: { hactctx = INVALID_HANDLE_VALUE; actctx_cookie = 0; - ACTCTXA actx = {0}; - actx.cbSize = sizeof(ACTCTXA); + ACTCTXA actx = {}; + actx.cbSize = sizeof(actx); actx.lpResourceName = MAKEINTRESOURCEA(resid); actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; #ifdef _MSC_VER @@ -229,9 +226,12 @@ void CALLBACK simconnect::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWO default: break; case SIMCONNECT_RECV_ID_EXCEPTION: + qDebug() << "simconnect: got exception"; + //self.should_reconnect = true; + break; case SIMCONNECT_RECV_ID_QUIT: + qDebug() << "simconnect: got quit event"; self.should_reconnect = true; - qDebug() << "simconnect: received ID_QUIT event"; break; case SIMCONNECT_RECV_ID_EVENT_FRAME: self.handle(); diff --git a/proto-simconnect/ftnoir_protocol_sc.h b/proto-simconnect/ftnoir_protocol_sc.h index 93376885..151dd741 100644 --- a/proto-simconnect/ftnoir_protocol_sc.h +++ b/proto-simconnect/ftnoir_protocol_sc.h @@ -3,7 +3,7 @@ * ISC License (ISC) * * * * Copyright (c) 2015, Wim Vriend * - * Copyright (c) 2014, Stanislaw Halik * + * Copyright (c) 2014, 2017 Stanislaw Halik * * * * Permission to use, copy, modify, and/or distribute this software for any * * purpose with or without fee is hereby granted, provided that the above * @@ -30,7 +30,7 @@ struct settings : opts { value<int> sxs_manifest; settings() : opts("proto-simconnect"), - sxs_manifest(b, "sxs-manifest-version", 0) + sxs_manifest(b, "simconnect-manifest", 2) {} }; diff --git a/proto-simconnect/ftnoir_sccontrols.ui b/proto-simconnect/ftnoir_sccontrols.ui index 887d6d80..7a607096 100644 --- a/proto-simconnect/ftnoir_sccontrols.ui +++ b/proto-simconnect/ftnoir_sccontrols.ui @@ -53,17 +53,32 @@ </property> <item> <property name="text"> + <string>RTM</string> + </property> + </item> + <item> + <property name="text"> <string>SP1</string> </property> </item> <item> <property name="text"> - <string>SP2</string> + <string>SP2 -- Acceleration</string> + </property> + </item> + <item> + <property name="text"> + <string>Prepar3d SP2 XPACK</string> + </property> + </item> + <item> + <property name="text"> + <string>Steam FSX (older)</string> </property> </item> <item> <property name="text"> - <string>Acceleration</string> + <string>Steam FSX (new)</string> </property> </item> </widget> diff --git a/proto-simconnect/manifest-template.in b/proto-simconnect/manifest-template.in new file mode 100644 index 00000000..fdf2c74a --- /dev/null +++ b/proto-simconnect/manifest-template.in @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
+<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='VERSION' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' />
+ </dependentAssembly>
+ </dependency>
+</assembly>
diff --git a/proto-simconnect/scserver_acceleration.manifest b/proto-simconnect/scserver_acceleration.manifest deleted file mode 100644 index 06459587..00000000 --- a/proto-simconnect/scserver_acceleration.manifest +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version='1.0' encoding='UTF-8' standalone='yes'?> -<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect ' version='10.0.61242.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> - </dependentAssembly> - </dependency> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> - </dependentAssembly> - </dependency> -</assembly> diff --git a/proto-simconnect/scserver_sp2.manifest b/proto-simconnect/scserver_sp2.manifest deleted file mode 100644 index 3020d16c..00000000 --- a/proto-simconnect/scserver_sp2.manifest +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version='1.0' encoding='UTF-8' standalone='yes'?> -<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect ' version='10.0.60905.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> - </dependentAssembly> - </dependency> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> - </dependentAssembly> - </dependency> -</assembly> diff --git a/proto-simconnect/simconnect versions.txt b/proto-simconnect/simconnect versions.txt new file mode 100644 index 00000000..dde71f8f --- /dev/null +++ b/proto-simconnect/simconnect versions.txt @@ -0,0 +1,20 @@ +#define LVERS_ORIG "10.0.60905.0" +#define LVERS_SP1B1 "10.0.61232.0" +#define LVERS_SP1B2 "10.0.61233.0" +#define LVERS_SP1B3 "10.0.61234.0" +#define LVERS_SP1B4 "10.0.61240.0" +#define LVERS_SP1 "10.0.61242.0" +#define LVERS_ACCA1 "10.0.61245.0" +#define LVERS_ACCB1 "10.0.61246.0" +#define LVERS_ACCB2 "10.0.61247.0" +#define LVERS_ACCB3 "10.0.61248.0" +#define LVERS_ACCSP2 "10.0.61259.0" +#define LVERS_STEAM "10.0.62607.0" +#define LVERS_STEAM2 "10.0.62608.0" +#define LVERS_STEAM3 "10.0.62609.0" +#define LVERS_STEAM4 "10.0.62610.0" +#define LVERS_STEAM5 "10.0.62611.0" +#define LVERS_STEAM6 "10.0.62612.0" +#define LVERS_STEAM7 "10.0.62613.0" +#define LVERS_STEAM8 "10.0.62614.0" +#define LVERS_STEAM9 "10.0.62615.0" diff --git a/python/lang/nl_NL.ts b/python/lang/nl_NL.ts deleted file mode 100644 index 9e739505..00000000 --- a/python/lang/nl_NL.ts +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1" language="nl_NL"> -</TS> diff --git a/python/lang/ru_RU.ts b/python/lang/ru_RU.ts deleted file mode 100644 index f62cf2e1..00000000 --- a/python/lang/ru_RU.ts +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1" language="ru_RU"> -</TS> diff --git a/python/lang/stub.ts b/python/lang/stub.ts deleted file mode 100644 index 6401616d..00000000 --- a/python/lang/stub.ts +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1"> -</TS> diff --git a/tracker-pt/FTNoIR_PT_Controls.ui b/tracker-pt/FTNoIR_PT_Controls.ui index 62b49747..8d044654 100644 --- a/tracker-pt/FTNoIR_PT_Controls.ui +++ b/tracker-pt/FTNoIR_PT_Controls.ui @@ -250,7 +250,7 @@ </sizepolicy> </property> <property name="text"> - <string>Dynamic pose resolution</string> + <string>Dynamic pose (for caps only, never clips)</string> </property> </widget> </item> diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index f4e60bba..938acc1c 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -92,8 +92,6 @@ void Tracker_PT::run() s.dynamic_pose ? s.init_phase_timeout : 0); ever_success = true; } - else - point_tracker.invalidate_pose(); { Affine X_CM; diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index c2079c27..ee80fe6f 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -104,16 +104,31 @@ void TrackerDialog_PT::startstop_trans_calib(bool start) qDebug() << "pt: stopping translation calibration"; { cv::Vec3f tmp; - unsigned nsamples; + cv::Vec3i nsamples; std::tie(tmp, nsamples) = trans_calib.get_estimate(); s.t_MH_x = int(tmp[0]); s.t_MH_y = int(tmp[1]); s.t_MH_z = int(tmp[2]); - static constexpr unsigned min_samples = 80; - const QString sample_feedback = nsamples >= min_samples - ? tr("%1 samples. Over %2, good!").arg(nsamples).arg(min_samples) - : tr("%1 samples. Try for at least %2 for a precise calibration.").arg(nsamples).arg(min_samples); + static constexpr unsigned min_yaw_samples = 15; + static constexpr unsigned min_pitch_samples = 15; + static constexpr unsigned min_samples = min_yaw_samples+min_pitch_samples; + + // Don't bother counting roll samples. Roll calibration is hard enough + // that it's a hidden unsupported feature anyway. + + const QString sample_feedback = progn( + if (nsamples[0] < min_yaw_samples) + return tr("%1 yaw samples. Yaw more to %2 samples for stable calibration.") + .arg(nsamples[0]).arg(min_yaw_samples); + if (nsamples[1] < min_pitch_samples) + return tr("%1 pitch samples. Pitch more to %2 samples for stable calibration.") + .arg(nsamples[1]).arg(min_pitch_samples); + + const unsigned nsamples_total = nsamples[0] + nsamples[1]; + + return tr("%1 samples. Over %2, good!").arg(nsamples_total).arg(min_samples); + ); ui.sample_count_display->setText(sample_feedback); } diff --git a/tracker-pt/ftnoir_tracker_pt_settings.h b/tracker-pt/ftnoir_tracker_pt_settings.h index d890bbd2..79c1e103 100644 --- a/tracker-pt/ftnoir_tracker_pt_settings.h +++ b/tracker-pt/ftnoir_tracker_pt_settings.h @@ -62,7 +62,7 @@ struct settings_pt : opts cap_z(b, "cap-z", 100), fov(b, "camera-fov", 56), dynamic_pose(b, "dynamic-pose-resolution", true), - init_phase_timeout(b, "init-phase-timeout", 500), + init_phase_timeout(b, "init-phase-timeout", 250), auto_threshold(b, "automatic-threshold", true) {} }; diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp index 4022cbb2..73745d8f 100644 --- a/tracker-pt/point_tracker.cpp +++ b/tracker-pt/point_tracker.cpp @@ -162,7 +162,7 @@ bool PointTracker::maybe_use_old_point_order(const PointOrder& order, const CamI } // CAVEAT don't increase too much, it visibly loses precision - static constexpr f max_dist = f(.35); + static constexpr f max_dist = f(.2); const bool validp = sum < max_dist; @@ -178,7 +178,7 @@ bool PointTracker::maybe_use_old_point_order(const PointOrder& order, const CamI { static Timer tt; static int cnt1 = 0, cnt2 = 0; - if (tt.elapsed_ms() >= 5000) + if (tt.elapsed_ms() >= 1000) { tt.start(); if (cnt1 + cnt2) diff --git a/tracker-pt/point_tracker.h b/tracker-pt/point_tracker.h index b867cea4..a25c1458 100644 --- a/tracker-pt/point_tracker.h +++ b/tracker-pt/point_tracker.h @@ -62,7 +62,6 @@ public: Affine pose() { return X_CM; } vec2 project(const vec3& v_M, f focal_length); vec2 project(const vec3& v_M, f focal_length, const Affine& X_CM); - void invalidate_pose() { X_CM = Affine(); } private: // the points in model order |