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); } } }