Index: sys/dev/usb/ums.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/ums.c,v retrieving revision 1.80 diff -a -u -r1.80 ums.c --- sys/dev/usb/ums.c 14 Jan 2010 09:30:39 -0000 1.80 +++ sys/dev/usb/ums.c 6 Oct 2010 07:41:38 -0000 @@ -61,6 +61,7 @@ #include #include +#include #ifdef USB_DEBUG #define DPRINTF(x) if (umsdebug) logprintf x @@ -100,7 +101,11 @@ int nbuttons; u_int32_t sc_buttons; /* mouse button status */ + int sc_x; /* last X (UMS_ABS) */ + int sc_y; /* last Y (UMS_ABS) */ device_t sc_wsmousedev; + struct tpcalib_softc sc_tpcalib; + struct wsmouse_calibcoords sc_calibcoords; char sc_dying; }; @@ -173,6 +178,9 @@ sc->sc_hdev.sc_parent = uha->parent; sc->sc_hdev.sc_report_id = uha->reportid; + memset(&sc->sc_calibcoords, 0, sizeof(sc->sc_calibcoords)); + sc->sc_calibcoords.samplelen = WSMOUSE_CALIBCOORDS_RESET; + quirks = usbd_get_quirks(uha->parent->sc_udev)->uq_flags; if (quirks & UQ_MS_REVZ) sc->flags |= UMS_REVZ; @@ -336,6 +344,10 @@ sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint); + tpcalib_init(&sc->sc_tpcalib); + tpcalib_ioctl(&sc->sc_tpcalib, WSMOUSEIO_SCALIBCOORDS, + (void *)&sc->sc_calibcoords, 0, 0); + USB_ATTACH_SUCCESS_RETURN; } @@ -384,6 +396,7 @@ { struct ums_softc *sc = (struct ums_softc *)addr; int dx, dy, dz, dw; + int cx, cy; u_int32_t buttons = 0; int i, flags, s; @@ -406,7 +419,16 @@ if (hid_get_data(ibuf, &sc->sc_loc_btn[i])) buttons |= (1 << UMS_BUT(i)); - if (dx != 0 || dy != 0 || dz != 0 || dw != 0 || + if (sc->flags & UMS_ABS) { + tpcalib_trans(&sc->sc_tpcalib, dx, dy, &dx, &dy); + cx = sc->sc_x; + cy = sc->sc_y; + } else { + cx = 0; + cy = 0; + } + + if (dx != cx || dy != cy || dz != 0 || dw != 0 || buttons != sc->sc_buttons) { DPRINTFN(10, ("ums_intr: x:%d y:%d z:%d w:%d buttons:0x%x\n", dx, dy, dz, dw, buttons)); @@ -418,6 +440,11 @@ splx(s); } } + + if (sc->flags & UMS_ABS) { + sc->sc_x = dx; + sc->sc_y = dy; + } } Static int @@ -470,6 +497,10 @@ else *(u_int *)data = WSMOUSE_TYPE_USB; return (0); + + case WSMOUSEIO_SCALIBCOORDS: + case WSMOUSEIO_GCALIBCOORDS: + return tpcalib_ioctl(&sc->sc_tpcalib, cmd, data, flag, p); } return (EPASSTHROUGH);