diff options
-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) |