Simplify AT keyboards and support 102nd key

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-05-10 20:57:01 +02:00
parent 08bfb543c4
commit 1ff38af9b9
3 changed files with 17 additions and 18 deletions

View file

@ -58,19 +58,12 @@ get_abstract_code (grub_term_input_t term, int in)
unsigned flags = 0; unsigned flags = 0;
switch (term->flags & GRUB_TERM_INPUT_FLAGS_TYPE_MASK) switch (term->flags & GRUB_TERM_INPUT_FLAGS_TYPE_MASK)
{ {
case GRUB_TERM_INPUT_FLAGS_TYPE_TERMCODES:
default: default:
return in; return in;
case GRUB_TERM_INPUT_FLAGS_TYPE_BIOS: case GRUB_TERM_INPUT_FLAGS_TYPE_BIOS:
{ {
unsigned status = 0; unsigned status = 0;
if (term->getkeystatus)
status = term->getkeystatus ();
if (status & GRUB_TERM_CAPS)
flags |= GRUB_TERM_CAPS;
}
/* Fall through. */
case GRUB_TERM_INPUT_FLAGS_TYPE_AT:
{
struct { struct {
int from, to; int from, to;
} translations[] = } translations[] =
@ -88,12 +81,16 @@ get_abstract_code (grub_term_input_t term, int in)
{0x5600 | '|', GRUB_TERM_KEY_SHIFT_102}, {0x5600 | '|', GRUB_TERM_KEY_SHIFT_102},
}; };
unsigned i; unsigned i;
if (term->getkeystatus)
status = term->getkeystatus ();
if (status & GRUB_TERM_CAPS)
flags |= GRUB_TERM_CAPS;
for (i = 0; i < ARRAY_SIZE (translations); i++) for (i = 0; i < ARRAY_SIZE (translations); i++)
if (translations[i].from == (in & 0xffff)) if (translations[i].from == (in & 0xffff))
return translations[i].to | flags; return translations[i].to | flags;
if ((term->flags & GRUB_TERM_INPUT_FLAGS_TYPE_MASK)
== GRUB_TERM_INPUT_FLAGS_TYPE_AT)
return in & ~0xff00;
/* Detect CTRL'ed keys. */ /* Detect CTRL'ed keys. */
if ((in & 0xff) > 0 && (in & 0xff) < 0x20 if ((in & 0xff) > 0 && (in & 0xff) < 0x20
&& ((in & 0xffff) != (0x0100 | '\e')) && ((in & 0xffff) != (0x0100 | '\e'))

View file

@ -153,8 +153,8 @@ struct grub_term_input
typedef struct grub_term_input *grub_term_input_t; typedef struct grub_term_input *grub_term_input_t;
#define GRUB_TERM_INPUT_FLAGS_TYPE_MASK 0xf #define GRUB_TERM_INPUT_FLAGS_TYPE_MASK 0xf
#define GRUB_TERM_INPUT_FLAGS_TYPE_AT 0x1 #define GRUB_TERM_INPUT_FLAGS_TYPE_TERMCODES 0x0
#define GRUB_TERM_INPUT_FLAGS_TYPE_BIOS 0x2 #define GRUB_TERM_INPUT_FLAGS_TYPE_BIOS 0x1
struct grub_term_output struct grub_term_output
{ {

View file

@ -53,13 +53,14 @@ static int keyboard_map[128] =
'\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0', '\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', GRUB_TERM_KEY_HOME, '\0', '\0', '\0', '\0', '\0', '\0', '\0', GRUB_TERM_KEY_HOME,
GRUB_TERM_KEY_UP, GRUB_TERM_KEY_NPAGE, '-', GRUB_TERM_KEY_LEFT, '\0', GRUB_TERM_KEY_RIGHT, '+', GRUB_TERM_KEY_END, GRUB_TERM_KEY_UP, GRUB_TERM_KEY_NPAGE, '-', GRUB_TERM_KEY_LEFT, '\0', GRUB_TERM_KEY_RIGHT, '+', GRUB_TERM_KEY_END,
GRUB_TERM_KEY_DOWN, GRUB_TERM_KEY_PPAGE, '\0', GRUB_TERM_KEY_DC, '\0', '\0', '\0', '\0', GRUB_TERM_KEY_DOWN, GRUB_TERM_KEY_PPAGE, '\0', GRUB_TERM_KEY_DC, '\0', '\0',
GRUB_TERM_KEY_102, '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', OLPC_UP, OLPC_DOWN, OLPC_LEFT, '\0', '\0', '\0', '\0', '\0', OLPC_UP, OLPC_DOWN, OLPC_LEFT,
OLPC_RIGHT OLPC_RIGHT
}; };
static char keyboard_map_shift[128] = static int keyboard_map_shift[128] =
{ {
'\0', '\0', '!', '@', '#', '$', '%', '^', '\0', '\0', '!', '@', '#', '$', '%', '^',
'&', '*', '(', ')', '_', '+', '\0', '\0', '&', '*', '(', ')', '_', '+', '\0', '\0',
@ -67,7 +68,8 @@ static char keyboard_map_shift[128] =
'O', 'P', '{', '}', '\n', '\0', 'A', 'S', 'O', 'P', '{', '}', '\n', '\0', 'A', 'S',
'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',
'\"', '~', '\0', '|', 'Z', 'X', 'C', 'V', '\"', '~', '\0', '|', 'Z', 'X', 'C', 'V',
'B', 'N', 'M', '<', '>', '?' 'B', 'N', 'M', '<', '>', '?',
[0x56] = GRUB_TERM_KEY_SHIFT_102
}; };
static grub_uint8_t grub_keyboard_controller_orig; static grub_uint8_t grub_keyboard_controller_orig;
@ -300,7 +302,7 @@ static struct grub_term_input grub_at_keyboard_term =
.fini = grub_keyboard_controller_fini, .fini = grub_keyboard_controller_fini,
.checkkey = grub_at_keyboard_checkkey, .checkkey = grub_at_keyboard_checkkey,
.getkey = grub_at_keyboard_getkey, .getkey = grub_at_keyboard_getkey,
.flags = GRUB_TERM_INPUT_FLAGS_TYPE_AT .flags = GRUB_TERM_INPUT_FLAGS_TYPE_TERMCODES
}; };
GRUB_MOD_INIT(at_keyboard) GRUB_MOD_INIT(at_keyboard)