{"id":818698,"url":"http://patchwork.ozlabs.org/api/patches/818698/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1506437019-17946-2-git-send-email-owen.smith@citrix.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1506437019-17946-2-git-send-email-owen.smith@citrix.com>","list_archive_url":null,"date":"2017-09-26T14:43:37","name":"[1/3,v4] ui/input: add qemu_input_qcode_to_linux","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7693cf8f980454775b4edbfafa77cdc6685e81d4","submitter":{"id":64781,"url":"http://patchwork.ozlabs.org/api/people/64781/?format=json","name":"Owen Smith","email":"owen.smith@citrix.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1506437019-17946-2-git-send-email-owen.smith@citrix.com/mbox/","series":[{"id":5156,"url":"http://patchwork.ozlabs.org/api/series/5156/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=5156","date":"2017-09-26T14:43:39","name":"xenfb: Enablement for Windows PV HID frontend","version":4,"mbox":"http://patchwork.ozlabs.org/series/5156/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/818698/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/818698/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y1kQq3MVkz9t1G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 27 Sep 2017 00:50:43 +1000 (AEST)","from localhost ([::1]:47951 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dwrC5-00068O-Hy\n\tfor incoming@patchwork.ozlabs.org; Tue, 26 Sep 2017 10:50:41 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:42603)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <prvs=435739c2e=owen.smith@citrix.com>)\n\tid 1dwrBH-0005u3-At\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 10:49:52 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <prvs=435739c2e=owen.smith@citrix.com>)\n\tid 1dwrBC-000413-Mj\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 10:49:51 -0400","from smtp.citrix.com ([66.165.176.89]:54430)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71)\n\t(envelope-from <prvs=435739c2e=owen.smith@citrix.com>)\n\tid 1dwrBC-00040M-Ew\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 10:49:46 -0400"],"X-IronPort-AV":"E=Sophos;i=\"5.42,441,1500940800\"; d=\"scan'208\";a=\"441260934\"","From":"Owen Smith <owen.smith@citrix.com>","To":"<sstabellini@kernel.org>, <anthony.perard@citrix.com>,\n\t<kraxel@redhat.com>","Date":"Tue, 26 Sep 2017 14:43:37 +0000","Message-ID":"<1506437019-17946-2-git-send-email-owen.smith@citrix.com>","X-Mailer":"git-send-email 2.1.4","In-Reply-To":"<1506437019-17946-1-git-send-email-owen.smith@citrix.com>","References":"<1506437019-17946-1-git-send-email-owen.smith@citrix.com>","MIME-Version":"1.0","Content-Type":"text/plain","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"66.165.176.89","Subject":"[Qemu-devel] [PATCH 1/3 v4] ui/input: add qemu_input_qcode_to_linux","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"xen-devel@lists.xenproject.org, qemu-devel@nongnu.org,\n\tOwen Smith <owen.smith@citrix.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"Build a reverse mapping on first call that converts qcodes to\nlinux KEY_* identifiers.\n\nSigned-off-by: Owen Smith <owen.smith@citrix.com>\n---\n include/ui/input.h |  1 +\n ui/input-keymap.c  | 16 ++++++++++++++++\n 2 files changed, 17 insertions(+)","diff":"diff --git a/include/ui/input.h b/include/ui/input.h\nindex c488585..c3c1664 100644\n--- a/include/ui/input.h\n+++ b/include/ui/input.h\n@@ -49,6 +49,7 @@ int qemu_input_key_value_to_qcode(const KeyValue *value);\n int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,\n                                      int *codes);\n int qemu_input_linux_to_qcode(unsigned int lnx);\n+unsigned int qemu_input_qcode_to_linux(int qcode);\n \n InputEvent *qemu_input_event_new_btn(InputButton btn, bool down);\n void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);\ndiff --git a/ui/input-keymap.c b/ui/input-keymap.c\nindex cf979c2..5f020fc 100644\n--- a/ui/input-keymap.c\n+++ b/ui/input-keymap.c\n@@ -300,6 +300,7 @@ static const int qcode_to_number[] = {\n };\n \n static int number_to_qcode[0x100];\n+static unsigned int qcode_to_linux[Q_KEY_CODE__MAX];\n \n int qemu_input_linux_to_qcode(unsigned int lnx)\n {\n@@ -307,6 +308,21 @@ int qemu_input_linux_to_qcode(unsigned int lnx)\n     return linux_to_qcode[lnx];\n }\n \n+unsigned int qemu_input_qcode_to_linux(int qcode)\n+{\n+    static int first = true;\n+\n+    if (first) {\n+        unsigned int lnx;\n+        first = false;\n+        for (lnx = 0; lnx < KEY_CNT; ++lnx) {\n+            qcode_to_linux[linux_to_qcode[lnx]] = lnx;\n+        }\n+    }\n+\n+    return qcode_to_linux[qcode];\n+}\n+\n int qemu_input_key_value_to_number(const KeyValue *value)\n {\n     if (value->type == KEY_VALUE_KIND_QCODE) {\n","prefixes":["1/3","v4"]}