> Date: Fri, 31 Aug 2018 16:44:57 -0500
> From: joshua stein <[email protected]>
>
> If there is an i2c HID device that has a Digitizers/Touchscreen
> collection and an X report, attach ims to it. hidms already has
> support for touchscreens.
>
> This may help if you have a newer laptop with a touchscreen.
>
> Also limit the logical min/max finding in hidms to the first
> non-zero result. The HID descriptor for these touchscreens have
> lots of complicated reports which may produce false positives.
Not sure if that is indeed the right approach, but we can always fix
it in a better way later.
ok kettenis@
> Index: sys/dev/i2c/ims.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/i2c/ims.c,v
> retrieving revision 1.1
> diff -u -p -u -p -r1.1 ims.c
> --- sys/dev/i2c/ims.c 12 Jan 2016 01:11:15 -0000 1.1
> +++ sys/dev/i2c/ims.c 31 Aug 2018 21:42:30 -0000
> @@ -85,6 +85,12 @@ ims_match(struct device *parent, void *m
> HID_USAGE2(HUP_DIGITIZERS, HUD_PEN)))
> return (IMATCH_IFACECLASS);
>
> + if (hid_is_collection(desc, size, iha->reportid,
> + HID_USAGE2(HUP_DIGITIZERS, HUD_TOUCHSCREEN)) &&
> + hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
> + iha->reportid, hid_input, NULL, NULL))
> + return (IMATCH_IFACECLASS);
> +
> return (IMATCH_NONE);
> }
>
> Index: sys/dev/hid/hidms.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/hid/hidms.c,v
> retrieving revision 1.3
> diff -u -p -u -p -r1.3 hidms.c
> --- sys/dev/hid/hidms.c 22 May 2016 22:06:11 -0000 1.3
> +++ sys/dev/hid/hidms.c 31 Aug 2018 21:42:30 -0000
> @@ -241,13 +241,15 @@ hidms_setup(struct device *self, struct
> h.usage, h.logical_minimum, h.logical_maximum));
> switch (HID_GET_USAGE(h.usage)) {
> case HUG_X:
> - if (ms->sc_flags & HIDMS_ABSX) {
> + if (ms->sc_flags & HIDMS_ABSX &&
> + !ms->sc_tsscale.minx && !ms->sc_tsscale.maxy) {
> ms->sc_tsscale.minx = h.logical_minimum;
> ms->sc_tsscale.maxx = h.logical_maximum;
> }
> break;
> case HUG_Y:
> - if (ms->sc_flags & HIDMS_ABSY) {
> + if (ms->sc_flags & HIDMS_ABSY &&
> + !ms->sc_tsscale.miny && !ms->sc_tsscale.maxy) {
> ms->sc_tsscale.miny = h.logical_minimum;
> ms->sc_tsscale.maxy = h.logical_maximum;
> }
>
>