These diffs adapt the drivers that attach to wsmouse to its new interface.
Most changes are fairly trivial and replace wsmouse_input calls with the
WSMOUSE_INPUT/WSMOUSE_TOUCH macros. However, some cases may need a second
thought. hidms, for example, now permits, at least in principle, to mix
relative and absolute coordinates, which looks somewhat strange. Do
scenarios exist where this makes sense?

I believe it doesn't make sense to stick to the Synaptics "W mode"
encoding in the wsmouse infrastructure any longer. Among the devices that
provide touch data it is an exception and not the common case. Please
note that the last argument of WSMOUSE_TOUCH is always the plain contact
count, not the W value as produced by Synaptics touchpads.

Drivers can pass 0 as contact count if it is redundant (wsmouse_touch
adapts the value to the pressure state). Width values must be reported
via wsmouse_set.

I haven't tried to introduce MT functions into drivers that I couldn't test,
up to now the elantech-v4 handler in pms is the only one that uses them. As
pointed out in the previous message, a call to wsmouse_mt_init is necessary
when the device is enabled.  Moreover, the ioctl function passes the mode
setting back to wsmouse via wsmouse_set_mode; the packet handler has no
branches for native mode and compat mode, the modes are handled by
wsmouse_input_sync. For the same reason there is no need to track
coordinates and check for deltas here, wsmouse does this anyway (with more
hardware information it could do more, like controlling and switching the
modes without that callback, and handling the other ioctl calls; the code
that is repeated over and over again in the wsmouse-dependent drivers could
be removed).


Index: arch/i386/isa/lms.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/isa/lms.c,v
retrieving revision 1.20
diff -u -p -r1.20 lms.c
--- arch/i386/isa/lms.c 10 Apr 2007 22:37:17 -0000      1.20
+++ arch/i386/isa/lms.c 12 Mar 2016 20:42:46 -0000
@@ -235,8 +235,7 @@ lmsintr(void *arg)
        sc->oldbuttons = buttons;

        if (dx || dy || changed)
-               wsmouse_input(sc->sc_wsmousedev,
-                             buttons, dx, dy, 0, 0, WSMOUSE_INPUT_DELTA);
+               WSMOUSE_INPUT(sc->sc_wsmousedev, buttons, dx, dy, 0, 0);

        return -1;
 }
Index: arch/i386/isa/mms.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/isa/mms.c,v
retrieving revision 1.19
diff -u -p -r1.19 mms.c
--- arch/i386/isa/mms.c 10 Apr 2007 22:37:17 -0000      1.19
+++ arch/i386/isa/mms.c 12 Mar 2016 20:42:46 -0000
@@ -229,8 +229,7 @@ mmsintr(void *arg)
        changed = status & 0x38;

        if (dx || dy || changed)
-               wsmouse_input(sc->sc_wsmousedev,
-                             buttons, dx, dy, 0, 0, WSMOUSE_INPUT_DELTA);
+               WSMOUSE_INPUT(sc->sc_wsmousedev, buttons, dx, dy, 0, 0);

        return -1;
 }
Index: arch/luna88k/dev/lunaws.c
===================================================================
RCS file: /cvs/src/sys/arch/luna88k/dev/lunaws.c,v
retrieving revision 1.11
diff -u -p -r1.11 lunaws.c
--- arch/luna88k/dev/lunaws.c   7 Jun 2014 11:55:35 -0000       1.11
+++ arch/luna88k/dev/lunaws.c   12 Mar 2016 20:42:46 -0000
@@ -260,9 +260,8 @@ wsintr(int chan)
                        else if (sc->sc_msreport == 2) {
                                sc->dy = (signed char)code;
                                if (sc->sc_wsmousedev != NULL)
-                                       wsmouse_input(sc->sc_wsmousedev,
-                                           sc->buttons, sc->dx, sc->dy, 0, 0,
-                                           WSMOUSE_INPUT_DELTA);
+                                       WSMOUSE_INPUT(sc->sc_wsmousedev,
+                                           sc->buttons, sc->dx, sc->dy, 0, 0);
                                sc->sc_msreport = 0;
                        }
 #else
