summaryrefslogtreecommitdiff
path: root/sys/dev/wscons
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-04-10 22:37:18 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-04-10 22:37:18 +0000
commit4395ebb5d960c7e79e0751653ed70652bb5c750e (patch)
treef3fbbc3ee965b802ffcc2ec46881747e95afdf75 /sys/dev/wscons
parentb50c42daab6dfe37e18820055d043474e3fa21f7 (diff)
Add support for a fourth axis on wsmouse devices, e.g. on the Apple Might
Mouse. Currently limited to USB mice. Adapted from a diff from Gareth <garf@loveandnature.co.za> on tech@
Diffstat (limited to 'sys/dev/wscons')
-rw-r--r--sys/dev/wscons/wsconsio.h8
-rw-r--r--sys/dev/wscons/wsdisplay.c4
-rw-r--r--sys/dev/wscons/wsmouse.c31
-rw-r--r--sys/dev/wscons/wsmousevar.h5
4 files changed, 39 insertions, 9 deletions
diff --git a/sys/dev/wscons/wsconsio.h b/sys/dev/wscons/wsconsio.h
index 73ffb75dc3b..1bf7ad94f7b 100644
--- a/sys/dev/wscons/wsconsio.h
+++ b/sys/dev/wscons/wsconsio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsconsio.h,v 1.43 2006/11/27 18:04:28 gwk Exp $ */
+/* $OpenBSD: wsconsio.h,v 1.44 2007/04/10 22:37:17 miod Exp $ */
/* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */
/*
@@ -76,6 +76,9 @@ struct wscons_event {
#define WSCONS_EVENT_MOUSE_ABSOLUTE_Y 9 /* Y location */
#define WSCONS_EVENT_MOUSE_DELTA_Z 10 /* Z delta amount */
#define WSCONS_EVENT_MOUSE_ABSOLUTE_Z 11 /* Z location */
+ /* 12-15, see below */
+#define WSCONS_EVENT_MOUSE_DELTA_W 16 /* W delta amount */
+#define WSCONS_EVENT_MOUSE_ABSOLUTE_W 17 /* W location */
/*
* Following events are not real wscons_event but are used as parameters of the
* WSDISPLAYIO_WSMOUSED ioctl
@@ -88,7 +91,8 @@ struct wscons_event {
#define IS_MOTION_EVENT(type) (((type) == WSCONS_EVENT_MOUSE_DELTA_X) || \
((type) == WSCONS_EVENT_MOUSE_DELTA_Y) || \
- ((type) == WSCONS_EVENT_MOUSE_DELTA_Z))
+ ((type) == WSCONS_EVENT_MOUSE_DELTA_Z) || \
+ ((type) == WSCONS_EVENT_MOUSE_DELTA_W))
#define IS_BUTTON_EVENT(type) (((type) == WSCONS_EVENT_MOUSE_UP) || \
((type) == WSCONS_EVENT_MOUSE_DOWN))
#define IS_CTRL_EVENT(type) ((type == WSCONS_EVENT_WSMOUSED_ON) || \
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index c2d8fcf81bb..f8a8fff7d2c 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay.c,v 1.79 2007/04/10 17:47:55 miod Exp $ */
+/* $OpenBSD: wsdisplay.c,v 1.80 2007/04/10 22:37:17 miod Exp $ */
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -3283,7 +3283,7 @@ wsmoused_release(struct wsdisplay_softc *sc)
/* inject event to notify wsmoused(8) to close mouse device */
if (wsms_dev != NULL)
- wsmouse_input(wsms_dev, 0, 0, 0, 0,
+ wsmouse_input(wsms_dev, 0, 0, 0, 0, 0,
WSMOUSE_INPUT_WSMOUSED_CLOSE);
}
diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c
index 14c7a321dcb..bf3c483e71e 100644
--- a/sys/dev/wscons/wsmouse.c
+++ b/sys/dev/wscons/wsmouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmouse.c,v 1.18 2006/11/01 03:37:24 tedu Exp $ */
+/* $OpenBSD: wsmouse.c,v 1.19 2007/04/10 22:37:17 miod Exp $ */
/* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -117,6 +117,7 @@ extern int wsmuxdebug;
#define INVALID_X INT_MAX
#define INVALID_Y INT_MAX
#define INVALID_Z INT_MAX
+#define INVALID_W INT_MAX
struct wsmouse_softc {
struct wsevsrc sc_base;
@@ -129,9 +130,11 @@ struct wsmouse_softc {
int sc_dx; /* delta-x */
int sc_dy; /* delta-y */
int sc_dz; /* delta-z */
+ int sc_dw; /* delta-w */
int sc_x; /* absolute-x */
int sc_y; /* absolute-y */
int sc_z; /* absolute-z */
+ int sc_w; /* absolute-w */
int sc_refcnt;
u_char sc_dying; /* device is being detached */
@@ -285,14 +288,14 @@ wsmouse_detach(struct device *self, int flags)
void
wsmouse_input(struct device *wsmousedev, u_int btns, /* 0 is up */
- int x, int y, int z, u_int flags)
+ int x, int y, int z, int w, u_int flags)
{
struct wsmouse_softc *sc = (struct wsmouse_softc *)wsmousedev;
struct wscons_event *ev;
struct wseventvar *evar;
int mb, ub, d, get, put, any;
- add_mouse_randomness(x ^ y ^ z ^ btns);
+ add_mouse_randomness(x ^ y ^ z ^ w ^ btns);
/*
* Discard input if not ready.
@@ -320,6 +323,8 @@ wsmouse_input(struct device *wsmousedev, u_int btns, /* 0 is up */
sc->sc_dy += y;
if (!(flags & WSMOUSE_INPUT_ABSOLUTE_Z))
sc->sc_dz += z;
+ if (!(flags & WSMOUSE_INPUT_ABSOLUTE_W))
+ sc->sc_dw += w;
/*
* We have at least one event (mouse button, delta-X, or
@@ -411,6 +416,25 @@ wsmouse_input(struct device *wsmousedev, u_int btns, /* 0 is up */
sc->sc_dz = 0;
}
}
+ if (flags & WSMOUSE_INPUT_ABSOLUTE_W) {
+ if (sc->sc_w != w) {
+ NEXT;
+ ev->type = WSCONS_EVENT_MOUSE_ABSOLUTE_W;
+ ev->value = w;
+ TIMESTAMP;
+ ADVANCE;
+ sc->sc_w = w;
+ }
+ } else {
+ if (sc->sc_dw) {
+ NEXT;
+ ev->type = WSCONS_EVENT_MOUSE_DELTA_W;
+ ev->value = sc->sc_dw;
+ TIMESTAMP;
+ ADVANCE;
+ sc->sc_dw = 0;
+ }
+ }
mb = sc->sc_mb;
while ((d = mb ^ ub) != 0) {
@@ -527,6 +551,7 @@ wsmousedoopen(struct wsmouse_softc *sc, struct wseventvar *evp)
sc->sc_x = INVALID_X;
sc->sc_y = INVALID_Y;
sc->sc_z = INVALID_Z;
+ sc->sc_w = INVALID_W;
/* enable the device, and punt if that's not possible */
return (*sc->sc_accessops->enable)(sc->sc_accesscookie);
diff --git a/sys/dev/wscons/wsmousevar.h b/sys/dev/wscons/wsmousevar.h
index cc20831bb11..99e83e9db20 100644
--- a/sys/dev/wscons/wsmousevar.h
+++ b/sys/dev/wscons/wsmousevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmousevar.h,v 1.4 2002/03/27 18:54:09 jbm Exp $ */
+/* $OpenBSD: wsmousevar.h,v 1.5 2007/04/10 22:37:17 miod Exp $ */
/* $NetBSD: wsmousevar.h,v 1.4 2000/01/08 02:57:24 takemura Exp $ */
/*
@@ -71,8 +71,9 @@ int wsmousedevprint(void *, const char *);
#define WSMOUSE_INPUT_ABSOLUTE_X (1<<0)
#define WSMOUSE_INPUT_ABSOLUTE_Y (1<<1)
#define WSMOUSE_INPUT_ABSOLUTE_Z (1<<2)
+#define WSMOUSE_INPUT_ABSOLUTE_W (1<<4)
#define WSMOUSE_INPUT_WSMOUSED_CLOSE (1<<3) /* notify wsmoused(8) to close
mouse device */
void wsmouse_input(struct device *kbddev, u_int btns,
- int x, int y, int z, u_int flags);
+ int x, int y, int z, int w, u_int flags);