Hi,
I have been working with mpi@ and matthieu@ to improve support for my
x230t, in particular the digitiser/pen. Last week I committed a small
change to uhts(4) which enables basic support for the digitiser.
During our discussions we noticed that uhts(4) is almost identical to
the code of ums(4).
The following diff merges uhts(4) into ums(4). There should be no
functional change. Please can people test for mouse regressions and
provide feedback. If this is good, then uhts(4) can disappear and the
commented lines in ums_match() can be restored.
I have CC'd people who may be interested.
Thanks
Index: share/man/man4/ums.4
===================================================================
RCS file: /cvs/src/share/man/man4/ums.4,v
retrieving revision 1.10
diff -u -p -r1.10 ums.4
--- share/man/man4/ums.4 26 Jun 2008 05:42:07 -0000 1.10
+++ share/man/man4/ums.4 18 Jul 2013 17:13:33 -0000
@@ -28,23 +28,30 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: June 26 2008 $
+.Dd $Mdocdate: July 17 2013 $
.Dt UMS 4
.Os
.Sh NAME
.Nm ums
-.Nd USB mouse support
+.Nd USB HID mouse, touchscreen and digitiser support
.Sh SYNOPSIS
.Cd "ums* at uhidev?"
.Cd "wsmouse* at ums? mux 0"
.Sh DESCRIPTION
The
.Nm
-driver provides support for USB mice.
-Access to the mouse is through the
+driver provides support for USB HID mice, touchscreens and digitisers.
+Access to these devices is through the
.Xr wscons 4
driver.
+.Pp
+If the touchscreen sensor is poorly aligned, then
+.Xr xtsscale 1
+should be used to provide calibration results to the
+.Nm
+driver.
.Sh SEE ALSO
+.Xr xtsscale 1 ,
.Xr uhidev 4 ,
.Xr usb 4 ,
.Xr wsmouse 4
@@ -54,3 +61,16 @@ The
driver
first appeared in
.Ox 2.8 .
+.Sh AUTHORS
+.An -nosplit
+HID touchscreen and digitiser support was written by
+.An Robert Nagy
+and
+.An Matthieu Herrb
+then later merged into the generic
+.Xr ums 4
+driver by
+.An Edd Barrett.
+.Sh CAVEATS
+Touchscreen and digitiser pressure sensitivity is not yet implemented.
+
Index: share/man/man4/usb.4
===================================================================
RCS file: /cvs/src/share/man/man4/usb.4,v
retrieving revision 1.140
diff -u -p -r1.140 usb.4
--- share/man/man4/usb.4 1 Jun 2013 17:04:57 -0000 1.140
+++ share/man/man4/usb.4 18 Jul 2013 17:13:33 -0000
@@ -252,7 +252,7 @@ HID touchscreen support
keyboards that follow the boot protocol
.It Xr ums 4
.Tn USB
-mouse devices
+HID mouse, touchscreen and digitiser devices
.It Xr uoaklux 4
Toradex OAK USB illuminance sensor
.It Xr uoakrh 4
Index: sys/dev/usb/hidms.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/hidms.c,v
retrieving revision 1.4
diff -u -p -r1.4 hidms.c
--- sys/dev/usb/hidms.c 19 Aug 2011 18:46:22 -0000 1.4
+++ sys/dev/usb/hidms.c 18 Jul 2013 17:13:38 -0000
@@ -194,6 +194,27 @@ hidms_setup(struct device *self, struct
break;
ms->sc_num_buttons = i - 1;
+ if (hid_locate(desc, dlen, HID_USAGE2(HUP_DIGITIZERS,
+ HUD_TIP_SWITCH), id, hid_input,
+ &ms->sc_loc_btn[ms->sc_num_buttons], NULL)){
+ ms->sc_flags |= HIDMS_TIP;
+ ms->sc_num_buttons++;
+ }
+
+ if (hid_locate(desc, dlen, HID_USAGE2(HUP_DIGITIZERS,
+ HUD_ERASER), id, hid_input,
+ &ms->sc_loc_btn[ms->sc_num_buttons], NULL)){
+ ms->sc_flags |= HIDMS_ERASER;
+ ms->sc_num_buttons++;
+ }
+
+ if (hid_locate(desc, dlen, HID_USAGE2(HUP_DIGITIZERS,
+ HUD_BARREL_SWITCH), id, hid_input,
+ &ms->sc_loc_btn[ms->sc_num_buttons], NULL)){
+ ms->sc_flags |= HIDMS_BARREL;
+ ms->sc_num_buttons++;
+ }
+
/*
* The Microsoft Wireless Notebook Optical Mouse seems to be in worse
* shape than the Wireless Intellimouse 2.0, as its X, Y, wheel, and
@@ -216,6 +237,11 @@ hidms_setup(struct device *self, struct
/* Parse descriptors to get touch panel bounds */
d = hid_start_parse(desc, dlen, hid_input);
while (hid_get_item(d, &h)) {
+ if (h.kind != hid_input ||
+ HID_GET_USAGE_PAGE(h.usage) != HUP_GENERIC_DESKTOP)
+ continue;
+ DPRINTF(("hidms: usage=0x%x range %d..%d\n",
+ h.usage, h.logical_minimum, h.logical_maximum));
switch (HID_GET_USAGE(h.usage)) {
case HUG_X:
if (ms->sc_flags & HIDMS_ABSX) {
@@ -255,6 +281,14 @@ hidms_attach(struct hidms *ms, const str
printf(", Z and W dir");
break;
}
+
+ if (ms->sc_flags & HIDMS_TIP)
+ printf(", tip");
+ if (ms->sc_flags & HIDMS_BARREL)
+ printf(", barrel");
+ if (ms->sc_flags & HIDMS_ERASER)
+ printf(", eraser");
+
printf("\n");
#ifdef HIDMS_DEBUG
Index: sys/dev/usb/hidmsvar.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/hidmsvar.h,v
retrieving revision 1.2
diff -u -p -r1.2 hidmsvar.h
--- sys/dev/usb/hidmsvar.h 4 Mar 2011 23:57:52 -0000 1.2
+++ sys/dev/usb/hidmsvar.h 18 Jul 2013 17:13:38 -0000
@@ -43,14 +43,17 @@ struct tsscale {
struct hidms {
int sc_enabled;
int sc_flags; /* device configuration */
-#define HIDMS_SPUR_BUT_UP 0x01 /* spurious button up events */
-#define HIDMS_Z 0x02 /* Z direction available */
-#define HIDMS_REVZ 0x04 /* Z-axis is reversed */
-#define HIDMS_W 0x08 /* W direction available */
-#define HIDMS_REVW 0x10 /* W-axis is reversed */
-#define HIDMS_LEADINGBYTE 0x20 /* Unknown leading byte */
-#define HIDMS_ABSX 0x40 /* X-axis is absolute */
-#define HIDMS_ABSY 0x80 /* Y-axis is absolute */
+#define HIDMS_SPUR_BUT_UP 0x001 /* spurious button up events */
+#define HIDMS_Z 0x002 /* Z direction available */
+#define HIDMS_REVZ 0x004 /* Z-axis is reversed */
+#define HIDMS_W 0x008 /* W direction available */
+#define HIDMS_REVW 0x010 /* W-axis is reversed */
+#define HIDMS_LEADINGBYTE 0x020 /* Unknown leading byte */
+#define HIDMS_ABSX 0x040 /* X-axis is absolute */
+#define HIDMS_ABSY 0x080 /* Y-axis is absolute */
+#define HIDMS_TIP 0x100 /* Tip switch on a digitiser pen */
+#define HIDMS_BARREL 0x200 /* Barrel switch on a digitiser pen */
+#define HIDMS_ERASER 0x400 /* Eraser switch on a digitiser pen */
int sc_num_buttons;
u_int32_t sc_buttons; /* mouse button status */
Index: sys/dev/usb/ums.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ums.c,v
retrieving revision 1.35
diff -u -p -r1.35 ums.c
--- sys/dev/usb/ums.c 3 Jul 2011 15:47:17 -0000 1.35
+++ sys/dev/usb/ums.c 18 Jul 2013 17:13:38 -0000
@@ -100,11 +100,26 @@ ums_match(struct device *parent, void *m
void *desc;
uhidev_get_report_desc(uha->parent, &desc, &size);
- if (!hid_is_collection(desc, size, uha->reportid,
- HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE)))
- return (UMATCH_NONE);
- return (UMATCH_IFACECLASS);
+ if (hid_is_collection(desc, size, uha->reportid,
+ HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE)))
+ return (UMATCH_IFACECLASS);
+
+ /*
+ * For now return a value higher than UMATCH_IFACECLASS to make sure
+ * touchscreens and digitizers no longer attach to uhts(4).
+ */
+ if (hid_is_collection(desc, size, uha->reportid,
+ HID_USAGE2(HUP_DIGITIZERS, HUD_TOUCHSCREEN)))
+ return (UMATCH_IFACECLASS_IFACESUBCLASS); /* XXX */
+ /* return (UMATCH_IFACECLASS); */
+
+ if (hid_is_collection(desc, size, uha->reportid,
+ HID_USAGE2(HUP_DIGITIZERS, HUD_PEN)))
+ return (UMATCH_IFACECLASS_IFACESUBCLASS); /* XXX */
+ /* return (UMATCH_IFACECLASS); */
+
+ return (UMATCH_NONE);
}
void
--
Best Regards
Edd Barrett
http://www.theunixzoo.co.uk