summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Brosziewski <bru@cvs.openbsd.org>2018-11-10 14:27:52 +0000
committerUlf Brosziewski <bru@cvs.openbsd.org>2018-11-10 14:27:52 +0000
commit9d77e82beae167bdeb5b614a38b3a4292dda03f5 (patch)
tree19bbcbf29fd5ce9becfdc858129da0767cb57535
parent16282c5c863073007fe35902824c9af73a5cfab4 (diff)
Remove the strong hysteresis filter.
It seems that the filter is obsolete, the default method is sufficient. Simplify and clean up some related code in wsmouse. ok mpi@
-rw-r--r--sys/dev/wscons/wsconsio.h5
-rw-r--r--sys/dev/wscons/wsmouse.c74
-rw-r--r--sys/dev/wscons/wsmouseinput.h8
-rw-r--r--sys/dev/wscons/wstpad.c35
4 files changed, 36 insertions, 86 deletions
diff --git a/sys/dev/wscons/wsconsio.h b/sys/dev/wscons/wsconsio.h
index 64478d4efd9..97803143bc3 100644
--- a/sys/dev/wscons/wsconsio.h
+++ b/sys/dev/wscons/wsconsio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsconsio.h,v 1.89 2018/07/30 15:56:30 jcs Exp $ */
+/* $OpenBSD: wsconsio.h,v 1.90 2018/11/10 14:27:51 bru Exp $ */
/* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */
/*
@@ -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) */
/*
diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c
index be654aa7ab8..9f3a34fa93a 100644
--- a/sys/dev/wscons/wsmouse.c
+++ b/sys/dev/wscons/wsmouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmouse.c,v 1.45 2018/05/07 21:58:42 bru Exp $ */
+/* $OpenBSD: wsmouse.c,v 1.46 2018/11/10 14:27:51 bru Exp $ */
/* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -625,7 +625,10 @@ set_x(struct position *pos, int x, u_int *sync, u_int mask)
}
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 *sync, u_int mask)
}
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;
}
}
@@ -704,7 +710,6 @@ wsmouse_mtstate(struct device *sc, int slot, int x, int y, int pressure)
struct mt_state *mt = &input->mt;
struct mt_slot *mts;
u_int bit;
- int initial;
if (slot < 0 || slot >= mt->num_slots)
return;
@@ -712,24 +717,17 @@ wsmouse_mtstate(struct device *sc, int slot, int x, int y, int pressure)
bit = (1 << slot);
mt->frame |= bit;
- /* Is this a new touch? */
- initial = ((mt->touches & bit) == (mt->sync[MTS_TOUCH] & bit));
-
mts = &mt->slots[slot];
- if (initial) {
- mts->pos.x = x;
- mts->pos.y = y;
+ set_x(&mts->pos, x, mt->sync + MTS_X, bit);
+ set_y(&mts->pos, y, mt->sync + MTS_Y, bit);
+
+ /* Is this a new touch? */
+ if ((mt->touches & bit) == (mt->sync[MTS_TOUCH] & bit))
cleardeltas(&mts->pos);
- mt->sync[MTS_X] |= bit;
- mt->sync[MTS_Y] |= bit;
- } else {
- set_x(&mts->pos, x, mt->sync + MTS_X, bit);
- set_y(&mts->pos, y, mt->sync + MTS_Y, bit);
- }
pressure = normalized_pressure(input, pressure);
- if (pressure != mts->pressure || initial) {
+ if (pressure != mts->pressure) {
mts->pressure = pressure;
mt->sync[MTS_PRESSURE] |= bit;
@@ -738,6 +736,9 @@ wsmouse_mtstate(struct device *sc, int slot, int x, int y, int pressure)
mt->num_touches++;
mt->touches |= bit;
mt->sync[MTS_TOUCH] |= bit;
+
+ mt->sync[MTS_X] |= bit;
+ mt->sync[MTS_Y] |= bit;
}
} else if (mt->touches & bit) {
mt->num_touches--;
@@ -850,7 +851,7 @@ wsmouse_mt_update(struct wsmouseinput *input)
* (pressure == 0). Clear the sync flags for touches that have
* been released.
*/
- if (input->mt.sync[MTS_TOUCH] & ~input->mt.touches) {
+ if (input->mt.frame & ~input->mt.touches) {
for (i = MTS_X; i < MTS_SIZE; i++)
input->mt.sync[i] &= input->mt.touches;
}
@@ -860,18 +861,6 @@ wsmouse_mt_update(struct wsmouseinput *input)
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);
}
@@ -896,6 +885,14 @@ wsmouse_ptr_ctrl(struct wsmouseinput *input)
u_int updates;
int select, slot;
+ mt->prev_ptr = mt->ptr;
+
+ if (mt->num_touches <= 1) {
+ mt->ptr = mt->touches;
+ mt->ptr_cycle = mt->ptr;
+ return;
+ }
+
updates = (mt->sync[MTS_X] | mt->sync[MTS_Y]) & ~mt->sync[MTS_TOUCH];
FOREACHBIT(updates, slot) {
/*
@@ -907,14 +904,6 @@ wsmouse_ptr_ctrl(struct wsmouseinput *input)
updates ^= (1 << slot);
}
- mt->prev_ptr = mt->ptr;
-
- if (mt->num_touches <= 1) {
- mt->ptr = mt->touches;
- mt->ptr_cycle = mt->ptr;
- return;
- }
-
/*
* If there is no pointer-controlling slot, or if it should be
* masked, select a new one.
@@ -1489,8 +1478,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 =
@@ -1570,12 +1558,6 @@ wsmouse_set_params(struct device *sc,
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;
input->filter.mode |= (val & SMOOTHING_MASK);
diff --git a/sys/dev/wscons/wsmouseinput.h b/sys/dev/wscons/wsmouseinput.h
index e4735fc970a..68231755012 100644
--- a/sys/dev/wscons/wsmouseinput.h
+++ b/sys/dev/wscons/wsmouseinput.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmouseinput.h,v 1.11 2018/05/07 21:58:42 bru Exp $ */
+/* $OpenBSD: wsmouseinput.h,v 1.12 2018/11/10 14:27:51 bru Exp $ */
/*
* Copyright (c) 2015, 2016 Ulf Brosziewski
@@ -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;
diff --git a/sys/dev/wscons/wstpad.c b/sys/dev/wscons/wstpad.c
index d4c9cb474d8..9ed1887b400 100644
--- a/sys/dev/wscons/wstpad.c
+++ b/sys/dev/wscons/wstpad.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wstpad.c,v 1.18 2018/11/05 23:38:04 bru Exp $ */
+/* $OpenBSD: wstpad.c,v 1.19 2018/11/10 14:27:51 bru Exp $ */
/*
* Copyright (c) 2015, 2016 Ulf Brosziewski
@@ -1219,33 +1219,6 @@ wstpad_decelerate(struct wsmouseinput *input, int *dx, int *dy)
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. */