The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=3b2175fdb62c7f872e78ce732952f2ac2ff99c8d
commit 3b2175fdb62c7f872e78ce732952f2ac2ff99c8d Author: Vladimir Kondratyev <w...@freebsd.org> AuthorDate: 2020-11-30 21:10:04 +0000 Commit: Vladimir Kondratyev <w...@freebsd.org> CommitDate: 2021-01-07 23:18:44 +0000 evdev: Implement fuzz. Fuzz is used to filter noise from the event stream. Upcoming gamepad drivers use it. Reviewed by: hselasky (as part of D27993) --- sys/dev/evdev/evdev.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index e76abbc816d3..086ee36333dc 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -684,6 +684,7 @@ static void evdev_modify_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, int32_t *value) { + int32_t fuzz, old_value, abs_change; EVDEV_LOCK_ASSERT(evdev); @@ -710,7 +711,24 @@ evdev_modify_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, break; case EV_ABS: - /* TBD: implement fuzz */ + fuzz = evdev->ev_absinfo[code].fuzz; + if (fuzz == 0 || code == ABS_MT_SLOT) + break; + else if (!ABS_IS_MT(code)) + old_value = evdev->ev_absinfo[code].value; + else if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) + old_value = evdev_get_mt_value(evdev, + evdev_get_last_mt_slot(evdev), code); + else /* Pass MT protocol type A events as is */ + break; + + abs_change = abs(*value - old_value); + if (abs_change < fuzz / 2) + *value = old_value; + else if (abs_change < fuzz) + *value = (old_value * 3 + *value) / 4; + else if (abs_change < fuzz * 2) + *value = (old_value + *value) / 2; break; } } _______________________________________________ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"