qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Owen Smith <owen.smith@citrix.com>
To: sstabellini@kernel.org, anthony.perard@citrix.com, kraxel@redhat.com
Cc: xen-devel@lists.xenproject.org, qemu-devel@nongnu.org,
	Owen Smith <owen.smith@citrix.com>
Subject: [Qemu-devel] [PATCH 1/3 v4] ui/input: add qemu_input_qcode_to_linux
Date: Tue, 26 Sep 2017 14:43:37 +0000	[thread overview]
Message-ID: <1506437019-17946-2-git-send-email-owen.smith@citrix.com> (raw)
In-Reply-To: <1506437019-17946-1-git-send-email-owen.smith@citrix.com>

Build a reverse mapping on first call that converts qcodes to
linux KEY_* identifiers.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 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

  reply	other threads:[~2017-09-26 14:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-26 14:43 [Qemu-devel] [PATCH 0/3 v4] xenfb: Enablement for Windows PV HID frontend Owen Smith
2017-09-26 14:43 ` Owen Smith [this message]
2017-09-26 14:43 ` [Qemu-devel] [PATCH 2/3 v4] xenfb: Use Input Handlers directly Owen Smith
2017-10-02 17:33   ` Anthony PERARD
2017-09-26 14:43 ` [Qemu-devel] [PATCH 3/3 v4] xenfb: Add [feature|request]-raw-pointer Owen Smith
2017-10-02 17:01   ` Anthony PERARD
2017-10-10 23:52     ` Stefano Stabellini
2017-10-11 15:47       ` Anthony PERARD
2017-10-11 20:19         ` Stefano Stabellini
2017-10-12  7:58           ` [Qemu-devel] [Xen-devel] " Paul Durrant
2017-10-12  9:26             ` Gerd Hoffmann
2017-10-12  9:39               ` Paul Durrant
2017-10-12 17:27                 ` Stefano Stabellini
2017-10-19  9:00                   ` Owen Smith
2017-10-12 10:38           ` [Qemu-devel] " Anthony PERARD
2017-09-29 10:26 ` [Qemu-devel] [PATCH 0/3 v4] xenfb: Enablement for Windows PV HID frontend Gerd Hoffmann
2017-09-29 10:33   ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1506437019-17946-2-git-send-email-owen.smith@citrix.com \
    --to=owen.smith@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).