diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-12-06 20:13:42 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-12-06 20:13:42 +0100 |
commit | 75b4a6e3a32b4345941e15953d55572384eb210e (patch) | |
tree | 8867dfd025b1358eaf675749afa7f6319baa2679 | |
parent | dcd4df5e49e6207273c961069d14ce42ad83d147 (diff) |
api/joy: prevent idempotent keypressed passed to receiver
-rw-r--r-- | opentrack/win32-joystick.cpp | 4 | ||||
-rw-r--r-- | opentrack/win32-joystick.hpp | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/opentrack/win32-joystick.cpp b/opentrack/win32-joystick.cpp index f4bfba76..73e27f80 100644 --- a/opentrack/win32-joystick.cpp +++ b/opentrack/win32-joystick.cpp @@ -169,7 +169,7 @@ bool win32_joy_ctx::joy::poll(fn f) for (int i = 0; i < 128; i++) { - const bool state = !!(js.rgbButtons[i] & 0x80); + const bool state = !!(js.rgbButtons[i] & 0x80) && js.rgbButtons[i] != js_old.rgbButtons[i]; if (state != pressed[i]) { f(guid, i, state); @@ -178,6 +178,8 @@ bool win32_joy_ctx::joy::poll(fn f) pressed[i] = state; } + js_old = js; + return true; } diff --git a/opentrack/win32-joystick.hpp b/opentrack/win32-joystick.hpp index e68ea2c6..df00aee7 100644 --- a/opentrack/win32-joystick.hpp +++ b/opentrack/win32-joystick.hpp @@ -76,6 +76,7 @@ private: QString guid, name; bool pressed[128]; Timer first_timer; + DIJOYSTATE2 js_old; joy(LPDIRECTINPUTDEVICE8 handle, const QString& guid, const QString& name) : joy_handle(handle), guid(guid), name(name) |