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))
|
if ((0x5600 | '|') == (in & 0xffff))
|
||||||
return GRUB_TERM_KEY_SHIFT_102 | flags;
|
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. */
|
/* 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'))
|
||||||
|
@ -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 grub_uint32_t mapping[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
|
||||||
|
|
||||||
static int
|
static unsigned
|
||||||
map (grub_term_input_t term __attribute__ ((unused)), int in)
|
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. */
|
/* AltGr isn't supported yet. */
|
||||||
if (in & GRUB_TERM_ALT_GR)
|
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'
|
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) == '\t' || (in & GRUB_TERM_KEY_MASK) == '\e'
|
||||||
|
|| (in & GRUB_TERM_KEY_MASK) == '\r'
|
||||||
|| (in & GRUB_TERM_KEY_MASK) >= ARRAY_SIZE (mapping))
|
|| (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
|
static int
|
||||||
|
@ -99,14 +118,15 @@ translate (grub_term_input_t term, int in)
|
||||||
{
|
{
|
||||||
int code, flags;
|
int code, flags;
|
||||||
code = get_abstract_code (term, in);
|
code = get_abstract_code (term, in);
|
||||||
if ((code & GRUB_TERM_CAPS) && (code & 0xff) >= 'a' && (code & 0xff) <= 'z')
|
if ((code & GRUB_TERM_CAPS) && (code & GRUB_TERM_KEY_MASK) >= 'a'
|
||||||
code = (code & 0xff) + 'A' - 'a';
|
&& (code & GRUB_TERM_KEY_MASK) <= 'z')
|
||||||
else if ((code & GRUB_TERM_CAPS) && (code & 0xff) >= 'A'
|
code = (code & GRUB_TERM_KEY_MASK) + 'A' - 'a';
|
||||||
&& (code & 0xff) <= 'Z')
|
else if ((code & GRUB_TERM_CAPS) && (code & GRUB_TERM_KEY_MASK) >= 'A'
|
||||||
code = (code & 0xff) + 'a' - '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);
|
flags = code & ~(GRUB_TERM_KEY_MASK | GRUB_TERM_ALT_GR | GRUB_TERM_KEYPAD);
|
||||||
code &= (GRUB_TERM_KEY_MASK | GRUB_TERM_ALT_GR);
|
code &= (GRUB_TERM_KEY_MASK | GRUB_TERM_ALT_GR | GRUB_TERM_KEYPAD);
|
||||||
code = map (term, code);
|
code = map (term, code);
|
||||||
/* Transform unconsumed AltGr into Alt. */
|
/* Transform unconsumed AltGr into Alt. */
|
||||||
if (code & GRUB_TERM_ALT_GR)
|
if (code & GRUB_TERM_ALT_GR)
|
||||||
|
|
|
@ -51,28 +51,40 @@
|
||||||
#define OLPC_RIGHT '\0'
|
#define OLPC_RIGHT '\0'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GRUB_AT_KEY_KEYBOARD_MAP(name) \
|
#define GRUB_AT_KEY_KEYBOARD_MAP(name) \
|
||||||
static const unsigned name[128] = \
|
static const unsigned name[128] = \
|
||||||
{ \
|
{ \
|
||||||
'\0', GRUB_TERM_ESC, '1', '2', '3', '4', '5', '6', \
|
/* 0x00 */ '\0', GRUB_TERM_ESC, '1', '2', '3', '4', '5', '6', \
|
||||||
'7', '8', '9', '0', '-', '=', GRUB_TERM_BACKSPACE, GRUB_TERM_TAB, \
|
/* 0x08 */ '7', '8', '9', '0', \
|
||||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', \
|
/* 0x0c */ '-', '=', GRUB_TERM_BACKSPACE, GRUB_TERM_TAB, \
|
||||||
'o', 'p', '[', ']', '\n', '\0', 'a', 's', \
|
/* 0x10 */ 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', \
|
||||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', \
|
/* 0x18 */ 'o', 'p', '[', ']', '\n', '\0', 'a', 's', \
|
||||||
'\'', '`', '\0', '\\', 'z', 'x', 'c', 'v', \
|
/* 0x20 */ 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', \
|
||||||
'b', 'n', 'm', ',', '.', '/', '\0', '*', \
|
/* 0x28 */ '\'', '`', '\0', '\\', 'z', 'x', 'c', 'v', \
|
||||||
'\0', ' ', '\0', GRUB_TERM_KEY_F1, \
|
/* 0x30 */ 'b', 'n', 'm', ',', '.', '/', '\0', '*' | GRUB_TERM_KEYPAD, \
|
||||||
GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, \
|
/* 0x38 */ '\0', ' ', '\0', GRUB_TERM_KEY_F1, \
|
||||||
GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9, \
|
/* 0x3c */ GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, \
|
||||||
GRUB_TERM_KEY_F10, '\0', '\0', GRUB_TERM_KEY_HOME, \
|
/* 0x3e */ GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, \
|
||||||
GRUB_TERM_KEY_UP, GRUB_TERM_KEY_NPAGE, '-', GRUB_TERM_KEY_LEFT, \
|
/* 0x40 */ GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, \
|
||||||
'\0', GRUB_TERM_KEY_RIGHT, '+', GRUB_TERM_KEY_END, \
|
/* 0x42 */ GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9, \
|
||||||
GRUB_TERM_KEY_DOWN, GRUB_TERM_KEY_PPAGE, \
|
/* 0x44 */ GRUB_TERM_KEY_F10, '\0', \
|
||||||
GRUB_TERM_KEY_INSERT, GRUB_TERM_KEY_DC, \
|
/* 0x46 */ '\0', GRUB_TERM_KEY_HOME, \
|
||||||
'\0', '\0', GRUB_TERM_KEY_102, GRUB_TERM_KEY_F11, \
|
/* 0x48 */ GRUB_TERM_KEY_UP, \
|
||||||
GRUB_TERM_KEY_F12, '\0', '\0', '\0', '\0', '\0', '\0', '\0', \
|
/* 0x49 */ GRUB_TERM_KEY_NPAGE, \
|
||||||
'\0', '\0', '\0', '\0', '\0', OLPC_UP, OLPC_DOWN, OLPC_LEFT, \
|
/* 0x4a */ '-' | GRUB_TERM_KEYPAD, \
|
||||||
OLPC_RIGHT \
|
/* 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) \
|
#define GRUB_AT_KEY_KEYBOARD_MAP_SHIFT(name) \
|
||||||
|
|
|
@ -25,8 +25,9 @@
|
||||||
#define GRUB_TERM_CTRL 0x02000000
|
#define GRUB_TERM_CTRL 0x02000000
|
||||||
#define GRUB_TERM_ALT 0x04000000
|
#define GRUB_TERM_ALT 0x04000000
|
||||||
/* Used by keylayouts code. Never returned in grub_getkey. */
|
/* Used by keylayouts code. Never returned in grub_getkey. */
|
||||||
#define GRUB_TERM_ALT_GR 0x08000000
|
#define GRUB_TERM_ALT_GR 0x08000000
|
||||||
#define GRUB_TERM_CAPS 0x10000000
|
#define GRUB_TERM_CAPS 0x10000000
|
||||||
|
#define GRUB_TERM_KEYPAD 0x20000000
|
||||||
|
|
||||||
/* Keys without associated character. */
|
/* Keys without associated character. */
|
||||||
#define GRUB_TERM_EXTENDED 0x00800000
|
#define GRUB_TERM_EXTENDED 0x00800000
|
||||||
|
@ -53,6 +54,7 @@
|
||||||
#define GRUB_TERM_KEY_F11 (GRUB_TERM_EXTENDED | 20)
|
#define GRUB_TERM_KEY_F11 (GRUB_TERM_EXTENDED | 20)
|
||||||
#define GRUB_TERM_KEY_F12 (GRUB_TERM_EXTENDED | 21)
|
#define GRUB_TERM_KEY_F12 (GRUB_TERM_EXTENDED | 21)
|
||||||
#define GRUB_TERM_KEY_INSERT (GRUB_TERM_EXTENDED | 22)
|
#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. */
|
/* Used by keylayouts code. Never returned in grub_getkey. */
|
||||||
#define GRUB_TERM_KEY_102 0x80
|
#define GRUB_TERM_KEY_102 0x80
|
||||||
|
|
Loading…
Reference in a new issue