Bug 118670 - [ums] [patch] Razer Copperhead Laser Mouse shows up as keyboard
Summary: [ums] [patch] Razer Copperhead Laser Mouse shows up as keyboard
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: John Baldwin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-13 16:40 UTC by Uwe Grohnwaldt
Modified: 2008-03-20 13:08 UTC (History)
0 users

See Also:


Attachments
patch-1.diff (765 bytes, patch)
2007-12-28 17:39 UTC, Jase Thew
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Grohnwaldt 2007-12-13 16:40:01 UTC
Since the version 1.95 of ums.c the mouse is recognized as a keyboard.
more information can be found in this thread:
http://lists.freebsd.org/pipermail/freebsd-usb/2007-July/003768.html

How-To-Repeat: Connect a Razer Copperhead Laser Mouse to any USB-Port. ;)
Comment 1 Jase Thew 2007-12-28 17:39:53 UTC
The Razer Copperhead is a compound device having both a mouse and
programmable keyboard component (so that mouse buttons can be
programmed to emulate keypresses), hence it previously attaching to both
ums and ukbd.

The problem with it no longer attaching to ums is due to changes made in
ums.c version 1.94 - specifically (snippet taken from ums.c v1.97) :

201:        if (id->bInterfaceClass == UICLASS_HID &&
202:            id->bInterfaceSubClass == UISUBCLASS_BOOT &&
203:            id->bInterfaceProtocol == UIPROTO_MOUSE)
204:                ret = UMATCH_IFACECLASS;
205:        else
206:                ret = UMATCH_NONE;

As the mouse device is Class 3 (HID), SubClass 0 (No SubClass), Protocol 
2 (Mouse), it fails to match and hence will not attach.

The attached patch, which applies against ums.c v1.97, changes the check 
to match either SubClass 0 (No SubClass) or SubClass 1 (Boot device) and 
defines the appropriate identifier in usb.h .

After applying the patch, the mouse attaches successfully and works 
correctly. This shouldn't affect any mice that use the Boot subclass - 
it will just allow mice that have no subclass to work correctly.

I would love to see this committed before 7.0-RELEASE is cut, but I 
understand if it's not, as it is rather late in the testing cycle.

Comment 2 Jase Thew 2007-12-28 19:34:43 UTC
Sorry, the patch got munged with my previous follow-up.

For reference in this PR, the patch can be downloaded from 
http://beastie.beardz.net/~bazerka/fbsd/copperhead.patch-1.diff

Also, a slight correction to my previous follow-up, the patch applies to 
ums.c,v 1.96 2007/07/25 06:43:06 imp (which is the latest version of 
ums.c in RELENG_7, as of posting).

Regards,

Jase.
Comment 3 Uwe Grohnwaldt 2007-12-29 01:26:24 UTC
Hi,
I tried your patch on my FreeBSD-Current and it works great for me,
although the file-version differs from the fbsd7 one. :)

Thanks,
-- 
Uwe Grohnwaldt
Max-Planck-Str 2A, 1.03.2
18059 Rostock

E-Mail : Uwe@Grohnwaldt.de
ICQ    : 149348486 *
Skype  : lando_calr

* nur nach vorheriger Vereinbarung
Comment 4 Oliver Herold 2008-01-27 12:18:37 UTC
Patch doesn't work anymore at FreeBSD 7 (RELENG_7).
Comment 5 Oliver Herold 2008-01-27 12:22:24 UTC
Patch doesn't work anymore in FreeBSD 7 (RELENG_7 of today).
Comment 6 Oliver Herold 2008-01-27 14:08:46 UTC
Sorry, used the wrong patch. Mea cupla, now the Copperhead is fully  
functional. Thanks.
Comment 7 John Baldwin freebsd_committer freebsd_triage 2008-02-27 21:41:13 UTC
According to the USB spec, the protocol field is only defined if the subclass 
is 1.  So a subclass of 0 is really a violation of the spec.  I think a 
better fix is to put back the old hid_is_collection() test first and then 
directly check the descriptor if that fails:

Index: ums.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/usb/ums.c,v
retrieving revision 1.97
diff -u -r1.97 ums.c
--- ums.c	26 Dec 2007 14:31:16 -0000	1.97
+++ ums.c	27 Feb 2008 21:40:48 -0000
@@ -198,7 +198,10 @@
 	if (err)
 		return (UMATCH_NONE);
 
-	if (id->bInterfaceClass == UICLASS_HID &&
+	if (hid_is_collection(desc, size,
+			      HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE)))
+		ret = UMATCH_IFACECLASS;
+	else if (id->bInterfaceClass == UICLASS_HID &&
 	    id->bInterfaceSubClass == UISUBCLASS_BOOT &&
 	    id->bInterfaceProtocol == UIPROTO_MOUSE)
 		ret = UMATCH_IFACECLASS;

-- 
John Baldwin
Comment 8 Oliver Herold 2008-02-28 14:41:33 UTC
Hi

http://lists.freebsd.org/pipermail/freebsd-stable/2008-February/040754.html

as I said there, the patch does work but to some degree only.

Cheers, 

Oliver

-- 
If you don't know what game you're playing, don't ask what the score is.
Comment 9 John Baldwin freebsd_committer freebsd_triage 2008-03-12 20:16:13 UTC
I think the X problems you have are a separate issue.

-- 
John Baldwin
Comment 10 dfilter service freebsd_committer freebsd_triage 2008-03-12 20:20:42 UTC
jhb         2008-03-12 20:20:36 UTC

  FreeBSD src repository

  Modified files:
    sys/dev/usb          ums.c 
  Log:
  Partially revert 1.95.  It changed the probe for a mouse device to only
  accept a mouse using the boot subclass.  Instead, restore the original
  hid_is_collection() test and fallback to testing the interface class,
  subclass, and protocol if that fails.
  
  MFC after:      1 week
  PR:             usb/118670
  
  Revision  Changes    Path
  1.98      +4 -1      src/sys/dev/usb/ums.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 11 John Baldwin freebsd_committer freebsd_triage 2008-03-12 20:24:57 UTC
State Changed
From-To: open->patched

Fixed in HEAD. 


Comment 12 John Baldwin freebsd_committer freebsd_triage 2008-03-12 20:24:57 UTC
Responsible Changed
From-To: freebsd-usb->jhb

Fixed in HEAD.
Comment 13 John Baldwin freebsd_committer freebsd_triage 2008-03-20 13:08:29 UTC
State Changed
From-To: patched->closed

Fix merged to RELENG_7.