[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/3 v4] ui/input: add qemu_input_qcode_to_linux
Build a reverse mapping on first call that converts qcodes to linux KEY_* identifiers. Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- include/ui/input.h | 1 + ui/input-keymap.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/ui/input.h b/include/ui/input.h index c488585..c3c1664 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -49,6 +49,7 @@ int qemu_input_key_value_to_qcode(const KeyValue *value); int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, int *codes); int qemu_input_linux_to_qcode(unsigned int lnx); +unsigned int qemu_input_qcode_to_linux(int qcode); InputEvent *qemu_input_event_new_btn(InputButton btn, bool down); void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down); diff --git a/ui/input-keymap.c b/ui/input-keymap.c index cf979c2..5f020fc 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -300,6 +300,7 @@ static const int qcode_to_number[] = { }; static int number_to_qcode[0x100]; +static unsigned int qcode_to_linux[Q_KEY_CODE__MAX]; int qemu_input_linux_to_qcode(unsigned int lnx) { @@ -307,6 +308,21 @@ int qemu_input_linux_to_qcode(unsigned int lnx) return linux_to_qcode[lnx]; } +unsigned int qemu_input_qcode_to_linux(int qcode) +{ + static int first = true; + + if (first) { + unsigned int lnx; + first = false; + for (lnx = 0; lnx < KEY_CNT; ++lnx) { + qcode_to_linux[linux_to_qcode[lnx]] = lnx; + } + } + + return qcode_to_linux[qcode]; +} + int qemu_input_key_value_to_number(const KeyValue *value) { if (value->type == KEY_VALUE_KIND_QCODE) { -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |