Tick threshold should be a reflection of the actual change in the encoder's value.
This commit is contained in:
parent
82927519ce
commit
70d7bdd3b2
|
@ -127,10 +127,9 @@ bool EncoderButton::Update(Joystick* js) {
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
long new_value = encoder->read();
|
long new_value = encoder->read();
|
||||||
if (new_value > last_value) {
|
if (new_value != last_value) {
|
||||||
ticks++;
|
ticks += last_value - new_value;
|
||||||
} else if (new_value < last_value) {
|
last_value = new_value;
|
||||||
ticks--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticks >= tick_threshold) {
|
if (ticks >= tick_threshold) {
|
||||||
|
@ -146,6 +145,5 @@ bool EncoderButton::Update(Joystick* js) {
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
last_value = new_value;
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user