/*-
* Copyright (c) 1999
* Shin Takemura and PocketBSD Project. 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 the PocketBSD project
* and its contributors.
* 4. Neither the name of the project 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.
*
*/
if (button_config[id].kevent) {
u_int evtype;
evtype = msg ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
#ifdef WSDISPLAY_COMPAT_RAWKBD
if (sc->sc_rawkbd) {
int n;
u_char data[16];
n = pckbd_encode(evtype, button_config[id].keycode,
data);
wskbd_rawinput(sc->sc_wskbddev, data, n);
} else
#endif
wskbd_input(sc->sc_wskbddev, evtype,
button_config[id].keycode);
}
if (id == CONFIG_HOOK_BUTTONEVENT_POWER && msg)
config_hook_call(CONFIG_HOOK_PMEVENT,
CONFIG_HOOK_PMEVENT_SUSPENDREQ, NULL);
else if (id == CONFIG_HOOK_BUTTONEVENT_COVER)
config_hook_call(CONFIG_HOOK_POWERCONTROL,
CONFIG_HOOK_POWERCONTROL_LCDLIGHT, (void*)(msg ? 0: 1));
return (0);
}
const char *
btnmgr_name(long id)
{
if (id < n_button_config)
return (button_config[id].name);
return ("unknown");
}
int
btnmgr_wskbd_enable(void *scx, int on)
{
struct btnmgr_softc *sc = scx;
if (on) {
if (sc->sc_enabled)
return (EBUSY);
sc->sc_enabled = 1;
} else {
sc->sc_enabled = 0;
}
return (0);
}
void
btnmgr_wskbd_set_leds(void *scx, int leds)
{
/*
* We have nothing to do.
*/
}
int
btnmgr_wskbd_ioctl(void *scx, u_long cmd, void *data, int flag,
struct lwp *l)
{
#ifdef WSDISPLAY_COMPAT_RAWKBD
struct btnmgr_softc *sc = scx;
#endif
switch (cmd) {
case WSKBDIO_GTYPE:
*(int *)data = WSKBD_TYPE_HPC_BTN;
return (0);
case WSKBDIO_SETLEDS:
DPRINTF(("%s(%d): no LED\n", __FILE__, __LINE__));
return (0);
case WSKBDIO_GETLEDS:
DPRINTF(("%s(%d): no LED\n", __FILE__, __LINE__));
*(int *)data = 0;
return (0);
#ifdef WSDISPLAY_COMPAT_RAWKBD
case WSKBDIO_SETMODE:
sc->sc_rawkbd = (*(int *)data == WSKBD_RAW);
DPRINTF(("%s(%d): rawkbd is %s\n", __FILE__, __LINE__,
sc->sc_rawkbd ? "on" : "off"));
return (0);
#endif
}
return (EPASSTHROUGH);
}
#ifdef notyet
int
btnmgropen(dev_t dev, int flag, int mode, struct lwp *l)
{
return (EINVAL);
}
int
btnmgrclose(dev_t dev, int flag, int mode, struct lwp *l)
{
return (EINVAL);
}
int
btnmgrread(dev_t dev, struct uio *uio, int flag)
{
return (EINVAL);
}
int
btnmgrwrite(dev_t dev, struct uio *uio, int flag)
{
return (EINVAL);
}
int
btnmgrioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
return (EINVAL);
}
#endif /* notyet */