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