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) { void Joystick::_UpdateButton(uint8_t index) {
Button button = _buttons[index]; Button* button = &_buttons[index];
bool changed = button.bouncer.update(); bool changed = button->bouncer.update();
switch (button.type) { switch (button->type) {
case BUTTON_LATCHED: case BUTTON_LATCHED:
if (button.bouncer.rose()) PressButton(index); if (button->bouncer.rose()) PressButton(index);
else if (button.bouncer.fell()) ReleaseButton(index); else if (button->bouncer.fell()) ReleaseButton(index);
break; break;
case BUTTON_PULSED: case BUTTON_PULSED:
if (button.bouncer.rose()) PressButton(index); if (button->bouncer.rose()) PressButton(index);
break; break;
case BUTTON_PULSED_DOUBLE_ACTION: case BUTTON_PULSED_DOUBLE_ACTION:
if (changed) PressButton(index); if (changed) PressButton(index);
@ -166,7 +166,7 @@ void Joystick::_UpdateButton(uint8_t index) {
default: default:
if (_debug) { if (_debug) {
Serial.print("DEBUG: Unhandled button type: "); Serial.print("DEBUG: Unhandled button type: ");
Serial.println(button.type); Serial.println(button->type);
} }
} }
} }