diff --git a/Button.cpp b/Button.cpp index 4fbe3d9..b47ed9c 100644 --- a/Button.cpp +++ b/Button.cpp @@ -127,10 +127,9 @@ bool EncoderButton::Update(Joystick* js) { bool changed = false; long new_value = encoder->read(); - if (new_value > last_value) { - ticks++; - } else if (new_value < last_value) { - ticks--; + if (new_value != last_value) { + ticks += last_value - new_value; + last_value = new_value; } if (ticks >= tick_threshold) { @@ -146,6 +145,5 @@ bool EncoderButton::Update(Joystick* js) { ticks = 0; } - last_value = new_value; return changed; }