diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-07-31 21:57:06 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-07-31 21:57:06 +0000 |
commit | 6ec13b7e0df11d25f78b25dd14bcc0479b695dc9 (patch) | |
tree | ed5a449f1541f04ceac4fc1469ba682d11b9aab8 /sys | |
parent | 1257d884cefd8130e093a5c6abd8aba87857d3a4 (diff) |
Since we now know which keyboard type we are connected to:
- report the proper type to WSKBDIO_GTYPE.
- merge the LK201 and LK401 keymaps.
- if the keyboard is LK201, handle the compose key as the left alt key,
unless shifted, so that you can have both an alt and a compose key.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/vax/dec/dzkbd.c | 9 | ||||
-rw-r--r-- | sys/arch/vax/dec/lk201_ws.c | 76 | ||||
-rw-r--r-- | sys/arch/vax/dec/lk201var.h | 4 | ||||
-rw-r--r-- | sys/arch/vax/dec/wskbdmap_lk201.c | 19 |
4 files changed, 66 insertions, 42 deletions
diff --git a/sys/arch/vax/dec/dzkbd.c b/sys/arch/vax/dec/dzkbd.c index 4ba622f3663..56cfbf1db71 100644 --- a/sys/arch/vax/dec/dzkbd.c +++ b/sys/arch/vax/dec/dzkbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dzkbd.c,v 1.8 2006/07/31 06:47:25 miod Exp $ */ +/* $OpenBSD: dzkbd.c,v 1.9 2006/07/31 21:57:05 miod Exp $ */ /* $NetBSD: dzkbd.c,v 1.1 2000/12/02 17:03:55 ragge Exp $ */ /* @@ -117,7 +117,7 @@ const struct wskbd_mapdata dzkbd_keymapdata = { #ifdef DZKBD_LAYOUT DZKBD_LAYOUT, #else - KB_US | KB_LK401, + KB_US, #endif }; @@ -250,14 +250,13 @@ dzkbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) switch (cmd) { case WSKBDIO_GTYPE: - *(int *)data = WSKBD_TYPE_LK201; + *(int *)data = lk201_get_type(&sc->sc_itl->dzi_ks); return 0; case WSKBDIO_SETLEDS: lk201_set_leds(&sc->sc_itl->dzi_ks, *(int *)data); return 0; case WSKBDIO_GETLEDS: - /* XXX don't dig in kbd internals */ - *(int *)data = sc->sc_itl->dzi_ks.leds_state; + *(int *)data = lk201_get_leds(&sc->sc_itl->dzi_ks); return 0; case WSKBDIO_COMPLEXBELL: lk201_bell(&sc->sc_itl->dzi_ks, diff --git a/sys/arch/vax/dec/lk201_ws.c b/sys/arch/vax/dec/lk201_ws.c index 7851521ab32..2f32e452651 100644 --- a/sys/arch/vax/dec/lk201_ws.c +++ b/sys/arch/vax/dec/lk201_ws.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lk201_ws.c,v 1.7 2006/07/31 18:50:48 miod Exp $ */ +/* $OpenBSD: lk201_ws.c,v 1.8 2006/07/31 21:57:05 miod Exp $ */ /* $NetBSD: lk201_ws.c,v 1.2 1998/10/22 17:55:20 drochner Exp $ */ /* @@ -187,6 +187,19 @@ lk201_decode(struct lk201_state *lks, int active, int datain, u_int *type, return (0); } + /* + * The LK-201 keyboard has a compose key (to the left of the spacebar), + * but no alt/meta key at all. The LK-401 keyboard fixes this and has + * two compose keys and two alt keys. + * + * If the keyboard is an LK-201, translate the left compose key + * scancode to a specific key code, which will map as a left alt key, + * and compose key when shifted), so that the user can have both + * an alt and a compose key available. + */ + if (lks->kbdtype == KBD_LK201 && datain == 177) + datain = 252; + *dataout = datain - MIN_LK201_KEY; freeslot = -1; @@ -211,9 +224,7 @@ lk201_decode(struct lk201_state *lks, int active, int datain, u_int *type, } void -lk201_bell(lks, bell) - struct lk201_state *lks; - struct wskbd_bell_data *bell; +lk201_bell(struct lk201_state *lks, struct wskbd_bell_data *bell) { unsigned int vol; @@ -232,32 +243,27 @@ lk201_bell(lks, bell) send(lks, LK_RING_BELL); } -void -lk201_set_leds(lks, leds) - struct lk201_state *lks; - int leds; +int +lk201_get_leds(struct lk201_state *lks) { - int newleds; - - newleds = 0; - if (leds & WSKBD_LED_SCROLL) - newleds |= LK_LED_WAIT; - if (leds & WSKBD_LED_CAPS) - newleds |= LK_LED_LOCK; - - send(lks, LK_LED_DISABLE); - send(lks, (0x80 | (~newleds & 0x0f))); - - send(lks, LK_LED_ENABLE); - send(lks, (0x80 | (newleds & 0x0f))); + return (lks->leds_state); +} - lks->leds_state = leds; +int +lk201_get_type(struct lk201_state *lks) +{ + /* + * Note that we report LK201 even if no keyboard is + * plugged to avoid confusing wsconsctl. + */ + if (lks->kbdtype == KBD_LK401) + return (WSKBD_TYPE_LK401); + else + return (WSKBD_TYPE_LK201); } void -lk201_set_keyclick(lks, vol) - struct lk201_state *lks; - int vol; +lk201_set_keyclick(struct lk201_state *lks, int vol) { unsigned int newvol; @@ -274,3 +280,23 @@ lk201_set_keyclick(lks, vol) lks->kcvol = vol; } + +void +lk201_set_leds(struct lk201_state *lks, int leds) +{ + int newleds; + + newleds = 0; + if (leds & WSKBD_LED_SCROLL) + newleds |= LK_LED_WAIT; + if (leds & WSKBD_LED_CAPS) + newleds |= LK_LED_LOCK; + + send(lks, LK_LED_DISABLE); + send(lks, (0x80 | (~newleds & 0x0f))); + + send(lks, LK_LED_ENABLE); + send(lks, (0x80 | (newleds & 0x0f))); + + lks->leds_state = leds; +} diff --git a/sys/arch/vax/dec/lk201var.h b/sys/arch/vax/dec/lk201var.h index 56a3a648a8a..800ac0ec651 100644 --- a/sys/arch/vax/dec/lk201var.h +++ b/sys/arch/vax/dec/lk201var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lk201var.h,v 1.5 2006/07/31 06:47:25 miod Exp $ */ +/* $OpenBSD: lk201var.h,v 1.6 2006/07/31 21:57:05 miod Exp $ */ /* $NetBSD: lk201var.h,v 1.2 1998/10/22 17:55:20 drochner Exp $ */ /* @@ -61,6 +61,8 @@ struct lk201_state { void lk201_bell(struct lk201_state *, struct wskbd_bell_data *); int lk201_decode(struct lk201_state *, int, int, u_int *, int *); +int lk201_get_leds(struct lk201_state *); +int lk201_get_type(struct lk201_state *); void lk201_init(struct lk201_state *); void lk201_set_keyclick(struct lk201_state *, int); void lk201_set_leds(struct lk201_state *, int); diff --git a/sys/arch/vax/dec/wskbdmap_lk201.c b/sys/arch/vax/dec/wskbdmap_lk201.c index 241da95f4f1..1fbb724b2ba 100644 --- a/sys/arch/vax/dec/wskbdmap_lk201.c +++ b/sys/arch/vax/dec/wskbdmap_lk201.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wskbdmap_lk201.c,v 1.3 2006/07/29 17:06:25 miod Exp $ */ +/* $OpenBSD: wskbdmap_lk201.c,v 1.4 2006/07/31 21:57:05 miod Exp $ */ /* $NetBSD: wskbdmap_lk201.c,v 1.4 2000/12/02 16:57:41 ragge Exp $ */ #include <sys/types.h> @@ -58,10 +58,14 @@ static const keysym_t lkkbd_keydesc_us[] = { KC(168), KS_Right, KC(169), KS_Down, KC(170), KS_Up, + KC(171), KS_Shift_R, /* LK 401 */ + KC(172), KS_Cmd2, KS_Alt_L, /* LK 401 */ + KC(173), KS_Multi_key, /* right compose */ /* LK 401 */ KC(174), KS_Shift_L, KC(175), KS_Cmd1, KS_Control_L, KC(176), KS_Caps_Lock, - KC(177), KS_Cmd2, KS_Multi_key, /* (left) compose */ + KC(177), KS_Multi_key, /* (left) compose */ /* LK 401 */ + KC(178), KS_Alt_R, /* LK 401 */ KC(188), KS_Delete, KC(189), KS_Return, KC(190), KS_Tab, @@ -114,14 +118,8 @@ static const keysym_t lkkbd_keydesc_us[] = { KC(249), KS_minus, KS_underscore, KC(250), KS_bracketleft, KS_braceleft, KC(251), KS_apostrophe, KS_quotedbl, -}; - -static const keysym_t lkkbd_keydesc_us_lk401[] = { - KC(171), KS_Shift_R, - KC(172), KS_Cmd2, KS_Alt_L, - KC(173), KS_Multi_key, /* right compose */ - KC(177), KS_Multi_key, /* left compose, not "cmd" */ - KC(178), KS_Alt_R, + /* remapped Compose key (177) for LK 201 */ + KC(252), KS_Cmd2, KS_Alt_L, KS_Multi_key }; #define KBD_MAP(name, base, map) \ @@ -129,7 +127,6 @@ static const keysym_t lkkbd_keydesc_us_lk401[] = { const struct wscons_keydesc lkkbd_keydesctab[] = { KBD_MAP(KB_US, 0, lkkbd_keydesc_us), - KBD_MAP(KB_US | KB_LK401, KB_US, lkkbd_keydesc_us_lk401), {0, 0, 0, 0} }; |