diff options
author | 2016-10-23 22:59:19 +0000 | |
---|---|---|
committer | 2016-10-23 22:59:19 +0000 | |
commit | 03a2e3afff649137d1fc69322debd38d073b5635 (patch) | |
tree | 935c05ea8e7a18fa0b384f83f67d853a9e32f6c3 | |
parent | Factor out "can bind to low ports" check into its own function. This will make (diff) | |
download | wireguard-openbsd-03a2e3afff649137d1fc69322debd38d073b5635.tar.xz wireguard-openbsd-03a2e3afff649137d1fc69322debd38d073b5635.zip |
Improved parameter handling in wsmouse and new ioctls for reading and
setting parameter values.
ok matthieu@
-rw-r--r-- | sys/dev/pckbc/pms.c | 16 | ||||
-rw-r--r-- | sys/dev/wscons/wsconsio.h | 56 | ||||
-rw-r--r-- | sys/dev/wscons/wsmouse.c | 248 | ||||
-rw-r--r-- | sys/dev/wscons/wsmouseinput.h | 39 | ||||
-rw-r--r-- | sys/dev/wscons/wsmousevar.h | 65 |
5 files changed, 280 insertions, 144 deletions
diff --git a/sys/dev/pckbc/pms.c b/sys/dev/pckbc/pms.c index 796c3d77ce1..5c08ad97774 100644 --- a/sys/dev/pckbc/pms.c +++ b/sys/dev/pckbc/pms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pms.c,v 1.70 2016/05/22 22:06:11 bru Exp $ */ +/* $OpenBSD: pms.c,v 1.71 2016/10/23 22:59:19 bru Exp $ */ /* $NetBSD: psm.c,v 1.11 2000/06/05 22:20:57 sommerfeld Exp $ */ /*- @@ -235,6 +235,12 @@ static const struct alps_model { #endif }; +static const struct wsmouse_param elantech_v4_cfg[] = { + { WSMOUSECFG_DX_SCALE, (4096 / SYNAPTICS_SCALE) }, + { WSMOUSECFG_DY_SCALE, (4096 / SYNAPTICS_SCALE) }, +}; +#define ELANTECH_V4_NPARAMS 2 + int pmsprobe(struct device *, void *, void *); void pmsattach(struct device *, struct device *, void *); int pmsactivate(struct device *, int); @@ -316,8 +322,6 @@ int elantech_set_absolute_mode_v2(struct pms_softc *); int elantech_set_absolute_mode_v3(struct pms_softc *); int elantech_set_absolute_mode_v4(struct pms_softc *); -void elantech_send_mt_input(struct pms_softc *, int); - struct cfattach pms_ca = { sizeof(struct pms_softc), pmsprobe, pmsattach, NULL, pmsactivate @@ -2025,11 +2029,11 @@ int pms_elantech_v4_configure(struct device *sc_wsmousedev, struct elantech_softc *elantech) { - if (wsmouse_mt_init(sc_wsmousedev, ELANTECH_MAX_FINGERS, 0)) + if (wsmouse_mt_init(sc_wsmousedev, ELANTECH_MAX_FINGERS, 0) + || wsmouse_set_params(sc_wsmousedev, elantech_v4_cfg, + ELANTECH_V4_NPARAMS)) return (-1); - wsmouse_set_param(sc_wsmousedev, WSMPARAM_DX_DIV, SYNAPTICS_SCALE); - wsmouse_set_param(sc_wsmousedev, WSMPARAM_DY_DIV, SYNAPTICS_SCALE); return (0); } diff --git a/sys/dev/wscons/wsconsio.h b/sys/dev/wscons/wsconsio.h index 777f22a2d7e..26d9eda8eaa 100644 --- a/sys/dev/wscons/wsconsio.h +++ b/sys/dev/wscons/wsconsio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsio.h,v 1.76 2016/09/30 12:05:46 kettenis Exp $ */ +/* $OpenBSD: wsconsio.h,v 1.77 2016/10/23 22:59:19 bru Exp $ */ /* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */ /* @@ -277,6 +277,60 @@ struct wsmouse_calibcoords { #define WSMOUSE_NATIVE 1 /* + * Keys of the configuration parameters in WSMOUSEIO_GETPARAMS/ + * WSMOUSEIO_SETPARAMS calls. Arbitrary subsets can be passed, provided + * that all keys are valid and that the number of key/value pairs doesn't + * exceed the enum size. + * + * WSMOUSECFG_DX_SCALE, WSMOUSECFG_DY_SCALE: + * Scale factors in [*.12] fixed-point format. + * WSMOUSECFG_PRESSURE_LO, WSMOUSECFG_PRESSURE_HI: + * Pressure limits defining the end and the start of touches. + * WSMOUSECFG_TRKMAXDIST: + * When tracking MT contacts, don't pair points with a distance that + * exceeds this limit. + * WSMOUSECFG_SWAPXY: + * Swap the X- and Y-axis. + * WSMOUSECFG_X_INV, WSMOUSECFG_Y_INV: + * Map an absolute coordinate C to (INV - C), negate relative coordinates. + * WSMOUSECFG_DX_MAX, WSMOUSECFG_DY_MAX: + * Ignore deltas that are greater than these limits (for touchpads in + * WSMOUSE_COMPAT mode only). + */ +#define wsmousecfg_group(group) \ + WSMOUSECFG_##group##_MAX, \ + WSMOUSECFG_##group##_ADV = (WSMOUSECFG_##group##_MAX | 0xff) + +enum wsmousecfg { + WSMOUSECFG_DX_SCALE, + WSMOUSECFG_DY_SCALE, + WSMOUSECFG_PRESSURE_LO, + WSMOUSECFG_PRESSURE_HI, + WSMOUSECFG_TRKMAXDIST, + WSMOUSECFG_SWAPXY, + WSMOUSECFG_X_INV, + WSMOUSECFG_Y_INV, + WSMOUSECFG_DX_MAX, + WSMOUSECFG_DY_MAX, + + wsmousecfg_group(FLTR), +}; +#undef wsmousecfg_group + +struct wsmouse_param { + enum wsmousecfg key; + int value; +}; + +struct wsmouse_parameters { + struct wsmouse_param *params; + u_int nparams; +}; + +#define WSMOUSEIO_GETPARAMS _IOW('W', 39, struct wsmouse_parameters) +#define WSMOUSEIO_SETPARAMS _IOW('W', 40, struct wsmouse_parameters) + +/* * Display ioctls (64 - 95) */ diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c index c2839bad194..0bf9f6e4dec 100644 --- a/sys/dev/wscons/wsmouse.c +++ b/sys/dev/wscons/wsmouse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmouse.c,v 1.34 2016/08/18 21:12:35 bru Exp $ */ +/* $OpenBSD: wsmouse.c,v 1.35 2016/10/23 22:59:19 bru Exp $ */ /* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */ /* @@ -173,6 +173,31 @@ struct wssrcops wsmouse_srcops = { }; #endif +static const size_t cfg_fltr[] = { + [WSMOUSECFG_DX_SCALE & 0xff] = + offsetof(struct wsmouseinput, fltr.h.scale), + [WSMOUSECFG_DY_SCALE & 0xff] = + offsetof(struct wsmouseinput, fltr.v.scale), + [WSMOUSECFG_PRESSURE_LO & 0xff] = + offsetof(struct wsmouseinput, fltr.pressure_lo), + [WSMOUSECFG_PRESSURE_HI & 0xff] = + offsetof(struct wsmouseinput, fltr.pressure_hi), + [WSMOUSECFG_TRKMAXDIST & 0xff] = + offsetof(struct wsmouseinput, fltr.tracking_maxdist), + [WSMOUSECFG_SWAPXY & 0xff] = + offsetof(struct wsmouseinput, fltr.swapxy), + [WSMOUSECFG_X_INV & 0xff] = + offsetof(struct wsmouseinput, fltr.h.inv), + [WSMOUSECFG_Y_INV & 0xff] = + offsetof(struct wsmouseinput, fltr.v.inv), + [WSMOUSECFG_DX_MAX & 0xff] = + offsetof(struct wsmouseinput, fltr.h.dmax), + [WSMOUSECFG_DY_MAX & 0xff] = + offsetof(struct wsmouseinput, fltr.v.dmax), + + [WSMOUSECFG_FLTR_MAX & 0xff] = 0 +}; + /* * Print function (for parent devices). */ @@ -433,6 +458,41 @@ wsmousedoioctl(struct device *dv, u_long cmd, caddr_t data, int flag, } int +wsmouse_param_ioctl(struct wsmouse_softc *sc, + u_long cmd, struct wsmouse_param *params, u_int nparams) +{ + struct wsmouse_param *buf; + int error, s, size; + + if (params == NULL || nparams > WSMOUSECFG_SIZE) + return (EINVAL); + + size = nparams * sizeof(struct wsmouse_param); + buf = malloc(size, M_DEVBUF, M_WAITOK); + if (buf == NULL) + return (ENOMEM); + + if ((error = copyin(params, buf, size))) { + free(buf, M_DEVBUF, size); + return (error); + } + + s = spltty(); + if (cmd == WSMOUSEIO_SETPARAMS) { + if (wsmouse_set_params((struct device *) sc, buf, nparams)) + error = EINVAL; + } else { + if (wsmouse_get_params((struct device *) sc, buf, nparams)) + error = EINVAL; + else + error = copyout(buf, params, size); + } + splx(s); + free(buf, M_DEVBUF, size); + return (error); +} + +int wsmouse_do_ioctl(struct wsmouse_softc *sc, u_long cmd, caddr_t data, int flag, struct proc *p) { @@ -477,6 +537,11 @@ wsmouse_do_ioctl(struct wsmouse_softc *sc, u_long cmd, caddr_t data, int flag, if (*(int *)data != sc->sc_base.me_evp->io->ps_pgid) return (EPERM); return (0); + case WSMOUSEIO_GETPARAMS: + case WSMOUSEIO_SETPARAMS: + return (wsmouse_param_ioctl(sc, cmd, + ((struct wsmouse_parameters *) data)->params, + ((struct wsmouse_parameters *) data)->nparams)); } /* @@ -759,10 +824,10 @@ wsmouse_touch_update(struct wsmouseinput *input) motion->x_delta = motion->y_delta = 0; if ((touch->sync & SYNC_PRESSURE) && touch->min_pressure) { - if (touch->pressure >= input->params.pressure_hi) - touch->min_pressure = input->params.pressure_lo; - else if (touch->pressure < input->params.pressure_lo) - touch->min_pressure = input->params.pressure_hi; + if (touch->pressure >= input->fltr.pressure_hi) + touch->min_pressure = input->fltr.pressure_lo; + else if (touch->pressure < input->fltr.pressure_lo) + touch->min_pressure = input->fltr.pressure_hi; } } @@ -914,23 +979,21 @@ void wsmouse_motion_sync(struct wsmouseinput *input, struct evq_access *evq) { struct motion_state *motion = &input->motion; - struct wsmouseparams *params = &input->params; - struct axis_filter *fltr; + struct axis_filter *h = &input->fltr.h; + struct axis_filter *v = &input->fltr.v; int x, y, dx, dy; if (motion->sync & SYNC_DELTAS) { - dx = params->x_inv ? -motion->dx : motion->dx; - dy = params->y_inv ? -motion->dy : motion->dy; - if (input->flags & SCALE_DELTAS) { - fltr = &input->fltr.h; - dx = scale(dx, fltr->scale, &fltr->rmdr); - fltr = &input->fltr.v; - dy = scale(dy, fltr->scale, &fltr->rmdr); - } + dx = h->inv ? -motion->dx : motion->dx; + dy = v->inv ? -motion->dy : motion->dy; + if (h->scale) + dx = scale(dx, h->scale, &h->rmdr); + if (v->scale) + dy = scale(dy, v->scale, &v->rmdr); if (dx) - wsmouse_evq_put(evq, DELTA_X_EV(input->flags), dx); + wsmouse_evq_put(evq, DELTA_X_EV(input), dx); if (dy) - wsmouse_evq_put(evq, DELTA_Y_EV(input->flags), dy); + wsmouse_evq_put(evq, DELTA_Y_EV(input), dy); if (motion->dz) wsmouse_evq_put(evq, DELTA_Z_EV, motion->dz); if (motion->dw) @@ -938,14 +1001,12 @@ wsmouse_motion_sync(struct wsmouseinput *input, struct evq_access *evq) } if (motion->sync & SYNC_POSITION) { if (motion->sync & SYNC_X) { - x = (params->x_inv - ? params->x_inv - motion->x : motion->x); - wsmouse_evq_put(evq, ABS_X_EV(input->flags), x); + x = (h->inv ? h->inv - motion->x : motion->x); + wsmouse_evq_put(evq, ABS_X_EV(input), x); } if (motion->sync & SYNC_Y) { - y = (params->y_inv - ? params->y_inv - motion->y : motion->y); - wsmouse_evq_put(evq, ABS_Y_EV(input->flags), y); + y = (v->inv ? v->inv - motion->y : motion->y); + wsmouse_evq_put(evq, ABS_Y_EV(input), y); } if (motion->x_delta == 0 && motion->y_delta == 0 && (input->flags & TPAD_NATIVE_MODE)) @@ -975,7 +1036,8 @@ void wsmouse_compat_convert(struct device *sc, struct evq_access *evq) { struct wsmouseinput *input = &((struct wsmouse_softc *) sc)->input; - struct wsmouseparams *params = &input->params; + struct axis_filter *h = &input->fltr.h; + struct axis_filter *v = &input->fltr.v; int dx, dy, dz, dw; dx = (input->motion.sync & SYNC_X) ? input->motion.x_delta : 0; @@ -983,11 +1045,9 @@ wsmouse_compat_convert(struct device *sc, struct evq_access *evq) dz = (input->motion.sync & SYNC_DELTAS) ? input->motion.dz : 0; dw = (input->motion.sync & SYNC_DELTAS) ? input->motion.dw : 0; - if ((params->dx_max && abs(dx) > params->dx_max) - || (params->dy_max && abs(dy) > params->dy_max)) { - + if ((h->dmax && (abs(dx) > h->dmax)) + || (v->dmax && (abs(dy) > v->dmax))) dx = dy = 0; - } wsmouse_motion(sc, dx, dy, dz, dw); @@ -1212,7 +1272,7 @@ wsmouse_mtframe(struct device *sc, struct mtpoint *pt, int size) r2c = p; c2r = p + m; - maxdist = input->params.tracking_maxdist; + maxdist = input->fltr.tracking_maxdist; maxdist = (maxdist ? maxdist * maxdist : INT_MAX); for (i = 0, p = mt->matrix; i < m; i++, p += n) if ((j = r2c[i]) >= 0) { @@ -1295,61 +1355,103 @@ wsmouse_mt_init(struct device *sc, int num_slots, int tracking) return (-1); } -void -wsmouse_init_scaling(struct wsmouseinput *input) +int +wsmouse_validate_keys(const struct wsmouse_param *params, u_int nparams) { - struct wsmouseparams *params = &input->params; - int m, n; - - if (params->dx_mul || params->dx_div - || params->dy_mul || params->dy_div) { - /* Scale factors have a [*.12] fixed point format. */ - m = (params->dx_mul ? abs(params->dx_mul) : 1); - n = (params->dx_div ? abs(params->dx_div) : 1); - input->fltr.h.scale = (m << 12) / n; - input->fltr.h.rmdr = 0; - m = (params->dy_mul ? abs(params->dy_mul) : 1); - n = (params->dy_div ? abs(params->dy_div): 1); - input->fltr.v.scale = (m << 12) / n; - input->fltr.v.rmdr = 0; - input->flags |= SCALE_DELTAS; - } else { - input->flags &= ~SCALE_DELTAS; + int i, k; + + if (params == NULL || nparams > WSMOUSECFG_SIZE) + return (-1); + for (i = 0; i < nparams; i++) { + k = params[i].key; + if (!IS_WSMOUSECFG_KEY(k)) { + printf("wsmouse parameter: invalid key %d\n", k); + return (-1); + } } + return (0); } -void -wsmouse_set_param(struct device *sc, size_t param, int value) +int +wsmouse_get_params(struct device *sc, + struct wsmouse_param *params, u_int nparams) { struct wsmouseinput *input = &((struct wsmouse_softc *) sc)->input; - struct wsmouseparams *params = &input->params; - int *p; + int i, key, delegate = 0; + void *p; - if (param > WSMPARAM_LASTFIELD) { - printf("wsmouse_set_param: invalid parameter type\n"); - return; + if (wsmouse_validate_keys(params, nparams)) + return (-1); + + for (i = 0; i < nparams; i++) { + key = params[i].key; + if (WSMOUSECFG_MATCH(key, FLTR)) { + p = input; + p += cfg_fltr[key & 0xff]; + if (p != input) + params[i].value = *((int *) p); + else + printf("wsmouse_get_params: " + "ignoring key %d\n", key); + } else { + delegate = 1; + } } + if (delegate) + return (-1); /* not yet */ - p = (int *) (((void *) params) + param); - *p = value; + return (0); +} - if (IS_WSMFLTR_PARAM(param)) { - wsmouse_init_scaling(input); - } else if (param == WSMPARAM_SWAPXY) { - if (value) - input->flags |= SWAPXY; - else - input->flags &= ~SWAPXY; - } else if (param == WSMPARAM_PRESSURE_LO) { - params->pressure_hi = - imax(params->pressure_lo, params->pressure_hi); - input->touch.min_pressure = params->pressure_hi; - } else if (param == WSMPARAM_PRESSURE_HI - && params->pressure_lo == 0) { - params->pressure_lo = params->pressure_hi; - input->touch.min_pressure = params->pressure_hi; +int +wsmouse_set_params(struct device *sc, + const struct wsmouse_param *params, u_int nparams) +{ + struct wsmouseinput *input = + &((struct wsmouse_softc *) sc)->input; + int i, key, val, delegate = 0; + void *p; + + if (wsmouse_validate_keys(params, nparams)) + return (-1); + + for (i = 0; i < nparams; i++) { + key = params[i].key; + if (!(WSMOUSECFG_MATCH(key, FLTR))) { + delegate = 1; + continue; + } + val = params[i].value; + switch (key) { + case WSMOUSECFG_PRESSURE_LO: + input->fltr.pressure_lo = val; + if (val > input->fltr.pressure_hi) + input->fltr.pressure_hi = val; + input->touch.min_pressure = + input->fltr.pressure_hi; + continue; + case WSMOUSECFG_PRESSURE_HI: + input->fltr.pressure_hi = val; + if (val < input->fltr.pressure_lo) + input->fltr.pressure_lo = val; + input->touch.min_pressure = val; + continue; + default: + p = input; + p += cfg_fltr[key & 0xff]; + if (p != input) + *((int *) p) = val; + else + printf("wsmouse_set_params: " + "ignoring key %d\n", key); + continue; + } } + if (delegate) + return (-1); /* not yet */ + + return (0); } int @@ -1379,7 +1481,7 @@ wsmouse_input_reset(struct wsmouseinput *input) 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; + input->touch.min_pressure = input->fltr.pressure_hi; if ((num_slots = input->mt.num_slots)) { slots = input->mt.slots; matrix = input->mt.matrix; diff --git a/sys/dev/wscons/wsmouseinput.h b/sys/dev/wscons/wsmouseinput.h index 50a12fe05fe..46c40f2ef6f 100644 --- a/sys/dev/wscons/wsmouseinput.h +++ b/sys/dev/wscons/wsmouseinput.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmouseinput.h,v 1.2 2016/08/18 21:12:35 bru Exp $ */ +/* $OpenBSD: wsmouseinput.h,v 1.3 2016/10/23 22:59:19 bru Exp $ */ /* * Copyright (c) 2015, 2016 Ulf Brosziewski @@ -96,9 +96,13 @@ struct mt_state { struct axis_filter { - /* scale factor in [*.12] fixed-point format */ + /* A scale factor in [*.12] fixed-point format */ int scale; int rmdr; + /* Invert coordinates. */ + int inv; + /* Ignore deltas that are greater than this limit. */ + int dmax; }; struct wsmouseinput { @@ -109,10 +113,14 @@ struct wsmouseinput { struct touch_state touch; struct mt_state mt; - struct wsmouseparams params; - struct { + struct { /* Parameters and state of various input filters. */ struct axis_filter h; struct axis_filter v; + + int swapxy; + int tracking_maxdist; + int pressure_lo; + int pressure_hi; } fltr; struct wseventvar **evar; @@ -120,9 +128,7 @@ struct wsmouseinput { /* wsmouseinput.flags */ #define TPAD_COMPAT_MODE (1 << 0) #define TPAD_NATIVE_MODE (1 << 1) -#define SCALE_DELTAS (1 << 2) -#define MT_TRACKING (1 << 3) -#define SWAPXY (1 << 4) +#define MT_TRACKING (1 << 2) #define RESYNC (1 << 16) struct evq_access { @@ -148,13 +154,13 @@ void wsmouse_input_cleanup(struct wsmouseinput *); for ((i) = ffs(v) - 1; (i) != -1; (i) = ffs((v) & (~1 << (i))) - 1) -#define DELTA_X_EV(flags) (((flags) & SWAPXY) ? \ +#define DELTA_X_EV(input) ((input)->fltr.swapxy ? \ WSCONS_EVENT_MOUSE_DELTA_Y : WSCONS_EVENT_MOUSE_DELTA_X) -#define DELTA_Y_EV(flags) (((flags) & SWAPXY) ? \ +#define DELTA_Y_EV(input) ((input)->fltr.swapxy ? \ WSCONS_EVENT_MOUSE_DELTA_X : WSCONS_EVENT_MOUSE_DELTA_Y) -#define ABS_X_EV(flags) (((flags) & SWAPXY) ? \ +#define ABS_X_EV(input) ((input)->fltr.swapxy ? \ WSCONS_EVENT_MOUSE_ABSOLUTE_Y : WSCONS_EVENT_MOUSE_ABSOLUTE_X) -#define ABS_Y_EV(flags) (((flags) & SWAPXY) ? \ +#define ABS_Y_EV(input) ((input)->fltr.swapxy ? \ WSCONS_EVENT_MOUSE_ABSOLUTE_X : WSCONS_EVENT_MOUSE_ABSOLUTE_Y) #define DELTA_Z_EV WSCONS_EVENT_MOUSE_DELTA_Z #define DELTA_W_EV WSCONS_EVENT_MOUSE_DELTA_W @@ -167,4 +173,15 @@ void wsmouse_input_cleanup(struct wsmouseinput *); /* buffer size for wsmouse_matching */ #define MATRIX_SIZE(slots) (((slots) + 7) * (slots) * sizeof(int)) + +#define WSMOUSECFG_MATCH(key, group) \ + ((key) < WSMOUSECFG_##group##_MAX && \ + (key) >= (WSMOUSECFG_##group##_MAX & ~0xff)) + +#define IS_WSMOUSECFG_KEY(key) \ + WSMOUSECFG_MATCH((key), FLTR) + +#define WSMOUSECFG_SIZE \ + (WSMOUSECFG_FLTR_MAX & 0xff) + #endif /* _WSMOUSEINPUT_H_ */ diff --git a/sys/dev/wscons/wsmousevar.h b/sys/dev/wscons/wsmousevar.h index 8db1efd9891..1cc60ba0908 100644 --- a/sys/dev/wscons/wsmousevar.h +++ b/sys/dev/wscons/wsmousevar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmousevar.h,v 1.11 2016/06/06 22:32:47 bru Exp $ */ +/* $OpenBSD: wsmousevar.h,v 1.12 2016/10/23 22:59:19 bru Exp $ */ /* $NetBSD: wsmousevar.h,v 1.4 2000/01/08 02:57:24 takemura Exp $ */ /* @@ -114,7 +114,6 @@ int wsmousedevprint(void *, const char *); struct device; -struct mtpoint; /* * Type codes for wsmouse_set. REL_X/Y, MT_REL_X/Y, and TOUCH_WIDTH @@ -140,8 +139,12 @@ enum wsmouseval { #define WSMOUSE_IS_MT_CODE(code) \ ((code) >= WSMOUSE_MT_REL_X && (code) <= WSMOUSE_MT_PRESSURE) - - +struct mtpoint { + int x; + int y; + int pressure; + int slot; /* An output field, set by wsmouse_mtframe. */ +}; /* Report button state. */ void wsmouse_buttons(struct device *, u_int); @@ -175,56 +178,12 @@ void wsmouse_input_sync(struct device *); /* Initialize MT structures (num_slots, tracking). */ int wsmouse_mt_init(struct device *, int, int); -/* Set a filter/transformation value (param type, value). */ -void wsmouse_set_param(struct device *, size_t, int); +#define WSMOUSE_MT_SLOTS_MAX 10 +#define WSMOUSE_MT_INIT_TRACKING 1 /* Switch between compatibility mode and native mode. */ int wsmouse_set_mode(struct device *, int); - -struct mtpoint { - int x; - int y; - int pressure; - int slot; /* An output field, set by wsmouse_mtframe. */ -}; - - -struct wsmouseparams { - int x_inv; - int y_inv; - - int dx_mul; /* delta scaling */ - int dx_div; - int dy_mul; - int dy_div; - - int swapxy; - - int pressure_lo; - int pressure_hi; - - int dx_max; /* (compat mode) */ - int dy_max; - - int tracking_maxdist; -}; - -#define WSMPARAM_X_INV offsetof(struct wsmouseparams, x_inv) -#define WSMPARAM_Y_INV offsetof(struct wsmouseparams, y_inv) -#define WSMPARAM_DX_MUL offsetof(struct wsmouseparams, dx_mul) -#define WSMPARAM_DX_DIV offsetof(struct wsmouseparams, dx_div) -#define WSMPARAM_DY_MUL offsetof(struct wsmouseparams, dy_mul) -#define WSMPARAM_DY_DIV offsetof(struct wsmouseparams, dy_div) -#define WSMPARAM_SWAPXY offsetof(struct wsmouseparams, swapxy) -#define WSMPARAM_PRESSURE_LO offsetof(struct wsmouseparams, pressure_lo) -#define WSMPARAM_PRESSURE_HI offsetof(struct wsmouseparams, pressure_hi) -#define WSMPARAM_DX_MAX offsetof(struct wsmouseparams, dx_max) -#define WSMPARAM_DY_MAX offsetof(struct wsmouseparams, dy_max) - -#define WSMPARAM_LASTFIELD WSMPARAM_DY_MAX - -#define IS_WSMFLTR_PARAM(param) \ - ((param) >= WSMPARAM_DX_MUL && (param) <= WSMPARAM_DY_DIV) - -#define WSMOUSE_MT_SLOTS_MAX 10 +/* Read/Set parameter values. */ +int wsmouse_get_params(struct device *, struct wsmouse_param *, u_int); +int wsmouse_set_params(struct device *, const struct wsmouse_param *, u_int); |