Absolute pointing device support.

- Wsmouse_input() get new argument 'flag', which indicates whether x/y/z are
   relative or absolute.
 - Wsmouse get new io controls, WSMOUSEIO_SCALIBCOORDS and
   WSMOUSEIO_GCALIBCOORDS.
This commit is contained in:
takemura 2000-01-08 02:57:22 +00:00
parent db96c5344b
commit ba04c55ed3
13 changed files with 140 additions and 110 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vrpiu.c,v 1.1 1999/12/28 03:15:18 takemura Exp $ */
/* $NetBSD: vrpiu.c,v 1.2 2000/01/08 02:57:24 takemura Exp $ */
/*
* Copyright (c) 1999 Shin Takemura All rights reserved.
@ -71,7 +71,6 @@ static u_short vrpiu_read __P((struct vrpiu_softc *, int));
static int vrpiu_intr __P((void *));
static void vrpiu_reset_param __P((struct vrpiu_softc *sc));
static void vrpiu_timeout __P((void *));
#ifdef DEBUG
static void vrpiu_dump_cntreg __P((unsigned int cmd));
#endif
@ -260,8 +259,6 @@ vrpiu_enable(v)
sc->sc_stat = (cnt & PIUCNT_PENSTC) ?
VRPIU_STAT_TOUCH : VRPIU_STAT_RELEASE;
sc->sc_timeout = 1;
splx(s);
return 0;
@ -272,7 +269,6 @@ vrpiu_disable(v)
void *v;
{
struct vrpiu_softc *sc = v;
int s;
DPRINTF(("%s(%d): vrpiu_disable()\n", __FILE__, __LINE__));
@ -286,12 +282,6 @@ vrpiu_disable(v)
/* mask clock to PIU */
__vrcmu_supply(CMUMSKPIU, 1);
s = spltty();
if (!sc->sc_timeout) {
untimeout(vrpiu_timeout, sc);
}
splx(s);
}
int
@ -308,7 +298,7 @@ vrpiu_ioctl(v, cmd, data, flag, p)
switch (cmd) {
case WSMOUSEIO_GTYPE:
*(u_int *)data = WSMOUSE_TYPE_PS2;
*(u_int *)data = WSMOUSE_TYPE_TPANEL;
break;
case WSMOUSEIO_SRES:
@ -391,34 +381,22 @@ vrpiu_intr(arg)
*/
DPRINTF(("PEN TOUCH\n"));
sc->sc_stat = VRPIU_STAT_TOUCH;
if (sc->sc_timeout) {
sc->sc_timeout = 0;
sc->sc_releasecount = 0;
timeout(vrpiu_timeout, sc, hz/3);
}
/* button 0 DOWN */
wsmouse_input(sc->sc_wsmousedev,
(1 << 0),
0, 0, 0, 0);
}
} else {
if (sc->sc_stat == VRPIU_STAT_TOUCH ||
sc->sc_stat == VRPIU_STAT_DRAG) {
if (sc->sc_stat == VRPIU_STAT_TOUCH) {
/*
* pen release
*/
DPRINTF(("RELEASE\n"));
sc->sc_stat = VRPIU_STAT_RELEASE;
if (!sc->sc_timeout) {
if (++sc->sc_releasecount == 2) {
untimeout(vrpiu_timeout, sc);
sc->sc_timeout = 1;
DPRINTF(("TAP!\n"));
/* button 0 DOWN */
wsmouse_input(sc->sc_wsmousedev,
(1 << 0),
0, 0, 0);
/* button 0 UP */
wsmouse_input(sc->sc_wsmousedev,
0, 0, 0, 0);
}
}
/* button 0 UP */
wsmouse_input(sc->sc_wsmousedev,
0,
0, 0, 0, 0);
}
}
@ -455,22 +433,13 @@ vrpiu_intr(arg)
if (sc->sc_prmys <= y)
y = sc->sc_prmys - 1;
DPRINTF(("->%4d %4d", x, y));
if (sc->sc_stat == VRPIU_STAT_TOUCH) {
sc->sc_stat = VRPIU_STAT_DRAG;
sc->sc_x = x;
sc->sc_y = y;
} else
if (sc->sc_stat == VRPIU_STAT_DRAG) {
DPRINTF((" delta %d %d",
x - sc->sc_x, y - sc->sc_y));
wsmouse_input(sc->sc_wsmousedev,
0, /* all buttons up */
x - sc->sc_x, /* dx */
y - sc->sc_y, /* dy */
0); /* dz */
sc->sc_x = x;
sc->sc_y = y;
}
wsmouse_input(sc->sc_wsmousedev,
(cnt & PIUCNT_PENSTC) ? 1 : 0,
x, /* x */
y, /* y */
0, /* z */
WSMOUSE_INPUT_ABSOLUTE_X |
WSMOUSE_INPUT_ABSOLUTE_Y);
DPRINTF(("\n"));
}
}
@ -498,14 +467,6 @@ vrpiu_reset_param(sc)
sc->sc_prmys = PIUPB_PADDATA_MAX;
}
void
vrpiu_timeout(arg)
void *arg;
{
struct vrpiu_softc *sc = arg;
sc->sc_timeout = 1;
}
#ifdef DEBUG
void
vrpiu_dump_cntreg(cnt)

