kern/90162: [patch] Add support for the MS Wireless USB Mouse

Hellmuth Michaelis hm at FreeBSD.org
Fri Dec 9 13:20:05 PST 2005


>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:


More information about the freebsd-bugs mailing list