Index: arch/sgi/hpc/z8530ms.c
===================================================================
RCS file: /cvs/src/sys/arch/sgi/hpc/z8530ms.c,v
retrieving revision 1.1
diff -u -p -r1.1 z8530ms.c
--- arch/sgi/hpc/z8530ms.c      17 Apr 2012 22:06:33 -0000      1.1
+++ arch/sgi/hpc/z8530ms.c      12 Mar 2016 20:42:47 -0000
@@ -296,7 +296,7 @@ zsms_wsmouse_input(struct zsms_softc *sc
        x = (int)sc->packet[ZSMS_PACKET_X1] + (int)sc->packet[ZSMS_PACKET_X2];
        y = (int)sc->packet[ZSMS_PACKET_Y1] + (int)sc->packet[ZSMS_PACKET_Y2];

-       wsmouse_input(sc->wsmousedev, btns, x, y, 0, 0, WSMOUSE_INPUT_DELTA);
+       WSMOUSE_INPUT(sc->sc_wsmousedev, btns, x, y, 0, 0);
 }

 int
Index: arch/zaurus/dev/zts.c
===================================================================
RCS file: /cvs/src/sys/arch/zaurus/dev/zts.c,v
retrieving revision 1.16
diff -u -p -r1.16 zts.c
--- arch/zaurus/dev/zts.c       29 Mar 2014 18:09:30 -0000      1.16
+++ arch/zaurus/dev/zts.c       12 Mar 2016 20:42:47 -0000
@@ -544,10 +544,9 @@ zts_irq(void *v)
                DPRINTF(("%s: tp.z = %d, tp.x = %d, tp.y = %d\n",
                    sc->sc_dev.dv_xname, tp.z, tp.x, tp.y));

-               wsmouse_input(sc->sc_wsmousedev, down, tp.x, tp.y,
-                   0 /* z */, 0 /* w */,
-                   WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
-                   WSMOUSE_INPUT_ABSOLUTE_Z);
+               wsmouse_buttons(sc->sc_wsmousedev, down);
+               wsmouse_position(sc->sc_wsmousedev, tp.x, tp.y);
+               wsmouse_input_sync(sc->sc_wsmousedev);
                sc->sc_buttons = down;
                sc->sc_oldx = tp.x;
                sc->sc_oldy = tp.y;
Index: dev/adb/ams.c
===================================================================
RCS file: /cvs/src/sys/dev/adb/ams.c,v
retrieving revision 1.6
diff -u -p -r1.6 ams.c
--- dev/adb/ams.c       15 Jun 2011 21:32:05 -0000      1.6
+++ dev/adb/ams.c       12 Mar 2016 20:42:47 -0000
@@ -501,8 +501,7 @@ ms_processevent(adb_event_t *event, stru
            ((event->bytes[0] & 0x40) ? 64 : 0);

        if (sc->sc_wsmousedev)
-               wsmouse_input(sc->sc_wsmousedev, buttons, dx, -dy, 0, 0,
-                   WSMOUSE_INPUT_DELTA);
+               WSMOUSE_INPUT(sc->sc_wsmousedev, buttons, dx, -dy, 0, 0);
 }

 int
Index: dev/hid/hidms.c
===================================================================
RCS file: /cvs/src/sys/dev/hid/hidms.c,v
retrieving revision 1.2
diff -u -p -r1.2 hidms.c
--- dev/hid/hidms.c     10 Feb 2016 05:49:50 -0000      1.2
+++ dev/hid/hidms.c     12 Mar 2016 20:42:47 -0000
@@ -331,7 +331,6 @@ hidms_input(struct hidms *ms, uint8_t *d
 {
        int dx, dy, dz, dw;
        u_int32_t buttons = 0;
-       int flags;
        int i, s;

        DPRINTFN(5,("hidms_input: len=%d\n", len));
@@ -358,12 +357,6 @@ hidms_input(struct hidms *ms, uint8_t *d
                        return;
        }

-       flags = WSMOUSE_INPUT_DELTA;
-       if (ms->sc_flags & HIDMS_ABSX)
-               flags |= WSMOUSE_INPUT_ABSOLUTE_X;
-       if (ms->sc_flags & HIDMS_ABSY)
-               flags |= WSMOUSE_INPUT_ABSOLUTE_Y;
-
        dx =  hid_get_data(data, len, &ms->sc_loc_x);
        dy = -hid_get_data(data, len, &ms->sc_loc_y);
        dz =  hid_get_data(data, len, &ms->sc_loc_z);
@@ -403,8 +396,18 @@ hidms_input(struct hidms *ms, uint8_t *d
                ms->sc_buttons = buttons;
                if (ms->sc_wsmousedev != NULL) {
                        s = spltty();
-                       wsmouse_input(ms->sc_wsmousedev, buttons,
-                           dx, dy, dz, dw, flags);
+                       if (ms->sc_flags & HIDMS_ABSX) {
+                               wsmouse_set(ms->sc_wsmousedev,
+                                   WSMOUSE_ABS_X, dx, 0);
+                               dx = 0;
+                       }
+                       if (ms->sc_flags & HIDMS_ABSY) {
+                               wsmouse_set(ms->sc_wsmousedev,
+                                   WSMOUSE_ABS_Y, dy, 0);
+                               dy = 0;
+                       }
+                       WSMOUSE_INPUT(ms->sc_wsmousedev,
+                           buttons, dx, dy, dz, dw);
                        splx(s);
                }
        }
Index: dev/hid/hidmt.c
===================================================================
RCS file: /cvs/src/sys/dev/hid/hidmt.c,v
retrieving revision 1.1
diff -u -p -r1.1 hidmt.c
--- dev/hid/hidmt.c     20 Jan 2016 01:26:00 -0000      1.1
+++ dev/hid/hidmt.c     12 Mar 2016 20:42:47 -0000
@@ -329,20 +329,15 @@ hidmt_input(struct hidmt *mt, uint8_t *d
                                        width = 50;
                        }

-                       wsmouse_input(mt->sc_wsmousedev, mt->sc_button,
+                       WSMOUSE_TOUCH(mt->sc_wsmousedev, mt->sc_button,
                            (mt->last_x = mt->sc_contacts[i].x),
                            (mt->last_y = mt->sc_contacts[i].y),
-                           width, tips,
-                           WSMOUSE_INPUT_ABSOLUTE_X |
-                           WSMOUSE_INPUT_ABSOLUTE_Y |
-                           WSMOUSE_INPUT_ABSOLUTE_Z |
-                           WSMOUSE_INPUT_ABSOLUTE_W);
+                           width, tips);
                } else {
-                       wsmouse_input(mt->sc_wsmousedev, mt->sc_button,
+                       WSMOUSE_INPUT(mt->sc_wsmousedev, mt->sc_button,
                            (mt->last_x - mt->sc_contacts[i].x),
                            (mt->last_y - mt->sc_contacts[i].y),
-                           0, 0,
-                           WSMOUSE_INPUT_DELTA);
+                           0, 0);
                        mt->last_x = mt->sc_contacts[i].x;
                        mt->last_y = mt->sc_contacts[i].y;
                }
Index: dev/hil/hilms.c
===================================================================
RCS file: /cvs/src/sys/dev/hil/hilms.c,v
retrieving revision 1.5
diff -u -p -r1.5 hilms.c
--- dev/hil/hilms.c     10 Apr 2007 22:37:17 -0000      1.5
+++ dev/hil/hilms.c     12 Mar 2016 20:42:47 -0000
@@ -219,7 +219,7 @@ void
 hilms_callback(struct hildev_softc *dev, u_int buflen, u_int8_t *buf)
 {
        struct hilms_softc *sc = (struct hilms_softc *)dev;
-       int type, flags;
+       int type;
        int dx, dy, dz, button;
 #ifdef DIAGNOSTIC
        int minlen;
@@ -256,9 +256,6 @@ hilms_callback(struct hildev_softc *dev,
         */

        if (type & HIL_MOUSEMOTION) {
-               flags = sc->sc_features & HIL_ABSOLUTE ?
-                   WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
-                   WSMOUSE_INPUT_ABSOLUTE_Z : WSMOUSE_INPUT_DELTA;
                if (sc->sc_features & HIL_16_BITS) {
                        dx = *buf++;
                        dx |= (*buf++) << 8;
@@ -303,7 +300,7 @@ hilms_callback(struct hildev_softc *dev,
                    sc->sc_buttons == 0)
                        dy = -dy;
        } else
-               dx = dy = dz = flags = 0;
+               dx = dy = dz = 0;

        if (type & HIL_MOUSEBUTTON) {
                button = *buf;
@@ -332,7 +329,12 @@ hilms_callback(struct hildev_softc *dev,
                /* buf++; */
        }
        
-       if (sc->sc_wsmousedev != NULL)
-               wsmouse_input(sc->sc_wsmousedev,
-                   sc->sc_buttonstate, dx, dy, dz, 0, flags);
+       if (sc->sc_wsmousedev != NULL) {
+               if (sc->sc_features & HIL_ABSOLUTE))
+                       WSMOUSE_TOUCH(sc->sc_wsmousedev,
+                           sc->sc_buttonstate, dx, dy, dz, 0);
+               else
+                       WSMOUSE_INPUT(sc->sc_wsmousedev,
+                           sc->sc_buttonstate, dx, dy, dz, 0);
+       }
 }
Index: dev/pckbc/pms.c
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.68
diff -u -p -r1.68 pms.c
--- dev/pckbc/pms.c     27 Feb 2016 22:01:58 -0000      1.68
+++ dev/pckbc/pms.c     12 Mar 2016 20:42:48 -0000
@@ -143,17 +143,8 @@ struct elantech_softc {

        int min_x, min_y;
        int max_x, max_y;
-       struct {
-               unsigned int x;
-               unsigned int y;
-               unsigned int z;
-       } mt[ELANTECH_MAX_FINGERS];
-       int mt_slots;
-       int mt_count;
-       int mt_filter;
-       int mt_lastid;
-       int mt_lastcount;
-       int mt_buttons;
+
+       u_int mt_slots;

        int width;

@@ -641,8 +632,7 @@ pms_proc_mouse(struct pms_softc *sc)
        else
                dz = 0;

-       wsmouse_input(sc->sc_wsmousedev,
-           buttons, dx, dy, dz, 0, WSMOUSE_INPUT_DELTA);
+       WSMOUSE_INPUT(sc->sc_wsmousedev, buttons, dx, dy, dz, 0);
 }

 int
@@ -997,8 +987,7 @@ synaptics_sec_proc(struct pms_softc *sc)
        dy = (sc->packet[1] & PMS_PS2_YNEG) ?
            (int)sc->packet[5] - 256 : sc->packet[5];

-       wsmouse_input(sc->sc_sec_wsmousedev,
-           buttons, dx, dy, 0, 0, WSMOUSE_INPUT_DELTA);
+       WSMOUSE_INPUT(sc->sc_sec_wsmousedev, buttons, dx, dy, 0, 0);
 }

 int
@@ -1162,7 +1151,7 @@ pms_proc_synaptics(struct pms_softc *sc)
 {
        struct synaptics_softc *syn = sc->synaptics;
        u_int buttons;
-       int x, y, z, w, dx, dy;
+       int x, y, z, w, dx, dy, width;

        w = ((sc->packet[0] & 0x30) >> 2) | ((sc->packet[0] & 0x04) >> 1) |
            ((sc->packet[3] & 0x04) >> 2);
@@ -1230,8 +1219,9 @@ pms_proc_synaptics(struct pms_softc *sc)
                            (sc->packet[5] & 0x01) ? WSMOUSE_BUTTON(3) : 0;
                        syn->sec_buttons |=
                            (sc->packet[4] & 0x02) ? WSMOUSE_BUTTON(2) : 0;
-                       wsmouse_input(sc->sc_sec_wsmousedev,
-                           syn->sec_buttons, 0, 0, 0, 0, WSMOUSE_INPUT_DELTA);
+                       wsmouse_buttons(
+                           sc->sc_sec_wsmousedev, syn->sec_buttons);
+                       wsmouse_input_sync(sc->sc_sec_wsmousedev);
                        return;
                }

@@ -1254,9 +1244,14 @@ pms_proc_synaptics(struct pms_softc *sc)
        }

        if (syn->wsmode == WSMOUSE_NATIVE) {
-               wsmouse_input(sc->sc_wsmousedev, buttons, x, y, z, w,
-                   WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
-                   WSMOUSE_INPUT_ABSOLUTE_Z | WSMOUSE_INPUT_ABSOLUTE_W);
+               if (z) {
+                       width = imax(w, 4);
+                       w = (w < 2 ? w + 2 : 1);
+               } else {
+                       width = w = 0;
+               }
+               wsmouse_set(sc->sc_wsmousedev, WSMOUSE_TOUCH_WIDTH, width, 0);
+               WSMOUSE_TOUCH(sc->sc_wsmousedev, buttons, x, y, z, w);
        } else {
                dx = dy = 0;
                if (z > SYNAPTICS_PRESSURE) {
@@ -1266,8 +1261,7 @@ pms_proc_synaptics(struct pms_softc *sc)
                        dy /= SYNAPTICS_SCALE;
                }
                if (dx || dy || buttons != syn->old_buttons)
-                       wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, 0, 0,
-                           WSMOUSE_INPUT_DELTA);
+                       WSMOUSE_INPUT(sc->sc_wsmousedev, buttons, dx, dy, 0, 0);
                syn->old_buttons = buttons;
        }

