Support KIOC_GETLAYOUT, so other than US keyboards can be dealt with better.
This commit is contained in:
parent
d1d1fbc094
commit
576bc844e5
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kbd.c,v 1.18 1995/05/10 16:04:55 pk Exp $ */
|
||||
/* $NetBSD: kbd.c,v 1.19 1995/07/06 05:35:34 pk Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -188,8 +188,9 @@ struct kbd_state {
|
||||
#define kbd_anyshift kbd_shift.s
|
||||
char kbd_control; /* true => ctrl down */
|
||||
char kbd_click; /* true => keyclick enabled */
|
||||
char kbd_takeid; /* take next byte as ID */
|
||||
u_char kbd_pending; /* Another code from the keyboard is due */
|
||||
u_char kbd_id; /* a place to store the ID */
|
||||
u_char kbd_layout; /* a place to store layout */
|
||||
char kbd_leds; /* LED state */
|
||||
};
|
||||
|
||||
@ -434,16 +435,31 @@ kbd_rint(register int c)
|
||||
}
|
||||
|
||||
/* Read the keyboard id if we read a KBD_RESET last time */
|
||||
if (k->k_state.kbd_takeid) {
|
||||
k->k_state.kbd_takeid = 0;
|
||||
if (k->k_state.kbd_pending == KBD_RESET) {
|
||||
k->k_state.kbd_pending = 0;
|
||||
k->k_state.kbd_id = c;
|
||||
kbd_reset(&k->k_state);
|
||||
if (c == KB_SUN4) {
|
||||
/* Arrange to get keyboard layout as well */
|
||||
(void)ttyoutput(KBD_CMD_GLAYOUT, k->k_kbd);
|
||||
(*k->k_kbd->t_oproc)(k->k_kbd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we have been reset, setup to grab the keyboard id next time */
|
||||
if (c == KBD_RESET) {
|
||||
k->k_state.kbd_takeid = 1;
|
||||
/* Read the keyboard layout if we read a KBD_LAYOUT last time */
|
||||
if (k->k_state.kbd_pending == KBD_LAYOUT) {
|
||||
k->k_state.kbd_pending = 0;
|
||||
k->k_state.kbd_layout = c;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If reset or layout in progress, setup to grab the accompanying
|
||||
* keyboard response next time (id on reset, dip switch on layout).
|
||||
*/
|
||||
if (c == KBD_RESET || c == KBD_LAYOUT) {
|
||||
k->k_state.kbd_pending = c;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -650,7 +666,7 @@ kbdioctl(dev_t dev, u_long cmd, register caddr_t data, int flag, struct proc *p)
|
||||
return (0);
|
||||
|
||||
case KIOCLAYOUT:
|
||||
*data = 0;
|
||||
*(unsigned int *)data = k->k_state.kbd_layout;
|
||||
return (0);
|
||||
|
||||
case KIOCSLED:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kbd.h,v 1.3 1995/04/26 14:24:56 pk Exp $ */
|
||||
/* $NetBSD: kbd.h,v 1.4 1995/07/06 05:36:29 pk Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -58,6 +58,7 @@
|
||||
*/
|
||||
#define KBD_RESET 0xff /* keyboard `reset' response */
|
||||
#define KBD_IDLE 0x7f /* keyboard `all keys are up' code */
|
||||
#define KBD_LAYOUT 0xfe /* keyboard `get layout' response */
|
||||
|
||||
/* Keyboard IDs */
|
||||
#define KB_SUN2 2 /* type 2 keyboard */
|
||||
@ -79,6 +80,7 @@
|
||||
#define KBD_CMD_CLICK 10 /* turn keyclick on */
|
||||
#define KBD_CMD_NOCLICK 11 /* turn keyclick off */
|
||||
#define KBD_CMD_SETLED 14 /* set LED state (type 4 kbd) */
|
||||
#define KBD_CMD_GLAYOUT 15 /* get DIP switch (type 4 kbd) */
|
||||
|
||||
#define LED_NUM_LOCK 0x1
|
||||
#define LED_COMPOSE 0x2
|
||||
|
Loading…
Reference in New Issue
Block a user