/*
* Copyright (c) 2004 Valeriy E. Ushakov
* 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.
*/
struct tty *sc_tp; /* back reference to the tty */
device_t sc_wskbd; /* wskbd child */
int sc_enabled;
#ifdef WSDISPLAY_COMPAT_RAWKBD
int sc_rawkbd;
#endif
};
/*
* It doesn't need to be exported, as only hpf1275aattach() uses it,
* but there's no "official" way to make it static.
*/
CFATTACH_DECL_NEW(hpf1275a, sizeof(struct hpf1275a_softc),
hpf1275a_match, hpf1275a_attach, hpf1275a_detach, NULL);
/*
* Autoconf match routine.
*
* XXX: unused: config_attach_pseudo(9) does not call ca_match.
*/
static int
hpf1275a_match(device_t self, cfdata_t cfdata, void *arg)
{
/* pseudo-device; always present */
return (1);
}
/*
* Autoconf attach routine. Called by config_attach_pseudo(9) when we
* open the line discipline.
*/
static void
hpf1275a_attach(device_t parent, device_t self, void *aux)
{
struct hpf1275a_softc *sc = device_private(self);
struct wskbddev_attach_args wska;
/*
* Autoconf detach routine. Called when we close the line discipline.
*/
static int
hpf1275a_detach(device_t self, int flags)
{
struct hpf1275a_softc *sc = device_private(self);
int error;
error = config_detach_children(self, flags);
if (error)
return error;
/*
* Feed input from the keyboard to wskbd(4).
*/
static int
hpf1275a_input(int c, struct tty *tp)
{
struct hpf1275a_softc *sc = tp->t_sc;
int code;
u_int type;
int xtscan;
if (!sc->sc_enabled)
return (0);
if (c & TTY_ERRORMASK)
return (0); /* TODO? */
code = c & TTY_CHARMASK;
if (code & 0x80) {
type = WSCONS_EVENT_KEY_UP;
code &= ~0x80;
} else
type = WSCONS_EVENT_KEY_DOWN;