View File

@ -1,4 +1,4 @@
/* $NetBSD: vrpiuvar.h,v 1.1 1999/12/28 03:15:19 takemura Exp $ */
/* $NetBSD: vrpiuvar.h,v 1.2 2000/01/08 02:57:25 takemura Exp $ */
/*
* Copyright (c) 1999 Shin Takemura All rights reserved.
@ -31,7 +31,6 @@ enum vrpiu_stat {
VRPIU_STAT_DISABLE,
VRPIU_STAT_RELEASE,
VRPIU_STAT_TOUCH,
VRPIU_STAT_DRAG,
};
struct vrpiu_softc {
@ -43,9 +42,6 @@ struct vrpiu_softc {
enum vrpiu_stat sc_stat;
struct device *sc_wsmousedev;
int sc_x, sc_y;
int sc_timeout;
int sc_releasecount;
/* correction parameters */
int sc_prmax, sc_prmbx, sc_prmcx, sc_prmxs;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lms.c,v 1.37 1999/01/23 15:03:50 drochner Exp $ */
/* $NetBSD: lms.c,v 1.38 2000/01/08 02:57:25 takemura Exp $ */
/*-
* Copyright (c) 1993, 1994 Charles M. Hannum.
@ -248,7 +248,7 @@ lmsintr(arg)
if (dx || dy || changed)
wsmouse_input(sc->sc_wsmousedev,
buttons, dx, dy, 0);
buttons, dx, dy, 0, WSMOUSE_INPUT_DELTA);
return -1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mms.c,v 1.34 1999/01/23 15:03:50 drochner Exp $ */
/* $NetBSD: mms.c,v 1.35 2000/01/08 02:57:25 takemura Exp $ */
/*-
* Copyright (c) 1993, 1994 Charles M. Hannum.
@ -242,7 +242,7 @@ mmsintr(arg)
if (dx || dy || changed)
wsmouse_input(sc->sc_wsmousedev,
buttons, dx, dy, 0);
buttons, dx, dy, 0, WSMOUSE_INPUT_DELTA);
return -1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ams.c,v 1.7 1999/08/16 06:28:09 tsubai Exp $ */
/* $NetBSD: ams.c,v 1.8 2000/01/08 02:57:25 takemura Exp $ */
/*
* Copyright (C) 1998 Colin Wood
@ -547,7 +547,8 @@ ms_processevent(event, msc)
if (msc->sc_wsmousedev)
wsmouse_input(msc->sc_wsmousedev, new_event.u.m.buttons,
new_event.u.m.dx, -new_event.u.m.dy, 0);
new_event.u.m.dx, -new_event.u.m.dy, 0,
WSMOUSE_INPUT_DELTA);
#if NAED > 0
aed_input(&new_event);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: vsxxx.c,v 1.1 1999/11/20 04:55:30 nisimura Exp $ */
/* $NetBSD: vsxxx.c,v 1.2 2000/01/08 02:57:22 takemura Exp $ */
/*
* Copyright (c) 1999 Tohru Nishimura. All rights reserved.
@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: vsxxx.c,v 1.1 1999/11/20 04:55:30 nisimura Exp $");
__KERNEL_RCSID(0, "$NetBSD: vsxxx.c,v 1.2 2000/01/08 02:57:22 takemura Exp $");
/*
* Common machinary for VSXXX mice and tablet
@ -141,5 +141,6 @@ vsxxx_input(data)
x = -x;
if ((sc->sc_report.raw[0] & VS_Y_SIGN) != 0)
y = -y; /* Eeeh? */
wsmouse_input(sc->sc_wsmousedev, sc->sc_report.raw[0] & 07, x, y, 0);
wsmouse_input(sc->sc_wsmousedev, sc->sc_report.raw[0] & 07, x, y, 0,
WSMOUSE_INPUT_DELTA);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: zsms.c,v 1.5 1999/10/26 18:20:44 drochner Exp $ */
/* $NetBSD: zsms.c,v 1.6 2000/01/08 02:57:22 takemura Exp $ */
/*
* Copyright (c) 1992, 1993
@ -305,7 +305,7 @@ zsms_input(vsc, data)
else
sc->dy = data;
wsmouse_input(sc->sc_wsmousedev, sc->buttons,
sc->dx, sc->dy, 0);
sc->dx, sc->dy, 0, WSMOUSE_INPUT_DELTA);
}
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: psm.c,v 1.9 1999/12/03 22:48:25 thorpej Exp $ */
/* $NetBSD: psm.c,v 1.10 2000/01/08 02:57:23 takemura Exp $ */
/*-
* Copyright (c) 1994 Charles M. Hannum.
@ -319,7 +319,8 @@ int data;
if (sc->dx || dy || changed)
wsmouse_input(sc->sc_wsmousedev,
sc->buttons, sc->dx, dy, 0);
sc->buttons, sc->dx, dy, 0,
WSMOUSE_INPUT_DELTA);
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: psm_intelli.c,v 1.6 1999/12/03 22:48:25 thorpej Exp $ */
/* $NetBSD: psm_intelli.c,v 1.7 2000/01/08 02:57:23 takemura Exp $ */
/*-
* Copyright (c) 1994 Charles M. Hannum.
@ -344,7 +344,8 @@ int data;
if (sc->dx || sc->dy || dz || changed)
wsmouse_input(sc->sc_wsmousedev,
sc->buttons, sc->dx, sc->dy, dz);
sc->buttons, sc->dx, sc->dy, dz,
WSMOUSE_INPUT_DELTA);
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ums.c,v 1.37 1999/12/24 01:14:01 augustss Exp $ */
/* $NetBSD: ums.c,v 1.38 2000/01/08 02:57:24 takemura Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -393,7 +393,8 @@ ums_intr(xfer, addr, status)
sc->sc_buttons = buttons;
if (sc->sc_wsmousedev != NULL) {
s = spltty();
wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, dz);
wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, dz,
WSMOUSE_INPUT_DELTA);
splx(s);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsconsio.h,v 1.23 2000/01/07 03:13:23 enami Exp $ */
/* $NetBSD: wsconsio.h,v 1.24 2000/01/08 02:57:24 takemura Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -156,6 +156,7 @@ struct wskbd_map_data {
#define WSMOUSE_TYPE_USB 3 /* USB mouse */
#define WSMOUSE_TYPE_LMS 4 /* Logitech busmouse */
#define WSMOUSE_TYPE_MMS 5 /* Microsoft InPort mouse */
#define WSMOUSE_TYPE_TPANEL 6 /* Generic Touch Panel */
/* Set resolution. Not applicable to all mouse types. */
#define WSMOUSEIO_SRES _IOR('W', 33, u_int)
@ -172,6 +173,22 @@ struct wskbd_map_data {
#define WSMOUSE_RATE_DEFAULT 50
#define WSMOUSE_RATE_MAX 100
/* Set/get sample coordinates for calibration */
#define WSMOUSE_CALIBCOORDS_MAX 16
#define WSMOUSE_CALIBCOORDS_RESET -1
struct wsmouse_calibcoords {
int minx, miny; /* minimum value of X/Y */
int maxx, maxy; /* maximum value of X/Y */
int samplelen; /* number of samples available or
WSMOUSE_CALIBCOORDS_RESET for raw mode */
struct wsmouse_calibcoord {
int rawx, rawy; /* raw coordinate */
int x, y; /* translated coordinate */
} samples[WSMOUSE_CALIBCOORDS_MAX]; /* sample coordinates */
};
#define WSMOUSEIO_SCALIBCOORDS _IOR('W', 36, struct wsmouse_calibcoords)
#define WSMOUSEIO_GCALIBCOORDS _IOR('R', 37, struct wsmouse_calibcoords)
/*
* Display ioctls (64 - 95)
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsmouse.c,v 1.10 2000/01/05 11:19:37 drochner Exp $ */
/* $NetBSD: wsmouse.c,v 1.11 2000/01/08 02:57:24 takemura Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.10 2000/01/05 11:19:37 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.11 2000/01/08 02:57:24 takemura Exp $");
/*
* Copyright (c) 1992, 1993
@ -107,6 +107,10 @@ __KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.10 2000/01/05 11:19:37 drochner Exp $"
#include <dev/wscons/wsmuxvar.h>
#endif
#define INVALID_X INT_MAX
#define INVALID_Y INT_MAX
#define INVALID_Z INT_MAX
struct wsmouse_softc {
struct device sc_dv;
@ -121,6 +125,9 @@ struct wsmouse_softc {
int sc_dx; /* delta-x */
int sc_dy; /* delta-y */
int sc_dz; /* delta-z */
int sc_x; /* absolute-x */
int sc_y; /* absolute-y */
int sc_z; /* absolute-z */
int sc_refcnt;
u_char sc_dying; /* device is being detached */
@ -276,10 +283,11 @@ wsmouse_detach(self, flags)
}
void
wsmouse_input(wsmousedev, btns, dx, dy, dz)
wsmouse_input(wsmousedev, btns, x, y, z, flags)
struct device *wsmousedev;
u_int btns; /* 0 is up */
int dx, dy, dz;
int x, y, z;
u_int flags;
{
struct wsmouse_softc *sc = (struct wsmouse_softc *)wsmousedev;
struct wscons_event *ev;
@ -300,9 +308,12 @@ wsmouse_input(wsmousedev, btns, dx, dy, dz)
evar = &sc->sc_events;
sc->sc_mb = btns;
sc->sc_dx += dx;
sc->sc_dy += dy;
sc->sc_dz += dz;
if (!(flags & WSMOUSE_INPUT_ABSOLUTE_X))
sc->sc_dx += x;
if (!(flags & WSMOUSE_INPUT_ABSOLUTE_Y))
sc->sc_dy += y;
if (!(flags & WSMOUSE_INPUT_ABSOLUTE_Z))
sc->sc_dz += z;
/*
* We have at least one event (mouse button, delta-X, or
@ -358,29 +369,62 @@ wsmouse_input(wsmousedev, btns, dx, dy, dz)
ADVANCE;
ub ^= d;
}
if (sc->sc_dx) {
NEXT;
ev->type = WSCONS_EVENT_MOUSE_DELTA_X;
ev->value = sc->sc_dx;
TIMESTAMP;
ADVANCE;
sc->sc_dx = 0;
if (flags & WSMOUSE_INPUT_ABSOLUTE_X) {
if (sc->sc_x != x) {
NEXT;
ev->type = WSCONS_EVENT_MOUSE_ABSOLUTE_X;
ev->value = x;
TIMESTAMP;
ADVANCE;
sc->sc_x = x;
}
} else {
if (sc->sc_dx) {
NEXT;
ev->type = WSCONS_EVENT_MOUSE_DELTA_X;
ev->value = sc->sc_dx;
TIMESTAMP;
ADVANCE;
sc->sc_dx = 0;
}
}
if (sc->sc_dy) {
NEXT;
ev->type = WSCONS_EVENT_MOUSE_DELTA_Y;
ev->value = sc->sc_dy;
TIMESTAMP;
ADVANCE;
sc->sc_dy = 0;
if (flags & WSMOUSE_INPUT_ABSOLUTE_Y) {
if (sc->sc_y != y) {
NEXT;
ev->type = WSCONS_EVENT_MOUSE_ABSOLUTE_Y;
ev->value = y;
TIMESTAMP;
ADVANCE;
sc->sc_y = y;
}
} else {
if (sc->sc_dy) {
NEXT;
ev->type = WSCONS_EVENT_MOUSE_DELTA_Y;
ev->value = sc->sc_dy;
TIMESTAMP;
ADVANCE;
sc->sc_dy = 0;
}
}
if (sc->sc_dz) {
NEXT;
ev->type = WSCONS_EVENT_MOUSE_DELTA_Z;
ev->value = sc->sc_dz;
TIMESTAMP;
ADVANCE;
sc->sc_dz = 0;
if (flags & WSMOUSE_INPUT_ABSOLUTE_Z) {
if (sc->sc_z != z) {
NEXT;
ev->type = WSCONS_EVENT_MOUSE_ABSOLUTE_Z;
ev->value = z;
TIMESTAMP;
ADVANCE;
sc->sc_z = z;
}
} else {
if (sc->sc_dz) {
NEXT;
ev->type = WSCONS_EVENT_MOUSE_DELTA_Z;
ev->value = sc->sc_dz;
TIMESTAMP;
ADVANCE;
sc->sc_dz = 0;
}
}
out:
if (any) {
@ -424,6 +468,9 @@ wsmouseopen(dev, flags, mode, p)
wsevent_init(&sc->sc_events); /* may cause sleep */
sc->sc_ready = 1; /* start accepting events */
sc->sc_x = INVALID_X;
sc->sc_y = INVALID_Y;
sc->sc_z = INVALID_Z;
/* enable the device, and punt if that's not possible */
error = (*sc->sc_accessops->enable)(sc->sc_accesscookie);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsmousevar.h,v 1.3 1999/07/29 18:20:03 augustss Exp $ */
/* $NetBSD: wsmousevar.h,v 1.4 2000/01/08 02:57:24 takemura Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -68,5 +68,9 @@ int wsmousedevprint __P((void *, const char *));
/*
* Callbacks from the mouse driver to the wsmouse interface driver.
*/
#define WSMOUSE_INPUT_DELTA 0
#define WSMOUSE_INPUT_ABSOLUTE_X (1<<0)
#define WSMOUSE_INPUT_ABSOLUTE_Y (1<<1)
#define WSMOUSE_INPUT_ABSOLUTE_Z (1<<2)
void wsmouse_input __P((struct device *kbddev, u_int btns,
int dx, int dy, int dz));
int x, int y, int z, u_int flags));