Reference the correct object, not a copy of it.
This commit is contained in:
parent
1834a50496
commit
29d1c4a556
16
Joystick.cpp
16
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user