/*
* Copyright (c) 1995 Leo Weppelman.
* All rights reserved.
*
* based on:
*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Lawrence Berkeley Laboratory.
*
* 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)ms.c 8.1 (Berkeley) 6/11/93
*
* Header: ms.c,v 1.5 92/11/26 01:28:47 torek Exp (LBL)
*/
rel_ms.id = TIMEOUT_ID;
rel_ms.dx = rel_ms.dy = 0;
mouse_soft(&rel_ms, sizeof(rel_ms), KBD_TIMEO_PKG);
}
/*
* Note that we are called from the keyboard software interrupt!
*/
void
mouse_soft(REL_MOUSE *rel_ms, int size, int type)
{
struct ms_softc *ms = &ms_softc[0];
struct firm_event *fe, *fe2;
REL_MOUSE fake_mouse;
int get, put;
int s;
uint8_t mbut, bmask;
int flush_buttons;
if (ms->ms_events.ev_io == NULL)
return;
switch (type) {
case KBD_JOY1_PKG:
/*
* Ignore if in emulation mode
*/
if (ms->ms_emul3b)
return;
/*
* There are some mice that have their middle button
* wired to the 'up' bit of joystick 1....
* Simulate a mouse packet with dx = dy = 0, the middle
* button state set by UP and the other buttons unchanged.
* Flush all button changes.
*/
flush_buttons = 1;
fake_mouse.id = ((rel_ms->dx & 0x01) != 0 ? 0x04 : 0x00) |
(ms->ms_buttons & 0x03);
fake_mouse.dx = fake_mouse.dy = 0;
rel_ms = &fake_mouse;
break;
case KBD_TIMEO_PKG:
/*
* Timeout package. No button changes and no movement.
* Flush all button changes.
*/
flush_buttons = 1;
fake_mouse.id = ms->ms_buttons;
fake_mouse.dx = fake_mouse.dy = 0;
rel_ms = &fake_mouse;
break;
case KBD_RMS_PKG:
/*
* Normal mouse package. Always copy the middle button
* status. The emulation code decides if button changes
* must be flushed.
*/
rel_ms->id = (ms->ms_buttons & 0x04) | (rel_ms->id & 0x03);
flush_buttons = ms->ms_emul3b ? 0 : 1;
break;
default:
return;
}
s = splev();
get = ms->ms_events.ev_get;
put = ms->ms_events.ev_put;
fe = &ms->ms_events.ev_q[put];