From owner-p4-projects@FreeBSD.ORG Sat Apr 21 19:08:21 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DB67516A4F3; Sat, 21 Apr 2007 19:08:20 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9772816A4D6 for ; Sat, 21 Apr 2007 19:08:20 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 88E7D13C4C5 for ; Sat, 21 Apr 2007 19:08:20 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l3LJ8K95045563 for ; Sat, 21 Apr 2007 19:08:20 GMT (envelope-from rpaulo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l3LJ8Jn0045560 for perforce@freebsd.org; Sat, 21 Apr 2007 19:08:19 GMT (envelope-from rpaulo@FreeBSD.org) Date: Sat, 21 Apr 2007 19:08:19 GMT Message-Id: <200704211908.l3LJ8Jn0045560@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rpaulo@FreeBSD.org using -f From: Rui Paulo To: Perforce Change Reviews Cc: Subject: PERFORCE change 118538 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Apr 2007 19:08:21 -0000 http://perforce.freebsd.org/chv.cgi?CH=118538 Change 118538 by rpaulo@rpaulo_epsilon on 2007/04/21 19:07:22 Apple's Mighty Mouse modifications that I submitted in PR usb/110357. Affected files ... .. //depot/projects/soc2007/rpaulo-macbook/dev/usb/ums.c#2 edit Differences ... ==== //depot/projects/soc2007/rpaulo-macbook/dev/usb/ums.c#2 (text+ko) ==== @@ -104,7 +104,7 @@ u_char *sc_ibuf; u_int8_t sc_iid; int sc_isize; - struct hid_location sc_loc_x, sc_loc_y, sc_loc_z, sc_loc_t; + struct hid_location sc_loc_x, sc_loc_y, sc_loc_z, sc_loc_t, sc_loc_w; struct hid_location *sc_loc_btn; usb_callout_t callout_handle; /* for spurious button ups */ @@ -116,6 +116,7 @@ #define UMS_Z 0x01 /* z direction available */ #define UMS_SPUR_BUT_UP 0x02 /* spurious button up events */ #define UMS_T 0x04 /* aa direction available (tilt) */ +#define UMS_REVZ 0x08 /* Z-axis is reversed */ int nbuttons; #define MAX_BUTTONS 31 /* chosen because sc_buttons is int */ @@ -209,7 +210,7 @@ usbd_status err; char devinfo[1024]; u_int32_t flags; - int i; + int i, wheel; struct hid_location loc_btn; sc->sc_disconnected = 1; @@ -266,13 +267,41 @@ USB_ATTACH_ERROR_RETURN; } - /* try to guess the Z activator: first check Z, then WHEEL */ - if (hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Z), - hid_input, &sc->sc_loc_z, &flags) || - hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL), - hid_input, &sc->sc_loc_z, &flags) || - hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_TWHEEL), - hid_input, &sc->sc_loc_z, &flags)) { + /* Try the wheel first as the Z activator since it's tradition. */ + wheel = hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, + HUG_WHEEL), + hid_input, &sc->sc_loc_z, &flags); + + if (wheel) { + if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) { + printf("\n%s: Wheel report 0x%04x not supported\n", + device_get_nameunit(sc->sc_dev), flags); + sc->sc_loc_z.size = 0; /* Bad Z coord, ignore it */ + } else { + sc->flags |= UMS_Z; + if (usbd_get_quirks(uaa->device)->uq_flags & + UQ_MS_REVZ) { + /* Some wheels need the Z axis reversed. */ + sc->flags |= UMS_REVZ; + } + + } + /* + * We might have both a wheel and Z direction, if so put + * put the Z on the W coordinate. + */ + if (hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, + HUG_Z), + hid_input, &sc->sc_loc_w, &flags)) { + if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) { + printf("\n%s: Z report 0x%04x not supported\n", + device_get_nameunit(sc->sc_dev), flags); + sc->sc_loc_w.size = 0; /* Bad Z, ignore */ + } + } + } else if (hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, + HUG_Z), + hid_input, &sc->sc_loc_z, &flags)) { if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) { sc->sc_loc_z.size = 0; /* Bad Z coord, ignore it */ } else { @@ -424,7 +453,7 @@ { struct ums_softc *sc = addr; u_char *ibuf; - int dx, dy, dz, dt; + int dx, dy, dz, dt, dw; int buttons = 0; int i; @@ -474,6 +503,9 @@ dx = hid_get_data(ibuf, &sc->sc_loc_x); dy = -hid_get_data(ibuf, &sc->sc_loc_y); dz = -hid_get_data(ibuf, &sc->sc_loc_z); + dw = hid_get_data(ibuf, &sc->sc_loc_w); + if (sc->flags & UMS_REVZ) + dz = -dz; if (sc->flags & UMS_T) dt = -hid_get_data(ibuf, &sc->sc_loc_t); else @@ -482,17 +514,18 @@ if (hid_get_data(ibuf, &sc->sc_loc_btn[i])) buttons |= (1 << UMS_BUT(i)); - if (dx || dy || dz || dt || (sc->flags & UMS_Z) + if (dx || dy || dz || dt || dw || (sc->flags & UMS_Z) || buttons != sc->status.button) { - DPRINTFN(5, ("ums_intr: x:%d y:%d z:%d t:%d buttons:0x%x\n", - dx, dy, dz, dt, buttons)); + DPRINTFN(5, ("ums_intr: x:%d y:%d z:%d t:%d w:%w buttons:0x%x\n", + dx, dy, dz, dt, dw, buttons)); sc->status.button = buttons; sc->status.dx += dx; sc->status.dy += dy; sc->status.dz += dz; /* sc->status.dt += dt;*/ /* no way to export this yet */ - + /* sc->status.dw += dw; */ /* idem */ + /* Discard data in case of full buffer */ if (sc->qcount == sizeof(sc->qbuf)) { DPRINTF(("Buffer full, discarded packet"));