1 /* $NetBSD: ms.c,v 1.5 2006/11/12 19:00:43 plunky Exp $ */
4 * Copyright (c) 2001 Izumi Tsutsui. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Copyright (c) 2000 Tsubai Masanari. All rights reserved.
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. The name of the author may not be used to endorse or promote products
39 * derived from this software without specific prior written permission.
41 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
42 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
45 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 #include <sys/cdefs.h>
54 __KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.5 2006/11/12 19:00:43 plunky Exp $");
56 #include <sys/param.h>
57 #include <sys/device.h>
58 #include <sys/systm.h>
60 #include <dev/wscons/wsconsio.h>
61 #include <dev/wscons/wsmousevar.h>
63 #include <machine/cpu.h>
64 #include <machine/bus.h>
66 #include <news68k/dev/msvar.h>
69 ms_intr(struct ms_softc
*sc
)
71 bus_space_tag_t bt
= sc
->sc_bt
;
72 bus_space_handle_t bh
= sc
->sc_bh
;
73 bus_size_t offset
= sc
->sc_offset
;
74 int code
, index
, byte0
, byte1
, byte2
;
77 if (sc
->sc_wsmousedev
== NULL
)
80 code
= bus_space_read_1(bt
, bh
, offset
);
83 if (code
& MS_S_MARK
) {
84 sc
->sc_buf
[MS_S_BYTE
] = code
;
85 sc
->sc_ndata
= MS_X_BYTE
;
89 if (index
== MS_X_BYTE
) {
90 sc
->sc_buf
[MS_X_BYTE
] = code
;
91 sc
->sc_ndata
= MS_Y_BYTE
;
95 if (index
== MS_Y_BYTE
) {
96 sc
->sc_buf
[MS_Y_BYTE
] = code
;
99 byte0
= sc
->sc_buf
[MS_S_BYTE
];
100 byte1
= sc
->sc_buf
[MS_X_BYTE
];
101 byte2
= sc
->sc_buf
[MS_Y_BYTE
];
104 if (byte0
& MS_S_SW1
)
106 if (byte0
& MS_S_SW3
)
108 if (byte0
& MS_S_SW2
)
111 dx
= byte1
& MS_X_DATA
;
112 if (byte0
& MS_S_XSIGN
)
114 dy
= byte2
& MS_Y_DATA
;
115 if (byte0
& MS_S_YSIGN
)
118 wsmouse_input(sc
->sc_wsmousedev
,
121 WSMOUSE_INPUT_DELTA
);