diff options
Diffstat (limited to 'logic')
-rw-r--r-- | logic/mappings.cpp | 10 | ||||
-rw-r--r-- | logic/mappings.hpp | 12 | ||||
-rw-r--r-- | logic/pipeline.cpp | 4 | ||||
-rw-r--r-- | logic/pipeline.hpp | 6 | ||||
-rw-r--r-- | logic/shortcuts.h | 17 | ||||
-rw-r--r-- | logic/win32-shortcuts.cpp | 232 |
6 files changed, 138 insertions, 143 deletions
diff --git a/logic/mappings.cpp b/logic/mappings.cpp index 8144f9b4..81bade4b 100644 --- a/logic/mappings.cpp +++ b/logic/mappings.cpp @@ -23,13 +23,3 @@ void Map::load() spline_alt.reload(); } -Mappings::Mappings(std::vector<axis_opts*> opts) : - axes { - Map("spline-X", "alt-spline-X", *opts[TX]), - Map("spline-Y", "alt-spline-Y", *opts[TY]), - Map("spline-Z", "alt-spline-Z", *opts[TZ]), - Map("spline-yaw", "alt-spline-yaw", *opts[Yaw]), - Map("spline-pitch", "alt-spline-pitch", *opts[Pitch]), - Map("spline-roll", "alt-spline-roll", *opts[Roll]) - } -{} diff --git a/logic/mappings.hpp b/logic/mappings.hpp index 4b71e9c5..834e969e 100644 --- a/logic/mappings.hpp +++ b/logic/mappings.hpp @@ -30,7 +30,17 @@ class OTR_LOGIC_EXPORT Mappings final private: Map axes[6]; public: - Mappings(std::vector<axis_opts*> opts); + template<typename t> + Mappings(t& opts) : + axes { + { "spline-X", "alt-spline-X", *opts[TX] }, + { "spline-Y", "alt-spline-Y", *opts[TY] }, + { "spline-Z", "alt-spline-Z", *opts[TZ] }, + { "spline-yaw", "alt-spline-yaw", *opts[Yaw] }, + { "spline-pitch", "alt-spline-pitch", *opts[Pitch] }, + { "spline-roll", "alt-spline-roll", *opts[Roll] } + } + {} Map& operator()(int i) { return axes[i]; } const Map& operator()(int i) const { return axes[i]; } diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index a77aa54a..78037227 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -37,9 +37,7 @@ pipeline::pipeline(Mappings& m, runtime_libraries& libs, event_handler& ev, Trac m(m), ev(ev), libs(libs), - logger(logger), - backlog_time(ns(0)), - tracking_started(false) + logger(logger) { } diff --git a/logic/pipeline.hpp b/logic/pipeline.hpp index 58900d34..0cb828e7 100644 --- a/logic/pipeline.hpp +++ b/logic/pipeline.hpp @@ -32,6 +32,8 @@ namespace gui_tracker_impl { +using namespace time_units; + struct OTR_LOGIC_EXPORT bits { enum flags : unsigned { @@ -83,9 +85,9 @@ private: state real_rotation, scaled_rotation; euler_t t_center; - time_units::ns backlog_time; + ns backlog_time = ns(0); - bool tracking_started; + bool tracking_started = false; double map(double pos, Map& axis); void logic(); diff --git a/logic/shortcuts.h b/logic/shortcuts.h index 5f23d2e7..2e630782 100644 --- a/logic/shortcuts.h +++ b/logic/shortcuts.h @@ -27,10 +27,14 @@ using namespace options; -struct OTR_LOGIC_EXPORT Shortcuts final : public QObject +class OTR_LOGIC_EXPORT Shortcuts final : public QObject { Q_OBJECT +#ifdef _WIN32 + void receiver(const Key& k); +#endif + public: using K = #ifndef _WIN32 @@ -46,21 +50,14 @@ public: using t_keys = std::vector<t_key>; std::vector<tt> keys; #ifdef _WIN32 - KeybindingWorker::Token key_token; + KeybindingWorker::Token key_token = [this](const Key& k) { receiver(k); }; #endif - Shortcuts() -#ifdef _WIN32 - : key_token([&](const Key& k) { receiver(k); }) -#endif - {} + Shortcuts() {} ~Shortcuts(); void reload(const t_keys& keys_); private: void free_binding(K& key); void bind_shortcut(K &key, const key_opts& k, bool held); -#ifdef _WIN32 - void receiver(const Key& k); -#endif }; diff --git a/logic/win32-shortcuts.cpp b/logic/win32-shortcuts.cpp index 8e53df83..901d2c0a 100644 --- a/logic/win32-shortcuts.cpp +++ b/logic/win32-shortcuts.cpp @@ -16,8 +16,7 @@ #include <QVariant> #include <QDebug> -QList<win_key> windows_key_mods = - QList<win_key>{ +QList<win_key> windows_key_mods { {DIK_LCONTROL, Qt::Key_Control}, {DIK_RCONTROL, Qt::Key_Control}, {DIK_LALT, Qt::Key_Alt}, @@ -26,123 +25,122 @@ QList<win_key> windows_key_mods = {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>{ - {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}, +QList<win_key> windows_key_sequences { + { 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) - {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)}, - }; + { 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) { |