From 9ae0777c6b0acb9981b8e6ce75dc5abac5bdbab4 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Thu, 12 Nov 2015 21:06:19 -0500 Subject: [PATCH] Speculative fix for latched buttons. --- Joystick.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Joystick.cpp b/Joystick.cpp index e27492c..1bef20d 100644 --- a/Joystick.cpp +++ b/Joystick.cpp @@ -134,8 +134,6 @@ void Joystick::_ReleasePulsedButtons() { for (uint8_t i = 0; i < _num_buttons; i++) { if (_buttons[i].type & _BUTTON_PULSED_TYPES) ReleaseButton(i); } - - if (_debug) Serial.println("DEBUG: Pulse button release recorded."); } void Joystick::Write() { @@ -164,8 +162,8 @@ void Joystick::_UpdateButton(Button& button, uint8_t index) { switch (button.type) { case BUTTON_LATCHED: - if (value == HIGH) PressButton(index); - else ReleaseButton(index); + if (value == HIGH && button.last_state != HIGH) PressButton(index); + else if (value == LOW && button.last_state != LOW) ReleaseButton(index); break; case BUTTON_PULSED: if (value == HIGH && button.last_state == LOW) PressButton(index);