@@ -1313,8 +1307,7 @@ alps_sec_proc(struct pms_softc *sc)
        dy = (sc->packet[pos] & PMS_PS2_YNEG) ?
            (int)sc->packet[pos + 2] - 256 : sc->packet[pos + 2];

-       wsmouse_input(sc->sc_sec_wsmousedev, alps->sec_buttons,
-           dx, dy, 0, 0, WSMOUSE_INPUT_DELTA);
+       WSMOUSE_INPUT(sc->sc_sec_wsmousedev, alps->sec_buttons, dx, dy, 0, 0);

        return (1);
 }
@@ -1514,7 +1507,7 @@ void
 pms_proc_alps(struct pms_softc *sc)
 {
        struct alps_softc *alps = sc->alps;
-       int x, y, z, w, dx, dy;
+       int x, y, z, dx, dy;
        u_int buttons, gesture;

        if ((alps->model & ALPS_DUALPOINT) && alps_sec_proc(sc))
@@ -1532,8 +1525,7 @@ pms_proc_alps(struct pms_softc *sc)
                dx = (x > ALPS_XSEC_BEZEL / 2) ? (x - ALPS_XSEC_BEZEL) : x;
                dy = (y > ALPS_YSEC_BEZEL / 2) ? (y - ALPS_YSEC_BEZEL) : y;

-               wsmouse_input(sc->sc_sec_wsmousedev, buttons, dx, dy, 0, 0,
-                   WSMOUSE_INPUT_DELTA);
+               WSMOUSE_INPUT(sc->sc_sec_wsmousedev, buttons, dx, dy, 0, 0);

                return;
        }
