diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-01-11 18:59:58 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-01-11 18:59:58 +0000 |
commit | f4c08b2bdaae60f2d643527d5821429adcd29729 (patch) | |
tree | b761b4cdcb6bf2e410ed10cdf67d007307ae5521 /sys/dev/sun | |
parent | 5e1c994afb882b4f20685da186237cf8985335c2 (diff) |
WSDISPLAY_COMPAT_RAWKBD support for sun serial keyboards (zskbd, comkbd).
Diffstat (limited to 'sys/dev/sun')
-rw-r--r-- | sys/dev/sun/sunkbd.c | 79 | ||||
-rw-r--r-- | sys/dev/sun/sunkbdmap.c | 141 | ||||
-rw-r--r-- | sys/dev/sun/sunkbdvar.h | 12 |
3 files changed, 226 insertions, 6 deletions
diff --git a/sys/dev/sun/sunkbd.c b/sys/dev/sun/sunkbd.c index 4ad9e80bc9e..83764933fe6 100644 --- a/sys/dev/sun/sunkbd.c +++ b/sys/dev/sun/sunkbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunkbd.c,v 1.22 2009/01/11 15:53:58 miod Exp $ */ +/* $OpenBSD: sunkbd.c,v 1.23 2009/01/11 18:59:54 miod Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -39,6 +39,9 @@ #include <dev/wscons/wsconsio.h> #include <dev/wscons/wskbdvar.h> +#ifdef WSDISPLAY_COMPAT_RAWKBD +#include <dev/wscons/wskbdraw.h> +#endif #include <dev/sun/sunkbdreg.h> #include <dev/sun/sunkbdvar.h> @@ -69,6 +72,10 @@ struct wskbd_accessops sunkbd_accessops = { void sunkbd_attach(struct sunkbd_softc *sc, struct wskbddev_attach_args *waa) { +#ifdef WSDISPLAY_COMPAT_RAWKBD + timeout_set(&sc->sc_rawrepeat_tmo, sunkbd_rawrepeat, sc); +#endif + sc->sc_wskbddev = config_found((struct device *)sc, waa, wskbddevprint); } @@ -155,10 +162,54 @@ sunkbd_input(struct sunkbd_softc *sc, u_int8_t *buf, u_int buflen) { u_int type; int value; + int s; + + if (sc->sc_wskbddev == NULL) + return; /* why bother */ + +#ifdef WSDISPLAY_COMPAT_RAWKBD + if (sc->sc_rawkbd) { + u_char rbuf[SUNKBD_MAX_INPUT_SIZE * 2]; + int c, rlen, npress; + + timeout_del(&sc->sc_rawrepeat_tmo); + + npress = rlen = 0; + while (buflen-- != 0) { + sunkbd_decode(*buf++, &type, &value); + c = sunkbd_rawmap[value]; + if (c == RAWKEY_Null) + continue; + /* fake extended scancode if necessary */ + if (c & 0x80) + rbuf[rlen++] = 0xe0; + rbuf[rlen] = c & 0x7f; + if (type == WSCONS_EVENT_KEY_UP) + rbuf[rlen] |= 0x80; + else { + /* remember down keys for autorepeat */ + if (c & 0x80) + sc->sc_rep[npress++] = 0xe0; + sc->sc_rep[npress++] = c & 0x7f; + } + rlen++; + } - while (buflen-- != 0) { - sunkbd_decode(*buf++, &type, &value); - wskbd_input(sc->sc_wskbddev, type, value); + s = spltty(); + wskbd_rawinput(sc->sc_wskbddev, rbuf, rlen); + splx(s); + sc->sc_nrep = npress; + if (npress != 0) + timeout_add_msec(&sc->sc_rawrepeat_tmo, REP_DELAY1); + } else +#endif + { + s = spltty(); + while (buflen-- != 0) { + sunkbd_decode(*buf++, &type, &value); + wskbd_input(sc->sc_wskbddev, type, value); + } + splx(s); } } @@ -186,6 +237,12 @@ sunkbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) case WSKBDIO_COMPLEXBELL: sunkbd_bell(sc, d_bell->period, d_bell->pitch, d_bell->volume); return (0); +#ifdef WSDISPLAY_COMPAT_RAWKBD + case WSKBDIO_SETMODE: + sc->sc_rawkbd = *(int *)data == WSKBD_RAW; + timeout_del(&sc->sc_rawrepeat_tmo); + return (0); +#endif } return (-1); @@ -233,6 +290,20 @@ sunkbd_raw(struct sunkbd_softc *sc, u_int8_t c) } } +#ifdef WSDISPLAY_COMPAT_RAWKBD +void +sunkbd_rawrepeat(void *v) +{ + struct sunkbd_softc *sc = v; + int s; + + s = spltty(); + wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep); + splx(s); + timeout_add_msec(&sc->sc_rawrepeat_tmo, REP_DELAYN); +} +#endif + int sunkbd_setclick(struct sunkbd_softc *sc, int click) { diff --git a/sys/dev/sun/sunkbdmap.c b/sys/dev/sun/sunkbdmap.c index e4c3cc75f17..b35c57e3c0b 100644 --- a/sys/dev/sun/sunkbdmap.c +++ b/sys/dev/sun/sunkbdmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunkbdmap.c,v 1.1 2005/05/14 15:25:20 miod Exp $ */ +/* $OpenBSD: sunkbdmap.c,v 1.2 2009/01/11 18:59:54 miod Exp $ */ /* * Copyright (c) 2002, 2003 Miodrag Vallat. @@ -46,6 +46,145 @@ #include <dev/sun/sunkbdreg.h> #include <dev/sun/sunkbdvar.h> +#ifdef WSDISPLAY_COMPAT_RAWKBD +#include <dev/wscons/wskbdraw.h> + +/* + * Translate Sun keycodes to US keyboard XT scancodes, for proper + * X11-over-wsmux operation. + */ +const u_int8_t sunkbd_rawmap[0x80] = { + RAWKEY_Null, + RAWKEY_L1, + RAWKEY_AudioLower, + RAWKEY_L2, + RAWKEY_AudioRaise, + RAWKEY_f1, + RAWKEY_f2, + RAWKEY_f10, + RAWKEY_f3, + RAWKEY_f11, + RAWKEY_f4, + RAWKEY_f12, + RAWKEY_f5, + RAWKEY_Alt_R, + RAWKEY_f6, + RAWKEY_Null, + RAWKEY_f7, + RAWKEY_f8, + RAWKEY_f9, + RAWKEY_Alt_L, + RAWKEY_Up, + RAWKEY_Pause, + RAWKEY_Print_Screen, + RAWKEY_Hold_Screen, + RAWKEY_Left, + RAWKEY_L3, + RAWKEY_L4, + RAWKEY_Down, + RAWKEY_Right, + RAWKEY_Escape, + RAWKEY_1, + RAWKEY_2, + RAWKEY_3, + RAWKEY_4, + RAWKEY_5, + RAWKEY_6, + RAWKEY_7, + RAWKEY_8, + RAWKEY_9, + RAWKEY_0, + RAWKEY_minus, + RAWKEY_equal, + RAWKEY_grave, + RAWKEY_BackSpace, + RAWKEY_Insert, + RAWKEY_KP_Equal, + RAWKEY_KP_Divide, + RAWKEY_KP_Multiply, + RAWKEY_Null, + RAWKEY_L5, + RAWKEY_KP_Delete, + RAWKEY_L6, + RAWKEY_Home, + RAWKEY_Tab, + RAWKEY_q, + RAWKEY_w, + RAWKEY_e, + RAWKEY_r, + RAWKEY_t, + RAWKEY_y, + RAWKEY_u, + RAWKEY_i, + RAWKEY_o, + RAWKEY_p, + RAWKEY_bracketleft, + RAWKEY_bracketright, + RAWKEY_Delete, + RAWKEY_Alt_R, + RAWKEY_KP_Home, + RAWKEY_KP_Up, + RAWKEY_KP_Prior, + RAWKEY_KP_Subtract, + RAWKEY_L7, + RAWKEY_L8, + RAWKEY_End, + RAWKEY_Null, + RAWKEY_Control_L, + RAWKEY_a, + RAWKEY_s, + RAWKEY_d, + RAWKEY_f, + RAWKEY_g, + RAWKEY_h, + RAWKEY_j, + RAWKEY_k, + RAWKEY_l, + RAWKEY_semicolon, + RAWKEY_apostrophe, + RAWKEY_backslash, + RAWKEY_Return, + RAWKEY_KP_Enter, + RAWKEY_KP_Left, + RAWKEY_KP_Begin, + RAWKEY_KP_Right, + RAWKEY_KP_Insert, + RAWKEY_L9, + RAWKEY_Prior, + RAWKEY_L10, + RAWKEY_Num_Lock, + RAWKEY_Shift_L, + RAWKEY_z, + RAWKEY_x, + RAWKEY_c, + RAWKEY_v, + RAWKEY_b, + RAWKEY_n, + RAWKEY_m, + RAWKEY_comma, + RAWKEY_period, + RAWKEY_slash, + RAWKEY_Shift_R, + RAWKEY_Null, /* KS_Linefeed on type 3/4 */ + RAWKEY_KP_End, + RAWKEY_KP_Down, + RAWKEY_KP_Next, + RAWKEY_Null, + RAWKEY_Null, + RAWKEY_Null, + RAWKEY_Help, + RAWKEY_Caps_Lock, + RAWKEY_Meta_L, + RAWKEY_space, + RAWKEY_Meta_R, + RAWKEY_Next, + RAWKEY_Null, + RAWKEY_KP_Add, + RAWKEY_Null, + RAWKEY_Null +}; +#endif + #define KC(n) KS_KEYCODE(n) /* 000/021/022 US English type 4/5 keyboard */ diff --git a/sys/dev/sun/sunkbdvar.h b/sys/dev/sun/sunkbdvar.h index db0f1efdb3f..280f4798146 100644 --- a/sys/dev/sun/sunkbdvar.h +++ b/sys/dev/sun/sunkbdvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sunkbdvar.h,v 1.12 2009/01/11 16:12:15 miod Exp $ */ +/* $OpenBSD: sunkbdvar.h,v 1.13 2009/01/11 18:59:54 miod Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -48,6 +48,15 @@ struct sunkbd_softc { struct timeout sc_bellto; struct device *sc_wskbddev; + +#ifdef WSDISPLAY_COMPAT_RAWKBD + int sc_rawkbd; + int sc_nrep; + char sc_rep[SUNKBD_MAX_INPUT_SIZE * 2]; + struct timeout sc_rawrepeat_tmo; +#define REP_DELAY1 400 +#define REP_DELAYN 100 +#endif }; extern struct wskbd_accessops sunkbd_accessops; @@ -75,3 +84,4 @@ extern struct wskbd_mapdata sunkbd5_keymapdata; #define MAXSUNLAYOUT 0x062 extern const int sunkbd_layouts[MAXSUNLAYOUT]; +extern const u_int8_t sunkbd_rawmap[0x80]; |