summaryrefslogtreecommitdiffhomepage
path: root/opentrack/keybinding-worker.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-11-11 15:28:50 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-11-11 15:28:50 +0100
commitc8805112acca1ba3bd0056fcf0b9332c4ba10f03 (patch)
tree1c7e3f7fdb2feebba1664eea5f2a64dbfbd4db7f /opentrack/keybinding-worker.cpp
parente79ab73d99d3cc19e0db82cce8884589e0e93396 (diff)
shortcuts: alloy kbd mods for joystick buttons
Diffstat (limited to 'opentrack/keybinding-worker.cpp')
-rw-r--r--opentrack/keybinding-worker.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/opentrack/keybinding-worker.cpp b/opentrack/keybinding-worker.cpp
index e9255801..fd777211 100644
--- a/opentrack/keybinding-worker.cpp
+++ b/opentrack/keybinding-worker.cpp
@@ -68,16 +68,29 @@ KeybindingWorker::KeybindingWorker(std::function<void(Key&)> receiver, WId h) :
}
void KeybindingWorker::run() {
- BYTE keystate[256];
+ BYTE keystate[256] = {0};
while (!should_quit)
{
{
+ const HRESULT hr = dinkeyboard->GetDeviceState(256, (LPVOID)keystate);
+
+ if (hr != DI_OK) {
+ qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError();
+ Sleep(25);
+ continue;
+ }
+ }
+
+ {
using joy_fn = std::function<void(const QString& guid, int idx, bool held)>;
joy_fn f = [&](const QString& guid, int idx, bool held) -> void {
Key k;
k.keycode = idx;
+ k.shift = !!(keystate[DIK_LSHIFT] & 0x80 || keystate[DIK_RSHIFT] & 0x80);
+ k.alt = !!(keystate[DIK_LALT] & 0x80 || keystate[DIK_RALT] & 0x80);
+ k.ctrl = !!(keystate[DIK_LCONTROL] & 0x80 || keystate[DIK_RCONTROL] & 0x80);
k.guid = guid;
k.held = held;
receiver(k);
@@ -85,12 +98,6 @@ void KeybindingWorker::run() {
joy_ctx.poll(f);
}
-
- if (dinkeyboard->GetDeviceState(256, (LPVOID)keystate) != DI_OK) {
- qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError();
- Sleep(25);
- continue;
- }
QMutexLocker l(&mtx);