/*-
* Copyright (c) 2001 Marcus Comstedt
* 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 Marcus Comstedt.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
static int
mkbddetach(device_t self, int flags)
{
struct mkbd_softc *sc = device_private(self);
int rv = 0;
if (sc == mkbd_console_softc) {
/*
* Hack to allow another Maple keyboard to be new console.
* XXX Should some other type device can be console.
*/
printf("%s: was console keyboard\n", device_xname(sc->sc_dev));
wskbd_cndetach();
mkbd_console_softc = NULL;
mkbd_console_initted = 0;
mkbd_is_console = 1;
}
if (sc->sc_wskbddev)
rv = config_detach(sc->sc_wskbddev, flags);
return rv;
}
int
mkbd_enable(void *v, int on)
{
return 0;
}
void
mkbd_set_leds(void *v, int on)
{
}
int
mkbd_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
{
switch (cmd) {
case WSKBDIO_GTYPE:
*(int *) data = WSKBD_TYPE_MAPLE;
return 0;
case WSKBDIO_SETLEDS:
return 0;
case WSKBDIO_GETLEDS:
*(int *) data = 0;
return 0;
case WSKBDIO_COMPLEXBELL:
return 0;
}
if ((flags & MAPLE_FLAG_PERIODIC) &&
sz >= sizeof(struct mkbd_condition)) {
int i, j, v;
v = sc->sc_condition.shift & ~kbddata->shift;
if (v)
for (i = 0; i < 8; i++)
if (v & (1 << i))
SHIFT_UP(i);
v = kbddata->shift & ~sc->sc_condition.shift;
if (v)
for (i = 0; i < 8; i++)
if (v & (1 << i))
SHIFT_DOWN(i);
for (i = 0, j = 0; i < 6; i++)
if (sc->sc_condition.key[i] < 4)
break;
else if (sc->sc_condition.key[i] == kbddata->key[j])
j++;
else
KEY_UP(sc->sc_condition.key[i]);
for (; j < 6; j++)
if (kbddata->key[j] < 4)
break;
else
KEY_DOWN(kbddata->key[j]);