@@ -1552,35 +1544,21 @@ pms_proc_alps(struct pms_softc *sc)
        if (alps->wsmode == WSMOUSE_NATIVE) {
                if (alps->gesture == ALPS_TAP) {
                        /* Report a touch with the tap coordinates. */
-                       wsmouse_input(sc->sc_wsmousedev, buttons,
-                           alps->old_x, alps->old_y, ALPS_PRESSURE, 4,
-                           WSMOUSE_INPUT_ABSOLUTE_X
-                           | WSMOUSE_INPUT_ABSOLUTE_Y
-                           | WSMOUSE_INPUT_ABSOLUTE_Z
-                           | WSMOUSE_INPUT_ABSOLUTE_W);
+                       WSMOUSE_TOUCH(sc->sc_wsmousedev, buttons,
+                           alps->old_x, alps->old_y, ALPS_PRESSURE, 0);
                        if (z > 0) {
                                /*
                                 * The hardware doesn't send a null pressure
                                 * event when dragging starts.
                                 */
-                               wsmouse_input(sc->sc_wsmousedev, buttons,
-                                   alps->old_x, alps->old_y, 0, 0,
-                                   WSMOUSE_INPUT_ABSOLUTE_X
-                                   | WSMOUSE_INPUT_ABSOLUTE_Y
-                                   | WSMOUSE_INPUT_ABSOLUTE_Z
-                                   | WSMOUSE_INPUT_ABSOLUTE_W);
+                               WSMOUSE_TOUCH(sc->sc_wsmousedev, buttons,
+                                   alps->old_x, alps->old_y, 0, 0);
                        }
                }

                gesture = sc->packet[2] & 0x03;
-               if (gesture != ALPS_TAP) {
-                       w = z ? 4 : 0;
-                       wsmouse_input(sc->sc_wsmousedev, buttons, x, y, z, w,
-                           WSMOUSE_INPUT_ABSOLUTE_X
-                           | WSMOUSE_INPUT_ABSOLUTE_Y
-                           | WSMOUSE_INPUT_ABSOLUTE_Z
-                           | WSMOUSE_INPUT_ABSOLUTE_W);
-               }
+               if (gesture != ALPS_TAP)
+                       WSMOUSE_TOUCH(sc->sc_wsmousedev, buttons, x, y, z, 0);

                if (alps->gesture != ALPS_DRAG || gesture != ALPS_TAP)
                        alps->gesture = gesture;
@@ -1600,8 +1578,7 @@ pms_proc_alps(struct pms_softc *sc)
                }

                if (dx || dy || buttons != alps->old_buttons)
-                       wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, 0, 0,
-                           WSMOUSE_INPUT_DELTA);
+                       WSMOUSE_INPUT(sc->sc_wsmousedev, buttons, dx, dy, 0, 0);

                alps->old_x = x;
                alps->old_y = y;
@@ -2045,6 +2022,18 @@ err:
 }

 int
