For a while now, wsmouse activates compatibility mode for touchpads by default. There have been no complaints about wobbling pointers or unstable pointer paths. I conclude that the default filtering is sufficient and that the type of touchpad which could profit from the "strong" variant of the hysteresis filter is dying out. This patch removes it (and somewhat simplifies related code of the default method).
The patch doesn't change the list of wsmouse parameters in wsconsio.h. Reading the parameter value for strong hysteresis returns 0, an attempt to set it results in an error (should someone actually stumble over the change, I'd like to know that). OK? Index: dev/wscons/wsconsio.h =================================================================== RCS file: /cvs/src/sys/dev/wscons/wsconsio.h,v retrieving revision 1.89 diff -u -p -r1.89 wsconsio.h --- dev/wscons/wsconsio.h 30 Jul 2018 15:56:30 -0000 1.89 +++ dev/wscons/wsconsio.h 6 Nov 2018 19:03:49 -0000 @@ -295,7 +295,8 @@ enum wsmousecfg { WSMOUSECFG_X_HYSTERESIS,/* retard value for X coordinates */ WSMOUSECFG_Y_HYSTERESIS,/* retard value for Y coordinates */ WSMOUSECFG_DECELERATION,/* threshold (distance) for deceleration */ - WSMOUSECFG_STRONG_HYSTERESIS, /* apply the filter continuously */ + WSMOUSECFG_STRONG_HYSTERESIS, /* FALSE and read-only, the fea- + ture is not supported anymore. */ WSMOUSECFG_SMOOTHING, /* smoothing factor (0-7) */ /* Index: dev/wscons/wsmouse.c =================================================================== RCS file: /cvs/src/sys/dev/wscons/wsmouse.c,v retrieving revision 1.45 diff -u -p -r1.45 wsmouse.c --- dev/wscons/wsmouse.c 7 May 2018 21:58:42 -0000 1.45 +++ dev/wscons/wsmouse.c 6 Nov 2018 19:03:49 -0000 @@ -625,7 +625,10 @@ set_x(struct position *pos, int x, u_int } if ((pos->dx = x - pos->x)) { pos->x = x; - pos->acc_dx += pos->dx; + if (pos->dx > 0 == pos->acc_dx > 0) + pos->acc_dx += pos->dx; + else + pos->acc_dx = pos->dx; *sync |= mask; } } @@ -641,7 +644,10 @@ set_y(struct position *pos, int y, u_int } if ((pos->dy = y - pos->y)) { pos->y = y; - pos->acc_dy += pos->dy; + if (pos->dy > 0 == pos->acc_dy > 0) + pos->acc_dy += pos->dy; + else + pos->acc_dy = pos->dy; *sync |= mask; } } @@ -860,18 +866,6 @@ wsmouse_mt_update(struct wsmouseinput *i int wsmouse_hysteresis(struct wsmouseinput *input, struct position *pos) { - - if (!(input->filter.h.hysteresis && input->filter.v.hysteresis)) - return (0); - - if ((pos->dx > 0 && pos->dx > pos->acc_dx) - || (pos->dx < 0 && pos->dx < pos->acc_dx)) - pos->acc_dx = pos->dx; - - if ((pos->dy > 0 && pos->dy > pos->acc_dy) - || (pos->dy < 0 && pos->dy < pos->acc_dy)) - pos->acc_dy = pos->dy; - return (abs(pos->acc_dx) < input->filter.h.hysteresis && abs(pos->acc_dy) < input->filter.v.hysteresis); } @@ -1489,8 +1483,7 @@ wsmouse_get_params(struct device *sc, params[i].value = input->filter.dclr; break; case WSMOUSECFG_STRONG_HYSTERESIS: - params[i].value = - !!(input->filter.mode & STRONG_HYSTERESIS); + params[i].value = 0; /* The feature has been removed. */ break; case WSMOUSECFG_SMOOTHING: params[i].value = @@ -1569,12 +1562,6 @@ wsmouse_set_params(struct device *sc, break; case WSMOUSECFG_DY_MAX: input->filter.v.dmax = val; - break; - case WSMOUSECFG_STRONG_HYSTERESIS: - if (val) - input->filter.mode |= STRONG_HYSTERESIS; - else - input->filter.mode &= ~STRONG_HYSTERESIS; break; case WSMOUSECFG_SMOOTHING: input->filter.mode &= ~SMOOTHING_MASK; Index: dev/wscons/wsmouseinput.h =================================================================== RCS file: /cvs/src/sys/dev/wscons/wsmouseinput.h,v retrieving revision 1.11 diff -u -p -r1.11 wsmouseinput.h --- dev/wscons/wsmouseinput.h 7 May 2018 21:58:42 -0000 1.11 +++ dev/wscons/wsmouseinput.h 6 Nov 2018 19:03:49 -0000 @@ -167,11 +167,9 @@ struct wsmouseinput { #define LOG_INPUT (1 << 19) #define LOG_EVENTS (1 << 20) -/* filter.mode (bit 0-2: smoothing factor, bit 3: hysteresis type) */ -#define WEAK_HYSTERESIS 0 -#define STRONG_HYSTERESIS (1 << 3) +/* filter.mode (bit 0-2: smoothing factor, bit 3-n: unused) */ #define SMOOTHING_MASK 7 -#define FILTER_MODE_DEFAULT WEAK_HYSTERESIS +#define FILTER_MODE_DEFAULT 0 struct evq_access { struct wseventvar *evar; Index: dev/wscons/wstpad.c =================================================================== RCS file: /cvs/src/sys/dev/wscons/wstpad.c,v retrieving revision 1.18 diff -u -p -r1.18 wstpad.c --- dev/wscons/wstpad.c 5 Nov 2018 23:38:04 -0000 1.18 +++ dev/wscons/wstpad.c 6 Nov 2018 19:03:49 -0000 @@ -1219,33 +1219,6 @@ wstpad_decelerate(struct wsmouseinput *i return (0); } -/* - * The hysteresis filter may suppress noise and accidental pointer - * movements. The "strong" variant applies independently to the axes, - * and it is applied continuously. It takes effect whenever the - * orientation on an axis changes, which makes pointer paths more stable. - * - * The default variant, wsmouse_hysteresis, is more precise and does not - * affect paths, it just filters noise when a touch starts or is resting. - */ -static inline void -strong_hysteresis(int *delta, int *acc, int threshold) -{ - int d; - - if (*delta > 0) { - if (*delta > *acc) - *acc = *delta; - if ((d = *acc - threshold) < *delta) - *delta = (d < 0 ? 0 : d); - } else if (*delta < 0) { - if (*delta < *acc) - *acc = *delta; - if ((d = *acc + threshold) > *delta) - *delta = (d > 0 ? 0 : d); - } -} - void wstpad_filter(struct wsmouseinput *input) { @@ -1263,12 +1236,8 @@ wstpad_filter(struct wsmouseinput *input dx = pos->dx; dy = pos->dy; - if (input->filter.mode & STRONG_HYSTERESIS) { - strong_hysteresis(&dx, &pos->acc_dx, h->hysteresis); - strong_hysteresis(&dy, &pos->acc_dy, v->hysteresis); - } else if (wsmouse_hysteresis(input, pos)) { + if (wsmouse_hysteresis(input, pos)) dx = dy = 0; - } if (input->filter.dclr && wstpad_decelerate(input, &dx, &dy)) /* Strong smoothing may hamper the precision at low speeds. */