summaryrefslogtreecommitdiffhomepage
path: root/opentrack/shortcuts.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-01-06 20:07:13 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-01-06 20:16:18 +0100
commit82f3d7373234cc0db79a22d476cb54b5eda7a0ea (patch)
tree65ee0194ad064cc470f95f7ca8efd533b089ca96 /opentrack/shortcuts.h
parent7e3807d048c5e0a8e0aa64fb49807bf5dfd11fc1 (diff)
parentf02baa0868f219076a641634625f7c032d3a9eef (diff)
Merge branch 'unstable' into trackhat
* unstable: (140 commits) tracker/pt: increase auto threshold bucket size again tracker/pt: limit max amount of extracted blobs gui: don't update main window if we're minimized tracker/pt: only show widget if the frame is visible tracker/pt: don't resize twice in widget freetrack/games: regen contrib/make-csv: perl sort isn't stable, don't ignore case tracker/pt: avoid widget temp QImage allocation spline-widget: oops, pass by reference tracker/pt: don't allocate temporary dynamic size arrays tracker/pt: don't copy points array needlessly tracker/pt: don't allocate temporary frame tracker/pt: cv::Mat::at<T> is slow, use cv::Mat::ptr tracker/pt: avoid widget malloc when able tracker/pt: optimize widget tracker/pt: update video widget at 40 -> 50 ms cmake/mingw-w64: update tracker/pt: reduce mutex contention gui: fix left margin tracker/pt: remove krap tracker/pt: move ctor out of the loop tracker/pt: nix unused tracker/pt: don't fill mask on frame pose-widget: also bilinear interpolation of alpha value ui: adjust margin ui: make more compact glwidget: use transparent octopus background api/mat: fix typos/breakage api/joy: refresh only manually on certain events pt: histogram more granular 6 -> 8 cmake/api: link with strmiids.lib on win32 tracker/pt: reduce auto thresholding histogram bucket size api/keys: prevent idempotent keys api/joy: move from header api/joy: prevent idempotent keypressed passed to receiver compat/options: get rid of std::string usage compat/options: move from header gui/settings: set parent, otherwise not modal gui/settings: don't forget to show a modal dialog before executing gui/main: don't raise a new window, it's enough to set visible api/joy: speed up poll_axis path api/joy: nix static, now that we're not a singleton tracker/joy: adapt to non-singleton joy worker joystick: no longer singleton, use fake window handle api/keys: use a fake window for DirectInput handle gui/keys: allow for pausing global keystrokes for options dialog api/keys: nix tautological #ifdef contrib/aruco: oops, right extension contrib/aruco: use @frost555's marker image api/camera-names: move to compat/ ...
Diffstat (limited to 'opentrack/shortcuts.h')
-rw-r--r--opentrack/shortcuts.h126
1 files changed, 26 insertions, 100 deletions
diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h
index 63d91829..38037923 100644
--- a/opentrack/shortcuts.h
+++ b/opentrack/shortcuts.h
@@ -8,86 +8,27 @@
#pragma once
#include <QObject>
-#include <QWidget>
-#include "opentrack-compat/timer.hpp"
-#include <QThread>
-#include <QMessageBox>
-#include <QCheckBox>
-#include <QComboBox>
-#include <QSettings>
-#include <QMutex>
+#include <tuple>
+#include <vector>
+#include <functional>
-#include "qxt-mini/QxtGlobalShortcut"
-#include "opentrack/plugin-support.hpp"
-#include "opentrack/options.hpp"
-#include "opentrack/main-settings.hpp"
-
-using namespace options;
-
-extern QList<QString> global_key_sequences;
-
-struct key_opts {
- value<QString> keycode;
-
- key_opts(pbundle b, const QString& name) :
- keycode(b, QString("keycode-%1").arg(name), "")
- {}
-};
-
-#if defined(_WIN32)
-extern QList<int> global_windows_key_sequences;
-# undef DIRECTINPUT_VERSION
-# define DIRECTINPUT_VERSION 0x0800
-# include <windows.h>
-# include <dinput.h>
-
-struct Key {
- BYTE keycode;
- bool shift;
- bool ctrl;
- bool alt;
- Timer timer;
-public:
- Key() : keycode(0), shift(false), ctrl(false), alt(false)
- {
- }
-
- bool should_process()
- {
- if (keycode == 0)
- return false;
- bool ret = timer.elapsed_ms() > 100;
- timer.start();
- return ret;
- }
-};
+#ifdef BUILD_api
+# include "opentrack-compat/export.hpp"
#else
-typedef unsigned char BYTE;
-struct Key { int foo; };
+# include "opentrack-compat/import.hpp"
#endif
-struct Shortcuts;
+#include "qxt-mini/QxtGlobalShortcut"
+#include "opentrack-compat/options.hpp"
+#include "opentrack/main-settings.hpp"
-struct KeybindingWorker : public QThread {
#ifdef _WIN32
-private:
- LPDIRECTINPUT8 din;
- LPDIRECTINPUTDEVICE8 dinkeyboard;
- QMutex mtx;
-public:
- volatile bool should_quit;
- std::function<void(Key&)> receiver;
- ~KeybindingWorker();
- KeybindingWorker(std::function<void(Key&)> receiver, WId h);
- void run();
-#else
-public:
- KeybindingWorker(Key, Key, Key, WId) {}
- void run() {}
+# include "keybinding-worker.hpp"
#endif
-};
-struct Shortcuts : public QObject {
+using namespace options;
+
+struct OPENTRACK_EXPORT Shortcuts : public QObject {
Q_OBJECT
public:
@@ -98,39 +39,24 @@ public:
Key
#endif
;
-
- K keyCenter;
- K keyToggle;
- K keyZero;
-
- WId handle;
+
+ using fun = std::function<void(void)>;
+ using tt = std::tuple<K, fun>;
+ std::vector<tt> keys;
#ifdef _WIN32
- mem<KeybindingWorker> keybindingWorker;
+ KeybindingWorker::Token key_token;
#endif
- struct settings : opts {
- key_opts center, toggle, zero;
- main_settings s_main;
- settings() :
- opts("keyboard-shortcuts"),
- center(b, "center"),
- toggle(b, "toggle"),
- zero(b, "zero")
- {}
- } s;
-
- Shortcuts(WId handle) : handle(handle) { reload(); }
+ Shortcuts()
+#ifdef _WIN32
+ : key_token([&](const Key& k) { receiver(k); })
+#endif
+ {}
- void reload();
+ void reload(const std::vector<std::tuple<key_opts &, fun> > &keys);
private:
- void bind_keyboard_shortcut(K &key, key_opts& k);
+ void bind_keyboard_shortcut(K &key, const key_opts& k);
#ifdef _WIN32
- void receiver(Key& k);
+ void receiver(const Key& k);
#endif
-signals:
- void center();
- void toggle();
- void zero();
};
-
-