summaryrefslogtreecommitdiffhomepage
path: root/gui/keyboard.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-24 22:45:38 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-12-24 22:45:38 +0100
commit323dd162f5326b998e1c92ab4cfec8a63574023f (patch)
treefb4f0f4f7585d3cb90aef453167c7f4df0c6eeee /gui/keyboard.cpp
parent3981f867377ca0652d0cc0ababbbc30208db7e1c (diff)
cmake: decruft, disable deprecated Qt functions
Diffstat (limited to 'gui/keyboard.cpp')
-rw-r--r--gui/keyboard.cpp50
1 files changed, 27 insertions, 23 deletions
diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp
index dbc3ab3a..90849bab 100644
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -1,39 +1,43 @@
+#undef NDEBUG
+#include <cassert>
+
#include "keyboard.h"
#include <QDebug>
#ifdef _WIN32
-auto keyboard_listener::make_token()
+
+void keyboard_listener::receive_key(const Key& k)
{
- return [this](const Key& k) {
- if(!k.guid.isEmpty())
- {
- int mods = 0;
- if (k.alt) mods |= Qt::AltModifier;
- if (k.shift) mods |= Qt::ShiftModifier;
- if (k.ctrl) mods |= Qt::ControlModifier;
- emit joystick_button_pressed(k.guid, k.keycode | mods, k.held);
- }
- else
- {
- Qt::KeyboardModifiers m;
- QKeySequence k_;
- if (win_key::to_qt(k, k_, m))
- emit key_pressed({ int(m) | int(k_) });
- }
- };
+ if(!k.guid.isEmpty())
+ {
+ int mods = 0;
+ if (k.alt) mods |= Qt::AltModifier;
+ if (k.shift) mods |= Qt::ShiftModifier;
+ if (k.ctrl) mods |= Qt::ControlModifier;
+
+ emit joystick_button_pressed(k.guid, k.keycode | mods, k.held);
+ }
+ else
+ {
+ Qt::KeyboardModifiers m;
+ QKeySequence k_;
+
+ if (win_key::to_qt(k, k_, m))
+ for (unsigned i = 0; i < (unsigned)k_.count(); i++)
+ emit key_pressed(QKeySequence(int(m) | k_[i]));
+ }
}
#endif
-keyboard_listener::keyboard_listener(QWidget* parent) :
- QDialog(parent)
-#ifdef _WIN32
- , token(make_token())
-#endif
+keyboard_listener::keyboard_listener(QWidget* parent) : QDialog(parent)
{
ui.setupUi(this);
setFocusPolicy(Qt::StrongFocus);
+#ifdef _WIN32
+ (void)token;
+#endif
}
#if !defined _WIN32