mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
Rework shifta/ctla/alta key handling. It appears that there was
misunderstanding between the PR originator and me. I hope I got it right this time.
This commit is contained in:
parent
5dfaebe1c3
commit
7642cc829e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=55820
@ -736,27 +736,23 @@ 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;
|
||||
@ -766,7 +762,6 @@ 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 */
|
||||
@ -776,7 +771,6 @@ 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;
|
||||
@ -786,7 +780,6 @@ 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
|
||||
|
@ -736,27 +736,23 @@ 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;
|
||||
@ -766,7 +762,6 @@ 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 */
|
||||
@ -776,7 +771,6 @@ 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;
|
||||
@ -786,7 +780,6 @@ 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
|
||||
|
@ -139,7 +139,6 @@ 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;
|
||||
}
|
||||
|
||||
@ -1027,7 +1026,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
/* special keys */
|
||||
switch (action) {
|
||||
case LSHA:
|
||||
if (kbd->kb_prev_key == keycode) {
|
||||
if (state & SHIFTAON) {
|
||||
set_lockkey_state(kbd, state, ALK);
|
||||
state &= ~ALKDOWN;
|
||||
}
|
||||
@ -1037,7 +1036,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
state &= ~SHIFTS1;
|
||||
break;
|
||||
case RSHA:
|
||||
if (kbd->kb_prev_key == keycode) {
|
||||
if (state & SHIFTAON) {
|
||||
set_lockkey_state(kbd, state, ALK);
|
||||
state &= ~ALKDOWN;
|
||||
}
|
||||
@ -1047,7 +1046,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
state &= ~SHIFTS2;
|
||||
break;
|
||||
case LCTRA:
|
||||
if (kbd->kb_prev_key == keycode) {
|
||||
if (state & SHIFTAON) {
|
||||
set_lockkey_state(kbd, state, ALK);
|
||||
state &= ~ALKDOWN;
|
||||
}
|
||||
@ -1057,7 +1056,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
state &= ~CTLS1;
|
||||
break;
|
||||
case RCTRA:
|
||||
if (kbd->kb_prev_key == keycode) {
|
||||
if (state & SHIFTAON) {
|
||||
set_lockkey_state(kbd, state, ALK);
|
||||
state &= ~ALKDOWN;
|
||||
}
|
||||
@ -1067,7 +1066,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
state &= ~CTLS2;
|
||||
break;
|
||||
case LALTA:
|
||||
if (kbd->kb_prev_key == keycode) {
|
||||
if (state & SHIFTAON) {
|
||||
set_lockkey_state(kbd, state, ALK);
|
||||
state &= ~ALKDOWN;
|
||||
}
|
||||
@ -1077,7 +1076,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
state &= ~ALTS1;
|
||||
break;
|
||||
case RALTA:
|
||||
if (kbd->kb_prev_key == keycode) {
|
||||
if (state & SHIFTAON) {
|
||||
set_lockkey_state(kbd, state, ALK);
|
||||
state &= ~ALKDOWN;
|
||||
}
|
||||
@ -1112,12 +1111,14 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
state &= ~ALKDOWN;
|
||||
break;
|
||||
}
|
||||
*shiftstate = state;
|
||||
*shiftstate = state & ~SHIFTAON;
|
||||
return (SPCLKEY | RELKEY | action);
|
||||
}
|
||||
/* release events of regular keys are not reported */
|
||||
*shiftstate &= ~SHIFTAON;
|
||||
return NOKEY;
|
||||
} else { /* make: key pressed */
|
||||
state &= ~SHIFTAON;
|
||||
if (key->spcl & (0x80 >> i)) {
|
||||
/* special keys */
|
||||
switch (action) {
|
||||
@ -1151,36 +1152,42 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
action |= BKEY;
|
||||
break;
|
||||
case LSHA:
|
||||
state |= SHIFTAON;
|
||||
action = LSH;
|
||||
/* FALL THROUGH */
|
||||
case LSH:
|
||||
state |= SHIFTS1;
|
||||
break;
|
||||
case RSHA:
|
||||
state |= SHIFTAON;
|
||||
action = RSH;
|
||||
/* FALL THROUGH */
|
||||
case RSH:
|
||||
state |= SHIFTS2;
|
||||
break;
|
||||
case LCTRA:
|
||||
state |= SHIFTAON;
|
||||
action = LCTR;
|
||||
/* FALL THROUGH */
|
||||
case LCTR:
|
||||
state |= CTLS1;
|
||||
break;
|
||||
case RCTRA:
|
||||
state |= SHIFTAON;
|
||||
action = RCTR;
|
||||
/* FALL THROUGH */
|
||||
case RCTR:
|
||||
state |= CTLS2;
|
||||
break;
|
||||
case LALTA:
|
||||
state |= SHIFTAON;
|
||||
action = LALT;
|
||||
/* FALL THROUGH */
|
||||
case LALT:
|
||||
state |= ALTS1;
|
||||
break;
|
||||
case RALTA:
|
||||
state |= SHIFTAON;
|
||||
action = RALT;
|
||||
/* FALL THROUGH */
|
||||
case RALT:
|
||||
@ -1194,6 +1201,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
break;
|
||||
default:
|
||||
/* is this an accent (dead) key? */
|
||||
*shiftstate = state;
|
||||
if (action >= F_ACC && action <= L_ACC) {
|
||||
action = save_accent_key(kbd, action,
|
||||
accents);
|
||||
@ -1217,12 +1225,13 @@ 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;
|
||||
return (SPCLKEY | action);
|
||||
}
|
||||
*shiftstate = state;
|
||||
return (SPCLKEY | action);
|
||||
} else {
|
||||
/* regular keys */
|
||||
*shiftstate = state;
|
||||
if (*accents > 0) {
|
||||
/* make an accented char */
|
||||
action = make_accent_char(kbd, action, accents);
|
||||
|
@ -88,7 +88,6 @@ 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 */
|
||||
};
|
||||
|
||||
@ -232,6 +231,7 @@ int kbd_detach(keyboard_t *kbd);
|
||||
#define SLKDOWN (1 << 27)
|
||||
#define CLKDOWN (1 << 28)
|
||||
#define ALKDOWN (1 << 29)
|
||||
#define SHIFTAON (1 << 30)
|
||||
/* lock key state (defined in machine/console.h) */
|
||||
/*
|
||||
#define CLKED LED_CAP
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "ukbd.h"
|
||||
#include "opt_kbd.h"
|
||||
#include "opt_ukbd.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -875,6 +876,7 @@ ukbd_read(keyboard_t *kbd, int wait)
|
||||
usbcode = ukbd_getc(state);
|
||||
if (!KBD_IS_ACTIVE(kbd) || (usbcode == -1))
|
||||
return -1;
|
||||
++kbd->kb_count;
|
||||
#ifdef UKBD_EMULATE_ATSCANCODE
|
||||
keycode = ukbd_trtab[KEY_INDEX(usbcode)];
|
||||
if (keycode == NN)
|
||||
@ -966,6 +968,7 @@ ukbd_read_char(keyboard_t *kbd, int wait)
|
||||
usbcode = ukbd_getc(state);
|
||||
if (usbcode == -1)
|
||||
return NOKEY;
|
||||
++kbd->kb_count;
|
||||
|
||||
#ifdef UKBD_EMULATE_ATSCANCODE
|
||||
/* USB key index -> key code -> AT scan code */
|
||||
|
Loading…
Reference in New Issue
Block a user