Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jul 2011 20:38:06 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r224499 - head/sys/dev/usb/input
Message-ID:  <201107292038.p6TKc6S3065242@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Jul 29 20:38:06 2011
New Revision: 224499
URL: http://svn.freebsd.org/changeset/base/224499

Log:
  Make ums(4) driver more picky, not attaching to "mouses" with absolute
  coordinates, such as digitizers and touch-screens, leaving these devices
  to uhid(4) and user-level. Specially patched xf86-input-mouse driver can
  handle them, that isn't done and can't be done properly with ums(4)
  because of mouse(4) protocol limitations.
  
  Approved by:	re (kib)

Modified:
  head/sys/dev/usb/input/ums.c

Modified: head/sys/dev/usb/input/ums.c
==============================================================================
--- head/sys/dev/usb/input/ums.c	Fri Jul 29 20:35:23 2011	(r224498)
+++ head/sys/dev/usb/input/ums.c	Fri Jul 29 20:38:06 2011	(r224499)
@@ -367,7 +367,9 @@ ums_probe(device_t dev)
 {
 	struct usb_attach_arg *uaa = device_get_ivars(dev);
 	void *d_ptr;
-	int error;
+	struct hid_data *hd;
+	struct hid_item hi;
+	int error, mdepth, found;
 	uint16_t d_len;
 
 	DPRINTFN(11, "\n");
@@ -388,14 +390,44 @@ ums_probe(device_t dev)
 	if (error)
 		return (ENXIO);
 
-	if (hid_is_collection(d_ptr, d_len,
-	    HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE)))
-		error = BUS_PROBE_DEFAULT;
-	else
-		error = ENXIO;
-
+	hd = hid_start_parse(d_ptr, d_len, 1 << hid_input);
+	if (hd == NULL)
+		return (0);
+	mdepth = 0;
+	found = 0;
+	while (hid_get_item(hd, &hi)) {
+		switch (hi.kind) {
+		case hid_collection:
+			if (mdepth != 0)
+				mdepth++;
+			else if (hi.collection == 1 &&
+			     hi.usage ==
+			      HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE))
+				mdepth++;
+			break;
+		case hid_endcollection:
+			if (mdepth != 0)
+				mdepth--;
+			break;
+		case hid_input:
+			if (mdepth == 0)
+				break;
+			if (hi.usage ==
+			     HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X) &&
+			    (hi.flags & MOUSE_FLAGS_MASK) == MOUSE_FLAGS)
+				found++;
+			if (hi.usage ==
+			     HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y) &&
+			    (hi.flags & MOUSE_FLAGS_MASK) == MOUSE_FLAGS)
+				found++;
+			break;
+		default:
+			break;
+		}
+	}
+	hid_end_parse(hd);
 	free(d_ptr, M_TEMP);
-	return (error);
+	return (found ? BUS_PROBE_DEFAULT : ENXIO);
 }
 
 static void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107292038.p6TKc6S3065242>