+pms_elantech_v4_configure(struct device *sc_wsmousedev,
+    struct elantech_softc *elantech)
+{
+       if (wsmouse_mt_init(sc_wsmousedev, ELANTECH_MAX_FINGERS, 0))
+               return (-1);
+
+       wsmouse_set_param(sc_wsmousedev, WSMPARAM_DX_DIV, SYNAPTICS_SCALE);
+       wsmouse_set_param(sc_wsmousedev, WSMPARAM_DY_DIV, SYNAPTICS_SCALE);
+       return (0);
+}
+
+int
 pms_enable_elantech_v4(struct pms_softc *sc)
 {
        struct elantech_softc *elantech = sc->elantech;
@@ -2068,6 +2057,15 @@ pms_enable_elantech_v4(struct pms_softc
                        goto err;
                }

+               if (pms_elantech_v4_configure(
+                   sc->sc_wsmousedev, sc->elantech)) {
+                       free(sc->elantech, M_DEVBUF, 0);
+                       sc->elantech = NULL;
+                       printf("%s: setup failed\n", DEVNAME(sc));
+                       goto err;
+               }
+               wsmouse_set_mode(sc->sc_wsmousedev, WSMOUSE_COMPAT);
+
                printf("%s: Elantech Clickpad, version %d, firmware 0x%x\n",
                    DEVNAME(sc), 4, sc->elantech->fw_version);
        } else if (elantech_set_absolute_mode_v4(sc))
