Reference the correct object, not a copy of it.

This commit is contained in:
Anna Rose 2015-11-13 01:21:49 -05:00
parent 1834a50496
commit 29d1c4a556

View File

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