1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-20 02:38:43 +00:00

Add support new keys: lshifta, rshifta, lctrla, rctrla, lalta, and

ralta.  These keys combine shift/ctrl/alt function and the AltLock
function.  When these keys pressed together with another key, they act
just like the ordinary shift/ctrl/alt keys.  When these keys are
pressed and released alone, Alt lock state is toggled.

PR: kern/12475
This commit is contained in:
Kazutaka YOKOTA 1999-12-10 04:31:33 +00:00
parent b2f564ea70
commit 82d654e855
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=54382
4 changed files with 100 additions and 13 deletions

View File

@ -514,6 +514,8 @@ atkbd_read(keyboard_t *kbd, int wait)
c = read_kbd_data(((atkbd_state_t *)kbd->kb_data)->kbdc);
else
c = read_kbd_data_no_wait(((atkbd_state_t *)kbd->kb_data)->kbdc);
if (c != -1)
++kbd->kb_count;
return (KBD_IS_ACTIVE(kbd) ? c : -1);
}
@ -556,6 +558,11 @@ atkbd_read_char(keyboard_t *kbd, int wait)
if (scancode == -1)
return NOKEY;
}
++kbd->kb_count;
#if KBDIO_DEBUG >= 10
printf("atkbd_read_char(): scancode:0x%x\n", scancode);
#endif
/* return the byte as is for the K_RAW mode */
if (state->ks_mode == K_RAW)
@ -709,23 +716,27 @@ atkbd_read_char(keyboard_t *kbd, int wait)
case 0x47: case 0x48: case 0x49: /* keypad 7,8,9 */
state->ks_composed_char *= 10;
state->ks_composed_char += keycode - 0x40;
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (state->ks_composed_char > UCHAR_MAX)
return ERRKEY;
goto next_code;
case 0x4B: case 0x4C: case 0x4D: /* keypad 4,5,6 */
state->ks_composed_char *= 10;
state->ks_composed_char += keycode - 0x47;
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (state->ks_composed_char > UCHAR_MAX)
return ERRKEY;
goto next_code;
case 0x4F: case 0x50: case 0x51: /* keypad 1,2,3 */
state->ks_composed_char *= 10;
state->ks_composed_char += keycode - 0x4E;
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (state->ks_composed_char > UCHAR_MAX)
return ERRKEY;
goto next_code;
case 0x52: /* keypad 0 */
state->ks_composed_char *= 10;
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (state->ks_composed_char > UCHAR_MAX)
return ERRKEY;
goto next_code;
@ -735,6 +746,7 @@ atkbd_read_char(keyboard_t *kbd, int wait)
case 0xCB: case 0xCC: case 0xCD: /* keypad 4,5,6 */
case 0xCF: case 0xD0: case 0xD1: /* keypad 1,2,3 */
case 0xD2: /* keypad 0 */
kbd->kb_prev_key = keycode | (scancode & 0x80);
goto next_code;
case 0x38: /* left alt key */
@ -744,6 +756,7 @@ atkbd_read_char(keyboard_t *kbd, int wait)
if (state->ks_composed_char > 0) {
state->ks_flags &= ~COMPOSE;
state->ks_composed_char = 0;
kbd->kb_prev_key = keycode | (scancode & 0x80);
return ERRKEY;
}
break;
@ -753,6 +766,7 @@ atkbd_read_char(keyboard_t *kbd, int wait)
/* keycode to key action */
action = genkbd_keyaction(kbd, keycode, scancode & 0x80,
&state->ks_state, &state->ks_accents);
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (action == NOKEY)
goto next_code;
else
@ -1056,7 +1070,7 @@ init_keyboard(KBDC kbdc, int *type, int flags)
}
/* save the current controller command byte */
empty_both_buffers(kbdc, 10);
empty_both_buffers(kbdc, 200);
c = get_controller_command_byte(kbdc);
if (c == -1) {
/* CONTROLLER ERROR */

View File

@ -514,6 +514,8 @@ atkbd_read(keyboard_t *kbd, int wait)
c = read_kbd_data(((atkbd_state_t *)kbd->kb_data)->kbdc);
else
c = read_kbd_data_no_wait(((atkbd_state_t *)kbd->kb_data)->kbdc);
if (c != -1)
++kbd->kb_count;
return (KBD_IS_ACTIVE(kbd) ? c : -1);
}
@ -556,6 +558,11 @@ atkbd_read_char(keyboard_t *kbd, int wait)
if (scancode == -1)
return NOKEY;
}
++kbd->kb_count;
#if KBDIO_DEBUG >= 10
printf("atkbd_read_char(): scancode:0x%x\n", scancode);
#endif
/* return the byte as is for the K_RAW mode */
if (state->ks_mode == K_RAW)
@ -709,23 +716,27 @@ atkbd_read_char(keyboard_t *kbd, int wait)
case 0x47: case 0x48: case 0x49: /* keypad 7,8,9 */
state->ks_composed_char *= 10;
state->ks_composed_char += keycode - 0x40;
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (state->ks_composed_char > UCHAR_MAX)
return ERRKEY;
goto next_code;
case 0x4B: case 0x4C: case 0x4D: /* keypad 4,5,6 */
state->ks_composed_char *= 10;
state->ks_composed_char += keycode - 0x47;
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (state->ks_composed_char > UCHAR_MAX)
return ERRKEY;
goto next_code;
case 0x4F: case 0x50: case 0x51: /* keypad 1,2,3 */
state->ks_composed_char *= 10;
state->ks_composed_char += keycode - 0x4E;
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (state->ks_composed_char > UCHAR_MAX)
return ERRKEY;
goto next_code;
case 0x52: /* keypad 0 */
state->ks_composed_char *= 10;
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (state->ks_composed_char > UCHAR_MAX)
return ERRKEY;
goto next_code;
@ -735,6 +746,7 @@ atkbd_read_char(keyboard_t *kbd, int wait)
case 0xCB: case 0xCC: case 0xCD: /* keypad 4,5,6 */
case 0xCF: case 0xD0: case 0xD1: /* keypad 1,2,3 */
case 0xD2: /* keypad 0 */
kbd->kb_prev_key = keycode | (scancode & 0x80);
goto next_code;
case 0x38: /* left alt key */
@ -744,6 +756,7 @@ atkbd_read_char(keyboard_t *kbd, int wait)
if (state->ks_composed_char > 0) {
state->ks_flags &= ~COMPOSE;
state->ks_composed_char = 0;
kbd->kb_prev_key = keycode | (scancode & 0x80);
return ERRKEY;
}
break;
@ -753,6 +766,7 @@ atkbd_read_char(keyboard_t *kbd, int wait)
/* keycode to key action */
action = genkbd_keyaction(kbd, keycode, scancode & 0x80,
&state->ks_state, &state->ks_accents);
kbd->kb_prev_key = keycode | (scancode & 0x80);
if (action == NOKEY)
goto next_code;
else
@ -1056,7 +1070,7 @@ init_keyboard(KBDC kbdc, int *type, int flags)
}
/* save the current controller command byte */
empty_both_buffers(kbdc, 10);
empty_both_buffers(kbdc, 200);
c = get_controller_command_byte(kbdc);
if (c == -1) {
/* CONTROLLER ERROR */

View File

@ -136,6 +136,8 @@ kbd_init_struct(keyboard_t *kbd, char *name, int type, int unit, int config,
kbd->kb_fkeytab_size = 0;
kbd->kb_delay1 = KB_DELAY1; /* these values are advisory only */
kbd->kb_delay2 = KB_DELAY2;
kbd->kb_prev_key = 0;
kbd->kb_count = 0L;
}
void
@ -673,14 +675,7 @@ genkbd_event(keyboard_t *kbd, int event, void *arg)
/* process special keys; most of them are just ignored... */
if (c & SPCLKEY) {
switch (KEYCHAR(c)) {
/* locking keys */
case NLK: case CLK: case SLK: case ALK:
/* shift keys */
case LSH: case RSH: case LCTR: case RCTR:
case LALT: case RALT: case ASH: case META:
/* other special keys */
case NOP: case SPSC: case RBT: case SUSP:
case STBY: case DBG: case NEXT:
default:
/* ignore them... */
continue;
case BTAB: /* a backtab: ESC [ Z */
@ -967,10 +962,11 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
int f;
int i;
i = keycode;
f = state & (AGRS | ALKED);
if ((f == AGRS1) || (f == AGRS2) || (f == ALKED))
keycode += ALTGR_OFFSET;
key = &kbd->kb_keymap->key[keycode];
i += ALTGR_OFFSET;
key = &kbd->kb_keymap->key[i];
i = ((state & SHIFTS) ? 1 : 0)
| ((state & CTLS) ? 2 : 0)
| ((state & ALTS) ? 4 : 0);
@ -983,21 +979,63 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
if (key->spcl & (0x80 >> i)) {
/* special keys */
switch (action) {
case LSHA:
if (kbd->kb_prev_key == keycode) {
set_lockkey_state(kbd, state, ALK);
state &= ~ALKDOWN;
}
action = LSH;
/* FALL THROUGH */
case LSH:
state &= ~SHIFTS1;
break;
case RSHA:
if (kbd->kb_prev_key == keycode) {
set_lockkey_state(kbd, state, ALK);
state &= ~ALKDOWN;
}
action = RSH;
/* FALL THROUGH */
case RSH:
state &= ~SHIFTS2;
break;
case LCTRA:
if (kbd->kb_prev_key == keycode) {
set_lockkey_state(kbd, state, ALK);
state &= ~ALKDOWN;
}
action = LCTR;
/* FALL THROUGH */
case LCTR:
state &= ~CTLS1;
break;
case RCTRA:
if (kbd->kb_prev_key == keycode) {
set_lockkey_state(kbd, state, ALK);
state &= ~ALKDOWN;
}
action = RCTR;
/* FALL THROUGH */
case RCTR:
state &= ~CTLS2;
break;
case LALTA:
if (kbd->kb_prev_key == keycode) {
set_lockkey_state(kbd, state, ALK);
state &= ~ALKDOWN;
}
action = LALT;
/* FALL THROUGH */
case LALT:
state &= ~ALTS1;
break;
case RALTA:
if (kbd->kb_prev_key == keycode) {
set_lockkey_state(kbd, state, ALK);
state &= ~ALKDOWN;
}
action = RALT;
/* FALL THROUGH */
case RALT:
state &= ~ALTS2;
break;
@ -1058,28 +1096,46 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
break;
/* NON-LOCKING KEYS */
case SPSC: case RBT: case SUSP: case STBY:
case DBG: case NEXT:
case DBG: case NEXT: case PREV: case PNC:
*accents = 0;
break;
case BTAB:
*accents = 0;
action |= BKEY;
break;
case LSHA:
action = LSH;
/* FALL THROUGH */
case LSH:
state |= SHIFTS1;
break;
case RSHA:
action = RSH;
/* FALL THROUGH */
case RSH:
state |= SHIFTS2;
break;
case LCTRA:
action = LCTR;
/* FALL THROUGH */
case LCTR:
state |= CTLS1;
break;
case RCTRA:
action = RCTR;
/* FALL THROUGH */
case RCTR:
state |= CTLS2;
break;
case LALTA:
action = LALT;
/* FALL THROUGH */
case LALT:
state |= ALTS1;
break;
case RALTA:
action = RALT;
/* FALL THROUGH */
case RALT:
state |= ALTS2;
break;
@ -1114,6 +1170,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
if (action >= F_FN && action <= L_FN)
action |= FKEY;
/* XXX: return fkey string for the FKEY? */
break;
}
*shiftstate = state;
return (SPCLKEY | action);

View File

@ -88,6 +88,8 @@ struct keyboard {
int kb_delay2;
#define KB_DELAY1 500
#define KB_DELAY2 100
int kb_prev_key; /* keycode previously seen */
unsigned long kb_count; /* # of processed key strokes */
};
#define KBD_IS_VALID(k) ((k)->kb_flags & KB_VALID)