From nobody Mon Apr 29 17:25:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517221649740364.5506679766404; Mon, 29 Jan 2018 02:27:29 -0800 (PST) Received: from localhost ([::1]:55217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6et-00024G-8g for importer@patchew.org; Mon, 29 Jan 2018 05:27:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6b6-0006Pv-2j for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eg6b1-0001WO-DJ for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45836) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eg6b1-0001VV-71 for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:27 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 818B6883A2; Mon, 29 Jan 2018 10:23:26 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id E449B5C54C; Mon, 29 Jan 2018 10:23:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 242CB11ABC; Mon, 29 Jan 2018 11:23:20 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 29 Jan 2018 11:23:14 +0100 Message-Id: <20180129102320.21534-2-kraxel@redhat.com> In-Reply-To: <20180129102320.21534-1-kraxel@redhat.com> References: <20180129102320.21534-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 29 Jan 2018 10:23:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/7] input: add mouse side buttons to virtio input X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Miika S , Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Miika S Signed-off-by: Miika S Message-Id: <20171222152531.1849-3-miika9764@gmail.com> Signed-off-by: Gerd Hoffmann --- hw/input/virtio-input-hid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index e78faec0b1..a5917c2754 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -147,6 +147,8 @@ static const unsigned int keymap_button[INPUT_BUTTON__M= AX] =3D { [INPUT_BUTTON_MIDDLE] =3D BTN_MIDDLE, [INPUT_BUTTON_WHEEL_UP] =3D BTN_GEAR_UP, [INPUT_BUTTON_WHEEL_DOWN] =3D BTN_GEAR_DOWN, + [INPUT_BUTTON_SIDE] =3D BTN_SIDE, + [INPUT_BUTTON_EXTRA] =3D BTN_EXTRA, }; =20 static const unsigned int axismap_rel[INPUT_AXIS__MAX] =3D { --=20 2.9.3 From nobody Mon Apr 29 17:25:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517221512751227.22242926037438; Mon, 29 Jan 2018 02:25:12 -0800 (PST) Received: from localhost ([::1]:55183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6ci-0000D4-11 for importer@patchew.org; Mon, 29 Jan 2018 05:25:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6b3-0006Nm-Fc for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eg6b0-0001VZ-NR for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32455) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eg6b0-0001Uv-Ij for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF074461C8; Mon, 29 Jan 2018 10:23:25 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id E248F4F9B8; Mon, 29 Jan 2018 10:23:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2CCBD11ABD; Mon, 29 Jan 2018 11:23:20 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 29 Jan 2018 11:23:15 +0100 Message-Id: <20180129102320.21534-3-kraxel@redhat.com> In-Reply-To: <20180129102320.21534-1-kraxel@redhat.com> References: <20180129102320.21534-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 29 Jan 2018 10:23:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/7] input: virtio: don't send mouse wheel event twice X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Miika S , Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Miika S On Linux, a mouse event is generated for both down and up when mouse wheel is used. This caused virtio_input_send() to be called twice each time the wheel was used. This commit adds a check for the button down state and only calls virtio_input_send() when it is true. Signed-off-by: Miika S Message-Id: <20171222152531.1849-4-miika9764@gmail.com> Signed-off-by: Gerd Hoffmann --- hw/input/virtio-input-hid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index a5917c2754..be054fd272 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -218,8 +218,10 @@ static void virtio_input_handle_event(DeviceState *dev= , QemuConsole *src, break; case INPUT_EVENT_KIND_BTN: btn =3D evt->u.btn.data; - if (vhid->wheel_axis && (btn->button =3D=3D INPUT_BUTTON_WHEEL_UP = || - btn->button =3D=3D INPUT_BUTTON_WHEEL_DOW= N)) { + if (vhid->wheel_axis && + (btn->button =3D=3D INPUT_BUTTON_WHEEL_UP || + btn->button =3D=3D INPUT_BUTTON_WHEEL_DOWN) && + btn->down) { event.type =3D cpu_to_le16(EV_REL); event.code =3D cpu_to_le16(REL_WHEEL); event.value =3D cpu_to_le32(btn->button =3D=3D INPUT_BUTTON_WH= EEL_UP --=20 2.9.3 From nobody Mon Apr 29 17:25:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517221649860702.7529850783836; Mon, 29 Jan 2018 02:27:29 -0800 (PST) Received: from localhost ([::1]:55219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6eu-00025n-KZ for importer@patchew.org; Mon, 29 Jan 2018 05:27:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6b2-0006NY-PM for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eg6ay-0001T5-IN for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eg6ay-0001SA-Bw for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:24 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 303BF780E4; Mon, 29 Jan 2018 10:23:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC86C6EE7C; Mon, 29 Jan 2018 10:23:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 34FEC11ABE; Mon, 29 Jan 2018 11:23:20 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 29 Jan 2018 11:23:16 +0100 Message-Id: <20180129102320.21534-4-kraxel@redhat.com> In-Reply-To: <20180129102320.21534-1-kraxel@redhat.com> References: <20180129102320.21534-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 29 Jan 2018 10:23:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/7] ps2: check PS2Queue pointers in post_load routine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Prasad J Pandit , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit During Qemu guest migration, a destination process invokes ps2 post_load function. In that, if 'rptr' and 'count' values were invalid, it could lead to OOB access or infinite loop issue. Add check to avoid it. Reported-by: Cyrille Chatras Signed-off-by: Prasad J Pandit Message-id: 20171116075155.22378-1-ppandit@redhat.com Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index f388a23c8e..de171a28dd 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -1225,24 +1225,21 @@ static void ps2_common_reset(PS2State *s) static void ps2_common_post_load(PS2State *s) { PS2Queue *q =3D &s->queue; - int size; - int i; - int tmp_data[PS2_QUEUE_SIZE]; + uint8_t i, size; + uint8_t tmp_data[PS2_QUEUE_SIZE]; =20 /* set the useful data buffer queue size, < PS2_QUEUE_SIZE */ - size =3D q->count > PS2_QUEUE_SIZE ? 0 : q->count; + size =3D (q->count < 0 || q->count > PS2_QUEUE_SIZE) ? 0 : q->count; =20 /* move the queue elements to the start of data array */ - if (size > 0) { - for (i =3D 0; i < size; i++) { - /* move the queue elements to the temporary buffer */ - tmp_data[i] =3D q->data[q->rptr]; - if (++q->rptr =3D=3D 256) { - q->rptr =3D 0; - } + for (i =3D 0; i < size; i++) { + if (q->rptr < 0 || q->rptr >=3D sizeof(q->data)) { + q->rptr =3D 0; } - memcpy(q->data, tmp_data, size); + tmp_data[i] =3D q->data[q->rptr++]; } + memcpy(q->data, tmp_data, size); + /* reset rptr/wptr/count */ q->rptr =3D 0; q->wptr =3D size; --=20 2.9.3 From nobody Mon Apr 29 17:25:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517221772933541.3538326848088; Mon, 29 Jan 2018 02:29:32 -0800 (PST) Received: from localhost ([::1]:55330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6gu-0003r2-3t for importer@patchew.org; Mon, 29 Jan 2018 05:29:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6b7-0006R2-AV for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eg6b2-0001XB-4o for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48352) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eg6b1-0001WE-R6 for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:28 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22999C04BD57 for ; Mon, 29 Jan 2018 10:23:27 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id F23B35C54E; Mon, 29 Jan 2018 10:23:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4718616E03; Mon, 29 Jan 2018 11:23:20 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 29 Jan 2018 11:23:17 +0100 Message-Id: <20180129102320.21534-5-kraxel@redhat.com> In-Reply-To: <20180129102320.21534-1-kraxel@redhat.com> References: <20180129102320.21534-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 29 Jan 2018 10:23:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/7] hw: convert ps2 device to keycodemapdb X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Replace the qcode_to_keycode_set1, qcode_to_keycode_set2, and qcode_to_keycode_set3 tables with automatically generated tables. Missing entries in qcode_to_keycode_set1 now fixed: - Q_KEY_CODE_SYSRQ -> 0x54 - Q_KEY_CODE_PRINT -> 0x54 (NB ignored due to special case) - Q_KEY_CODE_AGAIN -> 0xe005 - Q_KEY_CODE_PROPS -> 0xe006 - Q_KEY_CODE_UNDO -> 0xe007 - Q_KEY_CODE_FRONT -> 0xe00c - Q_KEY_CODE_COPY -> 0xe078 - Q_KEY_CODE_OPEN -> 0x64 - Q_KEY_CODE_PASTE -> 0x65 - Q_KEY_CODE_CUT -> 0xe03c - Q_KEY_CODE_LF -> 0x5b - Q_KEY_CODE_HELP -> 0xe075 - Q_KEY_CODE_COMPOSE -> 0xe05d - Q_KEY_CODE_PAUSE -> 0xe046 - Q_KEY_CODE_KP_EQUALS -> 0x59 And some mistakes corrected: - Q_KEY_CODE_HIRAGANA was mapped to 0x70 (Katakanahiragana) instead of of 0x77 (Hirigana) - Q_KEY_CODE_MENU was incorrectly mapped to the compose scancode (0xe05d) and is now mapped to 0xe01e - Q_KEY_CODE_FIND was mapped to 0xe065 (Search) instead of to 0xe041 (Find) - Q_KEY_CODE_POWER, SLEEP & WAKE had 0x0e instead of 0xe0 as the prefix Missing entries in qcode_to_keycode_set2 now fixed: - Q_KEY_CODE_PRINT -> 0x7f (NB ignored due to special case) - Q_KEY_CODE_COMPOSE -> 0xe02f - Q_KEY_CODE_PAUSE -> 0xe077 - Q_KEY_CODE_KP_EQUALS -> 0x0f And some mistakes corrected: - Q_KEY_CODE_HIRAGANA was mapped to 0x13 (Katakanahiragana) instead of of 0x62 (Hirigana) - Q_KEY_CODE_MENU was incorrectly mapped to the compose scancode (0xe02f) and is now not mapped - Q_KEY_CODE_FIND was mapped to 0xe010 (Search) and is now not mapped. - Q_KEY_CODE_POWER, SLEEP & WAKE had 0x0e instead of 0xe0 as the prefix Missing entries in qcode_to_keycode_set3 now fixed: - Q_KEY_CODE_ASTERISK -> 0x7e - Q_KEY_CODE_SYSRQ -> 0x57 - Q_KEY_CODE_LESS -> 0x13 - Q_KEY_CODE_STOP -> 0x0a - Q_KEY_CODE_AGAIN -> 0x0b - Q_KEY_CODE_PROPS -> 0x0c - Q_KEY_CODE_UNDO -> 0x10 - Q_KEY_CODE_COPY -> 0x18 - Q_KEY_CODE_OPEN -> 0x20 - Q_KEY_CODE_PASTE -> 0x28 - Q_KEY_CODE_FIND -> 0x30 - Q_KEY_CODE_CUT -> 0x38 - Q_KEY_CODE_HELP -> 0x09 - Q_KEY_CODE_COMPOSE -> 0x8d - Q_KEY_CODE_AUDIONEXT -> 0x93 - Q_KEY_CODE_AUDIOPREV -> 0x94 - Q_KEY_CODE_AUDIOSTOP -> 0x98 - Q_KEY_CODE_AUDIOMUTE -> 0x9c - Q_KEY_CODE_VOLUMEUP -> 0x95 - Q_KEY_CODE_VOLUMEDOWN -> 0x9d - Q_KEY_CODE_CALCULATOR -> 0xa3 - Q_KEY_CODE_AC_HOME -> 0x97 And some mistakes corrected: - Q_KEY_CODE_MENU was incorrectly mapped to the compose scancode (0x8d) and is now 0x91 Signed-off-by: Daniel P. Berrange Message-id: 20180117164118.8510-2-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- Makefile | 3 + include/ui/input.h | 9 ++ hw/input/ps2.c | 406 +------------------------------------------------= ---- ui/input-keymap.c | 3 + 4 files changed, 22 insertions(+), 399 deletions(-) diff --git a/Makefile b/Makefile index af31e8981f..cd65eb4a80 100644 --- a/Makefile +++ b/Makefile @@ -234,6 +234,9 @@ KEYCODEMAP_CSV =3D $(SRC_PATH)/ui/keycodemapdb/data/key= maps.csv KEYCODEMAP_FILES =3D \ ui/input-keymap-atset1-to-qcode.c \ ui/input-keymap-linux-to-qcode.c \ + ui/input-keymap-qcode-to-atset1.c \ + ui/input-keymap-qcode-to-atset2.c \ + ui/input-keymap-qcode-to-atset3.c \ ui/input-keymap-qcode-to-qnum.c \ ui/input-keymap-qnum-to-qcode.c \ ui/input-keymap-qcode-to-linux.c \ diff --git a/include/ui/input.h b/include/ui/input.h index 05aab2db5c..cffeb1c1a0 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -74,6 +74,15 @@ extern const guint16 qemu_input_map_atset1_to_qcode[]; extern const guint qemu_input_map_linux_to_qcode_len; extern const guint16 qemu_input_map_linux_to_qcode[]; =20 +extern const guint qemu_input_map_qcode_to_atset1_len; +extern const guint16 qemu_input_map_qcode_to_atset1[]; + +extern const guint qemu_input_map_qcode_to_atset2_len; +extern const guint16 qemu_input_map_qcode_to_atset2[]; + +extern const guint qemu_input_map_qcode_to_atset3_len; +extern const guint16 qemu_input_map_qcode_to_atset3[]; + extern const guint qemu_input_map_qcode_to_qnum_len; extern const guint16 qemu_input_map_qcode_to_qnum[]; =20 diff --git a/hw/input/ps2.c b/hw/input/ps2.c index de171a28dd..06f5d2ac4a 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -124,401 +124,6 @@ typedef struct { uint8_t mouse_buttons; } PS2MouseState; =20 -/* Table to convert from QEMU codes to scancodes. */ -static const uint16_t qcode_to_keycode_set1[Q_KEY_CODE__MAX] =3D { - [0 ... Q_KEY_CODE__MAX - 1] =3D 0, - - [Q_KEY_CODE_A] =3D 0x1e, - [Q_KEY_CODE_B] =3D 0x30, - [Q_KEY_CODE_C] =3D 0x2e, - [Q_KEY_CODE_D] =3D 0x20, - [Q_KEY_CODE_E] =3D 0x12, - [Q_KEY_CODE_F] =3D 0x21, - [Q_KEY_CODE_G] =3D 0x22, - [Q_KEY_CODE_H] =3D 0x23, - [Q_KEY_CODE_I] =3D 0x17, - [Q_KEY_CODE_J] =3D 0x24, - [Q_KEY_CODE_K] =3D 0x25, - [Q_KEY_CODE_L] =3D 0x26, - [Q_KEY_CODE_M] =3D 0x32, - [Q_KEY_CODE_N] =3D 0x31, - [Q_KEY_CODE_O] =3D 0x18, - [Q_KEY_CODE_P] =3D 0x19, - [Q_KEY_CODE_Q] =3D 0x10, - [Q_KEY_CODE_R] =3D 0x13, - [Q_KEY_CODE_S] =3D 0x1f, - [Q_KEY_CODE_T] =3D 0x14, - [Q_KEY_CODE_U] =3D 0x16, - [Q_KEY_CODE_V] =3D 0x2f, - [Q_KEY_CODE_W] =3D 0x11, - [Q_KEY_CODE_X] =3D 0x2d, - [Q_KEY_CODE_Y] =3D 0x15, - [Q_KEY_CODE_Z] =3D 0x2c, - [Q_KEY_CODE_0] =3D 0x0b, - [Q_KEY_CODE_1] =3D 0x02, - [Q_KEY_CODE_2] =3D 0x03, - [Q_KEY_CODE_3] =3D 0x04, - [Q_KEY_CODE_4] =3D 0x05, - [Q_KEY_CODE_5] =3D 0x06, - [Q_KEY_CODE_6] =3D 0x07, - [Q_KEY_CODE_7] =3D 0x08, - [Q_KEY_CODE_8] =3D 0x09, - [Q_KEY_CODE_9] =3D 0x0a, - [Q_KEY_CODE_GRAVE_ACCENT] =3D 0x29, - [Q_KEY_CODE_MINUS] =3D 0x0c, - [Q_KEY_CODE_EQUAL] =3D 0x0d, - [Q_KEY_CODE_BACKSLASH] =3D 0x2b, - [Q_KEY_CODE_BACKSPACE] =3D 0x0e, - [Q_KEY_CODE_SPC] =3D 0x39, - [Q_KEY_CODE_TAB] =3D 0x0f, - [Q_KEY_CODE_CAPS_LOCK] =3D 0x3a, - [Q_KEY_CODE_SHIFT] =3D 0x2a, - [Q_KEY_CODE_CTRL] =3D 0x1d, - [Q_KEY_CODE_META_L] =3D 0xe05b, - [Q_KEY_CODE_ALT] =3D 0x38, - [Q_KEY_CODE_SHIFT_R] =3D 0x36, - [Q_KEY_CODE_CTRL_R] =3D 0xe01d, - [Q_KEY_CODE_META_R] =3D 0xe05c, - [Q_KEY_CODE_ALT_R] =3D 0xe038, - [Q_KEY_CODE_MENU] =3D 0xe05d, - [Q_KEY_CODE_RET] =3D 0x1c, - [Q_KEY_CODE_ESC] =3D 0x01, - [Q_KEY_CODE_F1] =3D 0x3b, - [Q_KEY_CODE_F2] =3D 0x3c, - [Q_KEY_CODE_F3] =3D 0x3d, - [Q_KEY_CODE_F4] =3D 0x3e, - [Q_KEY_CODE_F5] =3D 0x3f, - [Q_KEY_CODE_F6] =3D 0x40, - [Q_KEY_CODE_F7] =3D 0x41, - [Q_KEY_CODE_F8] =3D 0x42, - [Q_KEY_CODE_F9] =3D 0x43, - [Q_KEY_CODE_F10] =3D 0x44, - [Q_KEY_CODE_F11] =3D 0x57, - [Q_KEY_CODE_F12] =3D 0x58, - /* special handling for Q_KEY_CODE_PRINT */ - [Q_KEY_CODE_SCROLL_LOCK] =3D 0x46, - /* special handling for Q_KEY_CODE_PAUSE */ - [Q_KEY_CODE_BRACKET_LEFT] =3D 0x1a, - [Q_KEY_CODE_INSERT] =3D 0xe052, - [Q_KEY_CODE_HOME] =3D 0xe047, - [Q_KEY_CODE_PGUP] =3D 0xe049, - [Q_KEY_CODE_DELETE] =3D 0xe053, - [Q_KEY_CODE_END] =3D 0xe04f, - [Q_KEY_CODE_PGDN] =3D 0xe051, - [Q_KEY_CODE_UP] =3D 0xe048, - [Q_KEY_CODE_LEFT] =3D 0xe04b, - [Q_KEY_CODE_DOWN] =3D 0xe050, - [Q_KEY_CODE_RIGHT] =3D 0xe04d, - [Q_KEY_CODE_NUM_LOCK] =3D 0x45, - [Q_KEY_CODE_KP_DIVIDE] =3D 0xe035, - [Q_KEY_CODE_KP_MULTIPLY] =3D 0x37, - [Q_KEY_CODE_KP_SUBTRACT] =3D 0x4a, - [Q_KEY_CODE_KP_ADD] =3D 0x4e, - [Q_KEY_CODE_KP_ENTER] =3D 0xe01c, - [Q_KEY_CODE_KP_DECIMAL] =3D 0x53, - [Q_KEY_CODE_KP_0] =3D 0x52, - [Q_KEY_CODE_KP_1] =3D 0x4f, - [Q_KEY_CODE_KP_2] =3D 0x50, - [Q_KEY_CODE_KP_3] =3D 0x51, - [Q_KEY_CODE_KP_4] =3D 0x4b, - [Q_KEY_CODE_KP_5] =3D 0x4c, - [Q_KEY_CODE_KP_6] =3D 0x4d, - [Q_KEY_CODE_KP_7] =3D 0x47, - [Q_KEY_CODE_KP_8] =3D 0x48, - [Q_KEY_CODE_KP_9] =3D 0x49, - [Q_KEY_CODE_BRACKET_RIGHT] =3D 0x1b, - [Q_KEY_CODE_SEMICOLON] =3D 0x27, - [Q_KEY_CODE_APOSTROPHE] =3D 0x28, - [Q_KEY_CODE_COMMA] =3D 0x33, - [Q_KEY_CODE_DOT] =3D 0x34, - [Q_KEY_CODE_SLASH] =3D 0x35, - - [Q_KEY_CODE_POWER] =3D 0x0e5e, - [Q_KEY_CODE_SLEEP] =3D 0x0e5f, - [Q_KEY_CODE_WAKE] =3D 0x0e63, - - [Q_KEY_CODE_AUDIONEXT] =3D 0xe019, - [Q_KEY_CODE_AUDIOPREV] =3D 0xe010, - [Q_KEY_CODE_AUDIOSTOP] =3D 0xe024, - [Q_KEY_CODE_AUDIOPLAY] =3D 0xe022, - [Q_KEY_CODE_AUDIOMUTE] =3D 0xe020, - [Q_KEY_CODE_VOLUMEUP] =3D 0xe030, - [Q_KEY_CODE_VOLUMEDOWN] =3D 0xe02e, - [Q_KEY_CODE_MEDIASELECT] =3D 0xe06d, - [Q_KEY_CODE_MAIL] =3D 0xe06c, - [Q_KEY_CODE_CALCULATOR] =3D 0xe021, - [Q_KEY_CODE_COMPUTER] =3D 0xe06b, - [Q_KEY_CODE_FIND] =3D 0xe065, - [Q_KEY_CODE_AC_HOME] =3D 0xe032, - [Q_KEY_CODE_AC_BACK] =3D 0xe06a, - [Q_KEY_CODE_AC_FORWARD] =3D 0xe069, - [Q_KEY_CODE_STOP] =3D 0xe068, - [Q_KEY_CODE_AC_REFRESH] =3D 0xe067, - [Q_KEY_CODE_AC_BOOKMARKS] =3D 0xe066, - - [Q_KEY_CODE_ASTERISK] =3D 0x37, - [Q_KEY_CODE_LESS] =3D 0x56, - [Q_KEY_CODE_RO] =3D 0x73, - [Q_KEY_CODE_HIRAGANA] =3D 0x70, - [Q_KEY_CODE_HENKAN] =3D 0x79, - [Q_KEY_CODE_YEN] =3D 0x7d, - [Q_KEY_CODE_KP_COMMA] =3D 0x7e, -}; - -static const uint16_t qcode_to_keycode_set2[Q_KEY_CODE__MAX] =3D { - [0 ... Q_KEY_CODE__MAX - 1] =3D 0, - - [Q_KEY_CODE_A] =3D 0x1c, - [Q_KEY_CODE_B] =3D 0x32, - [Q_KEY_CODE_C] =3D 0x21, - [Q_KEY_CODE_D] =3D 0x23, - [Q_KEY_CODE_E] =3D 0x24, - [Q_KEY_CODE_F] =3D 0x2b, - [Q_KEY_CODE_G] =3D 0x34, - [Q_KEY_CODE_H] =3D 0x33, - [Q_KEY_CODE_I] =3D 0x43, - [Q_KEY_CODE_J] =3D 0x3b, - [Q_KEY_CODE_K] =3D 0x42, - [Q_KEY_CODE_L] =3D 0x4b, - [Q_KEY_CODE_M] =3D 0x3a, - [Q_KEY_CODE_N] =3D 0x31, - [Q_KEY_CODE_O] =3D 0x44, - [Q_KEY_CODE_P] =3D 0x4d, - [Q_KEY_CODE_Q] =3D 0x15, - [Q_KEY_CODE_R] =3D 0x2d, - [Q_KEY_CODE_S] =3D 0x1b, - [Q_KEY_CODE_T] =3D 0x2c, - [Q_KEY_CODE_U] =3D 0x3c, - [Q_KEY_CODE_V] =3D 0x2a, - [Q_KEY_CODE_W] =3D 0x1d, - [Q_KEY_CODE_X] =3D 0x22, - [Q_KEY_CODE_Y] =3D 0x35, - [Q_KEY_CODE_Z] =3D 0x1a, - [Q_KEY_CODE_0] =3D 0x45, - [Q_KEY_CODE_1] =3D 0x16, - [Q_KEY_CODE_2] =3D 0x1e, - [Q_KEY_CODE_3] =3D 0x26, - [Q_KEY_CODE_4] =3D 0x25, - [Q_KEY_CODE_5] =3D 0x2e, - [Q_KEY_CODE_6] =3D 0x36, - [Q_KEY_CODE_7] =3D 0x3d, - [Q_KEY_CODE_8] =3D 0x3e, - [Q_KEY_CODE_9] =3D 0x46, - [Q_KEY_CODE_GRAVE_ACCENT] =3D 0x0e, - [Q_KEY_CODE_MINUS] =3D 0x4e, - [Q_KEY_CODE_EQUAL] =3D 0x55, - [Q_KEY_CODE_BACKSLASH] =3D 0x5d, - [Q_KEY_CODE_BACKSPACE] =3D 0x66, - [Q_KEY_CODE_SPC] =3D 0x29, - [Q_KEY_CODE_TAB] =3D 0x0d, - [Q_KEY_CODE_CAPS_LOCK] =3D 0x58, - [Q_KEY_CODE_SHIFT] =3D 0x12, - [Q_KEY_CODE_CTRL] =3D 0x14, - [Q_KEY_CODE_META_L] =3D 0xe01f, - [Q_KEY_CODE_ALT] =3D 0x11, - [Q_KEY_CODE_SHIFT_R] =3D 0x59, - [Q_KEY_CODE_CTRL_R] =3D 0xe014, - [Q_KEY_CODE_META_R] =3D 0xe027, - [Q_KEY_CODE_ALT_R] =3D 0xe011, - [Q_KEY_CODE_MENU] =3D 0xe02f, - [Q_KEY_CODE_RET] =3D 0x5a, - [Q_KEY_CODE_ESC] =3D 0x76, - [Q_KEY_CODE_F1] =3D 0x05, - [Q_KEY_CODE_F2] =3D 0x06, - [Q_KEY_CODE_F3] =3D 0x04, - [Q_KEY_CODE_F4] =3D 0x0c, - [Q_KEY_CODE_F5] =3D 0x03, - [Q_KEY_CODE_F6] =3D 0x0b, - [Q_KEY_CODE_F7] =3D 0x83, - [Q_KEY_CODE_F8] =3D 0x0a, - [Q_KEY_CODE_F9] =3D 0x01, - [Q_KEY_CODE_F10] =3D 0x09, - [Q_KEY_CODE_F11] =3D 0x78, - [Q_KEY_CODE_F12] =3D 0x07, - /* special handling for Q_KEY_CODE_PRINT */ - [Q_KEY_CODE_SCROLL_LOCK] =3D 0x7e, - /* special handling for Q_KEY_CODE_PAUSE */ - [Q_KEY_CODE_BRACKET_LEFT] =3D 0x54, - [Q_KEY_CODE_INSERT] =3D 0xe070, - [Q_KEY_CODE_HOME] =3D 0xe06c, - [Q_KEY_CODE_PGUP] =3D 0xe07d, - [Q_KEY_CODE_DELETE] =3D 0xe071, - [Q_KEY_CODE_END] =3D 0xe069, - [Q_KEY_CODE_PGDN] =3D 0xe07a, - [Q_KEY_CODE_UP] =3D 0xe075, - [Q_KEY_CODE_LEFT] =3D 0xe06b, - [Q_KEY_CODE_DOWN] =3D 0xe072, - [Q_KEY_CODE_RIGHT] =3D 0xe074, - [Q_KEY_CODE_NUM_LOCK] =3D 0x77, - [Q_KEY_CODE_KP_DIVIDE] =3D 0xe04a, - [Q_KEY_CODE_KP_MULTIPLY] =3D 0x7c, - [Q_KEY_CODE_KP_SUBTRACT] =3D 0x7b, - [Q_KEY_CODE_KP_ADD] =3D 0x79, - [Q_KEY_CODE_KP_ENTER] =3D 0xe05a, - [Q_KEY_CODE_KP_DECIMAL] =3D 0x71, - [Q_KEY_CODE_KP_0] =3D 0x70, - [Q_KEY_CODE_KP_1] =3D 0x69, - [Q_KEY_CODE_KP_2] =3D 0x72, - [Q_KEY_CODE_KP_3] =3D 0x7a, - [Q_KEY_CODE_KP_4] =3D 0x6b, - [Q_KEY_CODE_KP_5] =3D 0x73, - [Q_KEY_CODE_KP_6] =3D 0x74, - [Q_KEY_CODE_KP_7] =3D 0x6c, - [Q_KEY_CODE_KP_8] =3D 0x75, - [Q_KEY_CODE_KP_9] =3D 0x7d, - [Q_KEY_CODE_BRACKET_RIGHT] =3D 0x5b, - [Q_KEY_CODE_SEMICOLON] =3D 0x4c, - [Q_KEY_CODE_APOSTROPHE] =3D 0x52, - [Q_KEY_CODE_COMMA] =3D 0x41, - [Q_KEY_CODE_DOT] =3D 0x49, - [Q_KEY_CODE_SLASH] =3D 0x4a, - - [Q_KEY_CODE_POWER] =3D 0x0e37, - [Q_KEY_CODE_SLEEP] =3D 0x0e3f, - [Q_KEY_CODE_WAKE] =3D 0x0e5e, - - [Q_KEY_CODE_AUDIONEXT] =3D 0xe04d, - [Q_KEY_CODE_AUDIOPREV] =3D 0xe015, - [Q_KEY_CODE_AUDIOSTOP] =3D 0xe03b, - [Q_KEY_CODE_AUDIOPLAY] =3D 0xe034, - [Q_KEY_CODE_AUDIOMUTE] =3D 0xe023, - [Q_KEY_CODE_VOLUMEUP] =3D 0xe032, - [Q_KEY_CODE_VOLUMEDOWN] =3D 0xe021, - [Q_KEY_CODE_MEDIASELECT] =3D 0xe050, - [Q_KEY_CODE_MAIL] =3D 0xe048, - [Q_KEY_CODE_CALCULATOR] =3D 0xe02b, - [Q_KEY_CODE_COMPUTER] =3D 0xe040, - [Q_KEY_CODE_FIND] =3D 0xe010, - [Q_KEY_CODE_AC_HOME] =3D 0xe03a, - [Q_KEY_CODE_AC_BACK] =3D 0xe038, - [Q_KEY_CODE_AC_FORWARD] =3D 0xe030, - [Q_KEY_CODE_STOP] =3D 0xe028, - [Q_KEY_CODE_AC_REFRESH] =3D 0xe020, - [Q_KEY_CODE_AC_BOOKMARKS] =3D 0xe018, - - [Q_KEY_CODE_ASTERISK] =3D 0x7c, - [Q_KEY_CODE_LESS] =3D 0x61, - [Q_KEY_CODE_SYSRQ] =3D 0x7f, - [Q_KEY_CODE_RO] =3D 0x51, - [Q_KEY_CODE_HIRAGANA] =3D 0x13, - [Q_KEY_CODE_HENKAN] =3D 0x64, - [Q_KEY_CODE_YEN] =3D 0x6a, - [Q_KEY_CODE_KP_COMMA] =3D 0x6d, -}; - -static const uint16_t qcode_to_keycode_set3[Q_KEY_CODE__MAX] =3D { - [0 ... Q_KEY_CODE__MAX - 1] =3D 0, - - [Q_KEY_CODE_A] =3D 0x1c, - [Q_KEY_CODE_B] =3D 0x32, - [Q_KEY_CODE_C] =3D 0x21, - [Q_KEY_CODE_D] =3D 0x23, - [Q_KEY_CODE_E] =3D 0x24, - [Q_KEY_CODE_F] =3D 0x2b, - [Q_KEY_CODE_G] =3D 0x34, - [Q_KEY_CODE_H] =3D 0x33, - [Q_KEY_CODE_I] =3D 0x43, - [Q_KEY_CODE_J] =3D 0x3b, - [Q_KEY_CODE_K] =3D 0x42, - [Q_KEY_CODE_L] =3D 0x4b, - [Q_KEY_CODE_M] =3D 0x3a, - [Q_KEY_CODE_N] =3D 0x31, - [Q_KEY_CODE_O] =3D 0x44, - [Q_KEY_CODE_P] =3D 0x4d, - [Q_KEY_CODE_Q] =3D 0x15, - [Q_KEY_CODE_R] =3D 0x2d, - [Q_KEY_CODE_S] =3D 0x1b, - [Q_KEY_CODE_T] =3D 0x2c, - [Q_KEY_CODE_U] =3D 0x3c, - [Q_KEY_CODE_V] =3D 0x2a, - [Q_KEY_CODE_W] =3D 0x1d, - [Q_KEY_CODE_X] =3D 0x22, - [Q_KEY_CODE_Y] =3D 0x35, - [Q_KEY_CODE_Z] =3D 0x1a, - [Q_KEY_CODE_0] =3D 0x45, - [Q_KEY_CODE_1] =3D 0x16, - [Q_KEY_CODE_2] =3D 0x1e, - [Q_KEY_CODE_3] =3D 0x26, - [Q_KEY_CODE_4] =3D 0x25, - [Q_KEY_CODE_5] =3D 0x2e, - [Q_KEY_CODE_6] =3D 0x36, - [Q_KEY_CODE_7] =3D 0x3d, - [Q_KEY_CODE_8] =3D 0x3e, - [Q_KEY_CODE_9] =3D 0x46, - [Q_KEY_CODE_GRAVE_ACCENT] =3D 0x0e, - [Q_KEY_CODE_MINUS] =3D 0x4e, - [Q_KEY_CODE_EQUAL] =3D 0x55, - [Q_KEY_CODE_BACKSLASH] =3D 0x5c, - [Q_KEY_CODE_BACKSPACE] =3D 0x66, - [Q_KEY_CODE_SPC] =3D 0x29, - [Q_KEY_CODE_TAB] =3D 0x0d, - [Q_KEY_CODE_CAPS_LOCK] =3D 0x14, - [Q_KEY_CODE_SHIFT] =3D 0x12, - [Q_KEY_CODE_CTRL] =3D 0x11, - [Q_KEY_CODE_META_L] =3D 0x8b, - [Q_KEY_CODE_ALT] =3D 0x19, - [Q_KEY_CODE_SHIFT_R] =3D 0x59, - [Q_KEY_CODE_CTRL_R] =3D 0x58, - [Q_KEY_CODE_META_R] =3D 0x8c, - [Q_KEY_CODE_ALT_R] =3D 0x39, - [Q_KEY_CODE_MENU] =3D 0x8d, - [Q_KEY_CODE_RET] =3D 0x5a, - [Q_KEY_CODE_ESC] =3D 0x08, - [Q_KEY_CODE_F1] =3D 0x07, - [Q_KEY_CODE_F2] =3D 0x0f, - [Q_KEY_CODE_F3] =3D 0x17, - [Q_KEY_CODE_F4] =3D 0x1f, - [Q_KEY_CODE_F5] =3D 0x27, - [Q_KEY_CODE_F6] =3D 0x2f, - [Q_KEY_CODE_F7] =3D 0x37, - [Q_KEY_CODE_F8] =3D 0x3f, - [Q_KEY_CODE_F9] =3D 0x47, - [Q_KEY_CODE_F10] =3D 0x4f, - [Q_KEY_CODE_F11] =3D 0x56, - [Q_KEY_CODE_F12] =3D 0x5e, - [Q_KEY_CODE_PRINT] =3D 0x57, - [Q_KEY_CODE_SCROLL_LOCK] =3D 0x5f, - [Q_KEY_CODE_PAUSE] =3D 0x62, - [Q_KEY_CODE_BRACKET_LEFT] =3D 0x54, - [Q_KEY_CODE_INSERT] =3D 0x67, - [Q_KEY_CODE_HOME] =3D 0x6e, - [Q_KEY_CODE_PGUP] =3D 0x6f, - [Q_KEY_CODE_DELETE] =3D 0x64, - [Q_KEY_CODE_END] =3D 0x65, - [Q_KEY_CODE_PGDN] =3D 0x6d, - [Q_KEY_CODE_UP] =3D 0x63, - [Q_KEY_CODE_LEFT] =3D 0x61, - [Q_KEY_CODE_DOWN] =3D 0x60, - [Q_KEY_CODE_RIGHT] =3D 0x6a, - [Q_KEY_CODE_NUM_LOCK] =3D 0x76, - [Q_KEY_CODE_KP_DIVIDE] =3D 0x4a, - [Q_KEY_CODE_KP_MULTIPLY] =3D 0x7e, - [Q_KEY_CODE_KP_SUBTRACT] =3D 0x4e, - [Q_KEY_CODE_KP_ADD] =3D 0x7c, - [Q_KEY_CODE_KP_ENTER] =3D 0x79, - [Q_KEY_CODE_KP_DECIMAL] =3D 0x71, - [Q_KEY_CODE_KP_0] =3D 0x70, - [Q_KEY_CODE_KP_1] =3D 0x69, - [Q_KEY_CODE_KP_2] =3D 0x72, - [Q_KEY_CODE_KP_3] =3D 0x7a, - [Q_KEY_CODE_KP_4] =3D 0x6b, - [Q_KEY_CODE_KP_5] =3D 0x73, - [Q_KEY_CODE_KP_6] =3D 0x74, - [Q_KEY_CODE_KP_7] =3D 0x6c, - [Q_KEY_CODE_KP_8] =3D 0x75, - [Q_KEY_CODE_KP_9] =3D 0x7d, - [Q_KEY_CODE_BRACKET_RIGHT] =3D 0x5b, - [Q_KEY_CODE_SEMICOLON] =3D 0x4c, - [Q_KEY_CODE_APOSTROPHE] =3D 0x52, - [Q_KEY_CODE_COMMA] =3D 0x41, - [Q_KEY_CODE_DOT] =3D 0x49, - [Q_KEY_CODE_SLASH] =3D 0x4a, - - [Q_KEY_CODE_HIRAGANA] =3D 0x87, - [Q_KEY_CODE_HENKAN] =3D 0x86, - [Q_KEY_CODE_YEN] =3D 0x5d, -}; - static uint8_t translate_table[256] =3D { 0xff, 0x43, 0x41, 0x3f, 0x3d, 0x3b, 0x3c, 0x58, 0x64, 0x44, 0x42, 0x40, 0x3e, 0x0f, 0x29, 0x59, @@ -624,7 +229,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, PS2KbdState *s =3D (PS2KbdState *)dev; InputKeyEvent *key =3D evt->u.key.data; int qcode; - uint16_t keycode; + uint16_t keycode =3D 0; int mod; =20 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); @@ -706,7 +311,8 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } } } else { - keycode =3D qcode_to_keycode_set1[qcode]; + if (qcode < qemu_input_map_qcode_to_atset1_len) + keycode =3D qemu_input_map_qcode_to_atset1[qcode]; if (keycode) { if (keycode & 0xff00) { ps2_put_keycode(s, keycode >> 8); @@ -799,7 +405,8 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } } } else { - keycode =3D qcode_to_keycode_set2[qcode]; + if (qcode < qemu_input_map_qcode_to_atset2_len) + keycode =3D qemu_input_map_qcode_to_atset2[qcode]; if (keycode) { if (keycode & 0xff00) { ps2_put_keycode(s, keycode >> 8); @@ -814,7 +421,8 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } } } else if (s->scancode_set =3D=3D 3) { - keycode =3D qcode_to_keycode_set3[qcode]; + if (qcode < qemu_input_map_qcode_to_atset3_len) + keycode =3D qemu_input_map_qcode_to_atset3[qcode]; if (keycode) { /* FIXME: break code should be configured on a key by key basi= s */ if (!key->down) { diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 95b1e0cbfa..07be8f4415 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -7,6 +7,9 @@ =20 #include "ui/input-keymap-atset1-to-qcode.c" #include "ui/input-keymap-linux-to-qcode.c" +#include "ui/input-keymap-qcode-to-atset1.c" +#include "ui/input-keymap-qcode-to-atset2.c" +#include "ui/input-keymap-qcode-to-atset3.c" #include "ui/input-keymap-qcode-to-qnum.c" #include "ui/input-keymap-qnum-to-qcode.c" #include "ui/input-keymap-qcode-to-linux.c" --=20 2.9.3 From nobody Mon Apr 29 17:25:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517221505777456.4773187378091; Mon, 29 Jan 2018 02:25:05 -0800 (PST) Received: from localhost ([::1]:55180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6ca-0008WK-LJ for importer@patchew.org; Mon, 29 Jan 2018 05:25:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6b3-0006Ns-MX for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eg6b2-0001X1-2w for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48354) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eg6b1-0001WK-R9 for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:28 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32955C047B8E for ; Mon, 29 Jan 2018 10:23:27 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBACA7A02B; Mon, 29 Jan 2018 10:23:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 523E517442; Mon, 29 Jan 2018 11:23:20 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 29 Jan 2018 11:23:18 +0100 Message-Id: <20180129102320.21534-6-kraxel@redhat.com> In-Reply-To: <20180129102320.21534-1-kraxel@redhat.com> References: <20180129102320.21534-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 29 Jan 2018 10:23:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/7] hw: convert the escc device to keycodemapdb X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Replace the qcode_to_keycode table with automatically generated tables. Missing entries in qcode_to_keycode now fixed: - Q_KEY_CODE_KP_COMMA -> 0x2d Signed-off-by: Daniel P. Berrange Message-id: 20180117164118.8510-3-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- Makefile | 1 + include/ui/input.h | 3 ++ hw/char/escc.c | 126 +++----------------------------------------------= ---- ui/input-keymap.c | 1 + 4 files changed, 10 insertions(+), 121 deletions(-) diff --git a/Makefile b/Makefile index cd65eb4a80..f9278f14c9 100644 --- a/Makefile +++ b/Makefile @@ -238,6 +238,7 @@ KEYCODEMAP_FILES =3D \ ui/input-keymap-qcode-to-atset2.c \ ui/input-keymap-qcode-to-atset3.c \ ui/input-keymap-qcode-to-qnum.c \ + ui/input-keymap-qcode-to-sun.c \ ui/input-keymap-qnum-to-qcode.c \ ui/input-keymap-qcode-to-linux.c \ ui/input-keymap-usb-to-qcode.c \ diff --git a/include/ui/input.h b/include/ui/input.h index cffeb1c1a0..7d6c92224e 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -86,6 +86,9 @@ extern const guint16 qemu_input_map_qcode_to_atset3[]; extern const guint qemu_input_map_qcode_to_qnum_len; extern const guint16 qemu_input_map_qcode_to_qnum[]; =20 +extern const guint qemu_input_map_qcode_to_sun_len; +extern const guint16 qemu_input_map_qcode_to_sun[]; + extern const guint qemu_input_map_qnum_to_qcode_len; extern const guint16 qemu_input_map_qnum_to_qcode[]; =20 diff --git a/hw/char/escc.c b/hw/char/escc.c index 3ab831a6a7..449bf2fc63 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -717,126 +717,6 @@ MemoryRegion *escc_init(hwaddr base, qemu_irq irqA, q= emu_irq irqB, return &d->mmio; } =20 -static const uint8_t qcode_to_keycode[Q_KEY_CODE__MAX] =3D { - [Q_KEY_CODE_SHIFT] =3D 99, - [Q_KEY_CODE_SHIFT_R] =3D 110, - [Q_KEY_CODE_ALT] =3D 19, - [Q_KEY_CODE_ALT_R] =3D 13, - [Q_KEY_CODE_CTRL] =3D 76, - [Q_KEY_CODE_CTRL_R] =3D 76, - [Q_KEY_CODE_ESC] =3D 29, - [Q_KEY_CODE_1] =3D 30, - [Q_KEY_CODE_2] =3D 31, - [Q_KEY_CODE_3] =3D 32, - [Q_KEY_CODE_4] =3D 33, - [Q_KEY_CODE_5] =3D 34, - [Q_KEY_CODE_6] =3D 35, - [Q_KEY_CODE_7] =3D 36, - [Q_KEY_CODE_8] =3D 37, - [Q_KEY_CODE_9] =3D 38, - [Q_KEY_CODE_0] =3D 39, - [Q_KEY_CODE_MINUS] =3D 40, - [Q_KEY_CODE_EQUAL] =3D 41, - [Q_KEY_CODE_BACKSPACE] =3D 43, - [Q_KEY_CODE_TAB] =3D 53, - [Q_KEY_CODE_Q] =3D 54, - [Q_KEY_CODE_W] =3D 55, - [Q_KEY_CODE_E] =3D 56, - [Q_KEY_CODE_R] =3D 57, - [Q_KEY_CODE_T] =3D 58, - [Q_KEY_CODE_Y] =3D 59, - [Q_KEY_CODE_U] =3D 60, - [Q_KEY_CODE_I] =3D 61, - [Q_KEY_CODE_O] =3D 62, - [Q_KEY_CODE_P] =3D 63, - [Q_KEY_CODE_BRACKET_LEFT] =3D 64, - [Q_KEY_CODE_BRACKET_RIGHT] =3D 65, - [Q_KEY_CODE_RET] =3D 89, - [Q_KEY_CODE_A] =3D 77, - [Q_KEY_CODE_S] =3D 78, - [Q_KEY_CODE_D] =3D 79, - [Q_KEY_CODE_F] =3D 80, - [Q_KEY_CODE_G] =3D 81, - [Q_KEY_CODE_H] =3D 82, - [Q_KEY_CODE_J] =3D 83, - [Q_KEY_CODE_K] =3D 84, - [Q_KEY_CODE_L] =3D 85, - [Q_KEY_CODE_SEMICOLON] =3D 86, - [Q_KEY_CODE_APOSTROPHE] =3D 87, - [Q_KEY_CODE_GRAVE_ACCENT] =3D 42, - [Q_KEY_CODE_BACKSLASH] =3D 88, - [Q_KEY_CODE_Z] =3D 100, - [Q_KEY_CODE_X] =3D 101, - [Q_KEY_CODE_C] =3D 102, - [Q_KEY_CODE_V] =3D 103, - [Q_KEY_CODE_B] =3D 104, - [Q_KEY_CODE_N] =3D 105, - [Q_KEY_CODE_M] =3D 106, - [Q_KEY_CODE_COMMA] =3D 107, - [Q_KEY_CODE_DOT] =3D 108, - [Q_KEY_CODE_SLASH] =3D 109, - [Q_KEY_CODE_ASTERISK] =3D 47, - [Q_KEY_CODE_SPC] =3D 121, - [Q_KEY_CODE_CAPS_LOCK] =3D 119, - [Q_KEY_CODE_F1] =3D 5, - [Q_KEY_CODE_F2] =3D 6, - [Q_KEY_CODE_F3] =3D 8, - [Q_KEY_CODE_F4] =3D 10, - [Q_KEY_CODE_F5] =3D 12, - [Q_KEY_CODE_F6] =3D 14, - [Q_KEY_CODE_F7] =3D 16, - [Q_KEY_CODE_F8] =3D 17, - [Q_KEY_CODE_F9] =3D 18, - [Q_KEY_CODE_F10] =3D 7, - [Q_KEY_CODE_NUM_LOCK] =3D 98, - [Q_KEY_CODE_SCROLL_LOCK] =3D 23, - [Q_KEY_CODE_KP_DIVIDE] =3D 46, - [Q_KEY_CODE_KP_MULTIPLY] =3D 47, - [Q_KEY_CODE_KP_SUBTRACT] =3D 71, - [Q_KEY_CODE_KP_ADD] =3D 125, - [Q_KEY_CODE_KP_ENTER] =3D 90, - [Q_KEY_CODE_KP_DECIMAL] =3D 50, - [Q_KEY_CODE_KP_0] =3D 94, - [Q_KEY_CODE_KP_1] =3D 112, - [Q_KEY_CODE_KP_2] =3D 113, - [Q_KEY_CODE_KP_3] =3D 114, - [Q_KEY_CODE_KP_4] =3D 91, - [Q_KEY_CODE_KP_5] =3D 92, - [Q_KEY_CODE_KP_6] =3D 93, - [Q_KEY_CODE_KP_7] =3D 68, - [Q_KEY_CODE_KP_8] =3D 69, - [Q_KEY_CODE_KP_9] =3D 70, - [Q_KEY_CODE_LESS] =3D 124, - [Q_KEY_CODE_F11] =3D 9, - [Q_KEY_CODE_F12] =3D 11, - [Q_KEY_CODE_HOME] =3D 52, - [Q_KEY_CODE_PGUP] =3D 96, - [Q_KEY_CODE_PGDN] =3D 123, - [Q_KEY_CODE_END] =3D 74, - [Q_KEY_CODE_LEFT] =3D 24, - [Q_KEY_CODE_UP] =3D 20, - [Q_KEY_CODE_DOWN] =3D 27, - [Q_KEY_CODE_RIGHT] =3D 28, - [Q_KEY_CODE_INSERT] =3D 44, - [Q_KEY_CODE_DELETE] =3D 66, - [Q_KEY_CODE_STOP] =3D 1, - [Q_KEY_CODE_AGAIN] =3D 3, - [Q_KEY_CODE_PROPS] =3D 25, - [Q_KEY_CODE_UNDO] =3D 26, - [Q_KEY_CODE_FRONT] =3D 49, - [Q_KEY_CODE_COPY] =3D 51, - [Q_KEY_CODE_OPEN] =3D 72, - [Q_KEY_CODE_PASTE] =3D 73, - [Q_KEY_CODE_FIND] =3D 95, - [Q_KEY_CODE_CUT] =3D 97, - [Q_KEY_CODE_LF] =3D 111, - [Q_KEY_CODE_HELP] =3D 118, - [Q_KEY_CODE_META_L] =3D 120, - [Q_KEY_CODE_META_R] =3D 122, - [Q_KEY_CODE_COMPOSE] =3D 67, - [Q_KEY_CODE_PRINT] =3D 22, - [Q_KEY_CODE_SYSRQ] =3D 21, -}; =20 static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) @@ -879,7 +759,11 @@ static void sunkbd_handle_event(DeviceState *dev, Qemu= Console *src, } } =20 - keycode =3D qcode_to_keycode[qcode]; + if (qcode > qemu_input_map_qcode_to_sun_len) { + return; + } + + keycode =3D qemu_input_map_qcode_to_sun[qcode]; if (!key->down) { keycode |=3D 0x80; } diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 07be8f4415..7a9475abd9 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -11,6 +11,7 @@ #include "ui/input-keymap-qcode-to-atset2.c" #include "ui/input-keymap-qcode-to-atset3.c" #include "ui/input-keymap-qcode-to-qnum.c" +#include "ui/input-keymap-qcode-to-sun.c" #include "ui/input-keymap-qnum-to-qcode.c" #include "ui/input-keymap-qcode-to-linux.c" #include "ui/input-keymap-usb-to-qcode.c" --=20 2.9.3 From nobody Mon Apr 29 17:25:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517221517135699.1800878276009; Mon, 29 Jan 2018 02:25:17 -0800 (PST) Received: from localhost ([::1]:55184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6ck-0000Dz-8T for importer@patchew.org; Mon, 29 Jan 2018 05:25:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6b3-0006Nn-G8 for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eg6az-0001Tm-5E for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42178) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eg6ay-0001Sp-Tz for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:25 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FE9113AA2 for ; Mon, 29 Jan 2018 10:23:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED2F96EE7C; Mon, 29 Jan 2018 10:23:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 5C38917443; Mon, 29 Jan 2018 11:23:20 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 29 Jan 2018 11:23:19 +0100 Message-Id: <20180129102320.21534-7-kraxel@redhat.com> In-Reply-To: <20180129102320.21534-1-kraxel@redhat.com> References: <20180129102320.21534-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 29 Jan 2018 10:23:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/7] ui: fix alphabetical ordering of keymaps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The qcode-to-linux keymaps was accidentally added in the wrong place by commit de80d78594b4c3767a12d8d42debcf12cbf85a5b Author: Owen Smith Date: Fri Nov 3 11:56:28 2017 +0000 ui: generate qcode to linux mappings breaking the alphabetical ordering of keymaps Signed-off-by: Daniel P. Berrange Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20180117164118.8510-4-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- Makefile | 2 +- include/ui/input.h | 6 +++--- ui/input-keymap.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index f9278f14c9..7073b3d842 100644 --- a/Makefile +++ b/Makefile @@ -237,10 +237,10 @@ KEYCODEMAP_FILES =3D \ ui/input-keymap-qcode-to-atset1.c \ ui/input-keymap-qcode-to-atset2.c \ ui/input-keymap-qcode-to-atset3.c \ + ui/input-keymap-qcode-to-linux.c \ ui/input-keymap-qcode-to-qnum.c \ ui/input-keymap-qcode-to-sun.c \ ui/input-keymap-qnum-to-qcode.c \ - ui/input-keymap-qcode-to-linux.c \ ui/input-keymap-usb-to-qcode.c \ ui/input-keymap-win32-to-qcode.c \ ui/input-keymap-x11-to-qcode.c \ diff --git a/include/ui/input.h b/include/ui/input.h index 7d6c92224e..ceb22b8eef 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -83,6 +83,9 @@ extern const guint16 qemu_input_map_qcode_to_atset2[]; extern const guint qemu_input_map_qcode_to_atset3_len; extern const guint16 qemu_input_map_qcode_to_atset3[]; =20 +extern const guint qemu_input_map_qcode_to_linux_len; +extern const guint16 qemu_input_map_qcode_to_linux[]; + extern const guint qemu_input_map_qcode_to_qnum_len; extern const guint16 qemu_input_map_qcode_to_qnum[]; =20 @@ -92,9 +95,6 @@ extern const guint16 qemu_input_map_qcode_to_sun[]; extern const guint qemu_input_map_qnum_to_qcode_len; extern const guint16 qemu_input_map_qnum_to_qcode[]; =20 -extern const guint qemu_input_map_qcode_to_linux_len; -extern const guint16 qemu_input_map_qcode_to_linux[]; - extern const guint qemu_input_map_usb_to_qcode_len; extern const guint16 qemu_input_map_usb_to_qcode[]; =20 diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 7a9475abd9..3d4e66bab5 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -10,10 +10,10 @@ #include "ui/input-keymap-qcode-to-atset1.c" #include "ui/input-keymap-qcode-to-atset2.c" #include "ui/input-keymap-qcode-to-atset3.c" +#include "ui/input-keymap-qcode-to-linux.c" #include "ui/input-keymap-qcode-to-qnum.c" #include "ui/input-keymap-qcode-to-sun.c" #include "ui/input-keymap-qnum-to-qcode.c" -#include "ui/input-keymap-qcode-to-linux.c" #include "ui/input-keymap-usb-to-qcode.c" #include "ui/input-keymap-win32-to-qcode.c" #include "ui/input-keymap-x11-to-qcode.c" --=20 2.9.3 From nobody Mon Apr 29 17:25:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517221779836552.2256685872171; Mon, 29 Jan 2018 02:29:39 -0800 (PST) Received: from localhost ([::1]:55332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6h1-0003xC-0m for importer@patchew.org; Mon, 29 Jan 2018 05:29:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eg6b3-0006Nu-N7 for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eg6b2-0001Wy-2l for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46232) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eg6b1-0001WG-Qt for qemu-devel@nongnu.org; Mon, 29 Jan 2018 05:23:28 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 292BD7EA90 for ; Mon, 29 Jan 2018 10:23:27 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 580DD6178A; Mon, 29 Jan 2018 10:23:24 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 649C617444; Mon, 29 Jan 2018 11:23:20 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 29 Jan 2018 11:23:20 +0100 Message-Id: <20180129102320.21534-8-kraxel@redhat.com> In-Reply-To: <20180129102320.21534-1-kraxel@redhat.com> References: <20180129102320.21534-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 29 Jan 2018 10:23:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/7] hw: convert virtio-input-hid device to keycodemapdb X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Replace the keymap_qcode table with automatically generated tables. Missing entries in keymap_qcode now fixed: Q_KEY_CODE_ASTERISK -> KEY_KPASTERISK Q_KEY_CODE_KP_MULTIPLY -> KEY_KPASTERISK Q_KEY_CODE_STOP -> KEY_STOP Q_KEY_CODE_AGAIN -> KEY_AGAIN Q_KEY_CODE_PROPS -> KEY_PROPS Q_KEY_CODE_UNDO -> KEY_UNDO Q_KEY_CODE_FRONT -> KEY_FRONT Q_KEY_CODE_COPY -> KEY_COPY Q_KEY_CODE_OPEN -> KEY_OPEN Q_KEY_CODE_PASTE -> KEY_PASTE Q_KEY_CODE_FIND -> KEY_FIND Q_KEY_CODE_CUT -> KEY_CUT Q_KEY_CODE_LF -> KEY_LINEFEED Q_KEY_CODE_HELP -> KEY_HELP Q_KEY_CODE_COMPOSE -> KEY_COMPOSE Q_KEY_CODE_RO -> KEY_RO Q_KEY_CODE_HIRAGANA -> KEY_HIRAGANA Q_KEY_CODE_HENKAN -> KEY_HENKAN Q_KEY_CODE_YEN -> KEY_YEN Q_KEY_CODE_KP_COMMA -> KEY_KPCOMMA Q_KEY_CODE_KP_EQUALS -> KEY_KPEQUAL Q_KEY_CODE_POWER -> KEY_POWER Q_KEY_CODE_SLEEP -> KEY_SLEEP Q_KEY_CODE_WAKE -> KEY_WAKEUP Q_KEY_CODE_AUDIONEXT -> KEY_NEXTSONG Q_KEY_CODE_AUDIOPREV -> KEY_PREVIOUSSONG Q_KEY_CODE_AUDIOSTOP -> KEY_STOPCD Q_KEY_CODE_AUDIOPLAY -> KEY_PLAYPAUSE Q_KEY_CODE_AUDIOMUTE -> KEY_MUTE Q_KEY_CODE_VOLUMEUP -> KEY_VOLUMEUP Q_KEY_CODE_VOLUMEDOWN -> KEY_VOLUMEDOWN Q_KEY_CODE_MEDIASELECT -> KEY_MEDIA Q_KEY_CODE_MAIL -> KEY_MAIL Q_KEY_CODE_CALCULATOR -> KEY_CALC Q_KEY_CODE_COMPUTER -> KEY_COMPUTER Q_KEY_CODE_AC_HOME -> KEY_HOMEPAGE Q_KEY_CODE_AC_BACK -> KEY_BACK Q_KEY_CODE_AC_FORWARD -> KEY_FORWARD Q_KEY_CODE_AC_REFRESH -> KEY_REFRESH Q_KEY_CODE_AC_BOOKMARKS -> KEY_BOOKMARKS NB, the virtio-input device reports a bitmask to the guest driver that has a bit set for each Linux keycode that the host is able to send to the guest. Thus by adding these extra key mappings we are technically changing the host<->guest ABI. This would also happen any time we defined new mappings for QEMU keycodes in future. When a keycode is removed from the list of possible keycodes that host can send to the guest, it means that the guest OS will think it is possible to receive a key that in pratice can never be generated, which is harmless. When a keycode is added to the list of possible keycodes that the host can send to the guest, it means that the guest OS can see an unexpected event. The Linux virtio_input.c driver code simply forwards this event to the input_event() method in the Linux input subsystem. This in turn calls input_handle_event(), which then calls input_get_disposition(). This method checks if the input event is present in the permitted keys bitmap, and if not returns INPUT_IGNORE_EVENT. Thus the unexpected event will get dropped, which is harmless. If the guest OS reboots, or otherwise re-initializes the virt-input device, it will read the new keycode bitmap. No matter how many keys are defined, the config space has a fixed 128 byte bitmap. There is, however, a size field defiend which says how many bytes in the bitmap are used. So the guest OS reads the size of the bitmap, and then it reads the data from bitmap upto the designated size. So if the guest OS re-initializes at precisely the time that QEMU is migrated across versions, in the worst case, it could conceiva= bly read the old size field, but then get the newly updated bitmap. If a key w= ere added this is harmless, since it simply means it may not process the newly added key. If a key were removed, then it could be readnig a byte from the bitmap that was not initialized. Fortunately QEMU always memsets() the enti= re bitmap to 0, prior to setting keybits. Thus the guest OS will simply read zeros, which is again harmless. Based on this analysis, it is believed that there is no need to preserve the virtio-input-hid keymaps across migration, as the host<->guest ABI change is harmless and self-resolving at time of guest reboot. NB, this behaviour should perhaps be formalized in the virtio-input spec to declare how guest OS drivers should be written to be robust in their handling of the potentially changable key bitmaps. Signed-off-by: Daniel P. Berrange Message-id: 20180117164118.8510-5-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- hw/input/virtio-input-hid.c | 136 +++-------------------------------------= ---- 1 file changed, 9 insertions(+), 127 deletions(-) diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index be054fd272..bc5f9a2ed2 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -22,126 +22,7 @@ =20 /* ----------------------------------------------------------------- */ =20 -static const unsigned int keymap_qcode[Q_KEY_CODE__MAX] =3D { - [Q_KEY_CODE_ESC] =3D KEY_ESC, - [Q_KEY_CODE_1] =3D KEY_1, - [Q_KEY_CODE_2] =3D KEY_2, - [Q_KEY_CODE_3] =3D KEY_3, - [Q_KEY_CODE_4] =3D KEY_4, - [Q_KEY_CODE_5] =3D KEY_5, - [Q_KEY_CODE_6] =3D KEY_6, - [Q_KEY_CODE_7] =3D KEY_7, - [Q_KEY_CODE_8] =3D KEY_8, - [Q_KEY_CODE_9] =3D KEY_9, - [Q_KEY_CODE_0] =3D KEY_0, - [Q_KEY_CODE_MINUS] =3D KEY_MINUS, - [Q_KEY_CODE_EQUAL] =3D KEY_EQUAL, - [Q_KEY_CODE_BACKSPACE] =3D KEY_BACKSPACE, - - [Q_KEY_CODE_TAB] =3D KEY_TAB, - [Q_KEY_CODE_Q] =3D KEY_Q, - [Q_KEY_CODE_W] =3D KEY_W, - [Q_KEY_CODE_E] =3D KEY_E, - [Q_KEY_CODE_R] =3D KEY_R, - [Q_KEY_CODE_T] =3D KEY_T, - [Q_KEY_CODE_Y] =3D KEY_Y, - [Q_KEY_CODE_U] =3D KEY_U, - [Q_KEY_CODE_I] =3D KEY_I, - [Q_KEY_CODE_O] =3D KEY_O, - [Q_KEY_CODE_P] =3D KEY_P, - [Q_KEY_CODE_BRACKET_LEFT] =3D KEY_LEFTBRACE, - [Q_KEY_CODE_BRACKET_RIGHT] =3D KEY_RIGHTBRACE, - [Q_KEY_CODE_RET] =3D KEY_ENTER, - - [Q_KEY_CODE_CTRL] =3D KEY_LEFTCTRL, - [Q_KEY_CODE_A] =3D KEY_A, - [Q_KEY_CODE_S] =3D KEY_S, - [Q_KEY_CODE_D] =3D KEY_D, - [Q_KEY_CODE_F] =3D KEY_F, - [Q_KEY_CODE_G] =3D KEY_G, - [Q_KEY_CODE_H] =3D KEY_H, - [Q_KEY_CODE_J] =3D KEY_J, - [Q_KEY_CODE_K] =3D KEY_K, - [Q_KEY_CODE_L] =3D KEY_L, - [Q_KEY_CODE_SEMICOLON] =3D KEY_SEMICOLON, - [Q_KEY_CODE_APOSTROPHE] =3D KEY_APOSTROPHE, - [Q_KEY_CODE_GRAVE_ACCENT] =3D KEY_GRAVE, - - [Q_KEY_CODE_SHIFT] =3D KEY_LEFTSHIFT, - [Q_KEY_CODE_BACKSLASH] =3D KEY_BACKSLASH, - [Q_KEY_CODE_LESS] =3D KEY_102ND, - [Q_KEY_CODE_Z] =3D KEY_Z, - [Q_KEY_CODE_X] =3D KEY_X, - [Q_KEY_CODE_C] =3D KEY_C, - [Q_KEY_CODE_V] =3D KEY_V, - [Q_KEY_CODE_B] =3D KEY_B, - [Q_KEY_CODE_N] =3D KEY_N, - [Q_KEY_CODE_M] =3D KEY_M, - [Q_KEY_CODE_COMMA] =3D KEY_COMMA, - [Q_KEY_CODE_DOT] =3D KEY_DOT, - [Q_KEY_CODE_SLASH] =3D KEY_SLASH, - [Q_KEY_CODE_SHIFT_R] =3D KEY_RIGHTSHIFT, - - [Q_KEY_CODE_ALT] =3D KEY_LEFTALT, - [Q_KEY_CODE_SPC] =3D KEY_SPACE, - [Q_KEY_CODE_CAPS_LOCK] =3D KEY_CAPSLOCK, - - [Q_KEY_CODE_F1] =3D KEY_F1, - [Q_KEY_CODE_F2] =3D KEY_F2, - [Q_KEY_CODE_F3] =3D KEY_F3, - [Q_KEY_CODE_F4] =3D KEY_F4, - [Q_KEY_CODE_F5] =3D KEY_F5, - [Q_KEY_CODE_F6] =3D KEY_F6, - [Q_KEY_CODE_F7] =3D KEY_F7, - [Q_KEY_CODE_F8] =3D KEY_F8, - [Q_KEY_CODE_F9] =3D KEY_F9, - [Q_KEY_CODE_F10] =3D KEY_F10, - [Q_KEY_CODE_NUM_LOCK] =3D KEY_NUMLOCK, - [Q_KEY_CODE_SCROLL_LOCK] =3D KEY_SCROLLLOCK, - - [Q_KEY_CODE_KP_0] =3D KEY_KP0, - [Q_KEY_CODE_KP_1] =3D KEY_KP1, - [Q_KEY_CODE_KP_2] =3D KEY_KP2, - [Q_KEY_CODE_KP_3] =3D KEY_KP3, - [Q_KEY_CODE_KP_4] =3D KEY_KP4, - [Q_KEY_CODE_KP_5] =3D KEY_KP5, - [Q_KEY_CODE_KP_6] =3D KEY_KP6, - [Q_KEY_CODE_KP_7] =3D KEY_KP7, - [Q_KEY_CODE_KP_8] =3D KEY_KP8, - [Q_KEY_CODE_KP_9] =3D KEY_KP9, - [Q_KEY_CODE_KP_SUBTRACT] =3D KEY_KPMINUS, - [Q_KEY_CODE_KP_ADD] =3D KEY_KPPLUS, - [Q_KEY_CODE_KP_DECIMAL] =3D KEY_KPDOT, - [Q_KEY_CODE_KP_ENTER] =3D KEY_KPENTER, - [Q_KEY_CODE_KP_DIVIDE] =3D KEY_KPSLASH, - [Q_KEY_CODE_KP_MULTIPLY] =3D KEY_KPASTERISK, - - [Q_KEY_CODE_F11] =3D KEY_F11, - [Q_KEY_CODE_F12] =3D KEY_F12, - - [Q_KEY_CODE_CTRL_R] =3D KEY_RIGHTCTRL, - [Q_KEY_CODE_SYSRQ] =3D KEY_SYSRQ, - [Q_KEY_CODE_PRINT] =3D KEY_SYSRQ, - [Q_KEY_CODE_PAUSE] =3D KEY_PAUSE, - [Q_KEY_CODE_ALT_R] =3D KEY_RIGHTALT, - - [Q_KEY_CODE_HOME] =3D KEY_HOME, - [Q_KEY_CODE_UP] =3D KEY_UP, - [Q_KEY_CODE_PGUP] =3D KEY_PAGEUP, - [Q_KEY_CODE_LEFT] =3D KEY_LEFT, - [Q_KEY_CODE_RIGHT] =3D KEY_RIGHT, - [Q_KEY_CODE_END] =3D KEY_END, - [Q_KEY_CODE_DOWN] =3D KEY_DOWN, - [Q_KEY_CODE_PGDN] =3D KEY_PAGEDOWN, - [Q_KEY_CODE_INSERT] =3D KEY_INSERT, - [Q_KEY_CODE_DELETE] =3D KEY_DELETE, - - [Q_KEY_CODE_META_L] =3D KEY_LEFTMETA, - [Q_KEY_CODE_META_R] =3D KEY_RIGHTMETA, - [Q_KEY_CODE_MENU] =3D KEY_MENU, -}; - -static const unsigned int keymap_button[INPUT_BUTTON__MAX] =3D { +static const unsigned short keymap_button[INPUT_BUTTON__MAX] =3D { [INPUT_BUTTON_LEFT] =3D BTN_LEFT, [INPUT_BUTTON_RIGHT] =3D BTN_RIGHT, [INPUT_BUTTON_MIDDLE] =3D BTN_MIDDLE, @@ -151,12 +32,12 @@ static const unsigned int keymap_button[INPUT_BUTTON__= MAX] =3D { [INPUT_BUTTON_EXTRA] =3D BTN_EXTRA, }; =20 -static const unsigned int axismap_rel[INPUT_AXIS__MAX] =3D { +static const unsigned short axismap_rel[INPUT_AXIS__MAX] =3D { [INPUT_AXIS_X] =3D REL_X, [INPUT_AXIS_Y] =3D REL_Y, }; =20 -static const unsigned int axismap_abs[INPUT_AXIS__MAX] =3D { +static const unsigned short axismap_abs[INPUT_AXIS__MAX] =3D { [INPUT_AXIS_X] =3D ABS_X, [INPUT_AXIS_Y] =3D ABS_Y, }; @@ -164,7 +45,7 @@ static const unsigned int axismap_abs[INPUT_AXIS__MAX] = =3D { /* ----------------------------------------------------------------- */ =20 static void virtio_input_key_config(VirtIOInput *vinput, - const unsigned int *keymap, + const unsigned short *keymap, size_t mapsize) { virtio_input_config keys; @@ -204,9 +85,10 @@ static void virtio_input_handle_event(DeviceState *dev,= QemuConsole *src, case INPUT_EVENT_KIND_KEY: key =3D evt->u.key.data; qcode =3D qemu_input_key_value_to_qcode(key->key); - if (qcode && keymap_qcode[qcode]) { + if (qcode < qemu_input_map_qcode_to_linux_len && + qemu_input_map_qcode_to_linux[qcode]) { event.type =3D cpu_to_le16(EV_KEY); - event.code =3D cpu_to_le16(keymap_qcode[qcode]); + event.code =3D cpu_to_le16(qemu_input_map_qcode_to_linux[qcod= e]); event.value =3D cpu_to_le32(key->down ? 1 : 0); virtio_input_send(vinput, &event); } else { @@ -399,8 +281,8 @@ static void virtio_keyboard_init(Object *obj) =20 vhid->handler =3D &virtio_keyboard_handler; virtio_input_init_config(vinput, virtio_keyboard_config); - virtio_input_key_config(vinput, keymap_qcode, - ARRAY_SIZE(keymap_qcode)); + virtio_input_key_config(vinput, qemu_input_map_qcode_to_linux, + qemu_input_map_qcode_to_linux_len); } =20 static const TypeInfo virtio_keyboard_info =3D { --=20 2.9.3