Solve keypad-related issues
This commit is contained in:
parent
d90aa78482
commit
7ea82054f5
3 changed files with 70 additions and 36 deletions
|
@ -55,6 +55,11 @@ get_abstract_code (grub_term_input_t term, int in)
|
|||
if ((0x5600 | '|') == (in & 0xffff))
|
||||
return GRUB_TERM_KEY_SHIFT_102 | flags;
|
||||
|
||||
if ((in & 0xff00) == 0x3500 || (in & 0xff00) == 0x3700
|
||||
|| (in & 0xff00) == 0x4500
|
||||
|| ((in & 0xff00) >= 0x4700 && (in & 0xff00) <= 0x5300))
|
||||
flags |= GRUB_TERM_KEYPAD;
|
||||
|
||||
/* Detect CTRL'ed keys. */
|
||||
if ((in & 0xff) > 0 && (in & 0xff) < 0x20
|
||||
&& ((in & 0xffff) != (0x0100 | '\e'))
|
||||
|
@ -79,19 +84,33 @@ get_abstract_code (grub_term_input_t term, int in)
|
|||
|
||||
static grub_uint32_t mapping[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
|
||||
|
||||
static int
|
||||
map (grub_term_input_t term __attribute__ ((unused)), int in)
|
||||
static unsigned
|
||||
clear_internal_flags (unsigned in)
|
||||
{
|
||||
if (in & GRUB_TERM_ALT_GR)
|
||||
in = (in & ~GRUB_TERM_ALT_GR) | GRUB_TERM_ALT;
|
||||
return in & ~GRUB_TERM_CAPS & ~GRUB_TERM_KEYPAD;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
map (grub_term_input_t term __attribute__ ((unused)), unsigned in)
|
||||
{
|
||||
if (in & GRUB_TERM_KEYPAD)
|
||||
return clear_internal_flags (in);
|
||||
|
||||
/* AltGr isn't supported yet. */
|
||||
if (in & GRUB_TERM_ALT_GR)
|
||||
in = (in & ~GRUB_TERM_ALT_GR) | GRUB_TERM_ALT_GR;
|
||||
in = (in & ~GRUB_TERM_ALT_GR) | GRUB_TERM_ALT;
|
||||
|
||||
if ((in & GRUB_TERM_EXTENDED) || (in & GRUB_TERM_KEY_MASK) == '\b'
|
||||
|| (in & GRUB_TERM_KEY_MASK) == '\n' || (in & GRUB_TERM_KEY_MASK) == ' '
|
||||
|| (in & GRUB_TERM_KEY_MASK) == '\t' || (in & GRUB_TERM_KEY_MASK) == '\e'
|
||||
|| (in & GRUB_TERM_KEY_MASK) == '\r'
|
||||
|| (in & GRUB_TERM_KEY_MASK) >= ARRAY_SIZE (mapping))
|
||||
return in;
|
||||
return clear_internal_flags (in);
|
||||
|
||||
return mapping[in & GRUB_TERM_KEY_MASK] | (in & ~GRUB_TERM_KEY_MASK);
|
||||
return mapping[in & GRUB_TERM_KEY_MASK]
|
||||
| clear_internal_flags (in & ~GRUB_TERM_KEY_MASK);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -99,14 +118,15 @@ translate (grub_term_input_t term, int in)
|
|||
{
|
||||
int code, flags;
|
||||
code = get_abstract_code (term, in);
|
||||
if ((code & GRUB_TERM_CAPS) && (code & 0xff) >= 'a' && (code & 0xff) <= 'z')
|
||||
code = (code & 0xff) + 'A' - 'a';
|
||||
else if ((code & GRUB_TERM_CAPS) && (code & 0xff) >= 'A'
|
||||
&& (code & 0xff) <= 'Z')
|
||||
code = (code & 0xff) + 'a' - 'A';
|
||||
if ((code & GRUB_TERM_CAPS) && (code & GRUB_TERM_KEY_MASK) >= 'a'
|
||||
&& (code & GRUB_TERM_KEY_MASK) <= 'z')
|
||||
code = (code & GRUB_TERM_KEY_MASK) + 'A' - 'a';
|
||||
else if ((code & GRUB_TERM_CAPS) && (code & GRUB_TERM_KEY_MASK) >= 'A'
|
||||
&& (code & GRUB_TERM_KEY_MASK) <= 'Z')
|
||||
code = (code & GRUB_TERM_KEY_MASK) + 'a' - 'A';
|
||||
|
||||
flags = code & ~(GRUB_TERM_KEY_MASK | GRUB_TERM_ALT_GR);
|
||||
code &= (GRUB_TERM_KEY_MASK | GRUB_TERM_ALT_GR);
|
||||
flags = code & ~(GRUB_TERM_KEY_MASK | GRUB_TERM_ALT_GR | GRUB_TERM_KEYPAD);
|
||||
code &= (GRUB_TERM_KEY_MASK | GRUB_TERM_ALT_GR | GRUB_TERM_KEYPAD);
|
||||
code = map (term, code);
|
||||
/* Transform unconsumed AltGr into Alt. */
|
||||
if (code & GRUB_TERM_ALT_GR)
|
||||
|
|
|
@ -51,28 +51,40 @@
|
|||
#define OLPC_RIGHT '\0'
|
||||
#endif
|
||||
|
||||
#define GRUB_AT_KEY_KEYBOARD_MAP(name) \
|
||||
static const unsigned name[128] = \
|
||||
{ \
|
||||
'\0', GRUB_TERM_ESC, '1', '2', '3', '4', '5', '6', \
|
||||
'7', '8', '9', '0', '-', '=', GRUB_TERM_BACKSPACE, GRUB_TERM_TAB, \
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', \
|
||||
'o', 'p', '[', ']', '\n', '\0', 'a', 's', \
|
||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', \
|
||||
'\'', '`', '\0', '\\', 'z', 'x', 'c', 'v', \
|
||||
'b', 'n', 'm', ',', '.', '/', '\0', '*', \
|
||||
'\0', ' ', '\0', GRUB_TERM_KEY_F1, \
|
||||
GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, \
|
||||
GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9, \
|
||||
GRUB_TERM_KEY_F10, '\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_DOWN, GRUB_TERM_KEY_PPAGE, \
|
||||
GRUB_TERM_KEY_INSERT, GRUB_TERM_KEY_DC, \
|
||||
'\0', '\0', GRUB_TERM_KEY_102, GRUB_TERM_KEY_F11, \
|
||||
GRUB_TERM_KEY_F12, '\0', '\0', '\0', '\0', '\0', '\0', '\0', \
|
||||
'\0', '\0', '\0', '\0', '\0', OLPC_UP, OLPC_DOWN, OLPC_LEFT, \
|
||||
OLPC_RIGHT \
|
||||
#define GRUB_AT_KEY_KEYBOARD_MAP(name) \
|
||||
static const unsigned name[128] = \
|
||||
{ \
|
||||
/* 0x00 */ '\0', GRUB_TERM_ESC, '1', '2', '3', '4', '5', '6', \
|
||||
/* 0x08 */ '7', '8', '9', '0', \
|
||||
/* 0x0c */ '-', '=', GRUB_TERM_BACKSPACE, GRUB_TERM_TAB, \
|
||||
/* 0x10 */ 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', \
|
||||
/* 0x18 */ 'o', 'p', '[', ']', '\n', '\0', 'a', 's', \
|
||||
/* 0x20 */ 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', \
|
||||
/* 0x28 */ '\'', '`', '\0', '\\', 'z', 'x', 'c', 'v', \
|
||||
/* 0x30 */ 'b', 'n', 'm', ',', '.', '/', '\0', '*' | GRUB_TERM_KEYPAD, \
|
||||
/* 0x38 */ '\0', ' ', '\0', GRUB_TERM_KEY_F1, \
|
||||
/* 0x3c */ GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, \
|
||||
/* 0x3e */ GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, \
|
||||
/* 0x40 */ GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, \
|
||||
/* 0x42 */ GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9, \
|
||||
/* 0x44 */ GRUB_TERM_KEY_F10, '\0', \
|
||||
/* 0x46 */ '\0', GRUB_TERM_KEY_HOME, \
|
||||
/* 0x48 */ GRUB_TERM_KEY_UP, \
|
||||
/* 0x49 */ GRUB_TERM_KEY_NPAGE, \
|
||||
/* 0x4a */ '-' | GRUB_TERM_KEYPAD, \
|
||||
/* 0x4b */ GRUB_TERM_KEY_LEFT, \
|
||||
/* 0x4c */ GRUB_TERM_KEY_CENTER | GRUB_TERM_KEYPAD, \
|
||||
/* 0x4d */ GRUB_TERM_KEY_RIGHT, \
|
||||
/* 0x4e */ '+' | GRUB_TERM_KEYPAD, \
|
||||
/* 0x4f */ GRUB_TERM_KEY_END, \
|
||||
/* 0x50 */ GRUB_TERM_KEY_DOWN, \
|
||||
/* 0x51 */ GRUB_TERM_KEY_PPAGE, \
|
||||
/* 0x52 */ GRUB_TERM_KEY_INSERT, \
|
||||
/* 0x53 */ GRUB_TERM_KEY_DC, \
|
||||
/* 0x54 */ '\0', '\0', GRUB_TERM_KEY_102, GRUB_TERM_KEY_F11, \
|
||||
/* 0x58 */ GRUB_TERM_KEY_F12, '\0', '\0', '\0', '\0', '\0', '\0', '\0', \
|
||||
/* 0x60 */ '\0', '\0', '\0', '\0', '\0', OLPC_UP, OLPC_DOWN, OLPC_LEFT, \
|
||||
/* 0x68 */ OLPC_RIGHT \
|
||||
}
|
||||
|
||||
#define GRUB_AT_KEY_KEYBOARD_MAP_SHIFT(name) \
|
||||
|
|
|
@ -25,8 +25,9 @@
|
|||
#define GRUB_TERM_CTRL 0x02000000
|
||||
#define GRUB_TERM_ALT 0x04000000
|
||||
/* Used by keylayouts code. Never returned in grub_getkey. */
|
||||
#define GRUB_TERM_ALT_GR 0x08000000
|
||||
#define GRUB_TERM_CAPS 0x10000000
|
||||
#define GRUB_TERM_ALT_GR 0x08000000
|
||||
#define GRUB_TERM_CAPS 0x10000000
|
||||
#define GRUB_TERM_KEYPAD 0x20000000
|
||||
|
||||
/* Keys without associated character. */
|
||||
#define GRUB_TERM_EXTENDED 0x00800000
|
||||
|
@ -53,6 +54,7 @@
|
|||
#define GRUB_TERM_KEY_F11 (GRUB_TERM_EXTENDED | 20)
|
||||
#define GRUB_TERM_KEY_F12 (GRUB_TERM_EXTENDED | 21)
|
||||
#define GRUB_TERM_KEY_INSERT (GRUB_TERM_EXTENDED | 22)
|
||||
#define GRUB_TERM_KEY_CENTER (GRUB_TERM_EXTENDED | 23)
|
||||
|
||||
/* Used by keylayouts code. Never returned in grub_getkey. */
|
||||
#define GRUB_TERM_KEY_102 0x80
|
||||
|
|
Loading…
Reference in a new issue