From d6eb142710e6ac307b4c5c0e0a54166852d71cbc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 6 Dec 2015 20:14:09 +0100 Subject: api/keys: prevent idempotent keys --- opentrack/keybinding-worker.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'opentrack') diff --git a/opentrack/keybinding-worker.cpp b/opentrack/keybinding-worker.cpp index 2ac814af..b0cef22d 100644 --- a/opentrack/keybinding-worker.cpp +++ b/opentrack/keybinding-worker.cpp @@ -85,6 +85,7 @@ KeybindingWorker& KeybindingWorker::make() void KeybindingWorker::run() { BYTE keystate[256] = {0}; + BYTE old_keystate[256] = {0}; while (!should_quit) { @@ -125,7 +126,7 @@ void KeybindingWorker::run() { for (int i = 0; i < 256; i++) { Key k; - if (keystate[i] & 0x80) + if (old_keystate[i] != keystate[i] && keystate[i] & 0x80) { switch (i) { @@ -147,6 +148,7 @@ void KeybindingWorker::run() { break; } } + old_keystate[i] = keystate[i]; } } } -- cgit v1.2.3