diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-02 08:52:18 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-02 08:52:18 +0200 |
commit | f1431409454f3b03c7e7ecb3a119c8b552c3443f (patch) | |
tree | f97038addf3283cfbb2015fcb123494d0f7fee73 /opentrack/shortcuts.h | |
parent | 4bc6c9e69170f2e4aa9bdcd908fda7027bcae044 (diff) | |
parent | 68d33b0c99cfac8f89c2224d457e1568232896f7 (diff) |
Merge branch 'unstable' into trackhat-ui
* unstable:
shortcuts: use dinput for consistency on win32
shortcuts: use our own timer, other one is thread-bound
shortcuts: implement dinput -> qt conversion
shortcuts: rework KeybindingWorker for win32
Diffstat (limited to 'opentrack/shortcuts.h')
-rw-r--r-- | opentrack/shortcuts.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h index 2d7fec54..576b5384 100644 --- a/opentrack/shortcuts.h +++ b/opentrack/shortcuts.h @@ -9,7 +9,7 @@ #pragma once #include <QObject> #include <QWidget> -#include <QElapsedTimer> +#include "opentrack-compat/timer.hpp" #include <QThread> #include <QMessageBox> #include <QCheckBox> @@ -46,7 +46,7 @@ struct Key { bool shift; bool ctrl; bool alt; - QElapsedTimer timer; + Timer timer; public: Key() : keycode(0), shift(false), ctrl(false), alt(false) { @@ -54,7 +54,9 @@ public: bool should_process() { - return !timer.isValid() ? (timer.start(), true) : timer.restart() > 100; + bool ret = timer.elapsed_ms() > 100; + timer.start(); + return ret; } }; #else @@ -67,19 +69,15 @@ struct Shortcuts; struct KeybindingWorker : public QThread { #ifdef _WIN32 private: - Shortcuts& sc; LPDIRECTINPUT8 din; LPDIRECTINPUTDEVICE8 dinkeyboard; - Key kCenter; - Key kToggle; - Key kZero; QMutex mtx; public: volatile bool should_quit; + std::function<void(Key&)> receiver; ~KeybindingWorker(); - KeybindingWorker(Key keyCenter, Key keyToggle, Key keyZero, WId handle, Shortcuts& sc); + KeybindingWorker(std::function<void(Key&)> receiver, WId h); void run(); - void set_keys(Key kCenter, Key kToggle, Key kZero); #else public: KeybindingWorker(Key, Key, Key, WId) {} @@ -124,6 +122,9 @@ public: void reload(); private: void bind_keyboard_shortcut(K &key, key_opts& k); +#ifdef _WIN32 + void receiver(Key& k); +#endif signals: void center(); void toggle(); |