summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-10-02 08:38:21 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-10-02 08:38:21 +0200
commit79815a8a759ae9fc48c26ee16bc3337463c35655 (patch)
tree6aae5159e9c807b6040821d87e2c983c95cf24f5
parentd6589a028919c671a3005d32202cdbbaf5caa010 (diff)
shortcuts: implement dinput -> qt conversion
-rw-r--r--opentrack/win32-shortcuts.cpp17
-rw-r--r--opentrack/win32-shortcuts.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/opentrack/win32-shortcuts.cpp b/opentrack/win32-shortcuts.cpp
index d4107949..bd51ae88 100644
--- a/opentrack/win32-shortcuts.cpp
+++ b/opentrack/win32-shortcuts.cpp
@@ -111,6 +111,23 @@ QList<win_key> windows_key_sequences =
win_key(DIK_SPACE, Qt::Key::Key_Space),
});
+bool win_key::to_qt(const Key& k, QKeySequence& qt_, Qt::KeyboardModifiers &mods)
+{
+ for (auto& wk : windows_key_sequences)
+ {
+ if (wk.win == k.keycode)
+ {
+ qt_ = wk.qt;
+ mods = Qt::NoModifier;
+ if (k.ctrl) mods |= Qt::ControlModifier;
+ if (k.shift) mods |= Qt::ShiftModifier;
+ if (k.alt) mods |= Qt::AltModifier;
+ return true;
+ }
+ }
+ return false;
+}
+
bool win_key::from_qt(QKeySequence qt_, int& dik, Qt::KeyboardModifiers& mods)
{
auto qt = static_cast<QVariant>(qt_).toInt();
diff --git a/opentrack/win32-shortcuts.h b/opentrack/win32-shortcuts.h
index 3e824b89..fe92ae53 100644
--- a/opentrack/win32-shortcuts.h
+++ b/opentrack/win32-shortcuts.h
@@ -3,6 +3,7 @@
#ifdef _WIN32
#include <QKeySequence>
+#include "opentrack/shortcuts.h"
struct win_key;
@@ -15,6 +16,7 @@ struct win_key
int win;
Qt::Key qt;
static bool from_qt(QKeySequence qt_, int& dik, Qt::KeyboardModifiers &mods);
+ static bool to_qt(const Key& k, QKeySequence& qt_, Qt::KeyboardModifiers &mods);
};
#endif