@@ -2107,6 +2105,8 @@ pms_ioctl_elantech(struct pms_softc *sc,
                if (wsmode != WSMOUSE_COMPAT && wsmode != WSMOUSE_NATIVE)
                        return (EINVAL);
                elantech->wsmode = wsmode;
+               if (sc->protocol->type == PMS_ELANTECH_V4)
+                       wsmouse_set_mode(sc->sc_wsmousedev, wsmode);
                break;
        default:
                return (-1);
@@ -2352,41 +2352,29 @@ void
 pms_proc_elantech_v4(struct pms_softc *sc)
 {
        struct elantech_softc *elantech = sc->elantech;
-       int n, id, slots, weight, dx, dy;
+       struct device *sc_wsmousedev = sc->sc_wsmousedev;
+       int id, weight, n, x, y, z;
+       u_int buttons, slots;

        switch (sc->packet[3] & 0x1f) {
        case ELANTECH_V4_PKT_STATUS:
-               if (elantech->mt_slots == 0)
-                       elantech->mt_lastid = -1;
-               slots = sc->packet[1] & 0x1f;
-               if (slots == 0 && elantech->mt_lastid > -1)
-                       /* Notify that we lifted. */
-                       elantech_send_input(sc,
-                           elantech->mt[elantech->mt_lastid].x,
-                           elantech->mt[elantech->mt_lastid].y, 0, 0);
-
-               elantech->mt_filter = elantech->mt_slots = slots;
-
-               for (elantech->mt_count = 0; slots != 0; slots >>= 1)
-                       elantech->mt_count += (1 & slots);
-
+               slots = elantech->mt_slots;
+               elantech->mt_slots = sc->packet[1] & 0x1f;
+               slots &= ~elantech->mt_slots;
+               for (id = 0; slots; id++, slots >>= 1) {
+                       if (slots & 1)
+                               wsmouse_mtstate(sc_wsmousedev, id, 0, 0, 0);
+               }
                break;

        case ELANTECH_V4_PKT_HEAD:
                id = ((sc->packet[3] & 0xe0) >> 5) - 1;
                if (id > -1 && id < ELANTECH_MAX_FINGERS) {
-                       elantech->mt[id].x =
-                           ((sc->packet[1] & 0x0f) << 8) | sc->packet[2];
-                       elantech->mt[id].y =
-                           ((sc->packet[4] & 0x0f) << 8) | sc->packet[5];
-                       elantech->mt[id].z =
-                           (sc->packet[1] & 0xf0)
+                       x = ((sc->packet[1] & 0x0f) << 8) | sc->packet[2];
+                       y = ((sc->packet[4] & 0x0f) << 8) | sc->packet[5];
+                       z = (sc->packet[1] & 0xf0)
                            | ((sc->packet[4] & 0xf0) >> 4);
-
-                       if (elantech->mt_filter & (1 << id)) {
-                               elantech_send_mt_input(sc, id);
-                               elantech->mt_filter = (1 << id);
-                       }
+                       wsmouse_mtstate(sc_wsmousedev, id, x, y, z);
                }
                break;

@@ -2396,22 +2384,12 @@ pms_proc_elantech_v4(struct pms_softc *s
                        id = ((sc->packet[n] & 0xe0) >> 5) - 1;
                        if (id < 0 || id >= ELANTECH_MAX_FINGERS)
                                continue;
-                       dx = weight * (signed char)sc->packet[n + 1];
-                       dy = weight * (signed char)sc->packet[n + 2];
-                       elantech->mt[id].x += dx;
-                       elantech->mt[id].y += dy;
-                       elantech->mt[id].z = 1;
-                       if (elantech->mt_filter & (1 << id)) {
-                               if ((dx | dy)
-                                   || elantech->mt_count !=
-                                   elantech->mt_lastcount
-                                   || (sc->packet[0] & 3) !=
-                                   elantech->mt_buttons)
-                                       elantech_send_mt_input(sc, id);
-
-                               elantech->mt_filter = (dx | dy) ?
-                                   (1 << id) : elantech->mt_slots;
-                       }
+                       x = weight * (signed char)sc->packet[n + 1];
+                       y = weight * (signed char)sc->packet[n + 2];
+                       z = WSMOUSE_DEFAULT_PRESSURE;
+                       wsmouse_set(sc_wsmousedev, WSMOUSE_MT_REL_X, x, id);
+                       wsmouse_set(sc_wsmousedev, WSMOUSE_MT_REL_Y, y, id);
+                       wsmouse_set(sc_wsmousedev, WSMOUSE_MT_PRESSURE, z, id);
                }

                break;
@@ -2421,37 +2399,15 @@ pms_proc_elantech_v4(struct pms_softc *s
                    sc->packet[3] & 0x1f);
                return;
        }
-}

-void
-elantech_send_mt_input(struct pms_softc *sc, int id)
-{
-       struct elantech_softc *elantech = sc->elantech;
+       buttons = 0;
+       if (sc->packet[0] & 0x01)
+               buttons |= WSMOUSE_BUTTON(1);
+       if (sc->packet[0] & 0x02)
+               buttons |= WSMOUSE_BUTTON(3);
+       wsmouse_buttons(sc_wsmousedev, buttons);

-       if (id != elantech->mt_lastid) {
-               /* Correct for compatibility mode, but not useful yet: */
-               elantech->old_x = elantech->mt[id].x;
-               elantech->old_y = elantech->mt[id].y;
-               /*
-                * To avoid a jump of the cursor, simulate a change of the
-                * number of touches (without producing tapping gestures
-                * accidentally). It should suffice to do that only if
-                * mt_count hasn't changed, but we cannot rely on the
-                * synaptics driver, which alters its finger counts when
-                * handling click-and-drag actions (see HandleTapProcessing
-                * and ComputeDeltas in synaptics.c).
-                */
-               if (elantech->mt_lastid > -1)
-                       elantech_send_input(sc,
-                           elantech->mt[id].x, elantech->mt[id].y,
-                           elantech->mt[id].z, ELANTECH_MAX_FINGERS);
-               elantech->mt_lastid = id;
-       }
-       elantech->mt_lastcount = elantech->mt_count;
-       elantech->mt_buttons = sc->packet[0] & 3;
-       elantech_send_input(sc,
-           elantech->mt[id].x, elantech->mt[id].y,
-           elantech->mt[id].z, elantech->mt_count);
+       wsmouse_input_sync(sc_wsmousedev);
 }

 void
@@ -2474,11 +2430,7 @@ elantech_send_input(struct pms_softc *sc
        }

        if (elantech->wsmode == WSMOUSE_NATIVE) {
-               wsmouse_input(sc->sc_wsmousedev, buttons, x, y, z, w,
-                   WSMOUSE_INPUT_ABSOLUTE_X |
-                   WSMOUSE_INPUT_ABSOLUTE_Y |
-                   WSMOUSE_INPUT_ABSOLUTE_Z |
-                   WSMOUSE_INPUT_ABSOLUTE_W);
+               WSMOUSE_TOUCH(sc->sc_wsmousedev, buttons, x, y, z, w);
        } else {
                dx = dy = 0;

@@ -2490,8 +2442,7 @@ elantech_send_input(struct pms_softc *sc
                        dy /= SYNAPTICS_SCALE;
                }
                if (dx || dy || buttons != elantech->old_buttons)
-                       wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, 0, 0,
-                           WSMOUSE_INPUT_DELTA);
+                       WSMOUSE_INPUT(sc->sc_wsmousedev, buttons, dx, dy, 0, 0);
                elantech->old_buttons = buttons;
        }

Index: dev/sun/sunms.c
===================================================================
RCS file: /cvs/src/sys/dev/sun/sunms.c,v
retrieving revision 1.1
diff -u -p -r1.1 sunms.c
--- dev/sun/sunms.c     20 May 2009 18:22:33 -0000      1.1
+++ dev/sun/sunms.c     12 Mar 2016 20:42:48 -0000
@@ -220,8 +220,8 @@ sunms_input(struct sunms_softc *sc, int
        if (sc->sc_byteno == sc->sc_pktlen) {
                timeout_del(&sc->sc_abort_tmo);
                sc->sc_byteno = -1;
-               wsmouse_input(sc->sc_wsmousedev, sc->sc_mb,
-                   sc->sc_dx, sc->sc_dy, 0, 0, WSMOUSE_INPUT_DELTA);
+               WSMOUSE_INPUT(sc->sc_wsmousedev,
+                   sc->sc_mb, sc->sc_dx, sc->sc_dy, 0, 0);
                sc->sc_dx = sc->sc_dy = 0;
        }
 }
