mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 03:13:44 +08:00
ui: add ctrl modifier support to kbd_put_qcode_console()
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20180321135041.15768-2-kraxel@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
991f366b2f
commit
da024b1ed2
@ -99,7 +99,7 @@ void hmp_mouse_set(Monitor *mon, const QDict *qdict);
|
||||
#define QEMU_KEY_CTRL_PAGEDOWN 0xe407
|
||||
|
||||
void kbd_put_keysym_console(QemuConsole *s, int keysym);
|
||||
bool kbd_put_qcode_console(QemuConsole *s, int qcode);
|
||||
bool kbd_put_qcode_console(QemuConsole *s, int qcode, bool ctrl);
|
||||
void kbd_put_string_console(QemuConsole *s, const char *str, int len);
|
||||
void kbd_put_keysym(int keysym);
|
||||
|
||||
|
15
ui/console.c
15
ui/console.c
@ -1191,11 +1191,22 @@ static const int qcode_to_keysym[Q_KEY_CODE__MAX] = {
|
||||
[Q_KEY_CODE_BACKSPACE] = QEMU_KEY_BACKSPACE,
|
||||
};
|
||||
|
||||
bool kbd_put_qcode_console(QemuConsole *s, int qcode)
|
||||
static const int ctrl_qcode_to_keysym[Q_KEY_CODE__MAX] = {
|
||||
[Q_KEY_CODE_UP] = QEMU_KEY_CTRL_UP,
|
||||
[Q_KEY_CODE_DOWN] = QEMU_KEY_CTRL_DOWN,
|
||||
[Q_KEY_CODE_RIGHT] = QEMU_KEY_CTRL_RIGHT,
|
||||
[Q_KEY_CODE_LEFT] = QEMU_KEY_CTRL_LEFT,
|
||||
[Q_KEY_CODE_HOME] = QEMU_KEY_CTRL_HOME,
|
||||
[Q_KEY_CODE_END] = QEMU_KEY_CTRL_END,
|
||||
[Q_KEY_CODE_PGUP] = QEMU_KEY_CTRL_PAGEUP,
|
||||
[Q_KEY_CODE_PGDN] = QEMU_KEY_CTRL_PAGEDOWN,
|
||||
};
|
||||
|
||||
bool kbd_put_qcode_console(QemuConsole *s, int qcode, bool ctrl)
|
||||
{
|
||||
int keysym;
|
||||
|
||||
keysym = qcode_to_keysym[qcode];
|
||||
keysym = ctrl ? ctrl_qcode_to_keysym[qcode] : qcode_to_keysym[qcode];
|
||||
if (keysym == 0) {
|
||||
return false;
|
||||
}
|
||||
|
4
ui/gtk.c
4
ui/gtk.c
@ -1197,12 +1197,12 @@ static gboolean gd_text_key_down(GtkWidget *widget,
|
||||
QemuConsole *con = vc->gfx.dcl.con;
|
||||
|
||||
if (key->keyval == GDK_KEY_Delete) {
|
||||
kbd_put_qcode_console(con, Q_KEY_CODE_DELETE);
|
||||
kbd_put_qcode_console(con, Q_KEY_CODE_DELETE, false);
|
||||
} else if (key->length) {
|
||||
kbd_put_string_console(con, key->string, key->length);
|
||||
} else {
|
||||
int qcode = gd_map_keycode(key->hardware_keycode);
|
||||
kbd_put_qcode_console(con, qcode);
|
||||
kbd_put_qcode_console(con, qcode, false);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ void sdl2_process_key(struct sdl2_console *scon,
|
||||
kbd_put_keysym_console(con, QEMU_KEY_BACKSPACE);
|
||||
break;
|
||||
default:
|
||||
kbd_put_qcode_console(con, qcode);
|
||||
kbd_put_qcode_console(con, qcode, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user