Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add support for USB HID devices that report absolute coordin...
details: https://anonhg.NetBSD.org/src/rev/e00d30c6ada1
branches: trunk
changeset: 749340:e00d30c6ada1
user: mbalmer <mbalmer%NetBSD.org@localhost>
date: Fri Nov 27 08:35:05 2009 +0000
description:
Add support for USB HID devices that report absolute coordinates instead
of relative movement data, i.e. touchpanels. Please note that calibration
must be done outside the wsons(4) driver for now.
diffstat:
doc/CHANGES | 3 ++-
share/man/man4/ums.4 | 12 +++++++-----
sys/dev/usb/ums.c | 51 ++++++++++++++++++++++++++++++++++++---------------
3 files changed, 45 insertions(+), 21 deletions(-)
diffs (190 lines):
diff -r 6cff630404be -r e00d30c6ada1 doc/CHANGES
--- a/doc/CHANGES Fri Nov 27 03:23:03 2009 +0000
+++ b/doc/CHANGES Fri Nov 27 08:35:05 2009 +0000
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1320 $>
+# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1321 $>
#
#
# [Note: This file does not mention every change made to the NetBSD source tree.
@@ -485,3 +485,4 @@
rump: Load rump virtual kernel symbol table at boot. This enables
the use of the kernel linker in a rump kernel.
[pooka 20091126]
+ ums(4): Added touchpanel support. [mbalmer 20091127]
diff -r 6cff630404be -r e00d30c6ada1 share/man/man4/ums.4
--- a/share/man/man4/ums.4 Fri Nov 27 03:23:03 2009 +0000
+++ b/share/man/man4/ums.4 Fri Nov 27 08:35:05 2009 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ums.4,v 1.8 2008/04/30 13:10:54 martin Exp $
+.\" $NetBSD: ums.4,v 1.9 2009/11/27 08:35:05 mbalmer Exp $
.\"
.\" Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,20 +27,20 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd July 12, 1998
+.Dd November 27, 2009
.Dt UMS 4
.Os
.Sh NAME
.Nm ums
-.Nd USB mouse support
+.Nd USB mouse and touchpanel support
.Sh SYNOPSIS
.Cd "ums* at uhidev? reportid ?"
.Cd "wsmouse* at ums?"
.Sh DESCRIPTION
The
.Nm
-driver provides support for USB mice.
-Access to the mouse is through the
+driver provides support for USB mice and touchpanels.
+Access to the movement data is through the
.Xr wscons 4
driver.
.Sh SEE ALSO
@@ -53,3 +53,5 @@
driver
appeared in
.Nx 1.4 .
+Touchpanel support was added in
+.Nx 5.1 .
diff -r 6cff630404be -r e00d30c6ada1 sys/dev/usb/ums.c
--- a/sys/dev/usb/ums.c Fri Nov 27 03:23:03 2009 +0000
+++ b/sys/dev/usb/ums.c Fri Nov 27 08:35:05 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ums.c,v 1.76 2009/11/12 19:58:27 dyoung Exp $ */
+/* $NetBSD: ums.c,v 1.77 2009/11/27 08:35:05 mbalmer Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.76 2009/11/12 19:58:27 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.77 2009/11/27 08:35:05 mbalmer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -95,6 +95,7 @@
#define UMS_SPUR_BUT_UP 0x02 /* spurious button up events */
#define UMS_REVZ 0x04 /* Z-axis is reversed */
#define UMS_W 0x08 /* w direction/tilt available */
+#define UMS_ABS 0x10 /* absolute position, touchpanel */
int nbuttons;
@@ -105,7 +106,6 @@
};
#define MOUSE_FLAGS_MASK (HIO_CONST|HIO_RELATIVE)
-#define MOUSE_FLAGS (HIO_RELATIVE)
Static void ums_intr(struct uhidev *addr, void *ibuf, u_int len);
@@ -180,7 +180,13 @@
USBDEVNAME(sc->sc_hdev.sc_dev));
USB_ATTACH_ERROR_RETURN;
}
- if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) {
+ switch (flags & MOUSE_FLAGS_MASK) {
+ case 0:
+ sc->flags |= UMS_ABS;
+ break;
+ case HIO_RELATIVE:
+ break;
+ default:
aprint_error("\n%s: X report 0x%04x not supported\n",
USBDEVNAME(sc->sc_hdev.sc_dev), flags);
USB_ATTACH_ERROR_RETURN;
@@ -192,7 +198,13 @@
USBDEVNAME(sc->sc_hdev.sc_dev));
USB_ATTACH_ERROR_RETURN;
}
- if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) {
+ switch (flags & MOUSE_FLAGS_MASK) {
+ case 0:
+ sc->flags |= UMS_ABS;
+ break;
+ case HIO_RELATIVE:
+ break;
+ default:
aprint_error("\n%s: Y report 0x%04x not supported\n",
USBDEVNAME(sc->sc_hdev.sc_dev), flags);
USB_ATTACH_ERROR_RETURN;
@@ -209,7 +221,7 @@
zloc = &sc->sc_loc_z;
if (hl) {
- if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) {
+ if ((flags & MOUSE_FLAGS_MASK) != HIO_RELATIVE) {
aprint_verbose("\n%s: Wheel report 0x%04x not "
"supported\n", USBDEVNAME(sc->sc_hdev.sc_dev),
flags);
@@ -247,7 +259,7 @@
}
if (hl) {
- if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) {
+ if ((flags & MOUSE_FLAGS_MASK) != HIO_RELATIVE) {
aprint_verbose("\n%s: Z report 0x%04x not supported\n",
USBDEVNAME(sc->sc_hdev.sc_dev), flags);
zloc->size = 0; /* Bad Z coord, ignore it */
@@ -362,15 +374,21 @@
struct ums_softc *sc = (struct ums_softc *)addr;
int dx, dy, dz, dw;
u_int32_t buttons = 0;
- int i;
- int s;
+ int i, flags, s;
DPRINTFN(5,("ums_intr: len=%d\n", len));
+ flags = WSMOUSE_INPUT_DELTA; /* equals 0 */
+
dx = hid_get_data(ibuf, &sc->sc_loc_x);
- dy = -hid_get_data(ibuf, &sc->sc_loc_y);
+ if (sc->flags & UMS_ABS) {
+ flags |= (WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
+ dy = hid_get_data(ibuf, &sc->sc_loc_y);
+ } else
+ dy = -hid_get_data(ibuf, &sc->sc_loc_y);
dz = hid_get_data(ibuf, &sc->sc_loc_z);
dw = hid_get_data(ibuf, &sc->sc_loc_w);
+
if (sc->flags & UMS_REVZ)
dz = -dz;
for (i = 0; i < sc->nbuttons; i++)
@@ -384,10 +402,8 @@
sc->sc_buttons = buttons;
if (sc->sc_wsmousedev != NULL) {
s = spltty();
- wsmouse_input(sc->sc_wsmousedev,
- buttons,
- dx, dy, dz, dw,
- WSMOUSE_INPUT_DELTA);
+ wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, dz,
+ dw, flags);
splx(s);
}
}
@@ -434,9 +450,14 @@
struct lwp * p)
{
+ struct ums_softc *sc = v;
+
switch (cmd) {
case WSMOUSEIO_GTYPE:
- *(u_int *)data = WSMOUSE_TYPE_USB;
+ if (sc->flags & UMS_ABS)
+ *(u_int *)data = WSMOUSE_TYPE_TPANEL;
+ else
+ *(u_int *)data = WSMOUSE_TYPE_USB;
return (0);
}
Home |
Main Index |
Thread Index |
Old Index