diff options
author | Samuel Thibault <samuel.thibault@gnu.org> | 2010-02-28 21:03:00 +0100 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2010-03-06 23:15:30 +0100 |
commit | 44bb61c8d9ad5fa0045465933b1ac8f2b1b98762 (patch) | |
tree | 34784bea640f307a4dd6c1e4bedf86cc937b97f3 /curses_keys.h | |
parent | 9d0706e44a14701e8449214c4a62a5a1ca370025 (diff) |
Fix curses interaction with keymaps
The combination of keymap support (-k option) and curses is currently
very broken. The patch below fixes it by first extending keymap support
to interpret the shift, ctrl, altgr and addupper keywords in keymaps,
and to fix curses into properly using keymaps.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'curses_keys.h')
-rw-r--r-- | curses_keys.h | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/curses_keys.h b/curses_keys.h index 5059d37e00..1decd1119d 100644 --- a/curses_keys.h +++ b/curses_keys.h @@ -28,20 +28,36 @@ #define KEY_RELEASE 0x80 #define KEY_MASK 0x7f -#define SHIFT_CODE 0x2a -#define SHIFT 0x0080 #define GREY_CODE 0xe0 -#define GREY 0x0100 +#define GREY SCANCODE_GREY +#define SHIFT_CODE 0x2a +#define SHIFT SCANCODE_SHIFT #define CNTRL_CODE 0x1d -#define CNTRL 0x0200 +#define CNTRL SCANCODE_CTRL #define ALT_CODE 0x38 -#define ALT 0x0400 +#define ALT SCANCODE_ALT +#define ALTGR SCANCODE_ALTGR + +#define KEYSYM_MASK 0x0ffffff +#define KEYSYM_SHIFT (SCANCODE_SHIFT << 16) +#define KEYSYM_CNTRL (SCANCODE_CTRL << 16) +#define KEYSYM_ALT (SCANCODE_ALT << 16) +#define KEYSYM_ALTGR (SCANCODE_ALTGR << 16) /* curses won't detect a Control + Alt + 1, so use Alt + 1 */ #define QEMU_KEY_CONSOLE0 (2 | ALT) /* (curses2keycode['1'] | ALT) */ #define CURSES_KEYS KEY_MAX /* KEY_MAX defined in <curses.h> */ +static const int curses2keysym[CURSES_KEYS] = { + [0 ... (CURSES_KEYS - 1)] = -1, + + [0x7f] = KEY_BACKSPACE, + ['\r'] = KEY_ENTER, + ['\n'] = KEY_ENTER, + [KEY_BTAB] = '\t' | KEYSYM_SHIFT, +}; + static const int curses2keycode[CURSES_KEYS] = { [0 ... (CURSES_KEYS - 1)] = -1, @@ -225,7 +241,7 @@ static const int curses2keycode[CURSES_KEYS] = { }; -static const int curses2keysym[CURSES_KEYS] = { +static const int curses2qemu[CURSES_KEYS] = { [0 ... (CURSES_KEYS - 1)] = -1, ['\n'] = '\n', @@ -449,9 +465,9 @@ static const name2keysym_t name2keysym[] = { { "ydiaeresis", 0x0ff }, /* Special keys */ - { "BackSpace", 0x07f }, + { "BackSpace", KEY_BACKSPACE }, { "Tab", '\t' }, - { "Return", '\n' }, + { "Return", KEY_ENTER }, { "Right", KEY_RIGHT }, { "Left", KEY_LEFT }, { "Up", KEY_UP }, |