/*
* Copyright (c) 2004 Steve Rumble
* 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. 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.
*/
/*
* EWS4800 serial mouse driver attached to zs channel 0 at 4800 or 1200bps.
* This layer feeds wsmouse.
*
* 5 byte packets: sync, x1, y1, x2, y2
* sync format: binary 10000LMR (left, middle, right) 0 is down
*
* This driver is taken from sgimips, but ews4800 has the similar protocol.
*/
/* No need to keep score if nobody is listening */
if (!sc->sc_enabled) {
sc->sc_rxq_head = sc->sc_rxq_tail;
return;
}
/*
* Here's the real action. Read a full packet and
* then let wsmouse know what has happened.
*/
while (sc->sc_rxq_head != sc->sc_rxq_tail) {
int8_t c = sc->sc_rxq[sc->sc_rxq_head];
switch (sc->sc_state) {
case EWSMS_STATE_SYNC:
sync = EWSMS_SYNC0;
if (sc->sc_flags & EWSMS_F_SYNC1)
sync = EWSMS_SYNC1;
if ((c & EWSMS_SYNC_MASK) == sync) {
sc->sc_packet[EWSMS_PACKET_SYNC] = c;
sc->sc_state = EWSMS_STATE_X1;
}
break;
case EWSMS_STATE_X1:
sc->sc_packet[EWSMS_PACKET_X1] = c;
sc->sc_state = EWSMS_STATE_Y1;
break;
case EWSMS_STATE_Y1:
sc->sc_packet[EWSMS_PACKET_Y1] = c;
sc->sc_state = EWSMS_STATE_X2;
break;
case EWSMS_STATE_X2:
sc->sc_packet[EWSMS_PACKET_X2] = c;
sc->sc_state = EWSMS_STATE_Y2;
break;
case EWSMS_STATE_Y2:
sc->sc_packet[EWSMS_PACKET_Y2] = c;
/* delta values are signed */
/* moving left is minus, moving right is plus */
dx = (int)sc->sc_packet[EWSMS_PACKET_X1] +
(int)sc->sc_packet[EWSMS_PACKET_X2];
/* moving back is minus, moving front is plus */
dy = (int)sc->sc_packet[EWSMS_PACKET_Y1] +
(int)sc->sc_packet[EWSMS_PACKET_Y2];
static int
ewsms_wsmouse_ioctl(void *cookie, u_long cmd, void *data, int flag,
struct lwp *l)
{
switch (cmd) {
case WSMOUSEIO_GTYPE:
*(u_int *)data = 0;
break;
#ifdef notyet
case WSMOUSEIO_SRES:
case WSMOUSEIO_SSCALE:
case WSMOUSEIO_SRATE:
case WSMOUSEIO_SCALIBCOORDS:
case WSMOUSEIO_GCALIBCOORDS:
case WSMOUSEIO_GETID:
#endif