summaryrefslogtreecommitdiffhomepage
path: root/opentrack/shortcuts.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-10-20 09:33:56 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-10-20 09:33:56 +0200
commitba0cd4a1fd743a7d0d025ca76c211c8f466e6879 (patch)
tree2bbd5f1939a7413e76cbe782e3da7b7c844cea8c /opentrack/shortcuts.h
parent7f0d0d1b9ef7711a4f1835b0120f014799b71e90 (diff)
refactor 2/n
Diffstat (limited to 'opentrack/shortcuts.h')
-rw-r--r--opentrack/shortcuts.h36
1 files changed, 16 insertions, 20 deletions
diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h
index 2962f4fd..54305a52 100644
--- a/opentrack/shortcuts.h
+++ b/opentrack/shortcuts.h
@@ -51,8 +51,9 @@ typedef unsigned char BYTE;
struct Key { int foo; };
#endif
-#if defined(_WIN32)
-class KeybindingWorkerImpl {
+struct KeybindingWorker : public QThread {
+ Q_OBJECT
+#ifdef _WIN32
private:
LPDIRECTINPUT8 din;
LPDIRECTINPUTDEVICE8 dinkeyboard;
@@ -60,26 +61,17 @@ private:
Key kToggle;
public:
volatile bool should_quit;
- ~KeybindingWorkerImpl();
- KeybindingWorkerImpl(Key keyCenter, Key keyToggle);
+ ~KeybindingWorker();
+ KeybindingWorker(Key keyCenter, Key keyToggle, WId handle);
void run();
-};
#else
-class KeybindingWorkerImpl {
public:
- KeybindingWorkerImpl(Key keyCenter, Key keyToggle);
+ KeybindingWorker(Key, Key, WId) {}
void run() {}
-};
#endif
-
-template<typename t_self>
-struct KeybindingWorker : public QThread, public KeybindingWorkerImpl {
- KeybindingWorker(Key keyCenter, Key keyToggle) : KeybindingWorkerImpl(keyCenter, keyToggle)
- {
- }
- void run() {
- KeybindingWorkerImpl::run();
- }
+signals:
+ void center();
+ void toggle();
};
@@ -108,14 +100,18 @@ struct Shortcuts {
{}
} s;
- Shortcuts()
+#ifdef _WIN32
+ Shortcuts(WId handle)
+#else
+ Shortcuts(WId)
+#endif
{
bind_keyboard_shortcut(keyCenter, s.center);
bind_keyboard_shortcut(keyToggle, s.toggle);
#ifdef _WIN32
keybindingWorker = nullptr;
- keybindingWorker = std::make_shared<KeybindingWorker>(*this, keyCenter, keyToggle);
- keybindingWorker.start();
+ keybindingWorker = std::make_shared<KeybindingWorker>(keyCenter, keyToggle, handle);
+ keybindingWorker->start();
#endif
}
private: