diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-02-09 12:11:49 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-02-09 12:13:39 +0100 |
commit | 14a976e4729d38f86d336fa6054279b33905b63c (patch) | |
tree | 41e5a48f3e75520800fe3937691af0755c565d64 /dinput/keybinding-worker.cpp | |
parent | 6073e15f2871f2699f3e821dc927b3c49187cfb9 (diff) |
dinput: fix api usage
Issue: #871
- don't sleep with a lock held
- fix Acquire() return value check
- remove needless Unacquire() calls
- always use Poll(), even for keyboard
- fix HRESULT debug output
Diffstat (limited to 'dinput/keybinding-worker.cpp')
-rw-r--r-- | dinput/keybinding-worker.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/dinput/keybinding-worker.cpp b/dinput/keybinding-worker.cpp index e4cc6659..3d792778 100644 --- a/dinput/keybinding-worker.cpp +++ b/dinput/keybinding-worker.cpp @@ -82,14 +82,6 @@ bool KeybindingWorker::init() } } - if (dinkeyboard->Acquire() != DI_OK) - { - dinkeyboard->Release(); - dinkeyboard = nullptr; - qDebug() << "dinput: acquire keyboard failed" << GetLastError(); - return false; - } - return true; } @@ -142,12 +134,15 @@ bool KeybindingWorker::run_keyboard_nolock() * Key-up events work on my end. */ + if (!di_t::poll_device(dinkeyboard)) + eval_once(qDebug() << "dinput: keyboard poll failed"); + DWORD sz = num_keyboard_states; - const HRESULT hr = dinkeyboard->GetDeviceData(sizeof(*keyboard_states), keyboard_states, &sz, 0); + HRESULT hr = dinkeyboard->GetDeviceData(sizeof(*keyboard_states), keyboard_states, &sz, 0); - if (hr != DI_OK) + if (FAILED(hr)) { - eval_once(qDebug() << "dinput: keyboard GetDeviceData" << hr); + eval_once(qDebug() << "dinput: keyboard GetDeviceData failed" << (void*)hr); return false; } |