Index: dev/usb/ubcmtp.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ubcmtp.c,v
retrieving revision 1.11
diff -u -p -r1.11 ubcmtp.c
--- dev/usb/ubcmtp.c    4 Dec 2015 16:22:27 -0000       1.11
+++ dev/usb/ubcmtp.c    12 Mar 2016 20:42:48 -0000
@@ -865,20 +865,13 @@ ubcmtp_tp_intr(struct usbd_xfer *xfer, v
                if (sc->wsmode == WSMOUSE_NATIVE) {
                        DPRINTF("absolute input %d, %d (finger %d, button 
%d)\n",
                            sc->pos[0].x, sc->pos[0].y, finger, sc->btn);
-                       wsmouse_input(sc->sc_wsmousedev, sc->btn, sc->pos[0].x,
-                           sc->pos[0].y,
-                           (finger == 0 ? 0 : 50), /* fake z for now */
-                           finger,
-                           WSMOUSE_INPUT_ABSOLUTE_X |
-                           WSMOUSE_INPUT_ABSOLUTE_Y |
-                           WSMOUSE_INPUT_ABSOLUTE_Z |
-                           WSMOUSE_INPUT_ABSOLUTE_W);
+                       WSMOUSE_TOUCH(sc->sc_wsmousedev, sc->btn, sc->pos[0].x,
+                           sc->pos[0].y, (finger ? 50 : 0), finger);
                } else {
                        DPRINTF("relative input %d, %d (button %d)\n",
                            sc->pos[0].dx, sc->pos[0].dy, sc->btn);
-                       wsmouse_input(sc->sc_wsmousedev, sc->btn,
-                           sc->pos[0].dx, sc->pos[0].dy, 0, 0,
-                           WSMOUSE_INPUT_DELTA);
+                       WSMOUSE_INPUT(sc->sc_wsmousedev, sc->btn,
+                           sc->pos[0].dx, sc->pos[0].dy, 0, 0);
                }
                splx(s);
        }
@@ -915,17 +908,7 @@ ubcmtp_bt_intr(struct usbd_xfer *xfer, v

        if (pkt->button != sc->btn) {
                sc->btn = pkt->button;
-
-               if (sc->wsmode == WSMOUSE_NATIVE)
-                       wsmouse_input(sc->sc_wsmousedev, sc->btn, sc->pos[0].x,
-                           sc->pos[0].y, 50 /* fake z for now */,
-                           1,
-                           WSMOUSE_INPUT_ABSOLUTE_X |
-                           WSMOUSE_INPUT_ABSOLUTE_Y |
-                           WSMOUSE_INPUT_ABSOLUTE_Z |
-                           WSMOUSE_INPUT_ABSOLUTE_W);
-               else
-                       wsmouse_input(sc->sc_wsmousedev, sc->btn,
-                           0, 0, 0, 0, WSMOUSE_INPUT_DELTA);
+               wsmouse_buttons(sc->sc_wsmousedev, sc->btn);
+               wsmouse_input_sync(sc->sc_wsmousedev);
        }
 }
Index: dev/usb/uts.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/uts.c,v
retrieving revision 1.37
diff -u -p -r1.37 uts.c
--- dev/usb/uts.c       10 Feb 2016 05:49:50 -0000      1.37
+++ dev/usb/uts.c       12 Mar 2016 20:42:48 -0000
@@ -476,9 +476,7 @@ uts_intr(struct usbd_xfer *xfer, void *a
        DPRINTF(("%s: tp.down = %d, tp.z = %d, tp.x = %d, tp.y = %d\n",
            sc->sc_dev.dv_xname, tp.down, tp.z, tp.x, tp.y));

-       wsmouse_input(sc->sc_wsmousedev, tp.down, tp.x, tp.y, tp.z, 0,
-           WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
-           WSMOUSE_INPUT_ABSOLUTE_Z);
+       WSMOUSE_TOUCH(sc->sc_wsmousedev, tp.down, tp.x, tp.y, tp.z, 0);
        sc->sc_oldy = tp.y;
        sc->sc_oldx = tp.x;

Reply via email to