diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-02 08:39:34 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-02 08:41:49 +0200 |
commit | 68d33b0c99cfac8f89c2224d457e1568232896f7 (patch) | |
tree | 4402f5f6b9fe4a4c94b00e105140a78ee1551dde | |
parent | aa58a960b92cf9c359aa61e19808c11d49fd7b65 (diff) |
shortcuts: use dinput for consistency on win32
Converting qt -> dinput causes keyboard layout and modifier issues.
Sponsored-by: TrackHat
-rw-r--r-- | facetracknoir/keyboard.h | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/facetracknoir/keyboard.h b/facetracknoir/keyboard.h index 3df295e1..62a9ce20 100644 --- a/facetracknoir/keyboard.h +++ b/facetracknoir/keyboard.h @@ -1,5 +1,9 @@ #pragma once #include "ui_keyboard_listener.h" +#ifdef _WIN32 +#include "opentrack/win32-shortcuts.h" +#include "opentrack/shortcuts.h" +#endif #include <QLabel> #include <QKeyEvent> #include <QDebug> @@ -8,35 +12,39 @@ class KeyboardListener : public QLabel { Q_OBJECT Ui_keyboard_listener ui; +#ifdef _WIN32 + KeybindingWorker w; +#endif public: KeyboardListener(QWidget* parent = nullptr) : QLabel(parent) +#ifdef _WIN32 + , w([&](Key& k) + { + Qt::KeyboardModifiers m; + QKeySequence k_; + if (win_key::to_qt(k, k_, m)) + key_pressed(static_cast<QVariant>(k_).toInt() | m); + }, this->winId()) +#endif { ui.setupUi(this); setFocusPolicy(Qt::StrongFocus); +#ifdef _WIN32 + w.start(); +#endif } +#ifndef _WIN32 void keyPressEvent(QKeyEvent* event) override { //qDebug() << "k" << (event->key() | event->modifiers()); switch (event->key() | event->modifiers()) { - case 83886113: // ctrl - case 50331680: // shift - case 150994979: // alt - case 218103841: // ctrl+alt - case 218103843: // ctrl+alt - case 117440545: // ctrl+shift - case 117440544: // ctrl+shift - case 184549408: // alt+shift - case 184549411: // alt+shift - case 251658272: // ctrl+alt+shift - case 251658275: // ctrl+alt+shift - case 251658273: // ctrl+alt+shift - break; default: emit key_pressed(QKeySequence(event->key() | event->modifiers())); break; } } +#endif signals: void key_pressed(QKeySequence k); }; |