Introduce wscons vsxxx mice (and possible tablet) routines; changes
of existing codes (lk201_ws.c, zskbd.c, and zsms.c) will follow.
This commit is contained in:
parent
f73590bbf0
commit
40f7514028
145
sys/dev/dec/vsxxx.c
Normal file
145
sys/dev/dec/vsxxx.c
Normal file
@ -0,0 +1,145 @@
|
||||
/* $NetBSD: vsxxx.c,v 1.1 1999/11/20 04:55:30 nisimura Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Tohru Nishimura. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Tohru Nishimura.
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#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 $");
|
||||
|
||||
/*
|
||||
* Common machinary for VSXXX mice and tablet
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wsmousevar.h>
|
||||
|
||||
#include <dev/dec/vsxxxvar.h>
|
||||
|
||||
/*
|
||||
* XXX XXX XXX
|
||||
*
|
||||
* collect various mice and tablet parameters/protocol design
|
||||
* and establish vsxxx.h
|
||||
*
|
||||
* XXX XXX XXX
|
||||
*/
|
||||
#define VS_SELFTEST 'T'
|
||||
#define VS_INCREMENTAL 'R'
|
||||
#define VS_PROMPTING 'D'
|
||||
#define VS_REQ_POSITION 'P'
|
||||
|
||||
#define VS_MOUSE_REPSZ 3
|
||||
#define VS_TABLET_REPSZ 5
|
||||
|
||||
/* first octet */
|
||||
#define VS_START_FRAME 0x80
|
||||
#define VS_R_BUTTON 0x01
|
||||
#define VS_M_BUTTON 0x02
|
||||
#define VS_L_BUTTON 0x04
|
||||
#define VS_Y_SIGN 0x08
|
||||
#define VS_X_SIGN 0x10
|
||||
|
||||
/* low order 4 bit of the second octet in a SELFTEST reply */
|
||||
#define VS_MOUSE 0x2
|
||||
#define VS_TABLET 0x4
|
||||
|
||||
extern struct cfdriver vsms_cd;
|
||||
|
||||
static int vsxxx_enable __P((void *));
|
||||
static int vsxxx_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
|
||||
static void vsxxx_disable __P((void *));
|
||||
|
||||
struct wsmouse_accessops vsxxx_accessops = { /* EXPORT */
|
||||
vsxxx_enable, /* MD? */
|
||||
vsxxx_ioctl,
|
||||
vsxxx_disable, /* MD? */
|
||||
};
|
||||
|
||||
static int
|
||||
vsxxx_enable(v)
|
||||
void *v;
|
||||
{
|
||||
/* turn on the hardware? */
|
||||
((struct vsxxx_softc *)v)->sc_nbyte = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
vsxxx_disable(v)
|
||||
void *v;
|
||||
{
|
||||
/* turn off the hardware? */
|
||||
}
|
||||
|
||||
/*ARGUSED*/
|
||||
static int
|
||||
vsxxx_ioctl(v, cmd, data, flag, p)
|
||||
void *v;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
if (cmd == WSMOUSEIO_GTYPE) {
|
||||
*(u_int *)data = WSMOUSE_TYPE_VSXXX;
|
||||
return 0;
|
||||
}
|
||||
return ENOTTY;
|
||||
}
|
||||
|
||||
/* EXPORT */ void
|
||||
vsxxx_input(data)
|
||||
int data;
|
||||
{
|
||||
struct vsxxx_softc *sc = (void *)vsms_cd.cd_devs[0];
|
||||
int x, y;
|
||||
|
||||
if (data & VS_START_FRAME)
|
||||
sc->sc_nbyte = 0;
|
||||
|
||||
sc->sc_report.raw[sc->sc_nbyte++] = data;
|
||||
|
||||
if (sc->sc_nbyte < VS_MOUSE_REPSZ)
|
||||
return;
|
||||
sc->sc_nbyte = 0;
|
||||
|
||||
x = sc->sc_report.ms.xpos;
|
||||
y = sc->sc_report.ms.ypos;
|
||||
if ((sc->sc_report.raw[0] & VS_X_SIGN) == 0)
|
||||
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);
|
||||
}
|
55
sys/dev/dec/vsxxxvar.h
Normal file
55
sys/dev/dec/vsxxxvar.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* $NetBSD: vsxxxvar.h,v 1.1 1999/11/20 04:55:30 nisimura Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Tohru Nishimura. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Tohru Nishimura.
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
struct vsxxx_softc {
|
||||
struct device sc_dev;
|
||||
struct device *sc_wsmousedev;
|
||||
unsigned sc_nbyte;
|
||||
union {
|
||||
u_int8_t raw[4];
|
||||
struct {
|
||||
u_int8_t data;
|
||||
u_int8_t xpos;
|
||||
u_int8_t ypos;
|
||||
} ms;
|
||||
#if 0
|
||||
struct {
|
||||
u_int8_t data;
|
||||
u_int8_t xloc[2];
|
||||
u_int8_t yloc[2];
|
||||
} tb;
|
||||
#endif
|
||||
} sc_report;
|
||||
};
|
||||
|
||||
extern struct wsmouse_accessops vsxxx_accessops;
|
||||
void vsxxx_input __P((int));
|
Loading…
Reference in New Issue
Block a user