diff options
author | Ulf Brosziewski <bru@cvs.openbsd.org> | 2016-08-18 21:12:36 +0000 |
---|---|---|
committer | Ulf Brosziewski <bru@cvs.openbsd.org> | 2016-08-18 21:12:36 +0000 |
commit | 9ac35321150c6d0cc1d751a6d4e69acf01a7f024 (patch) | |
tree | 148e5e8876ac7e9d62776dfa87bf6c9eaec12e13 /sys/dev | |
parent | 67f9b42cdbfb3a8e36938af4dd2c9f8db25de27a (diff) |
Reset the input state completely when wsmouse is (re-)opened.
ok mpi@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/wscons/wsmouse.c | 30 | ||||
-rw-r--r-- | sys/dev/wscons/wsmouseinput.h | 3 |
2 files changed, 30 insertions, 3 deletions
diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c index 6139deccae3..c2839bad194 100644 --- a/sys/dev/wscons/wsmouse.c +++ b/sys/dev/wscons/wsmouse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmouse.c,v 1.33 2016/07/13 15:41:51 deraadt Exp $ */ +/* $OpenBSD: wsmouse.c,v 1.34 2016/08/18 21:12:35 bru Exp $ */ /* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */ /* @@ -379,6 +379,8 @@ wsmousedoopen(struct wsmouse_softc *sc, struct wseventvar *evp) { sc->sc_base.me_evp = evp; + wsmouse_input_reset(&sc->input); + /* enable the device, and punt if that's not possible */ return (*sc->sc_accessops->enable)(sc->sc_accesscookie); } @@ -1266,8 +1268,11 @@ wsmouse_mt_init(struct device *sc, int num_slots, int tracking) &((struct wsmouse_softc *) sc)->input; int n, size; + if (num_slots == input->mt.num_slots + && (!tracking == ((input->flags & MT_TRACKING) == 0))) + return (0); + free_mt_slots(input); - memset(&input->mt, 0, sizeof(struct mt_state)); if (tracking) input->flags |= MT_TRACKING; @@ -1366,6 +1371,27 @@ wsmouse_set_mode(struct device *sc, int mode) } void +wsmouse_input_reset(struct wsmouseinput *input) +{ + int num_slots, *matrix; + struct mt_slot *slots; + + memset(&input->btn, 0, sizeof(struct btn_state)); + memset(&input->motion, 0, sizeof(struct motion_state)); + memset(&input->touch, 0, sizeof(struct touch_state)); + input->touch.min_pressure = input->params.pressure_hi; + if ((num_slots = input->mt.num_slots)) { + slots = input->mt.slots; + matrix = input->mt.matrix; + memset(&input->mt, 0, sizeof(struct mt_state)); + memset(slots, 0, num_slots * sizeof(struct mt_slot)); + input->mt.num_slots = num_slots; + input->mt.slots = slots; + input->mt.matrix = matrix; + } +} + +void wsmouse_input_init(struct wsmouseinput *input, struct wseventvar **evar) { input->evar = evar; diff --git a/sys/dev/wscons/wsmouseinput.h b/sys/dev/wscons/wsmouseinput.h index 0b377b405cc..50a12fe05fe 100644 --- a/sys/dev/wscons/wsmouseinput.h +++ b/sys/dev/wscons/wsmouseinput.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmouseinput.h,v 1.1 2016/03/30 23:34:12 bru Exp $ */ +/* $OpenBSD: wsmouseinput.h,v 1.2 2016/08/18 21:12:35 bru Exp $ */ /* * Copyright (c) 2015, 2016 Ulf Brosziewski @@ -139,6 +139,7 @@ struct evq_access { void wsmouse_evq_put(struct evq_access *, int, int); void wsmouse_init_scaling(struct wsmouseinput *); +void wsmouse_input_reset(struct wsmouseinput *); void wsmouse_input_init(struct wsmouseinput *, struct wseventvar **); void wsmouse_input_cleanup(struct wsmouseinput *); |