diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/hil/hilkbd.c | 87 | ||||
-rw-r--r-- | sys/dev/hil/hilkbdmap.c | 152 | ||||
-rw-r--r-- | sys/dev/hil/hilkbdmap.h | 3 | ||||
-rw-r--r-- | sys/dev/wscons/wskbdraw.h | 165 |
4 files changed, 397 insertions, 10 deletions
diff --git a/sys/dev/hil/hilkbd.c b/sys/dev/hil/hilkbd.c index 2a949cfcf86..970ef4211ea 100644 --- a/sys/dev/hil/hilkbd.c +++ b/sys/dev/hil/hilkbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hilkbd.c,v 1.9 2003/02/26 20:22:54 miod Exp $ */ +/* $OpenBSD: hilkbd.c,v 1.10 2005/01/18 18:52:31 miod Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * All rights reserved. @@ -30,6 +30,8 @@ #include <sys/systm.h> #include <sys/device.h> #include <sys/ioctl.h> +#include <sys/kernel.h> +#include <sys/timeout.h> #include <machine/autoconf.h> #include <machine/bus.h> @@ -43,6 +45,9 @@ #include <dev/wscons/wskbdvar.h> #include <dev/wscons/wsksymdef.h> #include <dev/wscons/wsksymvar.h> +#ifdef WSDISPLAY_COMPAT_RAWKBD +#include <dev/wscons/wskbdraw.h> +#endif #include <dev/hil/hilkbdmap.h> @@ -55,6 +60,15 @@ struct hilkbd_softc { int sc_console; struct device *sc_wskbddev; + +#ifdef WSDISPLAY_COMPAT_RAWKBD + int sc_rawkbd; + int sc_nrep; + char sc_rep[HILBUFSIZE * 2]; + struct timeout sc_rawrepeat_ch; +#define REP_DELAY1 400 +#define REP_DELAYN 100 +#endif }; int hilkbdprobe(struct device *, void *, void *); @@ -102,6 +116,7 @@ void hilkbd_bell(struct hil_softc *, u_int, u_int, u_int); void hilkbd_callback(struct hildev_softc *, u_int, u_int8_t *); void hilkbd_decode(u_int8_t, u_int8_t, u_int *, int *); int hilkbd_is_console(int); +void hilkbd_rawrepeat(void *); int seen_hilkbd_console; @@ -155,6 +170,10 @@ hilkbdattach(struct device *parent, struct device *self, void *aux) printf("\n"); +#ifdef WSDISPLAY_COMPAT_RAWKBD + timeout_set(&sc->sc_rawrepeat_ch, hilkbd_rawrepeat, sc); +#endif + a.console = hilkbd_is_console(ha->ha_console); a.keymap = &hilkbd_keymapdata; a.accessops = &hilkbd_accessops; @@ -263,6 +282,12 @@ hilkbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) case WSKBDIO_GETLEDS: *(int *)data = sc->sc_ledstate; return 0; +#ifdef WSDISPLAY_COMPAT_RAWKBD + case WSKBDIO_SETMODE: + sc->sc_rawkbd = *(int *)data == WSKBD_RAW; + timeout_del(&sc->sc_rawrepeat_ch); + return 0; +#endif case WSKBDIO_COMPLEXBELL: #define d ((struct wskbd_bell_data *)data) hilkbd_bell((struct hil_softc *)sc->hd_parent, @@ -331,7 +356,7 @@ hilkbd_callback(struct hildev_softc *dev, u_int buflen, u_int8_t *buf) struct hilkbd_softc *sc = (struct hilkbd_softc *)dev; u_int type; int key; - int i; + int i, s; /* * Ignore packet if we don't need it @@ -339,12 +364,54 @@ hilkbd_callback(struct hildev_softc *dev, u_int buflen, u_int8_t *buf) if (sc->sc_enabled == 0) return; - if (buflen > 1 && *buf == HIL_KBDDATA) { + if (buflen == 0 || *buf != HIL_KBDDATA) + return; + +#ifdef WSDISPLAY_COMPAT_RAWKBD + if (sc->sc_rawkbd) { + u_char cbuf[HILBUFSIZE * 2]; + int c, j, npress; + + npress = j = 0; + for (i = 1, buf++; i < buflen; i++) { + hilkbd_decode(0, *buf++, &type, &key); + c = hilkbd_raw[key]; + if (c == RAWKEY_Null) + continue; + /* fake extended scancode if necessary */ + if (c & 0x80) + cbuf[j++] = 0xe0; + cbuf[j] = c & 0x7f; + if (type == WSCONS_EVENT_KEY_UP) + cbuf[j] |= 0x80; + else { + /* remember pressed keys for autorepeat */ + if (c & 0x80) + sc->sc_rep[npress++] = 0xe0; + sc->sc_rep[npress++] = c & 0x7f; + } + j++; + } + + s = spltty(); + wskbd_rawinput(sc->sc_wskbddev, cbuf, j); + splx(s); + timeout_del(&sc->sc_rawrepeat_ch); + sc->sc_nrep = npress; + if (npress != 0) { + timeout_add(&sc->sc_rawrepeat_ch, + (hz * REP_DELAY1) / 1000); + } + } else +#endif + { + s = spltty(); for (i = 1, buf++; i < buflen; i++) { hilkbd_decode(0, *buf++, &type, &key); if (sc->sc_wskbddev != NULL) wskbd_input(sc->sc_wskbddev, type, key); } + splx(s); } } @@ -369,3 +436,17 @@ hilkbd_is_console(int hil_is_console) seen_hilkbd_console = 1; return (1); } + +#ifdef WSDISPLAY_COMPAT_RAWKBD +void +hilkbd_rawrepeat(void *v) +{ + struct hilkbd_softc *sc = v; + int s; + + s = spltty(); + wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep); + splx(s); + timeout_add(&sc->sc_rawrepeat_ch, (hz * REP_DELAYN) / 1000); +} +#endif diff --git a/sys/dev/hil/hilkbdmap.c b/sys/dev/hil/hilkbdmap.c index 8ed2427bfe3..36e353d6e14 100644 --- a/sys/dev/hil/hilkbdmap.c +++ b/sys/dev/hil/hilkbdmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hilkbdmap.c,v 1.4 2004/04/06 18:51:22 miod Exp $ */ +/* $OpenBSD: hilkbdmap.c,v 1.5 2005/01/18 18:52:31 miod Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * All rights reserved. @@ -31,6 +31,145 @@ #include <dev/wscons/wsksymvar.h> #include <dev/hil/hilkbdmap.h> +#ifdef WSDISPLAY_COMPAT_RAWKBD +#include <dev/wscons/wskbdraw.h> + +/* + * Translate HIL keycodes to US keyboard XT scancodes, for proper + * X11-over-wsmux operation. + */ +const u_int8_t hilkbd_raw[0x80] = { + RAWKEY_Control_R, + RAWKEY_Null, + RAWKEY_Alt_R, + RAWKEY_Alt_L, + RAWKEY_Shift_R, + RAWKEY_Shift_L, + RAWKEY_Control_L, + RAWKEY_Null, /* 7 Break/Reset */ + RAWKEY_KP_Left, + RAWKEY_KP_Up, + RAWKEY_KP_Begin, + RAWKEY_KP_Prior, + RAWKEY_KP_Right, + RAWKEY_KP_Home, + RAWKEY_comma, /* numeric pad */ + RAWKEY_KP_Enter, + RAWKEY_KP_End, + RAWKEY_KP_Divide, + RAWKEY_KP_Down, + RAWKEY_KP_Add, + RAWKEY_KP_Next, + RAWKEY_KP_Multiply, + RAWKEY_KP_Insert, + RAWKEY_KP_Subtract, + RAWKEY_b, + RAWKEY_v, + RAWKEY_c, + RAWKEY_x, + RAWKEY_z, + RAWKEY_Null, /* 29 Kanji Left */ + RAWKEY_Null, /* 30 */ + RAWKEY_Escape, + RAWKEY_Null, + RAWKEY_f10, + RAWKEY_Null, + RAWKEY_f11, + RAWKEY_KP_Delete, + RAWKEY_f9, + RAWKEY_Tab, + RAWKEY_f12, + RAWKEY_h, + RAWKEY_g, + RAWKEY_f, + RAWKEY_d, + RAWKEY_s, + RAWKEY_a, + RAWKEY_Null, /* 46 */ + RAWKEY_Caps_Lock, + RAWKEY_u, + RAWKEY_y, + RAWKEY_t, + RAWKEY_r, + RAWKEY_e, + RAWKEY_w, + RAWKEY_q, + RAWKEY_Tab, + RAWKEY_7, + RAWKEY_6, + RAWKEY_5, + RAWKEY_4, + RAWKEY_3, + RAWKEY_2, + RAWKEY_1, + RAWKEY_grave, + RAWKEY_Null, /* 64 */ + RAWKEY_Null, /* 65 */ + RAWKEY_Null, /* 66 */ + RAWKEY_Null, /* 67 */ + RAWKEY_Null, /* 68 */ + RAWKEY_Null, /* 69 */ + RAWKEY_Null, /* 70 */ + RAWKEY_Null, /* 71 */ + RAWKEY_Print_Screen, + RAWKEY_f4, + RAWKEY_f3, + RAWKEY_f2, + RAWKEY_f1, + RAWKEY_Null, /* 77 */ + RAWKEY_Hold_Screen, + RAWKEY_Return, + RAWKEY_Num_Lock, + RAWKEY_f5, + RAWKEY_f6, + RAWKEY_f7, + RAWKEY_f8, + RAWKEY_Null, /* 85 */ + RAWKEY_Null, /* 86 Clear line */ + RAWKEY_Null, /* 87 Clear display */ + RAWKEY_8, + RAWKEY_9, + RAWKEY_0, + RAWKEY_minus, + RAWKEY_equal, + RAWKEY_BackSpace, + RAWKEY_Null, /* 94 Insert line */ + RAWKEY_Null, /* 95 Delete line */ + RAWKEY_i, + RAWKEY_o, + RAWKEY_p, + RAWKEY_bracketleft, + RAWKEY_bracketright, + RAWKEY_backslash, + RAWKEY_Insert, + RAWKEY_Delete, + RAWKEY_j, + RAWKEY_k, + RAWKEY_l, + RAWKEY_semicolon, + RAWKEY_apostrophe, + RAWKEY_Return, + RAWKEY_Home, + RAWKEY_Prior, + RAWKEY_m, + RAWKEY_comma, + RAWKEY_period, + RAWKEY_slash, + RAWKEY_Null, /* 116 */ + RAWKEY_End, + RAWKEY_Null, /* 118 */ + RAWKEY_Next, + RAWKEY_n, + RAWKEY_space, + RAWKEY_Null, /* 122 */ + RAWKEY_Null, /* 123 Kanji Right */ + RAWKEY_Left, + RAWKEY_Down, + RAWKEY_Up, + RAWKEY_Right +}; +#endif + #define KC(n) KS_KEYCODE(n) /* @@ -67,6 +206,7 @@ const keysym_t hilkbd_keydesc_us[] = { KC(26), KS_c, KC(27), KS_x, KC(28), KS_z, + /* 29 Kanji Left */ KC(31), KS_Cmd_Debugger, KS_Escape, KS_Delete, KC(33), KS_Cmd_Screen9, KS_f10, /* also KS_KP_F2 */ @@ -81,7 +221,7 @@ const keysym_t hilkbd_keydesc_us[] = { KC(43), KS_d, KC(44), KS_s, KC(45), KS_a, - + /* 46 Mode_Switch ??? */ KC(47), KS_Caps_Lock, KC(48), KS_u, KC(49), KS_y, @@ -140,7 +280,6 @@ const keysym_t hilkbd_keydesc_us[] = { KC(109), KS_Return, KC(110), KS_Home, KC(111), KS_Cmd_ScrollBack, KS_Prior, - KC(112), KS_m, KC(113), KS_comma, KS_less, KC(114), KS_period, KS_greater, @@ -152,6 +291,7 @@ const keysym_t hilkbd_keydesc_us[] = { KC(120), KS_n, KC(121), KS_space, + /* 123 Kanji Right */ KC(124), KS_Left, KC(125), KS_Down, KC(126), KS_Up, @@ -307,7 +447,7 @@ const kbd_t hilkbd_layouts[MAXHILKBDLAYOUT] = { -1, /* 04 Portuguese */ -1, /* 05 Arabic */ -1, /* 06 Hebrew */ - -1, /* 07 Canada English */ + -1, /* 07 Canadian English */ -1, /* 08 Turkish */ -1, /* 09 Greek */ -1, /* 0a Thai */ @@ -320,11 +460,11 @@ const kbd_t hilkbd_layouts[MAXHILKBDLAYOUT] = { -1, /* 11 Traditional Chinese */ -1, /* 12 Swiss French 2 */ -1, /* 13 Euro Spanish */ - -1, /* 14 Swiss German 2*/ + -1, /* 14 Swiss German 2 */ -1, /* 15 Belgian */ -1, /* 16 Finnish */ KB_UK, /* 17 UK English */ - -1, /* 18 Canada French */ + -1, /* 18 Canadian French */ -1, /* 19 Swiss German */ -1, /* 1a Norwegian */ KB_FR, /* 1b French */ diff --git a/sys/dev/hil/hilkbdmap.h b/sys/dev/hil/hilkbdmap.h index 8e1edbecb9e..6e7a024180d 100644 --- a/sys/dev/hil/hilkbdmap.h +++ b/sys/dev/hil/hilkbdmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hilkbdmap.h,v 1.1 2003/02/11 19:39:30 miod Exp $ */ +/* $OpenBSD: hilkbdmap.h,v 1.2 2005/01/18 18:52:31 miod Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * All rights reserved. @@ -31,3 +31,4 @@ extern const struct wscons_keydesc hilkbd_keydesctab[]; #define MAXHILKBDLAYOUT 0x20 extern const kbd_t hilkbd_layouts[MAXHILKBDLAYOUT]; +extern const u_int8_t hilkbd_raw[0x80]; diff --git a/sys/dev/wscons/wskbdraw.h b/sys/dev/wscons/wskbdraw.h new file mode 100644 index 00000000000..3cdfebb27e9 --- /dev/null +++ b/sys/dev/wscons/wskbdraw.h @@ -0,0 +1,165 @@ +/* $OpenBSD: wskbdraw.h,v 1.1 2005/01/18 18:52:32 miod Exp $ */ + +/* + * Copyright (c) 2005, Miodrag Vallat + * + * 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. + * + * 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. + */ + +/* + * US keyboard XT scancodes + */ + +#define RAWKEY_Null 0x00 + +/* + * These names match KS_xxx symbols whenever possible + */ + +#define RAWKEY_Escape 0x01 +#define RAWKEY_1 0x02 +#define RAWKEY_2 0x03 +#define RAWKEY_3 0x04 +#define RAWKEY_4 0x05 +#define RAWKEY_5 0x06 +#define RAWKEY_6 0x07 +#define RAWKEY_7 0x08 +#define RAWKEY_8 0x09 +#define RAWKEY_9 0x0a +#define RAWKEY_0 0x0b +#define RAWKEY_minus 0x0c +#define RAWKEY_equal 0x0d +#define RAWKEY_Tab 0x0f +#define RAWKEY_q 0x10 +#define RAWKEY_w 0x11 +#define RAWKEY_e 0x12 +#define RAWKEY_r 0x13 +#define RAWKEY_t 0x14 +#define RAWKEY_y 0x15 +#define RAWKEY_u 0x16 +#define RAWKEY_i 0x17 +#define RAWKEY_o 0x18 +#define RAWKEY_p 0x19 +#define RAWKEY_bracketleft 0x1a +#define RAWKEY_bracketright 0x1b +#define RAWKEY_Return 0x1c +#define RAWKEY_Control_L 0x1d +#define RAWKEY_a 0x1e +#define RAWKEY_s 0x1f +#define RAWKEY_d 0x20 +#define RAWKEY_f 0x21 +#define RAWKEY_g 0x22 +#define RAWKEY_h 0x23 +#define RAWKEY_j 0x24 +#define RAWKEY_k 0x25 +#define RAWKEY_l 0x26 +#define RAWKEY_semicolon 0x27 +#define RAWKEY_apostrophe 0x28 +#define RAWKEY_grave 0x29 +#define RAWKEY_Shift_L 0x2a +#define RAWKEY_backslash 0x2b +#define RAWKEY_z 0x2c +#define RAWKEY_x 0x2d +#define RAWKEY_c 0x2e +#define RAWKEY_v 0x2f +#define RAWKEY_b 0x30 +#define RAWKEY_n 0x31 +#define RAWKEY_m 0x32 +#define RAWKEY_comma 0x33 +#define RAWKEY_period 0x34 +#define RAWKEY_slash 0x35 +#define RAWKEY_Shift_R 0x36 +#define RAWKEY_KP_Multiply 0x37 +#define RAWKEY_Alt_L 0x38 +#define RAWKEY_space 0x39 +#define RAWKEY_Caps_Lock 0x3a +#define RAWKEY_f1 0x3b +#define RAWKEY_f2 0x3c +#define RAWKEY_f3 0x3d +#define RAWKEY_f4 0x3e +#define RAWKEY_f5 0x3f +#define RAWKEY_f6 0x40 +#define RAWKEY_f7 0x41 +#define RAWKEY_f8 0x42 +#define RAWKEY_f9 0x43 +#define RAWKEY_f10 0x44 +#define RAWKEY_Num_Lock 0x45 +#define RAWKEY_Hold_Screen 0x46 /* Scroll Lock */ +#define RAWKEY_KP_Home 0x47 +#define RAWKEY_KP_Up 0x48 +#define RAWKEY_KP_Prior 0x49 +#define RAWKEY_KP_Subtract 0x4a +#define RAWKEY_KP_Left 0x4b +#define RAWKEY_KP_Begin 0x4c +#define RAWKEY_KP_Right 0x4d +#define RAWKEY_KP_Add 0x4e +#define RAWKEY_KP_End 0x4f +#define RAWKEY_KP_Down 0x50 +#define RAWKEY_KP_Next 0x51 +#define RAWKEY_KP_Insert 0x52 +#define RAWKEY_KP_Delete 0x53 +#define RAWKEY_less 0x56 /* < > on European keyboards */ +#define RAWKEY_f11 0x57 +#define RAWKEY_f12 0x58 +#define RAWKEY_Print_Screen 0x67 +#define RAWKEY_Pause 0x6a +#define RAWKEY_KP_Equal 0x76 +#define RAWKEY_KP_Enter 0x9c +#define RAWKEY_Control_R 0x9d +#define RAWKEY_KP_Divide 0xb5 +#define RAWKEY_Alt_R 0xb8 +#define RAWKEY_Home 0xc7 +#define RAWKEY_Up 0xc8 +#define RAWKEY_Prior 0xc9 +#define RAWKEY_Left 0xcb +#define RAWKEY_Right 0xcd +#define RAWKEY_End 0xcf +#define RAWKEY_Down 0xd0 +#define RAWKEY_Next 0xd1 +#define RAWKEY_Insert 0xd2 +#define RAWKEY_Delete 0xd3 + +#define RAWKEY_Begin 0x5d +#define RAWKEY_Menu 0x6d + +/* + * The following keys have no KS_xxx equivalents + */ + +#define RAWKEY_BackSpace 0x0e +#define RAWKEY_SysReq 0x54 + +#define RAWKEY_Power 0x84 +#define RAWKEY_AudioMute 0x85 +#define RAWKEY_AudioLower 0x86 +#define RAWKEY_AudioRaise 0x87 +#define RAWKEY_Help 0x88 +#define RAWKEY_L1 0x89 /* Stop */ +#define RAWKEY_L2 0x8a /* Again */ +#define RAWKEY_L3 0x8b /* Props */ +#define RAWKEY_L4 0x8c /* Undo */ +#define RAWKEY_L5 0x8d /* Front */ +#define RAWKEY_L6 0x8e /* Copy */ +#define RAWKEY_L7 0x8f /* Open */ +#define RAWKEY_L8 0x90 /* Paste */ +#define RAWKEY_L9 0x91 /* Find */ +#define RAWKEY_L10 0x92 /* Cut */ |