From owner-freebsd-bugs@FreeBSD.ORG Fri Dec 9 21:20:05 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6CF5816A422 for ; Fri, 9 Dec 2005 21:20:05 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5218A43D5F for ; Fri, 9 Dec 2005 21:20:03 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id jB9LK3IE094277 for ; Fri, 9 Dec 2005 21:20:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id jB9LK3tg094276; Fri, 9 Dec 2005 21:20:03 GMT (envelope-from gnats) Resent-Date: Fri, 9 Dec 2005 21:20:03 GMT Resent-Message-Id: <200512092120.jB9LK3tg094276@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Hellmuth Michaelis Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6154116A41F for ; Fri, 9 Dec 2005 21:14:29 +0000 (GMT) (envelope-from hm@kts.org) Received: from mailout10.sul.t-online.com (mailout10.sul.t-online.com [194.25.134.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 43EC343D79 for ; Fri, 9 Dec 2005 21:14:25 +0000 (GMT) (envelope-from hm@kts.org) Received: from fwd33.aul.t-online.de by mailout10.sul.t-online.com with smtp id 1EkpZN-000361-02; Fri, 09 Dec 2005 22:14:21 +0100 Received: from ernie.int.kts.org (SrvdHgZXweH-mb68h5eodYwBBniyfcVejLe4lvXlp6qY7PIj1aHYYm@[84.144.70.104]) by fwd33.sul.t-online.de with esmtp id 1EkpZG-0iLp4a0; Fri, 9 Dec 2005 22:14:14 +0100 Received: from ernie.int.kts.org ([127.0.0.1]) by localhost (ernie.int.kts.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 11939-06 for ; Fri, 9 Dec 2005 22:14:03 +0100 (CET) Received: from bert.int.kts.org (bert.int.kts.org [172.31.42.2]) by ernie.int.kts.org (Postfix) with ESMTP id AF65B1055E for ; Fri, 9 Dec 2005 22:13:58 +0100 (CET) Received: by bert.int.kts.org (Postfix, from userid 100) id A3E1B117D4; Fri, 9 Dec 2005 22:13:58 +0100 (CET) Message-Id: <20051209211358.A3E1B117D4@bert.int.kts.org> Date: Fri, 9 Dec 2005 22:13:58 +0100 (CET) From: Hellmuth Michaelis To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: kern/90162: [patch] Add support for the MS Wireless USB Mouse X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Hellmuth Michaelis List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Dec 2005 21:20:05 -0000 >Number: 90162 >Category: kern >Synopsis: [patch] Add support for the MS Wireless USB Mouse >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Dec 09 21:20:02 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Hellmuth Michaelis >Release: FreeBSD 5.4-STABLE i386 >Organization: Kitchen Table Systems >Environment: FreeBSD 5.4-STABLE i386 cvsuped late November 2005 on an IBM ThinkPad R40 >Description: Add support for a Microsoft Wireless USB Mouse, a nice small device for usage with a notebook. Saw this one and bought it but it with- stood several attempts to make it work under FreeBSD. Today i got it to work, but as i'm nearly completely unaware of how USB works i would like that someone with a deeper insight perhaps might have a look over this, clean it up and commit it. The device is best described by the output of a "usbdevs -v" command: low speed, power 50 mA, config 1, Microsoft USB Wireless Mouse(0x00b9), Microsoft(0x045e), rev 0.17 >How-To-Repeat: plug the mouse transceiver into a USB port of a 5.4 system :-) >Fix: The following are context diffs for files usbdevs, hid.c and ums.c in /usr/src/sys/devs/usb. The hid.c diff does not fix anything but lets one see the probing of the device. The ums.c diff is a hack: 1) the mose does not identify as HUP_GENERIC_DESKTOP, HUG_MOUSE but as HUP_CONSUMER, HUG_POINTER - the way i have handled it here is probably suboptimal. 2) not setting flag UMS_T prevents the special handling in ums_intr() 3) i have no clue, _why_ the offset of 40 has to be subtracted .. Anyway, using this patches the mouse works very well (left, right, middle buttons and wheel) and without any noticable gliches using this xorg entry: Section "InputDevice" Identifier "Mouse1" Driver "mouse" Option "Protocol" "auto" Option "Device" "/dev/ums0" Option "ZAxisMapping" "4 5" EndSection *** usbdevs-DIST Sat Oct 1 18:32:27 2005 --- usbdevs Fri Dec 9 11:48:16 2005 *************** *** 974,979 **** --- 974,980 ---- product MICROSOFT INTELLIEYE 0x0025 IntelliEye mouse product MICROSOFT INETPRO2 0x002b Internet Keyboard Pro product MICROSOFT MN110 0x007a 10/100 USB NIC + product MICROSOFT WLUSBMOUSE 0x00b9 Wireless USB Mouse /* Microtech products */ product MICROTECH SCSIDB25 0x0004 USB-SCSI-DB25 *** hid.c-DIST Fri Dec 9 21:12:46 2005 --- hid.c Fri Dec 9 21:11:57 2005 *************** *** 450,455 **** --- 450,459 ---- err = hid_get_item(hd, &hi) && hi.kind == hid_collection && hi.usage == usage; + + DPRINTFN(10, ("hid_is_collection: hi.kind=%x, hid_collection=%x, hi.usage=%x usage=%x\n", + hi.kind, hid_collection, hi.usage, usage)); + hid_end_parse(hd); return (err); } *** ums.c-DIST Sun Jan 30 02:00:10 2005 --- ums.c Fri Dec 9 21:23:51 2005 *************** *** 179,184 **** --- 179,185 ---- if (!uaa->iface) return (UMATCH_NONE); + id = usbd_get_interface_descriptor(uaa->iface); if (!id || id->bInterfaceClass != UICLASS_HID) return (UMATCH_NONE); *************** *** 188,198 **** return (UMATCH_NONE); if (hid_is_collection(desc, size, ! HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE))) ret = UMATCH_IFACECLASS; ! else ! ret = UMATCH_NONE; ! free(desc, M_TEMP); return (ret); } --- 189,208 ---- return (UMATCH_NONE); if (hid_is_collection(desc, size, ! HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE))) { ret = UMATCH_IFACECLASS; ! } ! else { ! if (hid_is_collection(desc, size, ! HID_USAGE2(HUP_CONSUMER, HUG_POINTER))) { ! /* The MICROSOFT Wireless USB Mouse identifies as this ... */ ! ret = UMATCH_IFACECLASS; ! } ! else { ! ret = UMATCH_NONE; ! } ! } ! free(desc, M_TEMP); return (ret); } *************** *** 284,293 **** --- 294,311 ---- * you to know that the byte after the wheel is the tilt axis. * There are no other HID axis descriptors other than X,Y and * TWHEEL */ + if (hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_TWHEEL), hid_input, &sc->sc_loc_t, &flags)) { + + /* the following prevents a false behaviour for this mouse + because of the "mis"-used UMS_T usage in ums_intr() */ + + if(!(uaa->vendor == USB_VENDOR_MICROSOFT && + uaa->product == USB_PRODUCT_MICROSOFT_WLUSBMOUSE)) { sc->sc_loc_t.pos = sc->sc_loc_t.pos + 8; sc->flags |= UMS_T; + } } /* figure out the number of buttons */ *************** *** 323,328 **** --- 341,359 ---- sc->sc_disconnected = 0; free(desc, M_TEMP); + if( uaa->vendor == USB_VENDOR_MICROSOFT && + uaa->product == USB_PRODUCT_MICROSOFT_WLUSBMOUSE ) { + /* The offset is wrong for this mouse, correct it */ + sc->sc_loc_x.pos -= 40; + sc->sc_loc_y.pos -= 40; + + if (sc->flags & UMS_Z) + sc->sc_loc_z.pos -= 40; + for (i = 1; i <= sc->nbuttons; i++) + sc->sc_loc_btn[i-1].pos -= 40; + } + + #ifdef USB_DEBUG DPRINTF(("ums_attach: sc=%p\n", sc)); DPRINTF(("ums_attach: X\t%d/%d\n", *************** *** 455,460 **** --- 486,496 ---- * This should sort that. * Currently it's the only user of UMS_T so use it as an identifier. * We probably should switch to some more official quirk. + * + * The MS Wireless USB Mouse sends either its identifier (11) or + * some different value (14). In the latter case it is followed by a + * 01 or 02 and somehow it generates left clicks which are prevented + * by not setting the UMS_T flag in ums_attach and the else case below. */ if (sc->flags & UMS_T) { if (sc->sc_iid) { >Release-Note: >Audit-Trail: >Unformatted: