From 29d1c4a556faa9f3b6db4bcc9a4a73f1805c1466 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Fri, 13 Nov 2015 01:21:49 -0500 Subject: [PATCH] Reference the correct object, not a copy of it. --- Joystick.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Joystick.cpp b/Joystick.cpp index 62ad8bf..63c5cf6 100644 --- a/Joystick.cpp +++ b/Joystick.cpp @@ -149,16 +149,16 @@ void Joystick::Write() { } void Joystick::_UpdateButton(uint8_t index) { - Button button = _buttons[index]; - bool changed = button.bouncer.update(); - - switch (button.type) { + Button* button = &_buttons[index]; + bool changed = button->bouncer.update(); + + switch (button->type) { case BUTTON_LATCHED: - if (button.bouncer.rose()) PressButton(index); - else if (button.bouncer.fell()) ReleaseButton(index); + if (button->bouncer.rose()) PressButton(index); + else if (button->bouncer.fell()) ReleaseButton(index); break; case BUTTON_PULSED: - if (button.bouncer.rose()) PressButton(index); + if (button->bouncer.rose()) PressButton(index); break; case BUTTON_PULSED_DOUBLE_ACTION: if (changed) PressButton(index); @@ -166,7 +166,7 @@ void Joystick::_UpdateButton(uint8_t index) { default: if (_debug) { Serial.print("DEBUG: Unhandled button type: "); - Serial.println(button.type); + Serial.println(button->type); } } }