Some devices provide more than three (X, Y, and Z) "directions". So add

a W "coordinate" that can be used for these.
This changes the type of wsmouse_input().  To avoid changing a lot of drivers
a compatibilty #define is provided.  Maybe changing all drivers would have
been better?
This commit is contained in:
augustss 2005-11-23 09:38:02 +00:00
parent f0b7793c4b
commit 5b71c2bf99
3 changed files with 37 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsconsio.h,v 1.75 2005/08/28 13:08:16 tsutsui Exp $ */
/* $NetBSD: wsconsio.h,v 1.76 2005/11/23 09:38:02 augustss Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -72,6 +72,8 @@ struct wscons_event {
#define WSCONS_EVENT_MOUSE_ABSOLUTE_Z 11 /* Z location */
#define WSCONS_EVENT_SCREEN_SWITCH 12 /* New screen number */
#define WSCONS_EVENT_ASCII 13 /* key code is already ascii */
#define WSCONS_EVENT_MOUSE_DELTA_W 14 /* W delta amount */
#define WSCONS_EVENT_MOUSE_ABSOLUTE_W 15 /* W location */
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsmouse.c,v 1.36 2005/06/21 14:01:13 ws Exp $ */
/* $NetBSD: wsmouse.c,v 1.37 2005/11/23 09:38:02 augustss Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.36 2005/06/21 14:01:13 ws Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.37 2005/11/23 09:38:02 augustss Exp $");
#include "wsmouse.h"
#include "wsdisplay.h"
@ -124,9 +124,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 */
@ -283,8 +285,8 @@ 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)
wsmouse_input_xyzw(struct device *wsmousedev, u_int btns /* 0 is up */,
int x, int y, int z, int w, u_int flags)
{
struct wsmouse_softc *sc = (struct wsmouse_softc *)wsmousedev;
struct wscons_event *ev;
@ -317,6 +319,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 +415,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) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsmousevar.h,v 1.5 2001/10/13 15:56:16 augustss Exp $ */
/* $NetBSD: wsmousevar.h,v 1.6 2005/11/23 09:38:02 augustss Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -72,5 +72,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)
void wsmouse_input(struct device *kbddev, u_int btns,
int x, int y, int z, u_int flags);
#define WSMOUSE_INPUT_ABSOLUTE_W (1<<3)
void wsmouse_input_xyzw(struct device *kbddev, u_int btns,
int x, int y, int z, int w, u_int flags);
/* Provide a define all the old mouse drivers that don't want w. */
#define wsmouse_input(kbddev, btns, x, y, z, flags) \
wsmouse_input_xyzw(kbddev, btns, x, y, z, 0, flags)