Tick threshold should be a reflection of the actual change in the encoder's value.

This commit is contained in:
Anna Rose 2021-12-21 04:58:17 +00:00
parent 82927519ce
commit 70d7bdd3b2

View File

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