From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364727; cv=none; d=zohomail.com; s=zohoarc; b=EN3/eGLtM+TB3dihOI3cRGa9TAabI8IV8gdTWBoqFT6yEWBSgwie6Qb/3IUI0jrmy/0tUuvYEkoeqNfyH9HxUccLPh4tSY3hGRuWdkRUv4fP/AjhSsNfEuddMTCsJKFC8eeyuGNia3QoUAIjc8CwqtSPLdCG2quo9awPsJ+f2jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364727; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bnddn3jK2GBEQZ5IObPXYSBjY5rgo/9BZjPxgwCqYvk=; b=HUFqZ5PNYWs0Jbcg8/8P45Y+o2tpM1lI1zeCGxnCreB6/pSZ3ujpgbu4CbKdBFSKH3qI5blqeSUAIuJ7/ZHCYglLyTMT+KKN+kqxBn2m093yXKveShTkEgwG22QZAm2/A+dYimisHCFSG1SpHttiVqJ81PL2Zz+YKKfU6qOcDJo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364727658231.87726752495132; Thu, 21 May 2026 04:58:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ21y-0004X5-TI; Thu, 21 May 2026 07:57:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ21w-0004ST-4N for qemu-devel@nongnu.org; Thu, 21 May 2026 07:57:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ21u-00040L-LC for qemu-devel@nongnu.org; Thu, 21 May 2026 07:57:35 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-cSaGH51TPOWiCHAokpxV3Q-1; Thu, 21 May 2026 07:57:30 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F0EDD18005BF; Thu, 21 May 2026 11:57:28 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CC7F51800357; Thu, 21 May 2026 11:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bnddn3jK2GBEQZ5IObPXYSBjY5rgo/9BZjPxgwCqYvk=; b=g7S1DIhmVszJwYSM7shKw42ukEn+JTGEkf3st52sSzwiEzXr+uLQeEG6qM2mhu9v4quz7B zuo7Xq+C7a6Fu9ZJWLQkhsT5wE7dkpbcfstnpEPajIddbNJFaMdydp5okM+OMirfdDd0v5 Vi5HgBTtSrnqwBRjpe9LjbUrIynXFk4= X-MC-Unique: cSaGH51TPOWiCHAokpxV3Q-1 X-Mimecast-MFC-AGG-ID: cSaGH51TPOWiCHAokpxV3Q_1779364649 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 01/38] ui/vt100: Standardize on uint8_t for "ch" byte variables Date: Thu, 21 May 2026 15:56:38 +0400 Message-ID: <20260521115717.1701482-2-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364729912158500 From: Peter Maydell The vt100 code is rather confused about how it handles bytes of data to be sent to the terminal: * vt100_input() takes a buffer of uint8_t * each byte is passed to vt100_putchar(), which takes "int ch" * that calls vt100_put_one(), which also takes "int ch" * vt100_put_one() sets TextCell::ch, which is uint8_t again * various places pass the TextCell:ch value to vt100_putcharxy(), which takes "int ch" again, but uses it unchecked as an index into a 256-entry array This confuses Coverity (e.g. CID 1659590) and the reader, who may be unsure whether the "int" variable really does hold only valid byte values 0..255 and whether we need to bounds-check before doing array dereferences. Standardize on keeping known-byte data in uint8_t all the way through. Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260512104210.3330835-2-peter.maydell@linaro.org> --- ui/vt100.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/vt100.c b/ui/vt100.c index e2fba822523..7e373766bc1 100644 --- a/ui/vt100.c +++ b/ui/vt100.c @@ -61,7 +61,7 @@ static void image_bitblt(pixman_image_t *image, xs, ys, 0, 0, xd, yd, w, h); } =20 -static void vt100_putcharxy(QemuVT100 *vt, int x, int y, int ch, +static void vt100_putcharxy(QemuVT100 *vt, int x, int y, uint8_t ch, TextAttributes *t_attrib) { static pixman_image_t *glyphs[256]; @@ -468,7 +468,7 @@ static uint32_t bh_utf8_decode(uint32_t *state, uint32_= t *codep, uint32_t byte) return *state; } =20 -static void vt100_put_one(QemuVT100 *vt, int ch) +static void vt100_put_one(QemuVT100 *vt, uint8_t ch) { TextCell *c; int y1; @@ -606,7 +606,7 @@ static void vt100_restore_cursor(QemuVT100 *vt) vt->t_attrib =3D vt->t_attrib_saved; } =20 -static void vt100_putchar(QemuVT100 *vt, int ch) +static void vt100_putchar(QemuVT100 *vt, uint8_t ch) { int i; int x, y; --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364672; cv=none; d=zohomail.com; s=zohoarc; b=DXu1twFYiqm2IeAVmaqOr4SDFLtRbfO/2IdN7Y1KlxDBiiPaCKKHRpE9y+ZSrivq89NlJ+qpyLHV70C7LpJaahdNWwDf3ERr0LWumtR/EQwWaYdVnfse84HtTG44jeQ4efM0oYFc3tINscvv4aVt0O4LnePYi4aIkW27ZM+FBts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364672; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RZe8CPnHyR2ivcxoMe01YPDfyJrlhdcOYxW+oU3Kn2Y=; b=LF4ldoBT7RkWspuEnGw20puftWmSi0wtkGDIBVkxot31LRgdaUgCFgndVlkvmT/4NYm8Uu+ph9sfKrr87V9Xi4b/ek7sya9GWxUu2wuGu8sjAhhBULMiYyZvyZOEGRfQ2Bp3i9ENvfUCKCjQDOyYidDSkkogbXXftByT9n+QmeQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17793646728011021.3441252031928; Thu, 21 May 2026 04:57:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ224-0004gS-Qz; Thu, 21 May 2026 07:57:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ220-0004a8-K9 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:57:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ21y-00043U-NV for qemu-devel@nongnu.org; Thu, 21 May 2026 07:57:40 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-107-ZO20lljpMVqHnRLbz8uFlg-1; Thu, 21 May 2026 07:57:35 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A59A8195609D; Thu, 21 May 2026 11:57:34 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2F2201681; Thu, 21 May 2026 11:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RZe8CPnHyR2ivcxoMe01YPDfyJrlhdcOYxW+oU3Kn2Y=; b=Y7Rr/JgdiAhMRGrX7HO8JilN5chtkmZGYVkMC5DroYcsN643L5KqMXPfI5xxLm+cz7Q4c6 l6pf1HKWsYgL4yZkHWmPM78ExGgW+EjLQVeykxxhKzw/pNqAqAHHqGQ1I+XOhGNlpB6QJQ jHvYl/Lkwq3AOERN1CfJLa9a9PV05Eo= X-MC-Unique: ZO20lljpMVqHnRLbz8uFlg-1 X-Mimecast-MFC-AGG-ID: ZO20lljpMVqHnRLbz8uFlg_1779364654 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 02/38] ui/vt100: Take byte as uint8_t in bh_utf8_decode() Date: Thu, 21 May 2026 15:56:39 +0400 Message-ID: <20260521115717.1701482-3-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364675638154100 From: Peter Maydell The bh_utf8_decode() UTF8 decoder takes its next byte as a "uint32_t byte" parameter, but it assumes it to be in bounds as it immediately indexes into its array with it. Use "uint8_t" as the argument type instead. This moves us away from the upstream implementation slightly, but it is the same type as we use in the one callsite, and it makes it clear that we can't be indexing off the end of the array with this guest-derived data. This probably helps make Coverity a bit happier (CID 1659590). Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260512104210.3330835-3-peter.maydell@linaro.org> --- ui/vt100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/vt100.c b/ui/vt100.c index 7e373766bc1..f8140cfa85c 100644 --- a/ui/vt100.c +++ b/ui/vt100.c @@ -438,7 +438,7 @@ static void vt100_clear_xy(QemuVT100 *vt, int x, int y) #define BH_UTF8_ACCEPT 0 #define BH_UTF8_REJECT 12 =20 -static uint32_t bh_utf8_decode(uint32_t *state, uint32_t *codep, uint32_t = byte) +static uint32_t bh_utf8_decode(uint32_t *state, uint32_t *codep, uint8_t b= yte) { static const uint8_t utf8d[] =3D { /* character class lookup */ --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364703; cv=none; d=zohomail.com; s=zohoarc; b=Pc7gWrmX5OCH9PA28mUUhaYk9ghCX2YKjBx4d8/Un6UBVwJZ3x7VhpFFw9WQy3Pe8LhjBjvOwA/0Bfu292inuodMNMh4w68f45ybjowr0eGOJaqFNsHha9YWuxi5biToQXCR6um5ecWdI4igq8bFXTOyE7dfe+yAaEif8VcMMVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364703; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=s98FdMTREin0x+HMEMyCXnMppXkvaTAPzFjNpL5lKUw=; b=bVQLokNJWQDOW/UrME1pkk61hCVT9z4oRGvRCCIPjQ0P67rhgRESpt7kRXCIFCvjGTWWmJNysGTlS3Qr6efcpbsmEPAqDA3hd5K5ipIRWGoFq+SiiHxJPjKBUCanqhkQWIiZShhSDijZSQmPUDIuyzIDOOEuX/zP4fkvyUmgsOY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364703166873.0114932152208; Thu, 21 May 2026 04:58:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ229-0004uf-H1; Thu, 21 May 2026 07:57:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ226-0004rk-Sh for qemu-devel@nongnu.org; Thu, 21 May 2026 07:57:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ225-000441-J4 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:57:46 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-vJ_jjUufOmy7Eqmz2yyVFw-1; Thu, 21 May 2026 07:57:41 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9CA1418005BA; Thu, 21 May 2026 11:57:40 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 35A7519560A3; Thu, 21 May 2026 11:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s98FdMTREin0x+HMEMyCXnMppXkvaTAPzFjNpL5lKUw=; b=YlCnWqgH9FcbH0lNld0o0HA6cs3606LoIlgTUMVLfJntWMu/rL0rSCZBeXBotumw9V7A4X /zrG5N7jmAM42NvgJfznVIOkVNAiIjSrYUwRowNmToy9eVnZjVkil7om2CKbucLwVLAtdm Ujxw+GjY7UoxnJo6UwLiiNdXh/HPQ+Y= X-MC-Unique: vJ_jjUufOmy7Eqmz2yyVFw-1 X-Mimecast-MFC-AGG-ID: vJ_jjUufOmy7Eqmz2yyVFw_1779364660 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 03/38] ui/vt100: add vt100_fini() check Date: Thu, 21 May 2026 15:56:40 +0400 Message-ID: <20260521115717.1701482-4-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364704109154100 From: Marc-Andr=C3=A9 Lureau vt100_fini() is called unconditonally from qemu_text_console_finalize(), but it may not have been vt100_init()/opened: fix the crash in that case. Fixes: 8fa294482eb ("ui/console-vc: move VT100 state machine ...") Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/vt100.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/vt100.c b/ui/vt100.c index f8140cfa85c..6e64845b6c0 100644 --- a/ui/vt100.c +++ b/ui/vt100.c @@ -978,6 +978,9 @@ void vt100_init(QemuVT100 *vt, =20 void vt100_fini(QemuVT100 *vt) { + if (!QTAILQ_IN_USE(vt, list)) { + return; + } QTAILQ_REMOVE(&vt100s, vt, list); fifo8_destroy(&vt->out_fifo); g_free(vt->cells); --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364716; cv=none; d=zohomail.com; s=zohoarc; b=H7SspZ1UvUVy3cIgGKIPZChnDKUiYqh7lWpyya++AxZFWUj1i4k7cUP25+Kd+9H3LpFQNa4JszTDfRqpM/NAqEB9Z2I8O0K870jdFMDCUUw74chgegn9lYZYdzZJSbMMkj+nZEZHuEfh+zOMrku8J5cu3VROkTVM+sq+Sqrkg+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364716; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XVdC8+ZAXrboODKEiUEFzI6uzqlzT6GSg5bz9+Srejc=; b=LDsvIerpo1xBA6lPv+waM+F8jSkZQk6B2Ul6EoIFZfutH+wMo+Lh9qj8PD21+cai3y4blPsDqeH2OugwQsRW9wCHY9OTyi+fsjBWrZVFAfeXLhJcjh5kuAmkVNLJ8MngwNtaD7WPOyvhY/w/ZqQ9zruQxImY/70CD+ry9wdCPxg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364716269990.4485293623391; Thu, 21 May 2026 04:58:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ22L-00058Y-Vn; Thu, 21 May 2026 07:58:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22C-0004xQ-VO for qemu-devel@nongnu.org; Thu, 21 May 2026 07:57:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22B-00044R-FI for qemu-devel@nongnu.org; Thu, 21 May 2026 07:57:52 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-6h0vVKEqNU6e_p-s80c_GA-1; Thu, 21 May 2026 07:57:47 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7554D18002EF; Thu, 21 May 2026 11:57:46 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1A6191684; Thu, 21 May 2026 11:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XVdC8+ZAXrboODKEiUEFzI6uzqlzT6GSg5bz9+Srejc=; b=UJSidoPtNSXYlCQ0o5m1dN9RAl0rVioBGWbTE/vs40ftoZDPayJX/3KLO8s+Ht5byt/WHk EsxCFh7eYADcrZGpU06PdHF8lvs5dPz+vDgzIXjlMV43A3HeXMndXtCLuTs77kQKzGhTBL 3bC8KRkAfGmcUZ739h2JI5tJiY2xKO0= X-MC-Unique: 6h0vVKEqNU6e_p-s80c_GA-1 X-Mimecast-MFC-AGG-ID: 6h0vVKEqNU6e_p-s80c_GA_1779364666 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 04/38] ui/vnc: fix OOB read access in VNC SASL mechname array Date: Thu, 21 May 2026 15:56:41 +0400 Message-ID: <20260521115717.1701482-5-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364717748158500 From: Daniel P. Berrang=C3=A9 When reading the SASL mechname array off the VNC connection, if malicious, the received data may contain embedded NULs. If this happens the memory buffer returned by g_strndup may be shorter than the original data. Unfortunately the code continued to index into this buffer with an offset equal to the original length. This is a potential OOB read of the array. Fixes: 5847d9e1 (ui/vnc: simplify and avoid strncpy) Reported-by: boy juju Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Daniel P. Berrang=C3=A9 Message-ID: <20260521103353.1645561-2-berrange@redhat.com> --- ui/vnc-auth-sasl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c index 9964b969ac2..298c8f3769f 100644 --- a/ui/vnc-auth-sasl.c +++ b/ui/vnc-auth-sasl.c @@ -489,6 +489,8 @@ static int protocol_client_auth_sasl_mechname(VncState = *vs, uint8_t *data, size_ char *mechname =3D g_strndup((const char *) data, len); trace_vnc_auth_sasl_mech_choose(vs, mechname); =20 + /* If 'data' had embedded NUL the dup'd string might now be shorter */ + len =3D strlen(mechname); if (strncmp(vs->sasl.mechlist, mechname, len) =3D=3D 0) { if (vs->sasl.mechlist[len] !=3D '\0' && vs->sasl.mechlist[len] !=3D ',') { --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364705; cv=none; d=zohomail.com; s=zohoarc; b=Qy+3OrHwXbMe41RfzznLtqBh5BQyoT7N4UonXzhRQQ8mPjugsJ4E4ZJ9kAR3fSPuAUKa2yVRULzy9KDtMfdUgS9XbiFhq44eAXdKI7Q7hbjp38pNKzbh/TgBxvjKvnubEgvrKB5Ed5rz0438yTKOmUEwLo6PdSy5+FV8oDxZsOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364705; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5cC5Lra/XS1ca25R2emCsvoivsZouoKYXejYAM6KjIo=; b=QQrqsy0ksJpkC1Ra9sw3DpUARlc/cDO0E11ogaqFwkukrxUjvFuRBvY9o3GAkIV3mN6qFx9LJ9nal0rpzwUASbQxk/hLKXpeGde/HJtibihSTT0WFSFFwXsw+ZMbbFk/OLjeAEgIuFbC3mR3HlDBCygj7JHGXnBiIyWzeQ3/uMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364705606525.6921981664286; Thu, 21 May 2026 04:58:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ22U-0005H2-6U; Thu, 21 May 2026 07:58:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22J-000582-1r for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22H-00045L-MC for qemu-devel@nongnu.org; Thu, 21 May 2026 07:57:58 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-KQTmiEc6OzKOKAcC25t3_w-1; Thu, 21 May 2026 07:57:53 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 218091956094; Thu, 21 May 2026 11:57:52 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 995091681; Thu, 21 May 2026 11:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5cC5Lra/XS1ca25R2emCsvoivsZouoKYXejYAM6KjIo=; b=DJDeFzde3I4yi+N536Vpc57P4IJ4xd26QB5jpB0PiMzfUFQgf7kiKf61NplaByGAyH0wFg pfCBD05nOpOnWgkDviGPDzEn13K3SswI7aFNM7mTEnBUOq2FJNQl1NtlmAQOkn+1zxeJ9y WkVoJhUY0zWB6V9nLgoESgUnng1f+gE= X-MC-Unique: KQTmiEc6OzKOKAcC25t3_w-1 X-Mimecast-MFC-AGG-ID: KQTmiEc6OzKOKAcC25t3_w_1779364672 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 05/38] ui/vnc: fix OOB write in VNC stats array Date: Thu, 21 May 2026 15:56:42 +0400 Message-ID: <20260521115717.1701482-6-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364708109154100 From: Daniel P. Berrang=C3=A9 The VncSurface struct maintains update statistics in an array: VncRectStat stats[VNC_STAT_ROWS][VNC_STAT_COLS]; where the dimensions are defined as: #define VNC_STAT_RECT 64 #define VNC_STAT_COLS (VNC_MAX_WIDTH / VNC_STAT_RECT) #define VNC_STAT_ROWS (VNC_MAX_HEIGHT / VNC_STAT_RECT) If VNC_MAX_WIDTH / VNC_MAX_HEIGHT are not an exact multiple of VNC_STAT_REC, the COLS/ROWS will be undersized by 1. Unfortunately: #define VNC_MAX_HEIGHT 2160 is not a multiple of 64, so there is potential for OOB reads and writes in the 'stats' array, if the guest surface is over 2112 pixels in height. An array overflow occurs when vnc_update_stats() records new statistics, either scribbling over data later in the VncDisplay struct that 'stats' is embedded in, or performing an OOB write on the allocated struct memory. Fixes: CVE-2026-48002 Reported-by: boy juju Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Daniel P. Berrang=C3=A9 Message-ID: <20260521103353.1645561-3-berrange@redhat.com> --- ui/vnc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/vnc.h b/ui/vnc.h index 0750bf5f72f..c8d87cd5301 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -85,8 +85,8 @@ typedef void VncSendHextileTile(VncState *vs, #define VNC_DIRTY_BPL(x) (sizeof((x)->dirty) / VNC_MAX_HEIGHT * BITS_PER_B= YTE) =20 #define VNC_STAT_RECT 64 -#define VNC_STAT_COLS (VNC_MAX_WIDTH / VNC_STAT_RECT) -#define VNC_STAT_ROWS (VNC_MAX_HEIGHT / VNC_STAT_RECT) +#define VNC_STAT_COLS DIV_ROUND_UP(VNC_MAX_WIDTH, VNC_STAT_RECT) +#define VNC_STAT_ROWS DIV_ROUND_UP(VNC_MAX_HEIGHT, VNC_STAT_RECT) =20 #define VNC_AUTH_CHALLENGE_SIZE 16 =20 --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364710; cv=none; d=zohomail.com; s=zohoarc; b=niDVFDO/lyXnRLax6XWUjQqtGHoMU4p+2R+AAj9RO10s22PYO+TCdiIYGOgFFnochfPq2LeS83LLRoHSnPoj7D0q7q5UaAlOyGpDimmHjWMc5k1VnTWej5mCJQX+iccUpwFcm91WX5FG22zSAplKj7XxdmNsPjSN0zY2xb5EobY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364710; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/LmMLkJ4Qku+Y2cyRfdOd8rfEGr0spPW29aDQZgW+gM=; b=VvARcaO7/HPtlbHbTItNeLifCrnlQUVTXm3iPiiN06mPwG1NnBgmE4xA7jifLfFZkC+zaHO8OEkKTiAY1Kp6jTNqwvEFt++p/DO41ZDiktPjoLdKTFnan+nDvFA2+SkrZc1lLXmMvDjf+7Pkwqu9SRprp3qb728A/80WaeAIORI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364710647720.7509888221526; Thu, 21 May 2026 04:58:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ22W-0005O0-UE; Thu, 21 May 2026 07:58:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22M-00059e-K8 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22L-00045q-6z for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:02 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-tu65Sy_GPL6xhqmZ2OzheA-1; Thu, 21 May 2026 07:57:59 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 58BE819560AA; Thu, 21 May 2026 11:57:58 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 95A0B19560AB; Thu, 21 May 2026 11:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/LmMLkJ4Qku+Y2cyRfdOd8rfEGr0spPW29aDQZgW+gM=; b=SzdyU70lXPofBNOFI4rLRt7/a+vaoA7yBbXmcn4PLuRdWwud/CPt7VwR7Ezkm4gsctjHiQ +hweQgeBPEmlv90Jw1LH8kpTSQB9yLWbatODC+ayYB/2V/ZcNoGK2zGeJUa/+uC5k6rAvI MWcheo59QjkK2MNF/jDq1NkAZwXFuAM= X-MC-Unique: tu65Sy_GPL6xhqmZ2OzheA-1 X-Mimecast-MFC-AGG-ID: tu65Sy_GPL6xhqmZ2OzheA_1779364678 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 06/38] ui/vnc: fix OOB write in lossy rect worker code Date: Thu, 21 May 2026 15:56:43 +0400 Message-ID: <20260521115717.1701482-7-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364712142154100 From: Daniel P. Berrang=C3=A9 Incorrect calculation of the boundary condition when tracking lossy rectangles in the worker thread will result in an OOB write which can corrupt further worker state, and/or trigger any guard pages that may lie beyond the VncWorker struct. This can be triggered through careful choice of the display resolution in the guest OS by an unprivileged user. Fixes: CVE-2026-48002 Reported-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Daniel P. Berrang=C3=A9 Message-ID: <20260521103353.1645561-4-berrange@redhat.com> [Marc-Andr=C3=A9 - added assert() suggest by philmd@linaro.org] Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/vnc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 56dd43d53ff..071a3cbb7fe 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2982,13 +2982,15 @@ void vnc_sent_lossy_rect(VncWorker *worker, int x, = int y, int w, int h) { int i, j; =20 - w =3D (x + w) / VNC_STAT_RECT; - h =3D (y + h) / VNC_STAT_RECT; + w =3D DIV_ROUND_UP((x + w), VNC_STAT_RECT); + h =3D DIV_ROUND_UP((y + h), VNC_STAT_RECT); + assert(h <=3D VNC_STAT_ROWS) + assert(w <=3D VNC_STAT_COLS) x /=3D VNC_STAT_RECT; y /=3D VNC_STAT_RECT; =20 - for (j =3D y; j <=3D h; j++) { - for (i =3D x; i <=3D w; i++) { + for (j =3D y; j < h; j++) { + for (i =3D x; i < w; i++) { worker->lossy_rect[j][i] =3D 1; } } --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364793; cv=none; d=zohomail.com; s=zohoarc; b=RcUx/Q4ry3pgmIpaFu0ZKDYyVgRacijhWreg8U+xgD+GNYRlS5D978ifvm29y8Pi6ZC/JBunCYgDqDhlaTxs9dFPvGzBMvW9DZvjSALLAyEGUpSxSQBG2G5tPyfJYTIVJVpvP8IEXL5Mtt7701TGD8jYlO7uXsx5xnPewZSpckU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364793; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bBxnePgDHIWCFCoWx0z4Cb2K3mZtkz0W6MiBDy9BTeI=; b=ANaUci58EhmNJWqQykx1pYXpfo2kJpPL/j2oQpRrlQedhgWtfcxbLsRGgqXlUu3Zx3dZYryfneNrnbOnDKWfQbHlmMosNkrq7m3BKkfygkbMBPKNF7f1h35Ks+5LEJzPLExOrHlVZzC1luiS84SLuBykuhPSTOCqXisY/veui8M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364793286862.213294499729; Thu, 21 May 2026 04:59:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ22X-0005Rr-00; Thu, 21 May 2026 07:58:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22U-0005Iu-Un for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22T-00047Q-FC for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:10 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-484-qVxPNka5NDW2cYmpJtnWeQ-1; Thu, 21 May 2026 07:58:04 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 021CD1800372; Thu, 21 May 2026 11:58:04 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D64491956056; Thu, 21 May 2026 11:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bBxnePgDHIWCFCoWx0z4Cb2K3mZtkz0W6MiBDy9BTeI=; b=WX7/Tx6jUOwBnRD7dctVwQLvZQJfgAB3nk8h1jOCQwdt6gXnDfLm7WChrfmC0jS4EcoaVp ab76ZUPWkY3Ke1khA37qHgMXXxJzjQk4FZZmhhOU3Kl85fPhjcVF+tnCEz/HHE+ZkMMC3X oQJCPbVheV+A/oEUJ4irOPtPVtwGW3Y= X-MC-Unique: qVxPNka5NDW2cYmpJtnWeQ-1 X-Mimecast-MFC-AGG-ID: qVxPNka5NDW2cYmpJtnWeQ_1779364684 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 07/38] ui/vnc: fix OOB read updating VNC update frequency stats Date: Thu, 21 May 2026 15:56:44 +0400 Message-ID: <20260521115717.1701482-8-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364794842158500 From: Daniel P. Berrang=C3=A9 Incorrect loop bounds in vnc_update_freq result in iterating past the last row and past the last column in the VNC stats array. With suitably chosen dimensions this could be a OOB read that accesses memory beyond the VncDisplay struct that the stats array is embedded in. Should this hit a guard page, it could trigger a guest crash. If it does not, then the VNC frequency stats will be updated with garbage. Fixes: CVE-2026-48003 Reported-by: boy juju Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Daniel P. Berrang=C3=A9 Message-ID: <20260521103353.1645561-5-berrange@redhat.com> --- ui/vnc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 071a3cbb7fe..92b62f62127 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3093,12 +3093,14 @@ double vnc_update_freq(VncState *vs, int x, int y, = int w, int h) int i, j; double total =3D 0; int num =3D 0; + int x_end =3D x + w; + int y_end =3D y + h; =20 x =3D QEMU_ALIGN_DOWN(x, VNC_STAT_RECT); y =3D QEMU_ALIGN_DOWN(y, VNC_STAT_RECT); =20 - for (j =3D y; j <=3D y + h; j +=3D VNC_STAT_RECT) { - for (i =3D x; i <=3D x + w; i +=3D VNC_STAT_RECT) { + for (j =3D y; j < y_end; j +=3D VNC_STAT_RECT) { + for (i =3D x; i < x_end; i +=3D VNC_STAT_RECT) { total +=3D vnc_stat_rect(vs->vd, i, j)->freq; num++; } --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364714; cv=none; d=zohomail.com; s=zohoarc; b=Vfec4fIJdhBJsQCnbQOghQk/E0dQNJIJgIoh6fmoc1DlmvFpkL6tjcRJBLY7lqWybSFUN5t4KHtzPPXUMSzAK3EzcA56dJ/8XzXgc6RYhtTrQRGpbbZ8czmEeeyMhG3lGLg1bSjjt0CmnN3+fOHB+DtvXJa4XfbzrawwAbmIDMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364714; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YIwiZmnjUXUCbjuzvEwbbIdtcVmXNfGuVljF3AGGI/k=; b=gNI01F0Ikuv//q4oancQdMhLAKSd3v3jl6PW5LLJ9J6a/ng1IQ0KX2Su++2xxJG2w1kbjaDhsI/mzMxDmGu/Up+8xLA2/1DkGXTe4uLABaqOPtgQzZC6KEOrIwcYlNcfFHyIfj0vTeauKS/P3xlZmZB0BU8qWt8K121pb4J8+oU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364714372693.2731100470392; Thu, 21 May 2026 04:58:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ22e-0005pT-1q; Thu, 21 May 2026 07:58:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22b-0005d6-0u for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22Z-00048b-4K for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:16 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-387-UFjspIO3PCWNcOAE6ex-MQ-1; Thu, 21 May 2026 07:58:10 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 930E919560A3; Thu, 21 May 2026 11:58:09 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3427B300019F; Thu, 21 May 2026 11:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YIwiZmnjUXUCbjuzvEwbbIdtcVmXNfGuVljF3AGGI/k=; b=bPt6LSfdhrMN7/jiFYgQHlBXEAGQ9Ax+HObCFdB2fp/aJPKjpxRxzF/LAraluK/PE1hsSG y5tPnwWMcvZ2kZIyAQzVL3rD9Lm/i0jJhvnZoqhXfuDePSNEjNaQ6YFvPlCGXoOJBhio3p oUSO/I1P9WwVewGi5i/eXME4JzfiO1w= X-MC-Unique: UFjspIO3PCWNcOAE6ex-MQ-1 X-Mimecast-MFC-AGG-ID: UFjspIO3PCWNcOAE6ex-MQ_1779364689 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Heechan Kang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 08/38] ui: fix validation of VNC extended clipboard data length Date: Thu, 21 May 2026 15:56:45 +0400 Message-ID: <20260521115717.1701482-9-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364716100154100 From: Heechan Kang QEMU's VNC extended clipboard handler inflates a client-controlled compressed clipboard payload. The code checks the declared text size against the total inflated buffer size: if (tsize < size) but then copies from: tbuf =3D buf + 4; qemu_clipboard_set_data(..., tsize, tbuf, true); The correct bound is the remaining data length after the 4-byte length field, not the total inflated buffer length. As a result, a VNC client can make QEMU copy up to 3 bytes past the end of the inflated heap buffer. With a second VNC client, those copied bytes are observable through the normal VNC extended clipboard PROVIDE path. Fixes: CVE-2026-8343 Reported-by: Heechan Kang Reported-by: Feifan Qian Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Heechan Kang [DB: added #include and 'return' statements] Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260512095543.459949-1-berrange@redhat.com> --- ui/vnc-clipboard.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/vnc-clipboard.c b/ui/vnc-clipboard.c index 124b6fbd9c2..fa05d86f424 100644 --- a/ui/vnc-clipboard.c +++ b/ui/vnc-clipboard.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "vnc.h" #include "vnc-jobs.h" =20 @@ -282,10 +283,16 @@ void vnc_client_cut_text_ext(VncState *vs, int32_t le= n, uint32_t flags, uint8_t buf && size >=3D 4) { uint32_t tsize =3D read_u32(buf, 0); uint8_t *tbuf =3D buf + 4; - if (tsize < size) { + if (tsize <=3D size - 4) { qemu_clipboard_set_data(&vs->cbpeer, vs->cbinfo, QEMU_CLIPBOARD_TYPE_TEXT, tsize, tbuf, true); + } else { + error_report("vnc: malformed extended clipboard payload " + "with text length %u exceeding available %u", + tsize, size - 4); + vnc_client_error(vs); + return; } } } --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364753; cv=none; d=zohomail.com; s=zohoarc; b=V2oYyT8mXT1kDGh6zMiJEPQsEl7LdO+h3uWyFcZE8VsMxTZJ/8VcMj1Xoj89qfjk84hK9JfGYi96XhtFa+F4jrQ2JQuprgtDBzeUqZOaOghuRryLydoXOKcYg59YIn1FQOO0TW+PsvyE6GwfIqEKFj+tyHHhk/v43I8JdtVCnmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364753; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Jnkl+SY9AP2/RSV/S8/BJ98fQdY44M9KF+GDVrKUz1s=; b=UlkRgfKsbuTChG7/1NMX6RCj0jfPOgH4cEla3GCDpvSt9oVUqngFMkAza+MFHOjQ0S03lIRuZZiEpMtjMd3E0IcR+zJLimkTeqCgaD1QxOaErmU+E+5FUFsoYH6/cq80Nsd9Xna6Mijy/YosOi2PxhzIhbsibEwd8gJ3yQ52Brc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364753380197.52122080801018; Thu, 21 May 2026 04:59:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ22m-0006Hb-Uy; Thu, 21 May 2026 07:58:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22j-0006Ct-Vh for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22h-0004AR-12 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:25 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-97-fbTxJEauNUuQBGKu3bDs6A-1; Thu, 21 May 2026 07:58:18 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 217651956096; Thu, 21 May 2026 11:58:16 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A1CFA300019F; Thu, 21 May 2026 11:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jnkl+SY9AP2/RSV/S8/BJ98fQdY44M9KF+GDVrKUz1s=; b=Xo6RENp7sLWZqg44wO6YfWk7GKIgCKveTJdY+FpBT5Di5oa0aRyz2fWBYixRmZOAOUsFeV QQ+FHUjAtUn5tBTKKiAkWK5PrQzlCsoiRiRL5/1Ia+MgpPtbTnZC8Px7J6PGc0uVK8yFdK +uhNO92Oo9MkcsIUhmKNJb0Lclnc6/A= X-MC-Unique: fbTxJEauNUuQBGKu3bDs6A-1 X-Mimecast-MFC-AGG-ID: fbTxJEauNUuQBGKu3bDs6A_1779364696 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Jan Kiszka , Peter Maydell , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Mark Cave-Ayland , "Michael S. Tsirkin" , Gerd Hoffmann , Thomas Huth , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org (open list:Musicpal), xen-devel@lists.xenproject.org (open list:X86 Xen CPUs), qemu-ppc@nongnu.org (open list:New World (mac99)) Subject: [PULL 09/38] ui/input: Introduce QemuInputEvent typedef Date: Thu, 21 May 2026 15:56:46 +0400 Message-ID: <20260521115717.1701482-10-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364754356158500 From: Akihiko Odaki Add QemuInputEvent as the input subsystem's name for InputEvent and use it in input handler, queue, and replay interfaces. This prepares for decoupling QEMU's internal input event representation from the QAPI InputEvent type. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-1-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- include/qemu/typedefs.h | 1 + include/system/replay.h | 2 +- include/ui/input.h | 6 +++--- replay/replay-internal.h | 6 +++--- chardev/msmouse.c | 2 +- chardev/wctablet.c | 2 +- hw/arm/musicpal.c | 2 +- hw/char/escc.c | 4 ++-- hw/display/xenfb.c | 4 ++-- hw/input/adb-kbd.c | 2 +- hw/input/adb-mouse.c | 2 +- hw/input/hid.c | 4 ++-- hw/input/ps2.c | 4 ++-- hw/input/stellaris_gamepad.c | 2 +- hw/input/virtio-input-hid.c | 2 +- hw/m68k/next-kbd.c | 3 ++- replay/replay-events.c | 4 ++-- replay/replay-input.c | 8 ++++---- replay/stubs-system.c | 2 +- ui/input-legacy.c | 2 +- ui/input.c | 26 +++++++++++++------------- ui/vdagent.c | 2 +- 22 files changed, 47 insertions(+), 45 deletions(-) diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 07f2ae7c9f1..da7097c5440 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -94,6 +94,7 @@ typedef struct QBool QBool; typedef struct QDict QDict; typedef struct QEMUBH QEMUBH; typedef struct QemuConsole QemuConsole; +typedef struct InputEvent QemuInputEvent; typedef struct QEMUCursor QEMUCursor; typedef struct QEMUFile QEMUFile; typedef struct QemuMutex QemuMutex; diff --git a/include/system/replay.h b/include/system/replay.h index 19fb6dbb396..3b00386821b 100644 --- a/include/system/replay.h +++ b/include/system/replay.h @@ -126,7 +126,7 @@ void replay_bh_schedule_event(QEMUBH *bh); void replay_bh_schedule_oneshot_event(AioContext *ctx, QEMUBHFunc *cb, void *opaque); /*! Adds input event to the queue */ -void replay_input_event(QemuConsole *src, InputEvent *evt); +void replay_input_event(QemuConsole *src, QemuInputEvent *evt); /*! Adds input sync event to the queue */ void replay_input_sync_event(void); /*! Adds block layer event to the queue */ diff --git a/include/ui/input.h b/include/ui/input.h index 52c164bde57..c455abdec6a 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -19,7 +19,7 @@ typedef struct QemuInputHandler QemuInputHandler; typedef struct QemuInputHandlerState QemuInputHandlerState; =20 typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src, - InputEvent *evt); + QemuInputEvent *evt); typedef void (*QemuInputHandlerSync)(DeviceState *dev); =20 struct QemuInputHandler { @@ -37,8 +37,8 @@ void qemu_input_handler_unregister(QemuInputHandlerState = *s); void qemu_input_handler_bind(QemuInputHandlerState *s, const char *device_id, int head, Error **errp); -void qemu_input_event_send(QemuConsole *src, InputEvent *evt); -void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt); +void qemu_input_event_send(QemuConsole *src, QemuInputEvent *evt); +void qemu_input_event_send_impl(QemuConsole *src, QemuInputEvent *evt); void qemu_input_event_sync(void); void qemu_input_event_sync_impl(void); =20 diff --git a/replay/replay-internal.h b/replay/replay-internal.h index 643b357da12..42c393542eb 100644 --- a/replay/replay-internal.h +++ b/replay/replay-internal.h @@ -171,11 +171,11 @@ void replay_add_event(ReplayAsyncEventKind event_kind= , void *opaque, /* Input events */ =20 /*! Saves input event to the log */ -void replay_save_input_event(InputEvent *evt); +void replay_save_input_event(QemuInputEvent *evt); /*! Reads input event from the log */ -InputEvent *replay_read_input_event(void); +QemuInputEvent *replay_read_input_event(void); /*! Adds input event to the queue */ -void replay_add_input_event(struct InputEvent *event); +void replay_add_input_event(QemuInputEvent *event); /*! Adds input sync event to the queue */ void replay_add_input_sync_event(void); =20 diff --git a/chardev/msmouse.c b/chardev/msmouse.c index 365f04546e9..146457661f9 100644 --- a/chardev/msmouse.c +++ b/chardev/msmouse.c @@ -122,7 +122,7 @@ static void msmouse_queue_event(MouseChardev *mouse) } =20 static void msmouse_input_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { MouseChardev *mouse =3D MOUSE_CHARDEV(dev); InputMoveEvent *move; diff --git a/chardev/wctablet.c b/chardev/wctablet.c index 214d5ca2e28..05d2333fb0c 100644 --- a/chardev/wctablet.c +++ b/chardev/wctablet.c @@ -146,7 +146,7 @@ static void wctablet_queue_event(TabletChardev *tablet) } =20 static void wctablet_input_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { TabletChardev *tablet =3D (TabletChardev *)dev; InputMoveEvent *move; diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index 83676eb7fea..ae171710e34 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -1066,7 +1066,7 @@ struct musicpal_key_state { }; =20 static void musicpal_key_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { musicpal_key_state *s =3D MUSICPAL_KEY(dev); InputKeyEvent *key =3D evt->u.key.data; diff --git a/hw/char/escc.c b/hw/char/escc.c index 3b46818ecc9..677c3a120e1 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -794,7 +794,7 @@ static const VMStateDescription vmstate_escc =3D { }; =20 static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { ESCCChannelState *s =3D (ESCCChannelState *)dev; int qcode, keycode; @@ -954,7 +954,7 @@ static void handle_kbd_command(ESCCChannelState *s, int= val) } =20 static void sunmouse_handle_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { ESCCChannelState *s =3D (ESCCChannelState *)dev; InputMoveEvent *move; diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index 8e9953bda43..c71174e1376 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -200,7 +200,7 @@ static int xenfb_send_position(struct XenInput *xenfb, * already has code for dealing with this... */ static void xenfb_key_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { struct XenInput *xenfb =3D (struct XenInput *)dev; InputKeyEvent *key =3D evt->u.key.data; @@ -227,7 +227,7 @@ static void xenfb_key_event(DeviceState *dev, QemuConso= le *src, * the button state. */ static void xenfb_mouse_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { struct XenInput *xenfb =3D (struct XenInput *)dev; InputBtnEvent *btn; diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c index 507557deecc..5ba6c9a7b5d 100644 --- a/hw/input/adb-kbd.c +++ b/hw/input/adb-kbd.c @@ -306,7 +306,7 @@ static bool adb_kbd_has_data(ADBDevice *d) =20 /* This is where keyboard events enter this file */ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { KBDState *s =3D (KBDState *)dev; int qcode, keycode; diff --git a/hw/input/adb-mouse.c b/hw/input/adb-mouse.c index 373ef3f953c..c37ccf26c16 100644 --- a/hw/input/adb-mouse.c +++ b/hw/input/adb-mouse.c @@ -56,7 +56,7 @@ struct ADBMouseClass { #define ADB_MOUSE_BUTTON_RIGHT 0x02 =20 static void adb_mouse_handle_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { MouseState *s =3D (MouseState *)dev; InputMoveEvent *move; diff --git a/hw/input/hid.c b/hw/input/hid.c index de24cd0ef04..53afb1d4340 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -108,7 +108,7 @@ void hid_set_next_idle(HIDState *hs) } =20 static void hid_pointer_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { static const int bmap[INPUT_BUTTON__MAX] =3D { [INPUT_BUTTON_LEFT] =3D 0x01, @@ -226,7 +226,7 @@ static void hid_pointer_sync(DeviceState *dev) } =20 static void hid_keyboard_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { HIDState *hs =3D (HIDState *)dev; int scancodes[3], i, count; diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 10ac7324030..90bcbcdff88 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -310,7 +310,7 @@ static void ps2_put_keycode(void *opaque, int keycode) } =20 static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { PS2KbdState *s =3D (PS2KbdState *)dev; InputKeyEvent *key =3D evt->u.key.data; @@ -787,7 +787,7 @@ static int ps2_mouse_send_packet(PS2MouseState *s) } =20 static void ps2_mouse_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { static const int bmap[INPUT_BUTTON__MAX] =3D { [INPUT_BUTTON_LEFT] =3D PS2_MOUSE_BUTTON_LEFT, diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index 42d43f9af51..db35905554d 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -16,7 +16,7 @@ #include "ui/console.h" =20 static void stellaris_gamepad_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { StellarisGamepad *s =3D STELLARIS_GAMEPAD(dev); InputKeyEvent *key =3D evt->u.key.data; diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 14dde90a48b..5b9f407c546 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -79,7 +79,7 @@ static void virtio_input_extend_config(VirtIOInput *vinpu= t, } =20 static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { VirtIOInput *vinput =3D VIRTIO_INPUT(dev); virtio_input_event event; diff --git a/hw/m68k/next-kbd.c b/hw/m68k/next-kbd.c index 571a9555040..9dbedac6479 100644 --- a/hw/m68k/next-kbd.c +++ b/hw/m68k/next-kbd.c @@ -242,7 +242,8 @@ static void nextkbd_put_keycode(NextKBDState *s, int ke= ycode) /* s->update_irq(s->update_arg, 1); */ } =20 -static void nextkbd_event(DeviceState *dev, QemuConsole *src, InputEvent *= evt) +static void nextkbd_event(DeviceState *dev, QemuConsole *src, + QemuInputEvent *evt) { NextKBDState *s =3D NEXTKBD(dev); int qcode, keycode; diff --git a/replay/replay-events.c b/replay/replay-events.c index 9e5af5e8495..20df810279e 100644 --- a/replay/replay-events.c +++ b/replay/replay-events.c @@ -41,7 +41,7 @@ static void replay_run_event(Event *event) ((QEMUBHFunc *)event->opaque)(event->opaque2); break; case REPLAY_ASYNC_EVENT_INPUT: - qemu_input_event_send_impl(NULL, (InputEvent *)event->opaque); + qemu_input_event_send_impl(NULL, (QemuInputEvent *)event->opaque); qapi_free_InputEvent((InputEvent *)event->opaque); break; case REPLAY_ASYNC_EVENT_INPUT_SYNC: @@ -143,7 +143,7 @@ void replay_bh_schedule_oneshot_event(AioContext *ctx, } } =20 -void replay_add_input_event(struct InputEvent *event) +void replay_add_input_event(QemuInputEvent *event) { replay_add_event(REPLAY_ASYNC_EVENT_INPUT, event, NULL, 0); } diff --git a/replay/replay-input.c b/replay/replay-input.c index 562bbf37175..3f506f2338a 100644 --- a/replay/replay-input.c +++ b/replay/replay-input.c @@ -17,7 +17,7 @@ #include "qapi/clone-visitor.h" #include "qapi/qapi-visit-ui.h" =20 -void replay_save_input_event(InputEvent *evt) +void replay_save_input_event(QemuInputEvent *evt) { InputKeyEvent *key; InputBtnEvent *btn; @@ -73,9 +73,9 @@ void replay_save_input_event(InputEvent *evt) } } =20 -InputEvent *replay_read_input_event(void) +QemuInputEvent *replay_read_input_event(void) { - InputEvent evt; + QemuInputEvent evt; KeyValue keyValue; InputKeyEvent key; key.key =3D &keyValue; @@ -135,7 +135,7 @@ InputEvent *replay_read_input_event(void) return QAPI_CLONE(InputEvent, &evt); } =20 -void replay_input_event(QemuConsole *src, InputEvent *evt) +void replay_input_event(QemuConsole *src, QemuInputEvent *evt) { if (replay_mode =3D=3D REPLAY_MODE_PLAY) { /* Nothing */ diff --git a/replay/stubs-system.c b/replay/stubs-system.c index b2c52bc4043..f8e17dcf1ce 100644 --- a/replay/stubs-system.c +++ b/replay/stubs-system.c @@ -2,7 +2,7 @@ #include "system/replay.h" #include "ui/input.h" =20 -void replay_input_event(QemuConsole *src, InputEvent *evt) +void replay_input_event(QemuConsole *src, QemuInputEvent *evt) { qemu_input_event_send_impl(src, evt); } diff --git a/ui/input-legacy.c b/ui/input-legacy.c index ca4bccb4113..5467010c371 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -110,7 +110,7 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_tim= e, int64_t hold_time, } =20 static void legacy_mouse_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { static const int bmap[INPUT_BUTTON__MAX] =3D { [INPUT_BUTTON_LEFT] =3D MOUSE_EVENT_LBUTTON, diff --git a/ui/input.c b/ui/input.c index 966023d4f4d..759855c67e8 100644 --- a/ui/input.c +++ b/ui/input.c @@ -30,7 +30,7 @@ struct QemuInputEventQueue { QEMUTimer *timer; uint32_t delay_ms; QemuConsole *src; - InputEvent *evt; + QemuInputEvent *evt; QTAILQ_ENTRY(QemuInputEventQueue) node; }; =20 @@ -174,7 +174,7 @@ void qmp_input_send_event(const char *device, qemu_input_event_sync(); } =20 -static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt) +static void qemu_input_event_trace(QemuConsole *src, QemuInputEvent *evt) { const char *name; int qcode, idx =3D -1; @@ -283,7 +283,7 @@ static void qemu_input_queue_delay(QemuInputEventQueueH= ead *queue, } =20 static void qemu_input_queue_event(QemuInputEventQueueHead *queue, - QemuConsole *src, InputEvent *evt) + QemuConsole *src, QemuInputEvent *evt) { QemuInputEventQueue *item =3D g_new0(QemuInputEventQueue, 1); =20 @@ -303,7 +303,7 @@ static void qemu_input_queue_sync(QemuInputEventQueueHe= ad *queue) queue_count++; } =20 -void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt) +void qemu_input_event_send_impl(QemuConsole *src, QemuInputEvent *evt) { QemuInputHandlerState *s; =20 @@ -318,7 +318,7 @@ void qemu_input_event_send_impl(QemuConsole *src, Input= Event *evt) s->events++; } =20 -void qemu_input_event_send(QemuConsole *src, InputEvent *evt) +void qemu_input_event_send(QemuConsole *src, QemuInputEvent *evt) { /* Expect all parts of QEMU to send events with QCodes exclusively. * Key numbers are only supported as end-user input via QMP */ @@ -372,9 +372,9 @@ void qemu_input_event_sync(void) replay_input_sync_event(); } =20 -static InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) +static QemuInputEvent *qemu_input_event_new_key(KeyValue *key, bool down) { - InputEvent *evt =3D g_new0(InputEvent, 1); + QemuInputEvent *evt =3D g_new0(QemuInputEvent, 1); evt->u.key.data =3D g_new0(InputKeyEvent, 1); evt->type =3D INPUT_EVENT_KIND_KEY; evt->u.key.data->key =3D key; @@ -384,7 +384,7 @@ static InputEvent *qemu_input_event_new_key(KeyValue *k= ey, bool down) =20 void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) { - InputEvent *evt; + QemuInputEvent *evt; evt =3D qemu_input_event_new_key(key, down); if (QTAILQ_EMPTY(&kbd_queue)) { qemu_input_event_send(src, evt); @@ -435,7 +435,7 @@ void qemu_input_queue_btn(QemuConsole *src, InputButton= btn, bool down) .button =3D btn, .down =3D down, }; - InputEvent evt =3D { + QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_BTN, .u.btn.data =3D &bevt, }; @@ -486,7 +486,7 @@ void qemu_input_queue_rel(QemuConsole *src, InputAxis a= xis, int value) .axis =3D axis, .value =3D value, }; - InputEvent evt =3D { + QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_REL, .u.rel.data =3D &move, }; @@ -503,7 +503,7 @@ void qemu_input_queue_abs(QemuConsole *src, InputAxis a= xis, int value, INPUT_EVENT_ABS_MIN, INPUT_EVENT_ABS_MAX), }; - InputEvent evt =3D { + QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_ABS, .u.abs.data =3D &move, }; @@ -519,7 +519,7 @@ void qemu_input_queue_mtt(QemuConsole *src, InputMultiT= ouchType type, .slot =3D slot, .tracking_id =3D tracking_id, }; - InputEvent evt =3D { + QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_MTT, .u.mtt.data =3D &mtt, }; @@ -539,7 +539,7 @@ void qemu_input_queue_mtt_abs(QemuConsole *src, InputAx= is axis, int value, INPUT_EVENT_ABS_MIN, INPUT_EVENT_ABS_MAX), }; - InputEvent evt =3D { + QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_MTT, .u.mtt.data =3D &mtt, }; diff --git a/ui/vdagent.c b/ui/vdagent.c index bb55cbefc9c..28a83c7c389 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -226,7 +226,7 @@ static void vdagent_send_mouse(VDAgentChardev *vd) } =20 static void vdagent_pointer_event(DeviceState *dev, QemuConsole *src, - InputEvent *evt) + QemuInputEvent *evt) { static const int bmap[INPUT_BUTTON__MAX] =3D { [INPUT_BUTTON_LEFT] =3D VD_AGENT_LBUTTON_MASK, --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364747; cv=none; d=zohomail.com; s=zohoarc; b=EC9WBR4a1m+LPVFO7Rzt0OQu+yuubEJKQYlglXwAdlQHOpIlK5locH9FB/nq18H/5hUPP8zX6g+hpeURBCkb2oYPh9jxQV7V6X2Nu6ToPk2WzIdUHy2qmeEninSfH0Hn/RzCVW81jJQlkyxwWqjOLR5PJGVkA4uAx5Ewou3thwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364747; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uyqfXSOr83jccfqc8F/tMw3y5tWSG/XsIVizc8cZQU4=; b=MrRyN6RyOrSEBQE0z2nnS+US2BBg1bsH2uToxM/cs1AqtRoeIqmZ3DmTib1ez5fKXE6z84wOp3RLz6M/vQFMAEvQiSqP9Fds1jnDbzeIEgJvQGJ0WQm5tWYeHFnDtIXqmYs8Fm7dmOdRdvjKrAtYuzO35SCO/PRzeG7yWoopkyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364747198437.7939527513777; Thu, 21 May 2026 04:59:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ22u-0006d6-Gm; Thu, 21 May 2026 07:58:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22r-0006V3-8e for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22m-0004Bq-FJ for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:32 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-I9qOmXFBPJOoI3kt79RVug-1; Thu, 21 May 2026 07:58:25 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 650BF1956068; Thu, 21 May 2026 11:58:23 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7BC421956053; Thu, 21 May 2026 11:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uyqfXSOr83jccfqc8F/tMw3y5tWSG/XsIVizc8cZQU4=; b=S+pAj9azOgcual6VWJCHpHTkDyrV5aTCMH0q2VrbAE8mahZi9Qv6i03mzjm0Ha11sBhNUj EuzhApBfZWSXJkD52XRlkSY+TSFd1HZDr3rbffpr5MclVS+DAs0y2caj97IR0ND1xxbeG/ bZNJD7DKTEknnPBTkdR2bIADloOC4e4= X-MC-Unique: I9qOmXFBPJOoI3kt79RVug-1 X-Mimecast-MFC-AGG-ID: I9qOmXFBPJOoI3kt79RVug_1779364703 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Jan Kiszka , Peter Maydell , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Mark Cave-Ayland , "Michael S. Tsirkin" , Gerd Hoffmann , Thomas Huth , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org (open list:Musicpal), xen-devel@lists.xenproject.org (open list:X86 Xen CPUs), qemu-ppc@nongnu.org (open list:Old World (g3beige)) Subject: [PULL 10/38] ui/input: Remove QAPI wrappers from QemuInputEvent Date: Thu, 21 May 2026 15:56:47 +0400 Message-ID: <20260521115717.1701482-11-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364748898154100 From: Akihiko Odaki QAPI represents union members with wrapper structs and pointer indirections. They are useful at the QMP boundary, but unnecessary for QEMU's internal input events and make handlers more verbose. Define QemuInputEvent as a plain internal tagged union and convert input handlers, queues, and replay code to access payloads directly. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-2-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- include/qemu/typedefs.h | 2 +- include/ui/input.h | 16 ++++ chardev/msmouse.c | 10 +- chardev/wctablet.c | 8 +- hw/arm/musicpal.c | 11 +-- hw/char/escc.c | 32 +++---- hw/display/xenfb.c | 32 +++---- hw/input/adb-kbd.c | 4 +- hw/input/adb-mouse.c | 20 ++-- hw/input/hid.c | 36 +++---- hw/input/ps2.c | 67 ++++++------- hw/input/stellaris_gamepad.c | 9 +- hw/input/virtio-input-hid.c | 53 +++++------ hw/m68k/next-kbd.c | 9 +- replay/replay-events.c | 2 +- replay/replay-input.c | 101 ++++++++------------ ui/input-legacy.c | 23 ++--- ui/input.c | 177 ++++++++++++++++++++--------------- ui/vdagent.c | 18 ++-- 19 files changed, 299 insertions(+), 331 deletions(-) diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index da7097c5440..2344c92182e 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -94,7 +94,7 @@ typedef struct QBool QBool; typedef struct QDict QDict; typedef struct QEMUBH QEMUBH; typedef struct QemuConsole QemuConsole; -typedef struct InputEvent QemuInputEvent; +typedef struct QemuInputEvent QemuInputEvent; typedef struct QEMUCursor QEMUCursor; typedef struct QEMUFile QEMUFile; typedef struct QemuMutex QemuMutex; diff --git a/include/ui/input.h b/include/ui/input.h index c455abdec6a..0b8c439fca7 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -18,6 +18,22 @@ typedef struct QemuInputHandler QemuInputHandler; typedef struct QemuInputHandlerState QemuInputHandlerState; =20 +typedef struct QemuInputKeyEvent { + KeyValue key; + bool down; +} QemuInputKeyEvent; + +typedef struct QemuInputEvent { + InputEventKind type; + union { + QemuInputKeyEvent key; + InputBtnEvent btn; + InputMoveEvent rel; + InputMoveEvent abs; + InputMultiTouchEvent mtt; + }; +} QemuInputEvent; + typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src, QemuInputEvent *evt); typedef void (*QemuInputHandlerSync)(DeviceState *dev); diff --git a/chardev/msmouse.c b/chardev/msmouse.c index 146457661f9..d72a16a2833 100644 --- a/chardev/msmouse.c +++ b/chardev/msmouse.c @@ -125,8 +125,6 @@ static void msmouse_input_event(DeviceState *dev, QemuC= onsole *src, QemuInputEvent *evt) { MouseChardev *mouse =3D MOUSE_CHARDEV(dev); - InputMoveEvent *move; - InputBtnEvent *btn; =20 /* Ignore events if serial mouse powered down. */ if (!MSMOUSE_PWR(mouse->tiocm)) { @@ -135,14 +133,12 @@ static void msmouse_input_event(DeviceState *dev, Qem= uConsole *src, =20 switch (evt->type) { case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; - mouse->axis[move->axis] +=3D move->value; + mouse->axis[evt->rel.axis] +=3D evt->rel.value; break; =20 case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - mouse->btns[btn->button] =3D btn->down; - mouse->btnc[btn->button] =3D true; + mouse->btns[evt->btn.button] =3D evt->btn.down; + mouse->btnc[evt->btn.button] =3D true; break; =20 default: diff --git a/chardev/wctablet.c b/chardev/wctablet.c index 05d2333fb0c..3ad24cce175 100644 --- a/chardev/wctablet.c +++ b/chardev/wctablet.c @@ -149,18 +149,14 @@ static void wctablet_input_event(DeviceState *dev, Qe= muConsole *src, QemuInputEvent *evt) { TabletChardev *tablet =3D (TabletChardev *)dev; - InputMoveEvent *move; - InputBtnEvent *btn; =20 switch (evt->type) { case INPUT_EVENT_KIND_ABS: - move =3D evt->u.abs.data; - tablet->axis[move->axis] =3D move->value; + tablet->axis[evt->abs.axis] =3D evt->abs.value; break; =20 case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - tablet->btns[btn->button] =3D btn->down; + tablet->btns[evt->btn.button] =3D evt->btn.down; break; =20 default: diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index ae171710e34..43c93cb72d7 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -1069,8 +1069,7 @@ static void musicpal_key_event(DeviceState *dev, Qemu= Console *src, QemuInputEvent *evt) { musicpal_key_state *s =3D MUSICPAL_KEY(dev); - InputKeyEvent *key =3D evt->u.key.data; - int qcode =3D qemu_input_key_value_to_qcode(key->key); + int qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); uint32_t event =3D 0; int i; =20 @@ -1113,14 +1112,14 @@ static void musicpal_key_event(DeviceState *dev, Qe= muConsole *src, * but do not repeat already-pressed buttons for the other key inputs. */ if (!(event & (MP_KEY_WHEEL_NAV | MP_KEY_WHEEL_VOL))) { - if (key->down && (s->pressed_keys & event)) { + if (evt->key.down && (s->pressed_keys & event)) { event =3D 0; } } =20 if (event) { /* Raise GPIO pin first if repeating a key */ - if (key->down && (s->pressed_keys & event)) { + if (evt->key.down && (s->pressed_keys & event)) { for (i =3D 0; i <=3D 7; i++) { if (event & (1 << i)) { qemu_set_irq(s->out[i], 1); @@ -1129,10 +1128,10 @@ static void musicpal_key_event(DeviceState *dev, Qe= muConsole *src, } for (i =3D 0; i <=3D 7; i++) { if (event & (1 << i)) { - qemu_set_irq(s->out[i], !key->down); + qemu_set_irq(s->out[i], !evt->key.down); } } - if (key->down) { + if (evt->key.down) { s->pressed_keys |=3D event; } else { s->pressed_keys &=3D ~event; diff --git a/hw/char/escc.c b/hw/char/escc.c index 677c3a120e1..c88b2d54ebe 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -798,16 +798,14 @@ static void sunkbd_handle_event(DeviceState *dev, Qem= uConsole *src, { ESCCChannelState *s =3D (ESCCChannelState *)dev; int qcode, keycode; - InputKeyEvent *key; =20 assert(evt->type =3D=3D INPUT_EVENT_KIND_KEY); - key =3D evt->u.key.data; - qcode =3D qemu_input_key_value_to_qcode(key->key); + qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); trace_escc_sunkbd_event_in(qcode, QKeyCode_str(qcode), - key->down); + evt->key.down); =20 if (qcode =3D=3D Q_KEY_CODE_CAPS_LOCK) { - if (key->down) { + if (evt->key.down) { s->caps_lock_mode ^=3D 1; if (s->caps_lock_mode =3D=3D 2) { return; /* Drop second press */ @@ -821,7 +819,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuC= onsole *src, } =20 if (qcode =3D=3D Q_KEY_CODE_NUM_LOCK) { - if (key->down) { + if (evt->key.down) { s->num_lock_mode ^=3D 1; if (s->num_lock_mode =3D=3D 2) { return; /* Drop second press */ @@ -839,7 +837,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuC= onsole *src, } =20 keycode =3D qemu_input_map_qcode_to_sun[qcode]; - if (!key->down) { + if (!evt->key.down) { keycode |=3D 0x80; } trace_escc_sunkbd_event_out(keycode); @@ -957,8 +955,6 @@ static void sunmouse_handle_event(DeviceState *dev, Qem= uConsole *src, QemuInputEvent *evt) { ESCCChannelState *s =3D (ESCCChannelState *)dev; - InputMoveEvent *move; - InputBtnEvent *btn; static const int bmap[INPUT_BUTTON__MAX] =3D { [INPUT_BUTTON_LEFT] =3D 0x4, [INPUT_BUTTON_MIDDLE] =3D 0x2, @@ -967,21 +963,19 @@ static void sunmouse_handle_event(DeviceState *dev, Q= emuConsole *src, =20 switch (evt->type) { case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; - if (move->axis =3D=3D INPUT_AXIS_X) { - s->sunmouse_dx +=3D move->value; - } else if (move->axis =3D=3D INPUT_AXIS_Y) { - s->sunmouse_dy -=3D move->value; + if (evt->rel.axis =3D=3D INPUT_AXIS_X) { + s->sunmouse_dx +=3D evt->rel.value; + } else if (evt->rel.axis =3D=3D INPUT_AXIS_Y) { + s->sunmouse_dy -=3D evt->rel.value; } break; =20 case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - if (bmap[btn->button]) { - if (btn->down) { - s->sunmouse_buttons |=3D bmap[btn->button]; + if (bmap[evt->btn.button]) { + if (evt->btn.down) { + s->sunmouse_buttons |=3D bmap[evt->btn.button]; } else { - s->sunmouse_buttons &=3D ~bmap[btn->button]; + s->sunmouse_buttons &=3D ~bmap[evt->btn.button]; } /* Indicate we have a supported button event */ s->sunmouse_buttons |=3D 0x80; diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index c71174e1376..82d2cbae7cc 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -203,16 +203,15 @@ static void xenfb_key_event(DeviceState *dev, QemuCon= sole *src, QemuInputEvent *evt) { struct XenInput *xenfb =3D (struct XenInput *)dev; - InputKeyEvent *key =3D evt->u.key.data; - int qcode =3D qemu_input_key_value_to_qcode(key->key); + int qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); int lnx; =20 if (qcode < qemu_input_map_qcode_to_linux_len) { lnx =3D qemu_input_map_qcode_to_linux[qcode]; =20 if (lnx) { - trace_xenfb_key_event(xenfb, lnx, key->down); - xenfb_send_key(xenfb, key->down, lnx); + trace_xenfb_key_event(xenfb, lnx, evt->key.down); + xenfb_send_key(xenfb, evt->key.down, lnx); } } } @@ -230,32 +229,29 @@ static void xenfb_mouse_event(DeviceState *dev, QemuC= onsole *src, QemuInputEvent *evt) { struct XenInput *xenfb =3D (struct XenInput *)dev; - InputBtnEvent *btn; - InputMoveEvent *move; QemuConsole *con; DisplaySurface *surface; int scale; =20 switch (evt->type) { case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - switch (btn->button) { + switch (evt->btn.button) { case INPUT_BUTTON_LEFT: - xenfb_send_key(xenfb, btn->down, BTN_LEFT); + xenfb_send_key(xenfb, evt->btn.down, BTN_LEFT); break; case INPUT_BUTTON_RIGHT: - xenfb_send_key(xenfb, btn->down, BTN_LEFT + 1); + xenfb_send_key(xenfb, evt->btn.down, BTN_LEFT + 1); break; case INPUT_BUTTON_MIDDLE: - xenfb_send_key(xenfb, btn->down, BTN_LEFT + 2); + xenfb_send_key(xenfb, evt->btn.down, BTN_LEFT + 2); break; case INPUT_BUTTON_WHEEL_UP: - if (btn->down) { + if (evt->btn.down) { xenfb->wheel--; } break; case INPUT_BUTTON_WHEEL_DOWN: - if (btn->down) { + if (evt->btn.down) { xenfb->wheel++; } break; @@ -265,9 +261,8 @@ static void xenfb_mouse_event(DeviceState *dev, QemuCon= sole *src, break; =20 case INPUT_EVENT_KIND_ABS: - move =3D evt->u.abs.data; if (xenfb->raw_pointer_wanted) { - xenfb->axis[move->axis] =3D move->value; + xenfb->axis[evt->abs.axis] =3D evt->abs.value; } else { con =3D qemu_console_lookup_by_index(0); if (!con) { @@ -275,7 +270,7 @@ static void xenfb_mouse_event(DeviceState *dev, QemuCon= sole *src, return; } surface =3D qemu_console_surface(con); - switch (move->axis) { + switch (evt->abs.axis) { case INPUT_AXIS_X: scale =3D surface_width(surface) - 1; break; @@ -285,13 +280,12 @@ static void xenfb_mouse_event(DeviceState *dev, QemuC= onsole *src, default: g_assert_not_reached(); } - xenfb->axis[move->axis] =3D move->value * scale / 0x7fff; + xenfb->axis[evt->abs.axis] =3D evt->abs.value * scale / 0x7fff; } break; =20 case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; - xenfb->axis[move->axis] +=3D move->value; + xenfb->axis[evt->rel.axis] +=3D evt->rel.value; break; =20 default: diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c index 5ba6c9a7b5d..5911e713925 100644 --- a/hw/input/adb-kbd.c +++ b/hw/input/adb-kbd.c @@ -311,7 +311,7 @@ static void adb_keyboard_event(DeviceState *dev, QemuCo= nsole *src, KBDState *s =3D (KBDState *)dev; int qcode, keycode; =20 - qcode =3D qemu_input_key_value_to_qcode(evt->u.key.data->key); + qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); if (qcode >=3D ARRAY_SIZE(qcode_to_adb_keycode)) { return; } @@ -321,7 +321,7 @@ static void adb_keyboard_event(DeviceState *dev, QemuCo= nsole *src, trace_adb_device_kbd_no_key(); return; } - if (evt->u.key.data->down =3D=3D false) { /* if key release event */ + if (evt->key.down =3D=3D false) { /* if key release event */ keycode =3D keycode | 0x80; /* create keyboard break code */ } =20 diff --git a/hw/input/adb-mouse.c b/hw/input/adb-mouse.c index c37ccf26c16..5dcdc851fcd 100644 --- a/hw/input/adb-mouse.c +++ b/hw/input/adb-mouse.c @@ -59,8 +59,6 @@ static void adb_mouse_handle_event(DeviceState *dev, Qemu= Console *src, QemuInputEvent *evt) { MouseState *s =3D (MouseState *)dev; - InputMoveEvent *move; - InputBtnEvent *btn; static const int bmap[INPUT_BUTTON__MAX] =3D { [INPUT_BUTTON_LEFT] =3D ADB_MOUSE_BUTTON_LEFT, [INPUT_BUTTON_RIGHT] =3D ADB_MOUSE_BUTTON_RIGHT, @@ -68,21 +66,19 @@ static void adb_mouse_handle_event(DeviceState *dev, Qe= muConsole *src, =20 switch (evt->type) { case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; - if (move->axis =3D=3D INPUT_AXIS_X) { - s->dx +=3D move->value; - } else if (move->axis =3D=3D INPUT_AXIS_Y) { - s->dy +=3D move->value; + if (evt->rel.axis =3D=3D INPUT_AXIS_X) { + s->dx +=3D evt->rel.value; + } else if (evt->rel.axis =3D=3D INPUT_AXIS_Y) { + s->dy +=3D evt->rel.value; } break; =20 case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - if (bmap[btn->button]) { - if (btn->down) { - s->buttons_state |=3D bmap[btn->button]; + if (bmap[evt->btn.button]) { + if (evt->btn.down) { + s->buttons_state |=3D bmap[evt->btn.button]; } else { - s->buttons_state &=3D ~bmap[btn->button]; + s->buttons_state &=3D ~bmap[evt->btn.button]; } } break; diff --git a/hw/input/hid.c b/hw/input/hid.c index 53afb1d4340..90b29682a25 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -119,42 +119,37 @@ static void hid_pointer_event(DeviceState *dev, QemuC= onsole *src, }; HIDState *hs =3D (HIDState *)dev; HIDPointerEvent *e; - InputMoveEvent *move; - InputBtnEvent *btn; =20 assert(hs->n < QUEUE_LENGTH); e =3D &hs->ptr.queue[(hs->head + hs->n) & QUEUE_MASK]; =20 switch (evt->type) { case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; - if (move->axis =3D=3D INPUT_AXIS_X) { - e->xdx +=3D move->value; - } else if (move->axis =3D=3D INPUT_AXIS_Y) { - e->ydy +=3D move->value; + if (evt->rel.axis =3D=3D INPUT_AXIS_X) { + e->xdx +=3D evt->rel.value; + } else if (evt->rel.axis =3D=3D INPUT_AXIS_Y) { + e->ydy +=3D evt->rel.value; } break; =20 case INPUT_EVENT_KIND_ABS: - move =3D evt->u.abs.data; - if (move->axis =3D=3D INPUT_AXIS_X) { - e->xdx =3D move->value; - } else if (move->axis =3D=3D INPUT_AXIS_Y) { - e->ydy =3D move->value; + if (evt->abs.axis =3D=3D INPUT_AXIS_X) { + e->xdx =3D evt->abs.value; + } else if (evt->abs.axis =3D=3D INPUT_AXIS_Y) { + e->ydy =3D evt->abs.value; } break; =20 case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - if (btn->down) { - e->buttons_state |=3D bmap[btn->button]; - if (btn->button =3D=3D INPUT_BUTTON_WHEEL_UP) { + if (evt->btn.down) { + e->buttons_state |=3D bmap[evt->btn.button]; + if (evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_UP) { e->dz--; - } else if (btn->button =3D=3D INPUT_BUTTON_WHEEL_DOWN) { + } else if (evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_DOWN) { e->dz++; } } else { - e->buttons_state &=3D ~bmap[btn->button]; + e->buttons_state &=3D ~bmap[evt->btn.button]; } break; =20 @@ -231,10 +226,9 @@ static void hid_keyboard_event(DeviceState *dev, QemuC= onsole *src, HIDState *hs =3D (HIDState *)dev; int scancodes[3], i, count; int slot; - InputKeyEvent *key =3D evt->u.key.data; =20 - count =3D qemu_input_key_value_to_scancode(key->key, - key->down, + count =3D qemu_input_key_value_to_scancode(&evt->key.key, + evt->key.down, scancodes); if (hs->n + count > QUEUE_LENGTH) { trace_hid_kbd_queue_full(); diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 90bcbcdff88..3e553176ef6 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -313,7 +313,6 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, QemuInputEvent *evt) { PS2KbdState *s =3D (PS2KbdState *)dev; - InputKeyEvent *key =3D evt->u.key.data; int qcode; uint16_t keycode =3D 0; int mod; @@ -325,12 +324,12 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, =20 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); assert(evt->type =3D=3D INPUT_EVENT_KIND_KEY); - qcode =3D qemu_input_key_value_to_qcode(key->key); + qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); =20 mod =3D ps2_modifier_bit(qcode); - trace_ps2_keyboard_event(s, qcode, key->down, mod, + trace_ps2_keyboard_event(s, qcode, evt->key.down, mod, s->modifiers, s->scancode_set, s->translate); - if (key->down) { + if (evt->key.down) { s->modifiers |=3D mod; } else { s->modifiers &=3D ~mod; @@ -339,14 +338,14 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, if (s->scancode_set =3D=3D 1) { if (qcode =3D=3D Q_KEY_CODE_PAUSE) { if (s->modifiers & (MOD_CTRL_L | MOD_CTRL_R)) { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0x46); ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0xc6); } } else { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe1); ps2_put_keycode(s, 0x1d); ps2_put_keycode(s, 0x45); @@ -357,7 +356,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } } else if (qcode =3D=3D Q_KEY_CODE_PRINT) { if (s->modifiers & MOD_ALT_L) { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xb8); ps2_put_keycode(s, 0x38); ps2_put_keycode(s, 0x54); @@ -367,7 +366,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0x38); } } else if (s->modifiers & MOD_ALT_R) { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0xb8); ps2_put_keycode(s, 0xe0); @@ -382,7 +381,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } } else if (s->modifiers & (MOD_SHIFT_L | MOD_CTRL_L | MOD_SHIFT_R | MOD_CTRL_R)) { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0x37); } else { @@ -390,7 +389,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0xb7); } } else { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0x2a); ps2_put_keycode(s, 0xe0); @@ -403,7 +402,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } } } else if ((qcode =3D=3D Q_KEY_CODE_LANG1 || qcode =3D=3D Q_KEY_CO= DE_LANG2) - && !key->down) { + && !evt->key.down) { /* Ignore release for these keys */ } else { if (qcode < qemu_input_map_qcode_to_atset1_len) { @@ -413,7 +412,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, if (keycode & 0xff00) { ps2_put_keycode(s, keycode >> 8); } - if (!key->down) { + if (!evt->key.down) { keycode |=3D 0x80; } ps2_put_keycode(s, keycode & 0xff); @@ -425,7 +424,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } else if (s->scancode_set =3D=3D 2) { if (qcode =3D=3D Q_KEY_CODE_PAUSE) { if (s->modifiers & (MOD_CTRL_L | MOD_CTRL_R)) { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0x7e); ps2_put_keycode(s, 0xe0); @@ -433,7 +432,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0x7e); } } else { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe1); ps2_put_keycode(s, 0x14); ps2_put_keycode(s, 0x77); @@ -446,7 +445,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } } else if (qcode =3D=3D Q_KEY_CODE_PRINT) { if (s->modifiers & MOD_ALT_L) { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xf0); ps2_put_keycode(s, 0x11); ps2_put_keycode(s, 0x11); @@ -459,7 +458,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0x11); } } else if (s->modifiers & MOD_ALT_R) { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0xf0); ps2_put_keycode(s, 0x11); @@ -477,7 +476,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } } else if (s->modifiers & (MOD_SHIFT_L | MOD_CTRL_L | MOD_SHIFT_R | MOD_CTRL_R)) { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0x7c); } else { @@ -486,7 +485,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0x7c); } } else { - if (key->down) { + if (evt->key.down) { ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0x12); ps2_put_keycode(s, 0xe0); @@ -501,7 +500,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } } } else if ((qcode =3D=3D Q_KEY_CODE_LANG1 || qcode =3D=3D Q_KEY_CO= DE_LANG2) && - !key->down) { + !evt->key.down) { /* Ignore release for these keys */ } else { if (qcode < qemu_input_map_qcode_to_atset2_len) { @@ -511,7 +510,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, if (keycode & 0xff00) { ps2_put_keycode(s, keycode >> 8); } - if (!key->down) { + if (!evt->key.down) { ps2_put_keycode(s, 0xf0); } ps2_put_keycode(s, keycode & 0xff); @@ -526,7 +525,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } if (keycode) { /* FIXME: break code should be configured on a key by key basi= s */ - if (!key->down) { + if (!evt->key.down) { ps2_put_keycode(s, 0xf0); } ps2_put_keycode(s, keycode); @@ -797,8 +796,6 @@ static void ps2_mouse_event(DeviceState *dev, QemuConso= le *src, [INPUT_BUTTON_EXTRA] =3D PS2_MOUSE_BUTTON_EXTRA, }; PS2MouseState *s =3D (PS2MouseState *)dev; - InputMoveEvent *move; - InputBtnEvent *btn; =20 /* check if deltas are recorded when disabled */ if (!(s->mouse_status & MOUSE_STATUS_ENABLED)) { @@ -807,31 +804,29 @@ static void ps2_mouse_event(DeviceState *dev, QemuCon= sole *src, =20 switch (evt->type) { case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; - if (move->axis =3D=3D INPUT_AXIS_X) { - s->mouse_dx +=3D move->value; - } else if (move->axis =3D=3D INPUT_AXIS_Y) { - s->mouse_dy -=3D move->value; + if (evt->rel.axis =3D=3D INPUT_AXIS_X) { + s->mouse_dx +=3D evt->rel.value; + } else if (evt->rel.axis =3D=3D INPUT_AXIS_Y) { + s->mouse_dy -=3D evt->rel.value; } break; =20 case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - if (btn->down) { - s->mouse_buttons |=3D bmap[btn->button]; - if (btn->button =3D=3D INPUT_BUTTON_WHEEL_UP) { + if (evt->btn.down) { + s->mouse_buttons |=3D bmap[evt->btn.button]; + if (evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_UP) { s->mouse_dz--; - } else if (btn->button =3D=3D INPUT_BUTTON_WHEEL_DOWN) { + } else if (evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_DOWN) { s->mouse_dz++; } =20 - if (btn->button =3D=3D INPUT_BUTTON_WHEEL_RIGHT) { + if (evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_RIGHT) { s->mouse_dw--; - } else if (btn->button =3D=3D INPUT_BUTTON_WHEEL_LEFT) { + } else if (evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_LEFT) { s->mouse_dw++; } } else { - s->mouse_buttons &=3D ~bmap[btn->button]; + s->mouse_buttons &=3D ~bmap[evt->btn.button]; } break; =20 diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index db35905554d..7d8ec38e888 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -19,14 +19,13 @@ static void stellaris_gamepad_event(DeviceState *dev, Q= emuConsole *src, QemuInputEvent *evt) { StellarisGamepad *s =3D STELLARIS_GAMEPAD(dev); - InputKeyEvent *key =3D evt->u.key.data; - int qcode =3D qemu_input_key_value_to_qcode(key->key); + int qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); int i; =20 for (i =3D 0; i < s->num_buttons; i++) { - if (s->keycodes[i] =3D=3D qcode && s->pressed[i] !=3D key->down) { - s->pressed[i] =3D key->down; - qemu_set_irq(s->irqs[i], key->down); + if (s->keycodes[i] =3D=3D qcode && s->pressed[i] !=3D evt->key.dow= n) { + s->pressed[i] =3D evt->key.down; + qemu_set_irq(s->irqs[i], evt->key.down); } } } diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 5b9f407c546..3f8a1bc249e 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -84,80 +84,71 @@ static void virtio_input_handle_event(DeviceState *dev,= QemuConsole *src, VirtIOInput *vinput =3D VIRTIO_INPUT(dev); virtio_input_event event; int qcode; - InputKeyEvent *key; - InputMoveEvent *move; - InputBtnEvent *btn; - InputMultiTouchEvent *mtt; =20 switch (evt->type) { case INPUT_EVENT_KIND_KEY: - key =3D evt->u.key.data; - qcode =3D qemu_input_key_value_to_qcode(key->key); + qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); 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(qemu_input_map_qcode_to_linux[qcod= e]); - event.value =3D cpu_to_le32(key->down ? 1 : 0); + event.value =3D cpu_to_le32(evt->key.down ? 1 : 0); virtio_input_send(vinput, &event); } else { - if (key->down) { + if (evt->key.down) { fprintf(stderr, "%s: unmapped key: %d [%s]\n", __func__, qcode, QKeyCode_str(qcode)); } } break; case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - if ((btn->button =3D=3D INPUT_BUTTON_WHEEL_UP || - btn->button =3D=3D INPUT_BUTTON_WHEEL_DOWN) && - btn->down) { + if ((evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_UP || + evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_DOWN) && + evt->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 + event.value =3D cpu_to_le32(evt->btn.button =3D=3D INPUT_BUTTO= N_WHEEL_UP ? 1 : -1); virtio_input_send(vinput, &event); - } else if (keymap_button[btn->button]) { + } else if (keymap_button[evt->btn.button]) { event.type =3D cpu_to_le16(EV_KEY); - event.code =3D cpu_to_le16(keymap_button[btn->button]); - event.value =3D cpu_to_le32(btn->down ? 1 : 0); + event.code =3D cpu_to_le16(keymap_button[evt->btn.button]); + event.value =3D cpu_to_le32(evt->btn.down ? 1 : 0); virtio_input_send(vinput, &event); } else { - if (btn->down) { + if (evt->btn.down) { fprintf(stderr, "%s: unmapped button: %d [%s]\n", __func__, - btn->button, - InputButton_str(btn->button)); + evt->btn.button, + InputButton_str(evt->btn.button)); } } break; case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; event.type =3D cpu_to_le16(EV_REL); - event.code =3D cpu_to_le16(axismap_rel[move->axis]); - event.value =3D cpu_to_le32(move->value); + event.code =3D cpu_to_le16(axismap_rel[evt->rel.axis]); + event.value =3D cpu_to_le32(evt->rel.value); virtio_input_send(vinput, &event); break; case INPUT_EVENT_KIND_ABS: - move =3D evt->u.abs.data; event.type =3D cpu_to_le16(EV_ABS); - event.code =3D cpu_to_le16(axismap_abs[move->axis]); - event.value =3D cpu_to_le32(move->value); + event.code =3D cpu_to_le16(axismap_abs[evt->abs.axis]); + event.value =3D cpu_to_le32(evt->abs.value); virtio_input_send(vinput, &event); break; case INPUT_EVENT_KIND_MTT: - mtt =3D evt->u.mtt.data; - if (mtt->type =3D=3D INPUT_MULTI_TOUCH_TYPE_DATA) { + if (evt->mtt.type =3D=3D INPUT_MULTI_TOUCH_TYPE_DATA) { event.type =3D cpu_to_le16(EV_ABS); - event.code =3D cpu_to_le16(axismap_tch[mtt->axis]); - event.value =3D cpu_to_le32(mtt->value); + event.code =3D cpu_to_le16(axismap_tch[evt->mtt.axis]); + event.value =3D cpu_to_le32(evt->mtt.value); virtio_input_send(vinput, &event); } else { event.type =3D cpu_to_le16(EV_ABS); event.code =3D cpu_to_le16(ABS_MT_SLOT); - event.value =3D cpu_to_le32(mtt->slot); + event.value =3D cpu_to_le32(evt->mtt.slot); virtio_input_send(vinput, &event); event.type =3D cpu_to_le16(EV_ABS); event.code =3D cpu_to_le16(ABS_MT_TRACKING_ID); - event.value =3D cpu_to_le32(mtt->tracking_id); + event.value =3D cpu_to_le32(evt->mtt.tracking_id); virtio_input_send(vinput, &event); } break; diff --git a/hw/m68k/next-kbd.c b/hw/m68k/next-kbd.c index 9dbedac6479..f3110ea0bca 100644 --- a/hw/m68k/next-kbd.c +++ b/hw/m68k/next-kbd.c @@ -247,16 +247,15 @@ static void nextkbd_event(DeviceState *dev, QemuConso= le *src, { NextKBDState *s =3D NEXTKBD(dev); int qcode, keycode; - bool key_down =3D evt->u.key.data->down; =20 - qcode =3D qemu_input_key_value_to_qcode(evt->u.key.data->key); + qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); if (qcode >=3D ARRAY_SIZE(qcode_to_nextkbd_keycode)) { return; } =20 /* Shift key currently has no keycode, so handle separately */ if (qcode =3D=3D Q_KEY_CODE_SHIFT) { - if (key_down) { + if (evt->key.down) { s->shift |=3D KD_LSHIFT; } else { s->shift &=3D ~KD_LSHIFT; @@ -264,7 +263,7 @@ static void nextkbd_event(DeviceState *dev, QemuConsole= *src, } =20 if (qcode =3D=3D Q_KEY_CODE_SHIFT_R) { - if (key_down) { + if (evt->key.down) { s->shift |=3D KD_RSHIFT; } else { s->shift &=3D ~KD_RSHIFT; @@ -277,7 +276,7 @@ static void nextkbd_event(DeviceState *dev, QemuConsole= *src, } =20 /* If key release event, create keyboard break code */ - if (!key_down) { + if (!evt->key.down) { keycode |=3D 0x80; } =20 diff --git a/replay/replay-events.c b/replay/replay-events.c index 20df810279e..3ff42acb06b 100644 --- a/replay/replay-events.c +++ b/replay/replay-events.c @@ -42,7 +42,7 @@ static void replay_run_event(Event *event) break; case REPLAY_ASYNC_EVENT_INPUT: qemu_input_event_send_impl(NULL, (QemuInputEvent *)event->opaque); - qapi_free_InputEvent((InputEvent *)event->opaque); + g_free(event->opaque); break; case REPLAY_ASYNC_EVENT_INPUT_SYNC: qemu_input_event_sync_impl(); diff --git a/replay/replay-input.c b/replay/replay-input.c index 3f506f2338a..0995b125f24 100644 --- a/replay/replay-input.c +++ b/replay/replay-input.c @@ -19,25 +19,20 @@ =20 void replay_save_input_event(QemuInputEvent *evt) { - InputKeyEvent *key; - InputBtnEvent *btn; - InputMoveEvent *move; - InputMultiTouchEvent *mtt; replay_put_dword(evt->type); =20 switch (evt->type) { case INPUT_EVENT_KIND_KEY: - key =3D evt->u.key.data; - replay_put_dword(key->key->type); + replay_put_dword(evt->key.key.type); =20 - switch (key->key->type) { + switch (evt->key.key.type) { case KEY_VALUE_KIND_NUMBER: - replay_put_qword(key->key->u.number.data); - replay_put_byte(key->down); + replay_put_qword(evt->key.key.u.number.data); + replay_put_byte(evt->key.down); break; case KEY_VALUE_KIND_QCODE: - replay_put_dword(key->key->u.qcode.data); - replay_put_byte(key->down); + replay_put_dword(evt->key.key.u.qcode.data); + replay_put_byte(evt->key.down); break; case KEY_VALUE_KIND__MAX: /* keep gcc happy */ @@ -45,27 +40,23 @@ void replay_save_input_event(QemuInputEvent *evt) } break; case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - replay_put_dword(btn->button); - replay_put_byte(btn->down); + replay_put_dword(evt->btn.button); + replay_put_byte(evt->btn.down); break; case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; - replay_put_dword(move->axis); - replay_put_qword(move->value); + replay_put_dword(evt->rel.axis); + replay_put_qword(evt->rel.value); break; case INPUT_EVENT_KIND_ABS: - move =3D evt->u.abs.data; - replay_put_dword(move->axis); - replay_put_qword(move->value); + replay_put_dword(evt->abs.axis); + replay_put_qword(evt->abs.value); break; case INPUT_EVENT_KIND_MTT: - mtt =3D evt->u.mtt.data; - replay_put_dword(mtt->type); - replay_put_qword(mtt->slot); - replay_put_qword(mtt->tracking_id); - replay_put_dword(mtt->axis); - replay_put_qword(mtt->value); + replay_put_dword(evt->mtt.type); + replay_put_qword(evt->mtt.slot); + replay_put_qword(evt->mtt.tracking_id); + replay_put_dword(evt->mtt.axis); + replay_put_qword(evt->mtt.value); break; case INPUT_EVENT_KIND__MAX: /* keep gcc happy */ @@ -75,29 +66,21 @@ void replay_save_input_event(QemuInputEvent *evt) =20 QemuInputEvent *replay_read_input_event(void) { - QemuInputEvent evt; - KeyValue keyValue; - InputKeyEvent key; - key.key =3D &keyValue; - InputBtnEvent btn; - InputMoveEvent rel; - InputMoveEvent abs; - InputMultiTouchEvent mtt; + QemuInputEvent *evt =3D g_new(QemuInputEvent, 1); =20 - evt.type =3D replay_get_dword(); - switch (evt.type) { + evt->type =3D replay_get_dword(); + switch (evt->type) { case INPUT_EVENT_KIND_KEY: - evt.u.key.data =3D &key; - evt.u.key.data->key->type =3D replay_get_dword(); + evt->key.key.type =3D replay_get_dword(); =20 - switch (evt.u.key.data->key->type) { + switch (evt->key.key.type) { case KEY_VALUE_KIND_NUMBER: - evt.u.key.data->key->u.number.data =3D replay_get_qword(); - evt.u.key.data->down =3D replay_get_byte(); + evt->key.key.u.number.data =3D replay_get_qword(); + evt->key.down =3D replay_get_byte(); break; case KEY_VALUE_KIND_QCODE: - evt.u.key.data->key->u.qcode.data =3D (QKeyCode)replay_get_dwo= rd(); - evt.u.key.data->down =3D replay_get_byte(); + evt->key.key.u.qcode.data =3D (QKeyCode)replay_get_dword(); + evt->key.down =3D replay_get_byte(); break; case KEY_VALUE_KIND__MAX: /* keep gcc happy */ @@ -105,34 +88,30 @@ QemuInputEvent *replay_read_input_event(void) } break; case INPUT_EVENT_KIND_BTN: - evt.u.btn.data =3D &btn; - evt.u.btn.data->button =3D (InputButton)replay_get_dword(); - evt.u.btn.data->down =3D replay_get_byte(); + evt->btn.button =3D (InputButton)replay_get_dword(); + evt->btn.down =3D replay_get_byte(); break; case INPUT_EVENT_KIND_REL: - evt.u.rel.data =3D &rel; - evt.u.rel.data->axis =3D (InputAxis)replay_get_dword(); - evt.u.rel.data->value =3D replay_get_qword(); + evt->rel.axis =3D (InputAxis)replay_get_dword(); + evt->rel.value =3D replay_get_qword(); break; case INPUT_EVENT_KIND_ABS: - evt.u.abs.data =3D &abs; - evt.u.abs.data->axis =3D (InputAxis)replay_get_dword(); - evt.u.abs.data->value =3D replay_get_qword(); + evt->abs.axis =3D (InputAxis)replay_get_dword(); + evt->abs.value =3D replay_get_qword(); break; case INPUT_EVENT_KIND_MTT: - evt.u.mtt.data =3D &mtt; - evt.u.mtt.data->type =3D (InputMultiTouchType)replay_get_dword(); - evt.u.mtt.data->slot =3D replay_get_qword(); - evt.u.mtt.data->tracking_id =3D replay_get_qword(); - evt.u.mtt.data->axis =3D (InputAxis)replay_get_dword(); - evt.u.mtt.data->value =3D replay_get_qword(); + evt->mtt.type =3D (InputMultiTouchType)replay_get_dword(); + evt->mtt.slot =3D replay_get_qword(); + evt->mtt.tracking_id =3D replay_get_qword(); + evt->mtt.axis =3D (InputAxis)replay_get_dword(); + evt->mtt.value =3D replay_get_qword(); break; case INPUT_EVENT_KIND__MAX: /* keep gcc happy */ break; } =20 - return QAPI_CLONE(InputEvent, &evt); + return evt; } =20 void replay_input_event(QemuConsole *src, QemuInputEvent *evt) @@ -140,7 +119,9 @@ void replay_input_event(QemuConsole *src, QemuInputEven= t *evt) if (replay_mode =3D=3D REPLAY_MODE_PLAY) { /* Nothing */ } else if (replay_mode =3D=3D REPLAY_MODE_RECORD) { - replay_add_input_event(QAPI_CLONE(InputEvent, evt)); + QemuInputEvent *clone =3D g_new(QemuInputEvent, 1); + *clone =3D *evt; + replay_add_input_event(clone); } else { qemu_input_event_send_impl(src, evt); } diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 5467010c371..e2b48dd8f0a 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -118,39 +118,36 @@ static void legacy_mouse_event(DeviceState *dev, Qemu= Console *src, [INPUT_BUTTON_RIGHT] =3D MOUSE_EVENT_RBUTTON, }; QEMUPutMouseEntry *s =3D (QEMUPutMouseEntry *)dev; - InputBtnEvent *btn; - InputMoveEvent *move; =20 switch (evt->type) { case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - if (btn->down) { - s->buttons |=3D bmap[btn->button]; + if (evt->btn.down) { + s->buttons |=3D bmap[evt->btn.button]; } else { - s->buttons &=3D ~bmap[btn->button]; + s->buttons &=3D ~bmap[evt->btn.button]; } - if (btn->down && btn->button =3D=3D INPUT_BUTTON_WHEEL_UP) { + if (evt->btn.down && evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_UP)= { s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque, s->axis[INPUT_AXIS_X], s->axis[INPUT_AXIS_Y], -1, s->buttons); } - if (btn->down && btn->button =3D=3D INPUT_BUTTON_WHEEL_DOWN) { + if (evt->btn.down && evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_DOW= N) { s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque, s->axis[INPUT_AXIS_X], s->axis[INPUT_AXIS_Y], 1, s->buttons); } - if (btn->down && btn->button =3D=3D INPUT_BUTTON_WHEEL_RIGHT) { + if (evt->btn.down && evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_RIG= HT) { s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque, s->axis[INPUT_AXIS_X], s->axis[INPUT_AXIS_Y], -2, s->buttons); } - if (btn->down && btn->button =3D=3D INPUT_BUTTON_WHEEL_LEFT) { + if (evt->btn.down && evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_LEF= T) { s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque, s->axis[INPUT_AXIS_X], s->axis[INPUT_AXIS_Y], @@ -159,12 +156,10 @@ static void legacy_mouse_event(DeviceState *dev, Qemu= Console *src, } break; case INPUT_EVENT_KIND_ABS: - move =3D evt->u.abs.data; - s->axis[move->axis] =3D move->value; + s->axis[evt->abs.axis] =3D evt->abs.value; break; case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; - s->axis[move->axis] +=3D move->value; + s->axis[evt->rel.axis] +=3D evt->rel.value; break; default: break; diff --git a/ui/input.c b/ui/input.c index 759855c67e8..97c473f40a2 100644 --- a/ui/input.c +++ b/ui/input.c @@ -30,7 +30,7 @@ struct QemuInputEventQueue { QEMUTimer *timer; uint32_t delay_ms; QemuConsole *src; - QemuInputEvent *evt; + QemuInputEvent evt; QTAILQ_ENTRY(QemuInputEventQueue) node; }; =20 @@ -159,16 +159,54 @@ void qmp_input_send_event(const char *device, } =20 for (e =3D events; e !=3D NULL; e =3D e->next) { - InputEvent *evt =3D e->value; + InputEvent *qapi =3D e->value; + QemuInputEvent evt; + + evt.type =3D qapi->type; + + switch (qapi->type) { + case INPUT_EVENT_KIND_KEY: { + KeyValue *key =3D qapi->u.key.data->key; + QKeyCode code; + + switch (key->type) { + case KEY_VALUE_KIND_NUMBER: + code =3D qemu_input_key_number_to_qcode(key->u.number.data= ); + break; + case KEY_VALUE_KIND_QCODE: + code =3D key->u.qcode.data; + break; + default: + g_assert_not_reached(); + } + + evt.key.key.type =3D KEY_VALUE_KIND_QCODE; + evt.key.key.u.qcode.data =3D code; + evt.key.down =3D qapi->u.key.data->down; + break; + } =20 - if (evt->type =3D=3D INPUT_EVENT_KIND_KEY && - evt->u.key.data->key->type =3D=3D KEY_VALUE_KIND_NUMBER) { - KeyValue *key =3D evt->u.key.data->key; - QKeyCode code =3D qemu_input_key_number_to_qcode(key->u.number= .data); - qemu_input_event_send_key_qcode(con, code, evt->u.key.data->do= wn); - } else { - qemu_input_event_send(con, evt); + case INPUT_EVENT_KIND_BTN: + evt.btn =3D *qapi->u.btn.data; + break; + + case INPUT_EVENT_KIND_REL: + evt.rel =3D *qapi->u.rel.data; + break; + + case INPUT_EVENT_KIND_ABS: + evt.abs =3D *qapi->u.abs.data; + break; + + case INPUT_EVENT_KIND_MTT: + evt.mtt =3D *qapi->u.mtt.data; + break; + + default: + g_assert_not_reached(); } + + qemu_input_event_send(con, &evt); } =20 qemu_input_event_sync(); @@ -178,7 +216,7 @@ static void qemu_input_event_trace(QemuConsole *src, Qe= muInputEvent *evt) { const char *name; int qcode, idx =3D -1; - InputKeyEvent *key; + QemuInputKeyEvent *key; InputBtnEvent *btn; InputMoveEvent *move; InputMultiTouchEvent *mtt; @@ -188,16 +226,16 @@ static void qemu_input_event_trace(QemuConsole *src, = QemuInputEvent *evt) } switch (evt->type) { case INPUT_EVENT_KIND_KEY: - key =3D evt->u.key.data; - switch (key->key->type) { + key =3D &evt->key; + switch (evt->key.key.type) { case KEY_VALUE_KIND_NUMBER: - qcode =3D qemu_input_key_number_to_qcode(key->key->u.number.da= ta); + qcode =3D qemu_input_key_number_to_qcode(key->key.u.number.dat= a); name =3D QKeyCode_str(qcode); - trace_input_event_key_number(idx, key->key->u.number.data, + trace_input_event_key_number(idx, key->key.u.number.data, name, key->down); break; case KEY_VALUE_KIND_QCODE: - name =3D QKeyCode_str(key->key->u.qcode.data); + name =3D QKeyCode_str(key->key.u.qcode.data); trace_input_event_key_qcode(idx, name, key->down); break; case KEY_VALUE_KIND__MAX: @@ -206,22 +244,22 @@ static void qemu_input_event_trace(QemuConsole *src, = QemuInputEvent *evt) } break; case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; + btn =3D &evt->btn; name =3D btn->button < INPUT_BUTTON__MAX ? InputButton_str(btn->bu= tton) : "invalid"; trace_input_event_btn(idx, name, btn->down); break; case INPUT_EVENT_KIND_REL: - move =3D evt->u.rel.data; + move =3D &evt->rel; name =3D move->axis < INPUT_AXIS__MAX ? InputAxis_str(move->axis) = : "invalid"; trace_input_event_rel(idx, name, move->value); break; case INPUT_EVENT_KIND_ABS: - move =3D evt->u.abs.data; + move =3D &evt->abs; name =3D move->axis < INPUT_AXIS__MAX ? InputAxis_str(move->axis) = : "invalid"; trace_input_event_abs(idx, name, move->value); break; case INPUT_EVENT_KIND_MTT: - mtt =3D evt->u.mtt.data; + mtt =3D &evt->mtt; name =3D mtt->axis < INPUT_AXIS__MAX ? InputAxis_str(mtt->axis) : = "invalid"; trace_input_event_mtt(idx, name, mtt->value); break; @@ -251,8 +289,7 @@ static void qemu_input_queue_process(void *opaque) + item->delay_ms); return; case QEMU_INPUT_QUEUE_EVENT: - qemu_input_event_send(item->src, item->evt); - qapi_free_InputEvent(item->evt); + qemu_input_event_send(item->src, &item->evt); break; case QEMU_INPUT_QUEUE_SYNC: qemu_input_event_sync(); @@ -289,7 +326,7 @@ static void qemu_input_queue_event(QemuInputEventQueueH= ead *queue, =20 item->type =3D QEMU_INPUT_QUEUE_EVENT; item->src =3D src; - item->evt =3D evt; + item->evt =3D *evt; QTAILQ_INSERT_TAIL(queue, item, node); queue_count++; } @@ -323,7 +360,7 @@ void qemu_input_event_send(QemuConsole *src, QemuInputE= vent *evt) /* Expect all parts of QEMU to send events with QCodes exclusively. * Key numbers are only supported as end-user input via QMP */ assert(!(evt->type =3D=3D INPUT_EVENT_KIND_KEY && - evt->u.key.data->key->type =3D=3D KEY_VALUE_KIND_NUMBER)); + evt->key.key.type =3D=3D KEY_VALUE_KIND_NUMBER)); =20 =20 /* @@ -335,8 +372,8 @@ void qemu_input_event_send(QemuConsole *src, QemuInputE= vent *evt) * need to deal with this mistake */ if (evt->type =3D=3D INPUT_EVENT_KIND_KEY && - evt->u.key.data->key->u.qcode.data =3D=3D Q_KEY_CODE_SYSRQ) { - evt->u.key.data->key->u.qcode.data =3D Q_KEY_CODE_PRINT; + evt->key.key.u.qcode.data =3D=3D Q_KEY_CODE_SYSRQ) { + evt->key.key.u.qcode.data =3D Q_KEY_CODE_PRINT; } =20 if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { @@ -372,29 +409,24 @@ void qemu_input_event_sync(void) replay_input_sync_event(); } =20 -static QemuInputEvent *qemu_input_event_new_key(KeyValue *key, bool down) -{ - QemuInputEvent *evt =3D g_new0(QemuInputEvent, 1); - evt->u.key.data =3D g_new0(InputKeyEvent, 1); - evt->type =3D INPUT_EVENT_KIND_KEY; - evt->u.key.data->key =3D key; - evt->u.key.data->down =3D down; - return evt; -} - void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) { - QemuInputEvent *evt; - evt =3D qemu_input_event_new_key(key, down); + QemuInputEvent evt =3D { + .type =3D INPUT_EVENT_KIND_KEY, + .key =3D { + .key =3D *key, + .down =3D down, + }, + }; + + g_free(key); + if (QTAILQ_EMPTY(&kbd_queue)) { - qemu_input_event_send(src, evt); + qemu_input_event_send(src, &evt); qemu_input_event_sync(); - qapi_free_InputEvent(evt); } else if (queue_count < queue_limit) { - qemu_input_queue_event(&kbd_queue, src, evt); + qemu_input_queue_event(&kbd_queue, src, &evt); qemu_input_queue_sync(&kbd_queue); - } else { - qapi_free_InputEvent(evt); } } =20 @@ -431,13 +463,12 @@ void qemu_input_event_send_key_delay(uint32_t delay_m= s) =20 void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down) { - InputBtnEvent bevt =3D { - .button =3D btn, - .down =3D down, - }; QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_BTN, - .u.btn.data =3D &bevt, + .btn =3D { + .button =3D btn, + .down =3D down, + } }; =20 qemu_input_event_send(src, &evt); @@ -482,13 +513,12 @@ int qemu_input_scale_axis(int value, =20 void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value) { - InputMoveEvent move =3D { - .axis =3D axis, - .value =3D value, - }; QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_REL, - .u.rel.data =3D &move, + .rel =3D { + .axis =3D axis, + .value =3D value, + }, }; =20 qemu_input_event_send(src, &evt); @@ -497,15 +527,14 @@ void qemu_input_queue_rel(QemuConsole *src, InputAxis= axis, int value) void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, int min_in, int max_in) { - InputMoveEvent move =3D { - .axis =3D axis, - .value =3D qemu_input_scale_axis(value, min_in, max_in, - INPUT_EVENT_ABS_MIN, - INPUT_EVENT_ABS_MAX), - }; QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_ABS, - .u.abs.data =3D &move, + .abs =3D { + .axis =3D axis, + .value =3D qemu_input_scale_axis(value, min_in, max_in, + INPUT_EVENT_ABS_MIN, + INPUT_EVENT_ABS_MAX), + }, }; =20 qemu_input_event_send(src, &evt); @@ -514,14 +543,13 @@ void qemu_input_queue_abs(QemuConsole *src, InputAxis= axis, int value, void qemu_input_queue_mtt(QemuConsole *src, InputMultiTouchType type, int slot, int tracking_id) { - InputMultiTouchEvent mtt =3D { - .type =3D type, - .slot =3D slot, - .tracking_id =3D tracking_id, - }; QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_MTT, - .u.mtt.data =3D &mtt, + .mtt =3D { + .type =3D type, + .slot =3D slot, + .tracking_id =3D tracking_id, + }, }; =20 qemu_input_event_send(src, &evt); @@ -530,18 +558,17 @@ void qemu_input_queue_mtt(QemuConsole *src, InputMult= iTouchType type, void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value, int min_in, int max_in, int slot, int tracki= ng_id) { - InputMultiTouchEvent mtt =3D { - .type =3D INPUT_MULTI_TOUCH_TYPE_DATA, - .slot =3D slot, - .tracking_id =3D tracking_id, - .axis =3D axis, - .value =3D qemu_input_scale_axis(value, min_in, max_in, - INPUT_EVENT_ABS_MIN, - INPUT_EVENT_ABS_MAX), - }; QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_MTT, - .u.mtt.data =3D &mtt, + .mtt =3D { + .type =3D INPUT_MULTI_TOUCH_TYPE_DATA, + .slot =3D slot, + .tracking_id =3D tracking_id, + .axis =3D axis, + .value =3D qemu_input_scale_axis(value, min_in, max_in, + INPUT_EVENT_ABS_MIN, + INPUT_EVENT_ABS_MAX), + } }; =20 qemu_input_event_send(src, &evt); diff --git a/ui/vdagent.c b/ui/vdagent.c index 28a83c7c389..8fa325bffa3 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -241,22 +241,19 @@ static void vdagent_pointer_event(DeviceState *dev, Q= emuConsole *src, }; =20 VDAgentChardev *vd =3D container_of(dev, struct VDAgentChardev, mouse_= dev); - InputMoveEvent *move; - InputBtnEvent *btn; uint32_t xres, yres; =20 switch (evt->type) { case INPUT_EVENT_KIND_ABS: - move =3D evt->u.abs.data; xres =3D qemu_console_get_width(src, 1024); yres =3D qemu_console_get_height(src, 768); - if (move->axis =3D=3D INPUT_AXIS_X) { - vd->mouse_x =3D qemu_input_scale_axis(move->value, + if (evt->abs.axis =3D=3D INPUT_AXIS_X) { + vd->mouse_x =3D qemu_input_scale_axis(evt->abs.value, INPUT_EVENT_ABS_MIN, INPUT_EVENT_ABS_MAX, 0, xres); - } else if (move->axis =3D=3D INPUT_AXIS_Y) { - vd->mouse_y =3D qemu_input_scale_axis(move->value, + } else if (evt->abs.axis =3D=3D INPUT_AXIS_Y) { + vd->mouse_y =3D qemu_input_scale_axis(evt->abs.value, INPUT_EVENT_ABS_MIN, INPUT_EVENT_ABS_MAX, 0, yres); @@ -265,11 +262,10 @@ static void vdagent_pointer_event(DeviceState *dev, Q= emuConsole *src, break; =20 case INPUT_EVENT_KIND_BTN: - btn =3D evt->u.btn.data; - if (btn->down) { - vd->mouse_btn |=3D bmap[btn->button]; + if (evt->btn.down) { + vd->mouse_btn |=3D bmap[evt->btn.button]; } else { - vd->mouse_btn &=3D ~bmap[btn->button]; + vd->mouse_btn &=3D ~bmap[evt->btn.button]; } break; =20 --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364790; cv=none; d=zohomail.com; s=zohoarc; b=KXRtpmYFfoRHu77uOVJ2n2zzlVXcAYu4nPZO0brS+VekaxC0WBjqHxMzjoV9VED8T5/yN9etEO0k2DMqAGrl/+sM1lObAFrTZpbOrpn071ZS/qoEXdYsjzd3v+wmhMqSN0fFVPdJaA71iQ7/XrS7Jim44a3HCuxuG5HMXpsP1U0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364790; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kXJCyBYPJ2LyljuxM9u8r6lghDNX43DPRG6Wz80yJRQ=; b=CYYK+Xi94C+WrL71kvIzhhQSJa4DwFzH2LWFAvWV5SfXbbq8MkTAUMvbl8pndoDG8Xjcl57uf/YHRzP2fT2zCGsI4dIOv6sq/UpI19G7hwNVnnl6luJbsBd+uwdMMpnfNOg+KzDOWXRcFGHygH0l3ZfwTHrk/x7Y4OSGLsSwirY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177936479028351.82871159473211; Thu, 21 May 2026 04:59:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ233-0006nv-G2; Thu, 21 May 2026 07:58:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22y-0006iU-FP for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ22w-0004DO-19 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:40 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-157-LviHhN-9PVWfPi1oLTxAYQ-1; Thu, 21 May 2026 07:58:32 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 377BF18002E8; Thu, 21 May 2026 11:58:30 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 18CC81800352; Thu, 21 May 2026 11:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kXJCyBYPJ2LyljuxM9u8r6lghDNX43DPRG6Wz80yJRQ=; b=RphmcnsHdRn6H04qbGo23H1J11kOgK4jQ9JAgvry9mRb4Xbkk2JUg+Z3nJIxXj/YoHouMB QO+lVkZdWKgeJZYTO73eUAvceGwif1Co4ZWZjM1bNWRtq11xSETLjbNyu9kJ/xSlKH/aSr KBaSIDlg52HI3YobwmcTnmW/rC7Smag= X-MC-Unique: LviHhN-9PVWfPi1oLTxAYQ-1 X-Mimecast-MFC-AGG-ID: LviHhN-9PVWfPi1oLTxAYQ_1779364710 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , Jan Kiszka , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Mark Cave-Ayland , "Michael S. Tsirkin" , Gerd Hoffmann , Thomas Huth , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org (open list:Musicpal), xen-devel@lists.xenproject.org (open list:X86 Xen CPUs), qemu-ppc@nongnu.org (open list:New World (mac99)) Subject: [PULL 11/38] ui/input: Store QKeyCode directly in QemuInputKeyEvent Date: Thu, 21 May 2026 15:56:48 +0400 Message-ID: <20260521115717.1701482-12-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364791846154100 From: Akihiko Odaki Since commit af07e5ff02ae ("ui: convert key events to QKeyCodes immediately"), all internal key events are expected to be represented as QKeyCode. Replace KeyValue in QemuInputKeyEvent with QKeyCode to enforce that and simplify key code retrieval. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-3-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- include/ui/input.h | 5 ++--- hw/arm/musicpal.c | 2 +- hw/char/escc.c | 2 +- hw/display/xenfb.c | 2 +- hw/input/adb-kbd.c | 2 +- hw/input/hid.c | 5 ++--- hw/input/ps2.c | 2 +- hw/input/stellaris_gamepad.c | 2 +- hw/input/virtio-input-hid.c | 2 +- hw/m68k/next-kbd.c | 2 +- replay/replay-input.c | 29 ++++++----------------------- ui/input-keymap.c | 9 ++++----- ui/input.c | 34 +++++++--------------------------- ui/trace-events | 1 - 14 files changed, 29 insertions(+), 70 deletions(-) diff --git a/include/ui/input.h b/include/ui/input.h index 0b8c439fca7..3c3dfa7b59d 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -19,7 +19,7 @@ typedef struct QemuInputHandler QemuInputHandler; typedef struct QemuInputHandlerState QemuInputHandlerState; =20 typedef struct QemuInputKeyEvent { - KeyValue key; + QKeyCode key; bool down; } QemuInputKeyEvent; =20 @@ -65,8 +65,7 @@ void qemu_input_event_send_key_delay(uint32_t delay_ms); int qemu_input_key_number_to_qcode(unsigned int nr); int qemu_input_key_value_to_number(const KeyValue *value); 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_qcode_to_scancode(QKeyCode qcode, bool down, int *codes); int qemu_input_linux_to_qcode(unsigned int lnx); =20 void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down); diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index 43c93cb72d7..f436bd13d91 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -1069,7 +1069,7 @@ static void musicpal_key_event(DeviceState *dev, Qemu= Console *src, QemuInputEvent *evt) { musicpal_key_state *s =3D MUSICPAL_KEY(dev); - int qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); + int qcode =3D evt->key.key; uint32_t event =3D 0; int i; =20 diff --git a/hw/char/escc.c b/hw/char/escc.c index c88b2d54ebe..3ad803537e5 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -800,7 +800,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuC= onsole *src, int qcode, keycode; =20 assert(evt->type =3D=3D INPUT_EVENT_KIND_KEY); - qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); + qcode =3D evt->key.key; trace_escc_sunkbd_event_in(qcode, QKeyCode_str(qcode), evt->key.down); =20 diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index 82d2cbae7cc..176796cbf62 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -203,7 +203,7 @@ static void xenfb_key_event(DeviceState *dev, QemuConso= le *src, QemuInputEvent *evt) { struct XenInput *xenfb =3D (struct XenInput *)dev; - int qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); + int qcode =3D evt->key.key; int lnx; =20 if (qcode < qemu_input_map_qcode_to_linux_len) { diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c index 5911e713925..db3c7777500 100644 --- a/hw/input/adb-kbd.c +++ b/hw/input/adb-kbd.c @@ -311,7 +311,7 @@ static void adb_keyboard_event(DeviceState *dev, QemuCo= nsole *src, KBDState *s =3D (KBDState *)dev; int qcode, keycode; =20 - qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); + qcode =3D evt->key.key; if (qcode >=3D ARRAY_SIZE(qcode_to_adb_keycode)) { return; } diff --git a/hw/input/hid.c b/hw/input/hid.c index 90b29682a25..31f6331c7d7 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -227,9 +227,8 @@ static void hid_keyboard_event(DeviceState *dev, QemuCo= nsole *src, int scancodes[3], i, count; int slot; =20 - count =3D qemu_input_key_value_to_scancode(&evt->key.key, - evt->key.down, - scancodes); + count =3D qemu_input_qcode_to_scancode(evt->key.key, evt->key.down, + scancodes); if (hs->n + count > QUEUE_LENGTH) { trace_hid_kbd_queue_full(); return; diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 3e553176ef6..9090a0427bd 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -324,7 +324,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, =20 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); assert(evt->type =3D=3D INPUT_EVENT_KIND_KEY); - qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); + qcode =3D evt->key.key; =20 mod =3D ps2_modifier_bit(qcode); trace_ps2_keyboard_event(s, qcode, evt->key.down, mod, diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index 7d8ec38e888..6f42c46ddad 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -19,7 +19,7 @@ static void stellaris_gamepad_event(DeviceState *dev, Qem= uConsole *src, QemuInputEvent *evt) { StellarisGamepad *s =3D STELLARIS_GAMEPAD(dev); - int qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); + int qcode =3D evt->key.key; int i; =20 for (i =3D 0; i < s->num_buttons; i++) { diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 3f8a1bc249e..d48be1ea211 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -87,7 +87,7 @@ static void virtio_input_handle_event(DeviceState *dev, Q= emuConsole *src, =20 switch (evt->type) { case INPUT_EVENT_KIND_KEY: - qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); + qcode =3D evt->key.key; if (qcode < qemu_input_map_qcode_to_linux_len && qemu_input_map_qcode_to_linux[qcode]) { event.type =3D cpu_to_le16(EV_KEY); diff --git a/hw/m68k/next-kbd.c b/hw/m68k/next-kbd.c index f3110ea0bca..39f223d0211 100644 --- a/hw/m68k/next-kbd.c +++ b/hw/m68k/next-kbd.c @@ -248,7 +248,7 @@ static void nextkbd_event(DeviceState *dev, QemuConsole= *src, NextKBDState *s =3D NEXTKBD(dev); int qcode, keycode; =20 - qcode =3D qemu_input_key_value_to_qcode(&evt->key.key); + qcode =3D evt->key.key; if (qcode >=3D ARRAY_SIZE(qcode_to_nextkbd_keycode)) { return; } diff --git a/replay/replay-input.c b/replay/replay-input.c index 0995b125f24..f1ee678ef72 100644 --- a/replay/replay-input.c +++ b/replay/replay-input.c @@ -23,21 +23,9 @@ void replay_save_input_event(QemuInputEvent *evt) =20 switch (evt->type) { case INPUT_EVENT_KIND_KEY: - replay_put_dword(evt->key.key.type); - - switch (evt->key.key.type) { - case KEY_VALUE_KIND_NUMBER: - replay_put_qword(evt->key.key.u.number.data); - replay_put_byte(evt->key.down); - break; - case KEY_VALUE_KIND_QCODE: - replay_put_dword(evt->key.key.u.qcode.data); - replay_put_byte(evt->key.down); - break; - case KEY_VALUE_KIND__MAX: - /* keep gcc happy */ - break; - } + replay_put_dword(KEY_VALUE_KIND_QCODE); + replay_put_dword(evt->key.key); + replay_put_byte(evt->key.down); break; case INPUT_EVENT_KIND_BTN: replay_put_dword(evt->btn.button); @@ -71,20 +59,15 @@ QemuInputEvent *replay_read_input_event(void) evt->type =3D replay_get_dword(); switch (evt->type) { case INPUT_EVENT_KIND_KEY: - evt->key.key.type =3D replay_get_dword(); - - switch (evt->key.key.type) { + switch (replay_get_dword()) { case KEY_VALUE_KIND_NUMBER: - evt->key.key.u.number.data =3D replay_get_qword(); + evt->key.key =3D qemu_input_key_number_to_qcode(replay_get_qwo= rd()); evt->key.down =3D replay_get_byte(); break; case KEY_VALUE_KIND_QCODE: - evt->key.key.u.qcode.data =3D (QKeyCode)replay_get_dword(); + evt->key.key =3D (QKeyCode)replay_get_dword(); evt->key.down =3D replay_get_byte(); break; - case KEY_VALUE_KIND__MAX: - /* keep gcc happy */ - break; } break; case INPUT_EVENT_KIND_BTN: diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 1b756a6970c..2f6d431c824 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -61,14 +61,13 @@ int qemu_input_key_value_to_qcode(const KeyValue *value) } } =20 -int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, - int *codes) +int qemu_input_qcode_to_scancode(QKeyCode qcode, bool down, int *codes) { - int keycode =3D qemu_input_key_value_to_number(value); + int keycode =3D qcode < qemu_input_map_qcode_to_qnum_len ? + qemu_input_map_qcode_to_qnum[qcode] : 0; int count =3D 0; =20 - if (value->type =3D=3D KEY_VALUE_KIND_QCODE && - value->u.qcode.data =3D=3D Q_KEY_CODE_PAUSE) { + if (qcode =3D=3D Q_KEY_CODE_PAUSE) { /* specific case */ int v =3D down ? 0 : 0x80; codes[count++] =3D 0xe1; diff --git a/ui/input.c b/ui/input.c index 97c473f40a2..9232dd7fdae 100644 --- a/ui/input.c +++ b/ui/input.c @@ -180,8 +180,7 @@ void qmp_input_send_event(const char *device, g_assert_not_reached(); } =20 - evt.key.key.type =3D KEY_VALUE_KIND_QCODE; - evt.key.key.u.qcode.data =3D code; + evt.key.key =3D code; evt.key.down =3D qapi->u.key.data->down; break; } @@ -215,7 +214,7 @@ void qmp_input_send_event(const char *device, static void qemu_input_event_trace(QemuConsole *src, QemuInputEvent *evt) { const char *name; - int qcode, idx =3D -1; + int idx =3D -1; QemuInputKeyEvent *key; InputBtnEvent *btn; InputMoveEvent *move; @@ -227,21 +226,8 @@ static void qemu_input_event_trace(QemuConsole *src, Q= emuInputEvent *evt) switch (evt->type) { case INPUT_EVENT_KIND_KEY: key =3D &evt->key; - switch (evt->key.key.type) { - case KEY_VALUE_KIND_NUMBER: - qcode =3D qemu_input_key_number_to_qcode(key->key.u.number.dat= a); - name =3D QKeyCode_str(qcode); - trace_input_event_key_number(idx, key->key.u.number.data, - name, key->down); - break; - case KEY_VALUE_KIND_QCODE: - name =3D QKeyCode_str(key->key.u.qcode.data); - trace_input_event_key_qcode(idx, name, key->down); - break; - case KEY_VALUE_KIND__MAX: - /* keep gcc happy */ - break; - } + name =3D QKeyCode_str(key->key); + trace_input_event_key_qcode(idx, name, key->down); break; case INPUT_EVENT_KIND_BTN: btn =3D &evt->btn; @@ -357,12 +343,6 @@ void qemu_input_event_send_impl(QemuConsole *src, Qemu= InputEvent *evt) =20 void qemu_input_event_send(QemuConsole *src, QemuInputEvent *evt) { - /* Expect all parts of QEMU to send events with QCodes exclusively. - * Key numbers are only supported as end-user input via QMP */ - assert(!(evt->type =3D=3D INPUT_EVENT_KIND_KEY && - evt->key.key.type =3D=3D KEY_VALUE_KIND_NUMBER)); - - /* * 'sysrq' was mistakenly added to hack around the fact that * the ps2 driver was not generating correct scancodes sequences @@ -372,8 +352,8 @@ void qemu_input_event_send(QemuConsole *src, QemuInputE= vent *evt) * need to deal with this mistake */ if (evt->type =3D=3D INPUT_EVENT_KIND_KEY && - evt->key.key.u.qcode.data =3D=3D Q_KEY_CODE_SYSRQ) { - evt->key.key.u.qcode.data =3D Q_KEY_CODE_PRINT; + evt->key.key =3D=3D Q_KEY_CODE_SYSRQ) { + evt->key.key =3D Q_KEY_CODE_PRINT; } =20 if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { @@ -414,7 +394,7 @@ void qemu_input_event_send_key(QemuConsole *src, KeyVal= ue *key, bool down) QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_KEY, .key =3D { - .key =3D *key, + .key =3D qemu_input_key_value_to_qcode(key), .down =3D down, }, }; diff --git a/ui/trace-events b/ui/trace-events index c1ea56874ee..1c0d96a92c3 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -127,7 +127,6 @@ vnc_tight_zlib_init(void *state, int stream_id, const v= oid *opaque) "VNC tight z =20 =20 # input.c -input_event_key_number(int conidx, int number, const char *qcode, bool dow= n) "con %d, key number 0x%x [%s], down %d" input_event_key_qcode(int conidx, const char *qcode, bool down) "con %d, k= ey qcode %s, down %d" input_event_btn(int conidx, const char *btn, bool down) "con %d, button %s= , down %d" input_event_rel(int conidx, const char *axis, int value) "con %d, axis %s,= value %d" --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364868; cv=none; d=zohomail.com; s=zohoarc; b=UIS28JshOY76EroGI4Kaz+LbtVvPm663HfoKk0iOsM54oX9RF4NDjwPgBP5+UG0jzI0abHmXgLBWZgq59rj8hIDg+v45l4rGVdTjLe0xykZxQPfzE/YKfH0Hwl0XfNMrjjKG8GS2V1KoCpZg7TFoMw61ja1UQdbcFiD5W1bmwWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364868; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=j68JGoJNkTWT/TXl2hNCJf2/YV33P7t1Mlhi5KcpYz0=; b=hVbCciGEq5/DAd3tDPPJ8OiQfXkBWVtCAWhDkbXT+WBwgYdp89yKVtoMhbebIMUckhn27tGgh1X+xvUfO5vDHv16rLlCtWHBrH4pS0x9+IEZkkNvQehplmq1Jeg6ByCC4vbWwnOdz9EQD9hv94UDEpYLuuonh9opU7rSTzx1lfs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364868057189.71999725653188; Thu, 21 May 2026 05:01:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ23I-0006xc-EY; Thu, 21 May 2026 07:59:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ234-0006pE-SV for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ231-0004EN-6A for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:45 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-325-21yScQ2eMbmZv9ULwJ0p5Q-1; Thu, 21 May 2026 07:58:39 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2444A195608D; Thu, 21 May 2026 11:58:37 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 693CB19560A6; Thu, 21 May 2026 11:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j68JGoJNkTWT/TXl2hNCJf2/YV33P7t1Mlhi5KcpYz0=; b=O8OkAqKwXF0tCyP0y1fWuuE0DMQxtgD+DrlsBZyPeizPY0UW+fFwhIbc87p91ECGifIuxG Sjlwl7TBMJzK3AWAU6F0wpq/m5ruWoR/0fVBU2D9Lx+3P0XdG4hE6t/vs3q4dRq4iHZoLV PZG3X4j7PKUzssKrBsjATOfJO4ft3hA= X-MC-Unique: 21yScQ2eMbmZv9ULwJ0p5Q-1 X-Mimecast-MFC-AGG-ID: 21yScQ2eMbmZv9ULwJ0p5Q_1779364717 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , Jan Kiszka , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Mark Cave-Ayland , Gerd Hoffmann , "Michael S. Tsirkin" , Thomas Huth , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org (open list:Musicpal), xen-devel@lists.xenproject.org (open list:X86 Xen CPUs), qemu-ppc@nongnu.org (open list:New World (mac99)) Subject: [PULL 12/38] ui/input: Use Linux key codes for internal key events Date: Thu, 21 May 2026 15:56:49 +0400 Message-ID: <20260521115717.1701482-13-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364870600158500 From: Akihiko Odaki Linux input key codes are a better internal representation than QKeyCode: - With Linux input key codes as the internal representation, keys previously lost solely because the middle layer between event sources and sinks used QKeyCode will be preserved, since Linux key codes cover all keys that those sources and sinks use. For example, KEY_KPJPCOMMA cannot be represented with QKeyCode, but it is widely supported by event sources and sinks since it is included in linux, atset1, atset2, usb, x11, osx, qnum (derived from atset1), xorgxquartz, and xorgevdev (derived from linux). - They make it possible to pass through Linux host key codes to Linux guests to preserve all key inputs. - They simplify consumers by avoiding QKeyCode aliases, namely asterisk/kp_multiply and sysrq/print. This matches the approach used by virtio and Xen. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-4-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- include/ui/input.h | 49 ++++++++++++++++++++++++++++++- hw/arm/musicpal.c | 2 +- hw/char/escc.c | 2 +- hw/display/xenfb.c | 2 +- hw/input/adb-kbd.c | 2 +- hw/input/hid.c | 3 +- hw/input/ps2.c | 2 +- hw/input/stellaris_gamepad.c | 2 +- hw/input/virtio-input-hid.c | 2 +- hw/m68k/next-kbd.c | 2 +- replay/replay-input.c | 11 +++++-- tools/qemu-vnc/input.c | 13 +++++++-- ui/input-keymap.c | 56 +++++++++++++++++++++++++++++------- ui/input.c | 51 ++++++++++---------------------- tools/qemu-vnc/trace-events | 2 +- ui/meson.build | 14 +++++++++ 16 files changed, 151 insertions(+), 64 deletions(-) diff --git a/include/ui/input.h b/include/ui/input.h index 3c3dfa7b59d..e76dd4b172a 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -19,7 +19,7 @@ typedef struct QemuInputHandler QemuInputHandler; typedef struct QemuInputHandlerState QemuInputHandlerState; =20 typedef struct QemuInputKeyEvent { - QKeyCode key; + unsigned int key; bool down; } QemuInputKeyEvent; =20 @@ -59,13 +59,18 @@ void qemu_input_event_sync(void); void qemu_input_event_sync_impl(void); =20 void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down); +void qemu_input_event_send_key_linux(QemuConsole *src, unsigned int lnx, + bool down); void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down= ); void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool do= wn); void qemu_input_event_send_key_delay(uint32_t delay_ms); int qemu_input_key_number_to_qcode(unsigned int nr); +unsigned int qemu_input_key_number_to_linux(unsigned int nr); int qemu_input_key_value_to_number(const KeyValue *value); int qemu_input_key_value_to_qcode(const KeyValue *value); +unsigned int qemu_input_key_value_to_linux(const KeyValue *value); int qemu_input_qcode_to_scancode(QKeyCode qcode, bool down, int *codes); +int qemu_input_linux_to_scancode(unsigned int lnx, bool down, int *codes); int qemu_input_linux_to_qcode(unsigned int lnx); =20 void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down); @@ -107,52 +112,94 @@ void qemu_remove_mouse_mode_change_notifier(Notifier = *notify); extern const guint qemu_input_map_atset1_to_qcode_len; extern const guint16 qemu_input_map_atset1_to_qcode[]; =20 +extern const guint qemu_input_map_atset1_to_linux_len; +extern const guint16 qemu_input_map_atset1_to_linux[]; + 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[]; =20 +extern const guint qemu_input_map_linux_to_atset1_len; +extern const guint16 qemu_input_map_linux_to_atset1[]; + extern const guint qemu_input_map_qcode_to_atset2_len; extern const guint16 qemu_input_map_qcode_to_atset2[]; =20 +extern const guint qemu_input_map_linux_to_atset2_len; +extern const guint16 qemu_input_map_linux_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_linux_to_atset3_len; +extern const guint16 qemu_input_map_linux_to_atset3[]; + extern const guint qemu_input_map_qcode_to_linux_len; extern const guint16 qemu_input_map_qcode_to_linux[]; =20 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_linux_to_qnum_len; +extern const guint16 qemu_input_map_linux_to_qnum[]; + extern const guint qemu_input_map_qcode_to_sun_len; extern const guint16 qemu_input_map_qcode_to_sun[]; =20 +extern const guint qemu_input_map_linux_to_sun_len; +extern const guint16 qemu_input_map_linux_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_qnum_to_linux_len; +extern const guint16 qemu_input_map_qnum_to_linux[]; + extern const guint qemu_input_map_usb_to_qcode_len; extern const guint16 qemu_input_map_usb_to_qcode[]; =20 +extern const guint qemu_input_map_usb_to_linux_len; +extern const guint16 qemu_input_map_usb_to_linux[]; + extern const guint qemu_input_map_win32_to_qcode_len; extern const guint16 qemu_input_map_win32_to_qcode[]; =20 +extern const guint qemu_input_map_win32_to_linux_len; +extern const guint16 qemu_input_map_win32_to_linux[]; + extern const guint qemu_input_map_x11_to_qcode_len; extern const guint16 qemu_input_map_x11_to_qcode[]; =20 +extern const guint qemu_input_map_x11_to_linux_len; +extern const guint16 qemu_input_map_x11_to_linux[]; + extern const guint qemu_input_map_xorgevdev_to_qcode_len; extern const guint16 qemu_input_map_xorgevdev_to_qcode[]; =20 extern const guint qemu_input_map_xorgkbd_to_qcode_len; extern const guint16 qemu_input_map_xorgkbd_to_qcode[]; =20 +extern const guint qemu_input_map_xorgkbd_to_linux_len; +extern const guint16 qemu_input_map_xorgkbd_to_linux[]; + extern const guint qemu_input_map_xorgxquartz_to_qcode_len; extern const guint16 qemu_input_map_xorgxquartz_to_qcode[]; =20 +extern const guint qemu_input_map_xorgxquartz_to_linux_len; +extern const guint16 qemu_input_map_xorgxquartz_to_linux[]; + extern const guint qemu_input_map_xorgxwin_to_qcode_len; extern const guint16 qemu_input_map_xorgxwin_to_qcode[]; =20 +extern const guint qemu_input_map_xorgxwin_to_linux_len; +extern const guint16 qemu_input_map_xorgxwin_to_linux[]; + extern const guint qemu_input_map_osx_to_qcode_len; extern const guint16 qemu_input_map_osx_to_qcode[]; =20 +extern const guint qemu_input_map_osx_to_linux_len; +extern const guint16 qemu_input_map_osx_to_linux[]; + #endif /* INPUT_H */ diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index f436bd13d91..c8985a58f99 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -1069,7 +1069,7 @@ static void musicpal_key_event(DeviceState *dev, Qemu= Console *src, QemuInputEvent *evt) { musicpal_key_state *s =3D MUSICPAL_KEY(dev); - int qcode =3D evt->key.key; + int qcode =3D qemu_input_linux_to_qcode(evt->key.key); uint32_t event =3D 0; int i; =20 diff --git a/hw/char/escc.c b/hw/char/escc.c index 3ad803537e5..39483ca03bf 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -800,7 +800,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuC= onsole *src, int qcode, keycode; =20 assert(evt->type =3D=3D INPUT_EVENT_KIND_KEY); - qcode =3D evt->key.key; + qcode =3D qemu_input_linux_to_qcode(evt->key.key); trace_escc_sunkbd_event_in(qcode, QKeyCode_str(qcode), evt->key.down); =20 diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index 176796cbf62..218f37f0740 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -203,7 +203,7 @@ static void xenfb_key_event(DeviceState *dev, QemuConso= le *src, QemuInputEvent *evt) { struct XenInput *xenfb =3D (struct XenInput *)dev; - int qcode =3D evt->key.key; + int qcode =3D qemu_input_linux_to_qcode(evt->key.key); int lnx; =20 if (qcode < qemu_input_map_qcode_to_linux_len) { diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c index db3c7777500..060481d0db6 100644 --- a/hw/input/adb-kbd.c +++ b/hw/input/adb-kbd.c @@ -311,7 +311,7 @@ static void adb_keyboard_event(DeviceState *dev, QemuCo= nsole *src, KBDState *s =3D (KBDState *)dev; int qcode, keycode; =20 - qcode =3D evt->key.key; + qcode =3D qemu_input_linux_to_qcode(evt->key.key); if (qcode >=3D ARRAY_SIZE(qcode_to_adb_keycode)) { return; } diff --git a/hw/input/hid.c b/hw/input/hid.c index 31f6331c7d7..013840562f6 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -224,10 +224,11 @@ static void hid_keyboard_event(DeviceState *dev, Qemu= Console *src, QemuInputEvent *evt) { HIDState *hs =3D (HIDState *)dev; + int qcode =3D qemu_input_linux_to_qcode(evt->key.key); int scancodes[3], i, count; int slot; =20 - count =3D qemu_input_qcode_to_scancode(evt->key.key, evt->key.down, + count =3D qemu_input_qcode_to_scancode(qcode, evt->key.down, scancodes); if (hs->n + count > QUEUE_LENGTH) { trace_hid_kbd_queue_full(); diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 9090a0427bd..93c3c737205 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -324,7 +324,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, =20 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); assert(evt->type =3D=3D INPUT_EVENT_KIND_KEY); - qcode =3D evt->key.key; + qcode =3D qemu_input_linux_to_qcode(evt->key.key); =20 mod =3D ps2_modifier_bit(qcode); trace_ps2_keyboard_event(s, qcode, evt->key.down, mod, diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index 6f42c46ddad..25769fc2616 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -19,7 +19,7 @@ static void stellaris_gamepad_event(DeviceState *dev, Qem= uConsole *src, QemuInputEvent *evt) { StellarisGamepad *s =3D STELLARIS_GAMEPAD(dev); - int qcode =3D evt->key.key; + int qcode =3D qemu_input_linux_to_qcode(evt->key.key); int i; =20 for (i =3D 0; i < s->num_buttons; i++) { diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index d48be1ea211..1d2e922567a 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -87,7 +87,7 @@ static void virtio_input_handle_event(DeviceState *dev, Q= emuConsole *src, =20 switch (evt->type) { case INPUT_EVENT_KIND_KEY: - qcode =3D evt->key.key; + qcode =3D qemu_input_linux_to_qcode(evt->key.key); if (qcode < qemu_input_map_qcode_to_linux_len && qemu_input_map_qcode_to_linux[qcode]) { event.type =3D cpu_to_le16(EV_KEY); diff --git a/hw/m68k/next-kbd.c b/hw/m68k/next-kbd.c index 39f223d0211..7efbd806b7c 100644 --- a/hw/m68k/next-kbd.c +++ b/hw/m68k/next-kbd.c @@ -248,7 +248,7 @@ static void nextkbd_event(DeviceState *dev, QemuConsole= *src, NextKBDState *s =3D NEXTKBD(dev); int qcode, keycode; =20 - qcode =3D evt->key.key; + qcode =3D qemu_input_linux_to_qcode(evt->key.key); if (qcode >=3D ARRAY_SIZE(qcode_to_nextkbd_keycode)) { return; } diff --git a/replay/replay-input.c b/replay/replay-input.c index f1ee678ef72..acf0993c728 100644 --- a/replay/replay-input.c +++ b/replay/replay-input.c @@ -24,7 +24,7 @@ void replay_save_input_event(QemuInputEvent *evt) switch (evt->type) { case INPUT_EVENT_KIND_KEY: replay_put_dword(KEY_VALUE_KIND_QCODE); - replay_put_dword(evt->key.key); + replay_put_dword(qemu_input_linux_to_qcode(evt->key.key)); replay_put_byte(evt->key.down); break; case INPUT_EVENT_KIND_BTN: @@ -55,20 +55,25 @@ void replay_save_input_event(QemuInputEvent *evt) QemuInputEvent *replay_read_input_event(void) { QemuInputEvent *evt =3D g_new(QemuInputEvent, 1); + int qcode; =20 evt->type =3D replay_get_dword(); switch (evt->type) { case INPUT_EVENT_KIND_KEY: switch (replay_get_dword()) { case KEY_VALUE_KIND_NUMBER: - evt->key.key =3D qemu_input_key_number_to_qcode(replay_get_qwo= rd()); + qcode =3D qemu_input_key_number_to_qcode(replay_get_qword()); evt->key.down =3D replay_get_byte(); break; case KEY_VALUE_KIND_QCODE: - evt->key.key =3D (QKeyCode)replay_get_dword(); + qcode =3D (QKeyCode)replay_get_dword(); evt->key.down =3D replay_get_byte(); break; + default: + g_assert_not_reached(); } + evt->key.key =3D qcode < qemu_input_map_qcode_to_linux_len ? + qemu_input_map_qcode_to_linux[qcode] : 0; break; case INPUT_EVENT_KIND_BTN: evt->btn.button =3D (InputButton)replay_get_dword(); diff --git a/tools/qemu-vnc/input.c b/tools/qemu-vnc/input.c index 2313b0a7c77..90e2e79d1ea 100644 --- a/tools/qemu-vnc/input.c +++ b/tools/qemu-vnc/input.c @@ -82,11 +82,18 @@ void qemu_input_event_send_key_delay(uint32_t delay_ms) } =20 void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool do= wn) +{ + unsigned int lnx =3D qemu_input_map_qcode_to_linux[q]; + qemu_input_event_send_key_linux(src, lnx, down); +} + +void qemu_input_event_send_key_linux(QemuConsole *src, unsigned int lnx, + bool down) { QemuDBusDisplay1Keyboard *kbd; guint qnum; =20 - trace_qemu_vnc_key_event(q, down); + trace_qemu_vnc_key_event(lnx, down); =20 if (!src) { return; @@ -96,10 +103,10 @@ void qemu_input_event_send_key_qcode(QemuConsole *src,= QKeyCode q, bool down) return; } =20 - if (q >=3D qemu_input_map_qcode_to_qnum_len) { + if (lnx >=3D qemu_input_map_linux_to_qnum_len) { return; } - qnum =3D qemu_input_map_qcode_to_qnum[q]; + qnum =3D qemu_input_map_linux_to_qnum[lnx]; =20 if (down) { qemu_dbus_display1_keyboard_call_press( diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 2f6d431c824..2b77ef09fd6 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -5,22 +5,36 @@ #include "standard-headers/linux/input.h" =20 #include "ui/input-keymap-atset1-to-qcode.c.inc" +#include "ui/input-keymap-atset1-to-linux.c.inc" #include "ui/input-keymap-linux-to-qcode.c.inc" #include "ui/input-keymap-qcode-to-atset1.c.inc" +#include "ui/input-keymap-linux-to-atset1.c.inc" #include "ui/input-keymap-qcode-to-atset2.c.inc" +#include "ui/input-keymap-linux-to-atset2.c.inc" #include "ui/input-keymap-qcode-to-atset3.c.inc" +#include "ui/input-keymap-linux-to-atset3.c.inc" #include "ui/input-keymap-qcode-to-linux.c.inc" #include "ui/input-keymap-qcode-to-qnum.c.inc" +#include "ui/input-keymap-linux-to-qnum.c.inc" #include "ui/input-keymap-qcode-to-sun.c.inc" +#include "ui/input-keymap-linux-to-sun.c.inc" #include "ui/input-keymap-qnum-to-qcode.c.inc" +#include "ui/input-keymap-qnum-to-linux.c.inc" #include "ui/input-keymap-usb-to-qcode.c.inc" +#include "ui/input-keymap-usb-to-linux.c.inc" #include "ui/input-keymap-win32-to-qcode.c.inc" +#include "ui/input-keymap-win32-to-linux.c.inc" #include "ui/input-keymap-x11-to-qcode.c.inc" +#include "ui/input-keymap-x11-to-linux.c.inc" #include "ui/input-keymap-xorgevdev-to-qcode.c.inc" #include "ui/input-keymap-xorgkbd-to-qcode.c.inc" +#include "ui/input-keymap-xorgkbd-to-linux.c.inc" #include "ui/input-keymap-xorgxquartz-to-qcode.c.inc" +#include "ui/input-keymap-xorgxquartz-to-linux.c.inc" #include "ui/input-keymap-xorgxwin-to-qcode.c.inc" +#include "ui/input-keymap-xorgxwin-to-linux.c.inc" #include "ui/input-keymap-osx-to-qcode.c.inc" +#include "ui/input-keymap-osx-to-linux.c.inc" =20 int qemu_input_linux_to_qcode(unsigned int lnx) { @@ -45,29 +59,49 @@ int qemu_input_key_value_to_number(const KeyValue *valu= e) =20 int qemu_input_key_number_to_qcode(unsigned int nr) { - if (nr >=3D qemu_input_map_qnum_to_qcode_len) { - return 0; + return qemu_input_linux_to_qcode(qemu_input_key_number_to_linux(nr)); +} + +unsigned int qemu_input_key_number_to_linux(unsigned int nr) +{ + if (nr >=3D qemu_input_map_qnum_to_linux_len) { + return KEY_RESERVED; } - return qemu_input_map_qnum_to_qcode[nr]; + return qemu_input_map_qnum_to_linux[nr]; } =20 int qemu_input_key_value_to_qcode(const KeyValue *value) { - if (value->type =3D=3D KEY_VALUE_KIND_QCODE) { - return value->u.qcode.data; - } else { - assert(value->type =3D=3D KEY_VALUE_KIND_NUMBER); - return qemu_input_key_number_to_qcode(value->u.number.data); + return qemu_input_linux_to_qcode(qemu_input_key_value_to_linux(value)); +} + +unsigned int qemu_input_key_value_to_linux(const KeyValue *value) +{ + switch (value->type) { + case KEY_VALUE_KIND_NUMBER: + return qemu_input_key_number_to_linux(value->u.number.data); + + case KEY_VALUE_KIND_QCODE: + return qemu_input_map_qcode_to_linux[value->u.qcode.data]; + + default: + g_assert_not_reached(); } } =20 int qemu_input_qcode_to_scancode(QKeyCode qcode, bool down, int *codes) { - int keycode =3D qcode < qemu_input_map_qcode_to_qnum_len ? - qemu_input_map_qcode_to_qnum[qcode] : 0; + return qemu_input_linux_to_scancode(qemu_input_map_qcode_to_linux[qcod= e], + down, codes); +} + +int qemu_input_linux_to_scancode(unsigned int lnx, bool down, int *codes) +{ + int keycode =3D lnx < qemu_input_map_linux_to_qnum_len ? + qemu_input_map_linux_to_qnum[lnx] : 0; int count =3D 0; =20 - if (qcode =3D=3D Q_KEY_CODE_PAUSE) { + if (lnx =3D=3D KEY_PAUSE) { /* specific case */ int v =3D down ? 0 : 0x80; codes[count++] =3D 0xe1; diff --git a/ui/input.c b/ui/input.c index 9232dd7fdae..aeb7bf35e19 100644 --- a/ui/input.c +++ b/ui/input.c @@ -165,25 +165,10 @@ void qmp_input_send_event(const char *device, evt.type =3D qapi->type; =20 switch (qapi->type) { - case INPUT_EVENT_KIND_KEY: { - KeyValue *key =3D qapi->u.key.data->key; - QKeyCode code; - - switch (key->type) { - case KEY_VALUE_KIND_NUMBER: - code =3D qemu_input_key_number_to_qcode(key->u.number.data= ); - break; - case KEY_VALUE_KIND_QCODE: - code =3D key->u.qcode.data; - break; - default: - g_assert_not_reached(); - } - - evt.key.key =3D code; + case INPUT_EVENT_KIND_KEY: + evt.key.key =3D qemu_input_key_value_to_linux(qapi->u.key.data= ->key); evt.key.down =3D qapi->u.key.data->down; break; - } =20 case INPUT_EVENT_KIND_BTN: evt.btn =3D *qapi->u.btn.data; @@ -226,7 +211,7 @@ static void qemu_input_event_trace(QemuConsole *src, Qe= muInputEvent *evt) switch (evt->type) { case INPUT_EVENT_KIND_KEY: key =3D &evt->key; - name =3D QKeyCode_str(key->key); + name =3D QKeyCode_str(qemu_input_linux_to_qcode(key->key)); trace_input_event_key_qcode(idx, name, key->down); break; case INPUT_EVENT_KIND_BTN: @@ -343,19 +328,6 @@ void qemu_input_event_send_impl(QemuConsole *src, Qemu= InputEvent *evt) =20 void qemu_input_event_send(QemuConsole *src, QemuInputEvent *evt) { - /* - * 'sysrq' was mistakenly added to hack around the fact that - * the ps2 driver was not generating correct scancodes sequences - * when 'alt+print' was pressed. This flaw is now fixed and the - * 'sysrq' key serves no further purpose. We normalize it to - * 'print', so that downstream receivers of the event don't - * need to deal with this mistake - */ - if (evt->type =3D=3D INPUT_EVENT_KIND_KEY && - evt->key.key =3D=3D Q_KEY_CODE_SYSRQ) { - evt->key.key =3D Q_KEY_CODE_PRINT; - } - if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { return; } @@ -390,17 +362,24 @@ void qemu_input_event_sync(void) } =20 void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) +{ + unsigned int lnx =3D qemu_input_key_value_to_linux(key); + + g_free(key); + qemu_input_event_send_key_linux(src, lnx, down); +} + +void qemu_input_event_send_key_linux(QemuConsole *src, unsigned int lnx, + bool down) { QemuInputEvent evt =3D { .type =3D INPUT_EVENT_KIND_KEY, .key =3D { - .key =3D qemu_input_key_value_to_qcode(key), + .key =3D lnx, .down =3D down, }, }; =20 - g_free(key); - if (QTAILQ_EMPTY(&kbd_queue)) { qemu_input_event_send(src, &evt); qemu_input_event_sync(); @@ -412,8 +391,8 @@ void qemu_input_event_send_key(QemuConsole *src, KeyVal= ue *key, bool down) =20 void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) { - QKeyCode code =3D qemu_input_key_number_to_qcode(num); - qemu_input_event_send_key_qcode(src, code, down); + unsigned int lnx =3D qemu_input_key_number_to_linux(num); + qemu_input_event_send_key_linux(src, lnx, down); } =20 void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool do= wn) diff --git a/tools/qemu-vnc/trace-events b/tools/qemu-vnc/trace-events index e3b550de10e..570062984a4 100644 --- a/tools/qemu-vnc/trace-events +++ b/tools/qemu-vnc/trace-events @@ -12,7 +12,7 @@ qemu_vnc_cursor_define(int width, int height, int hot_x, = int hot_y) "w=3D%d h=3D%d h qemu_vnc_input_abs(uint32_t x, uint32_t y) "x=3D%u y=3D%u" qemu_vnc_input_btn(int button, bool press) "button=3D%d press=3D%d" qemu_vnc_input_rel(int dx, int dy) "dx=3D%d dy=3D%d" -qemu_vnc_key_event(int qcode, bool down) "qcode=3D%d down=3D%d" +qemu_vnc_key_event(unsigned int lnx, bool down) "lnx=3D%u down=3D%d" qemu_vnc_owner_appeared(const char *name) "peer=3D%s" qemu_vnc_owner_vanished(const char *name) "peer=3D%s" qemu_vnc_scanout(uint32_t width, uint32_t height, uint32_t stride, uint32_= t format) "w=3D%u h=3D%u stride=3D%u fmt=3D0x%x" diff --git a/ui/meson.build b/ui/meson.build index 1b8f71796e4..1504e27248f 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -1,21 +1,35 @@ keymaps =3D [ ['atset1', 'qcode'], + ['atset1', 'linux'], ['linux', 'qcode'], ['qcode', 'atset1'], + ['linux', 'atset1'], ['qcode', 'atset2'], + ['linux', 'atset2'], ['qcode', 'atset3'], + ['linux', 'atset3'], ['qcode', 'linux'], ['qcode', 'qnum'], + ['linux', 'qnum'], ['qcode', 'sun'], + ['linux', 'sun'], ['qnum', 'qcode'], + ['qnum', 'linux'], ['usb', 'qcode'], + ['usb', 'linux'], ['win32', 'qcode'], + ['win32', 'linux'], ['x11', 'qcode'], + ['x11', 'linux'], ['xorgevdev', 'qcode'], ['xorgkbd', 'qcode'], + ['xorgkbd', 'linux'], ['xorgxquartz', 'qcode'], + ['xorgxquartz', 'linux'], ['xorgxwin', 'qcode'], + ['xorgxwin', 'linux'], ['osx', 'qcode'], + ['osx', 'linux'], ] =20 if have_system or xkbcommon.found() --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364798; cv=none; d=zohomail.com; s=zohoarc; b=E5EKkM7tHZjnLxrRFLuJHD76esDjsPKY50wYfQ3WiCpsQ6fE8VPSXHQMtzRtnW3ne+pwOnp0ODXSdvAMSUDOTHVTJbve76m/zLuj82ka0qhNSQ9+wYNyWYcAmW+CmqFpAB1mjrr954JfzLndST/bgqCE4+V/g9w0TU+sq6gLRR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364798; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vY4SDdDDaGor90cMSH3cjTrr2RbfDCsfSEP6irKOaSA=; b=AESy3zAZXMwODyZImmXak4yGBcj8hfxyjoshivUFCOmu7+tFMYrFKzmg99656hSoPJUKXcyyOukf13ES48YvgrsKdHcBJq1Ry445EDUcVW+hQS6P7w2uUCeGIVg4dntd0gfH4BYLvPXPC6Wgb0ZgosjkOeEDOXL9J/Uh6kZU8Vg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177936479891280.5433278537754; Thu, 21 May 2026 04:59:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ23T-0007IC-SB; Thu, 21 May 2026 07:59:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23A-0006xo-Ry for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ238-0004FF-AL for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:51 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-7QBr29WGOrm5te-IXyYTxg-1; Thu, 21 May 2026 07:58:44 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0920818002E0; Thu, 21 May 2026 11:58:43 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B3ED519560AB; Thu, 21 May 2026 11:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vY4SDdDDaGor90cMSH3cjTrr2RbfDCsfSEP6irKOaSA=; b=eVPY/w6JUGgTqyq19VI33/dGiKLWbSjODZnvM0V8NyYhW/p2J/2C+jLgcuf6eTE8cFFcOn Wg2ARpcNkM83LJUk0KdXq3zHbAyEJvdU+3ar/kORYdlXCOsaswwk8sCY3qU7a/vpGnTBJV qOqvUUPymvp31sDKgS5+tNO555CF1CA= X-MC-Unique: 7QBr29WGOrm5te-IXyYTxg-1 X-Mimecast-MFC-AGG-ID: 7QBr29WGOrm5te-IXyYTxg_1779364723 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 13/38] ui/input: Prohibit sending KEY_RESERVED Date: Thu, 21 May 2026 15:56:50 +0400 Message-ID: <20260521115717.1701482-14-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364801165158500 From: Akihiko Odaki xenfb and virtio-input no longer need key mapping because they operate on Linux key codes, but removing the key mapping code loses the ability to filter out KEY_RESERVED. Drop KEY_RESERVED at the common input event entry point so the logic is shared by both devices and no downstream input handler receives KEY_RESERVED accidentally. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-5-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/input.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/input.c b/ui/input.c index aeb7bf35e19..68c7ac6f1cc 100644 --- a/ui/input.c +++ b/ui/input.c @@ -328,6 +328,10 @@ void qemu_input_event_send_impl(QemuConsole *src, Qemu= InputEvent *evt) =20 void qemu_input_event_send(QemuConsole *src, QemuInputEvent *evt) { + if (evt->type =3D=3D INPUT_EVENT_KIND_KEY && !evt->key.key) { + return; + } + if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { return; } --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364886; cv=none; d=zohomail.com; s=zohoarc; b=B5fY/TCf7k/DxJUd/vrTOLKogvyuPwggh4qwyqqUa+PCVn39nM4IIa6pRxLzdvg8nSmTQitWhylAeOEa58UCp5/uk5I0szZHdChnSecTf5xVaplo4DKwoZ31WkdvJgPpUQ6Gz3UW6Kciw3tfXf2SRJErSXQ51dG03AZfYSRmTz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364886; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=y0KRCbh+DuowVvjWgeRAQvhYdmF0tf77Yft4EyxaRRo=; b=csA/kwlgz3fOuRs3yANP4BhHxykhRIVv24//+/hamudpHOFwS8lIZGFEUYIemexrYVeG1/lQMf1e50KPnF5+1ipUY/AyPX0MreLXazEBI8GEH4omtNOKjtirgvKc/mA1cRULowaVW/1mx/eep1mROkZDgcgfCjGAe6IT5W7UPYo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364886249730.1162891929758; Thu, 21 May 2026 05:01:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ23S-0007FF-Qk; Thu, 21 May 2026 07:59:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23D-0006y2-SV for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23C-0004FZ-2D for qemu-devel@nongnu.org; Thu, 21 May 2026 07:58:55 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-oOXzZddZMqir6NMuLDdmSw-1; Thu, 21 May 2026 07:58:49 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8CB6719560AE; Thu, 21 May 2026 11:58:48 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 40EEA1689; Thu, 21 May 2026 11:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y0KRCbh+DuowVvjWgeRAQvhYdmF0tf77Yft4EyxaRRo=; b=dGLLpxTSM83BLnzewc3887O18fm4qu4Hzt745yv1IPX62kKjLc+W9PqG8h7+4wcpy/4D1b dmrzoufEPsUdKqX5219vpqc9/whZMyDn5BAJ698LE8IdH9+XZttN2OnmSxFxH31QC2q9xt evh2gEpwa8974jW2GfcVgfcklmIB8ig= X-MC-Unique: oOXzZddZMqir6NMuLDdmSw-1 X-Mimecast-MFC-AGG-ID: oOXzZddZMqir6NMuLDdmSw_1779364728 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 14/38] ui/console: Add qemu_text_console_put_linux() Date: Thu, 21 May 2026 15:56:51 +0400 Message-ID: <20260521115717.1701482-15-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364888016154100 From: Akihiko Odaki Add a text console helper that accepts Linux input key codes and use it as the common implementation for qemu_text_console_put_qcode(). This lets callers that already use Linux key codes avoid converting them back to QKeyCode. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-6-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- include/ui/console.h | 2 ++ ui/console.c | 66 +++++++++++++++++++++++++++++--------------- 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index cfa940d4c66..691040f5948 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -109,6 +109,8 @@ bool qemu_mouse_set(int index, Error **errp); =20 void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym); bool qemu_text_console_put_qcode(QemuTextConsole *s, int qcode, bool ctrl); +bool qemu_text_console_put_linux(QemuTextConsole *s, unsigned int lnx, + bool ctrl); void qemu_text_console_put_string(QemuTextConsole *s, const char *str, int= len); =20 /* consoles */ diff --git a/ui/console.c b/ui/console.c index eaa41086743..2dcb4660fbf 100644 --- a/ui/console.c +++ b/ui/console.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/console.h" #include "ui/vgafont.h" #include "hw/core/qdev.h" @@ -302,36 +303,57 @@ void qemu_text_console_put_keysym(QemuTextConsole *s,= int keysym) qemu_text_console_handle_keysym(s, keysym); } =20 -static const int qcode_to_keysym[Q_KEY_CODE__MAX] =3D { - [Q_KEY_CODE_UP] =3D QEMU_KEY_UP, - [Q_KEY_CODE_DOWN] =3D QEMU_KEY_DOWN, - [Q_KEY_CODE_RIGHT] =3D QEMU_KEY_RIGHT, - [Q_KEY_CODE_LEFT] =3D QEMU_KEY_LEFT, - [Q_KEY_CODE_HOME] =3D QEMU_KEY_HOME, - [Q_KEY_CODE_END] =3D QEMU_KEY_END, - [Q_KEY_CODE_PGUP] =3D QEMU_KEY_PAGEUP, - [Q_KEY_CODE_PGDN] =3D QEMU_KEY_PAGEDOWN, - [Q_KEY_CODE_DELETE] =3D QEMU_KEY_DELETE, - [Q_KEY_CODE_TAB] =3D QEMU_KEY_TAB, - [Q_KEY_CODE_BACKSPACE] =3D QEMU_KEY_BACKSPACE, +static const int linux_to_keysym[] =3D { + [KEY_UP] =3D QEMU_KEY_UP, + [KEY_DOWN] =3D QEMU_KEY_DOWN, + [KEY_RIGHT] =3D QEMU_KEY_RIGHT, + [KEY_LEFT] =3D QEMU_KEY_LEFT, + [KEY_HOME] =3D QEMU_KEY_HOME, + [KEY_END] =3D QEMU_KEY_END, + [KEY_PAGEUP] =3D QEMU_KEY_PAGEUP, + [KEY_PAGEDOWN] =3D QEMU_KEY_PAGEDOWN, + [KEY_DELETE] =3D QEMU_KEY_DELETE, + [KEY_TAB] =3D QEMU_KEY_TAB, + [KEY_BACKSPACE] =3D QEMU_KEY_BACKSPACE, }; =20 -static const int ctrl_qcode_to_keysym[Q_KEY_CODE__MAX] =3D { - [Q_KEY_CODE_UP] =3D QEMU_KEY_CTRL_UP, - [Q_KEY_CODE_DOWN] =3D QEMU_KEY_CTRL_DOWN, - [Q_KEY_CODE_RIGHT] =3D QEMU_KEY_CTRL_RIGHT, - [Q_KEY_CODE_LEFT] =3D QEMU_KEY_CTRL_LEFT, - [Q_KEY_CODE_HOME] =3D QEMU_KEY_CTRL_HOME, - [Q_KEY_CODE_END] =3D QEMU_KEY_CTRL_END, - [Q_KEY_CODE_PGUP] =3D QEMU_KEY_CTRL_PAGEUP, - [Q_KEY_CODE_PGDN] =3D QEMU_KEY_CTRL_PAGEDOWN, +static const int ctrl_linux_to_keysym[] =3D { + [KEY_UP] =3D QEMU_KEY_CTRL_UP, + [KEY_DOWN] =3D QEMU_KEY_CTRL_DOWN, + [KEY_RIGHT] =3D QEMU_KEY_CTRL_RIGHT, + [KEY_LEFT] =3D QEMU_KEY_CTRL_LEFT, + [KEY_HOME] =3D QEMU_KEY_CTRL_HOME, + [KEY_END] =3D QEMU_KEY_CTRL_END, + [KEY_PAGEUP] =3D QEMU_KEY_CTRL_PAGEUP, + [KEY_PAGEDOWN] =3D QEMU_KEY_CTRL_PAGEDOWN, }; =20 bool qemu_text_console_put_qcode(QemuTextConsole *s, int qcode, bool ctrl) { + unsigned int lnx =3D qemu_input_map_qcode_to_linux[qcode]; + return qemu_text_console_put_linux(s, lnx, ctrl); +} + +bool qemu_text_console_put_linux(QemuTextConsole *s, unsigned int lnx, + bool ctrl) +{ + size_t maplen; + const int *map; int keysym; =20 - keysym =3D ctrl ? ctrl_qcode_to_keysym[qcode] : qcode_to_keysym[qcode]; + if (ctrl) { + maplen =3D ARRAY_SIZE(ctrl_linux_to_keysym); + map =3D ctrl_linux_to_keysym; + } else { + maplen =3D ARRAY_SIZE(linux_to_keysym); + map =3D linux_to_keysym; + } + + if (lnx >=3D maplen) { + return false; + } + + keysym =3D map[lnx]; if (keysym =3D=3D 0) { return false; } --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364815; cv=none; d=zohomail.com; s=zohoarc; b=EE1OeM7GIBnqrCLwkyawpkmMgXImwr1oe8bgOXAG6AIcS95FsiEIQy6arYjaD2759Sn0w0Tlzuo48089xa3OSYl2oRRpC8OBcPIZYK9nautok1DiPAz2bzm0pVaUV53iEUfShgDSzOdq/HpQBn7RXMz8bWJoriH3ShCV9U8FfSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364815; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XUKImSv9PKsnQuxzjs0V+OefpWbsMKdQ4Q/auOwOwFY=; b=hGqs2NWZZdM8+tcMLvzulioqeAOwcjMH6m5GvqVi77RE0E2jm0vJy2xbmqL25epMHRQvvfp1/vVNz8nVYIC+bPUPCeQxWIh12khCvlJwaQ+dQwDmByfOuN26jXTFugU95p0Bmut5g3GA/eWzkhrx4JE6olx6c+PEUTG4hJIKghI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364815853137.78781745241463; Thu, 21 May 2026 05:00:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ23Y-0007Wc-Ow; Thu, 21 May 2026 07:59:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23K-000712-Vr for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23I-0004Fx-NY for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:02 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-M_EDVNgmO0a12DRmzMltxQ-1; Thu, 21 May 2026 07:58:55 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5B3C019560BD; Thu, 21 May 2026 11:58:54 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ACE151800347; Thu, 21 May 2026 11:58:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XUKImSv9PKsnQuxzjs0V+OefpWbsMKdQ4Q/auOwOwFY=; b=L9TeEAes+YrxnTIXDeP6zFM+rdH1xEjG/2uWNK/zxzyOyIHBm+RSpn+nR4zx45XQRCoUN7 Ebpc366GAWfljhl6S8YWoh8daWwL6R95IBSlxnXaxULfJH2+pdIR6OXD0j+Wukx8cRjqGK AgtPV743TkPFSGJ9oD/oNDlqo8WQ0KM= X-MC-Unique: M_EDVNgmO0a12DRmzMltxQ-1 X-Mimecast-MFC-AGG-ID: M_EDVNgmO0a12DRmzMltxQ_1779364734 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 15/38] ui/kbd-state: Use Linux key codes Date: Thu, 21 May 2026 15:56:52 +0400 Message-ID: <20260521115717.1701482-16-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364818664154100 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-7-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- include/ui/kbd-state.h | 12 ++++---- ui/dbus-console.c | 4 +-- ui/gtk.c | 7 +++-- ui/kbd-state.c | 61 +++++++++++++++++++++----------------- ui/keymaps.c | 3 +- ui/sdl2-input.c | 3 +- ui/vnc.c | 10 +++++-- ui/cocoa.m | 67 +++++++++++++++++++++++++++++++----------- 8 files changed, 108 insertions(+), 59 deletions(-) diff --git a/include/ui/kbd-state.h b/include/ui/kbd-state.h index 1f37b932eb6..a70d5b5746b 100644 --- a/include/ui/kbd-state.h +++ b/include/ui/kbd-state.h @@ -52,11 +52,13 @@ void qkbd_state_free(QKbdState *kbd); * This function takes care to not send suspious events (keyup event * for a key not pressed for example). * + * This function drops events with key codes outside the defined range. + * * @kbd: state tracker state. - * @qcode: the key pressed or released. + * @lnx: the key pressed or released. * @down: true for key down events, false otherwise. */ -void qkbd_state_key_event(QKbdState *kbd, QKeyCode qcode, bool down); +void qkbd_state_key_event(QKbdState *kbd, unsigned int lnx, bool down); =20 /** * qkbd_state_set_delay: set key press delay. @@ -72,12 +74,12 @@ void qkbd_state_set_delay(QKbdState *kbd, int delay_ms); /** * qkbd_state_key_get: get key state. * - * Returns true when the key is down. + * Returns true when the key code is in the defined range and the key is d= own. * * @kbd: state tracker state. - * @qcode: the key to query. + * @lnx: the key to query. */ -bool qkbd_state_key_get(QKbdState *kbd, QKeyCode qcode); +bool qkbd_state_key_get(QKbdState *kbd, unsigned int lnx); =20 /** * qkbd_state_modifier_get: get modifier state. diff --git a/ui/dbus-console.c b/ui/dbus-console.c index b8e5c57b148..24f4542f312 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -343,7 +343,7 @@ dbus_kbd_press(DBusDisplayConsole *ddc, =20 trace_dbus_kbd_press(arg_keycode); =20 - qkbd_state_key_event(ddc->kbd, qcode, true); + qkbd_state_key_event(ddc->kbd, qemu_input_map_qcode_to_linux[qcode], t= rue); =20 qemu_dbus_display1_keyboard_complete_press(ddc->iface_kbd, invocation); =20 @@ -359,7 +359,7 @@ dbus_kbd_release(DBusDisplayConsole *ddc, =20 trace_dbus_kbd_release(arg_keycode); =20 - qkbd_state_key_event(ddc->kbd, qcode, false); + qkbd_state_key_event(ddc->kbd, qemu_input_map_qcode_to_linux[qcode], f= alse); =20 qemu_dbus_display1_keyboard_complete_release(ddc->iface_kbd, invocatio= n); =20 diff --git a/ui/gtk.c b/ui/gtk.c index 2c61b601f78..757ee80fa6a 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1343,7 +1343,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEv= entKey *key, void *opaque) || key->hardware_keycode =3D=3D VK_PAUSE #endif ) { - qkbd_state_key_event(vc->gfx.kbd, Q_KEY_CODE_PAUSE, + qkbd_state_key_event(vc->gfx.kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_PAUS= E], key->type =3D=3D GDK_KEY_PRESS); return TRUE; } @@ -1351,10 +1352,10 @@ static gboolean gd_key_event(GtkWidget *widget, Gdk= EventKey *key, void *opaque) keycode =3D gd_get_keycode(key); qcode =3D gd_map_keycode(keycode); =20 - trace_gd_key_event(vc->label, keycode, qcode, + trace_gd_key_event(vc->label, keycode, qemu_input_map_qcode_to_linux[q= code], (key->type =3D=3D GDK_KEY_PRESS) ? "down" : "up"); =20 - qkbd_state_key_event(vc->gfx.kbd, qcode, + qkbd_state_key_event(vc->gfx.kbd, qemu_input_map_qcode_to_linux[qcode], key->type =3D=3D GDK_KEY_PRESS); =20 return TRUE; diff --git a/ui/kbd-state.c b/ui/kbd-state.c index 52ed28b8a89..c407327da59 100644 --- a/ui/kbd-state.c +++ b/ui/kbd-state.c @@ -5,6 +5,7 @@ */ #include "qemu/osdep.h" #include "qemu/bitmap.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/console.h" #include "ui/input.h" #include "ui/kbd-state.h" @@ -12,15 +13,15 @@ struct QKbdState { QemuConsole *con; int key_delay_ms; - DECLARE_BITMAP(keys, Q_KEY_CODE__MAX); + DECLARE_BITMAP(keys, KEY_CNT); DECLARE_BITMAP(mods, QKBD_MOD__MAX); }; =20 static void qkbd_state_modifier_update(QKbdState *kbd, - QKeyCode qcode1, QKeyCode qcode2, + unsigned int lnx1, unsigned int lnx= 2, QKbdModifier mod) { - if (test_bit(qcode1, kbd->keys) || test_bit(qcode2, kbd->keys)) { + if (test_bit(lnx1, kbd->keys) || test_bit(lnx2, kbd->keys)) { set_bit(mod, kbd->mods); } else { clear_bit(mod, kbd->mods); @@ -32,14 +33,20 @@ bool qkbd_state_modifier_get(QKbdState *kbd, QKbdModifi= er mod) return test_bit(mod, kbd->mods); } =20 -bool qkbd_state_key_get(QKbdState *kbd, QKeyCode qcode) +bool qkbd_state_key_get(QKbdState *kbd, unsigned int lnx) { - return test_bit(qcode, kbd->keys); + return lnx < KEY_CNT && test_bit(lnx, kbd->keys); } =20 -void qkbd_state_key_event(QKbdState *kbd, QKeyCode qcode, bool down) +void qkbd_state_key_event(QKbdState *kbd, unsigned int lnx, bool down) { - bool state =3D test_bit(qcode, kbd->keys); + bool state; + + if (lnx >=3D KEY_CNT) { + return; + } + + state =3D test_bit(lnx, kbd->keys); =20 if (down =3D=3D false /* got key-up event */ && state =3D=3D false /* key is not pressed */) { @@ -59,35 +66,35 @@ void qkbd_state_key_event(QKbdState *kbd, QKeyCode qcod= e, bool down) =20 /* update key and modifier state */ if (down) { - set_bit(qcode, kbd->keys); + set_bit(lnx, kbd->keys); } else { - clear_bit(qcode, kbd->keys); + clear_bit(lnx, kbd->keys); } - switch (qcode) { - case Q_KEY_CODE_SHIFT: - case Q_KEY_CODE_SHIFT_R: - qkbd_state_modifier_update(kbd, Q_KEY_CODE_SHIFT, Q_KEY_CODE_SHIFT= _R, + switch (lnx) { + case KEY_LEFTSHIFT: + case KEY_RIGHTSHIFT: + qkbd_state_modifier_update(kbd, KEY_LEFTSHIFT, KEY_RIGHTSHIFT, QKBD_MOD_SHIFT); break; - case Q_KEY_CODE_CTRL: - case Q_KEY_CODE_CTRL_R: - qkbd_state_modifier_update(kbd, Q_KEY_CODE_CTRL, Q_KEY_CODE_CTRL_R, + case KEY_LEFTCTRL: + case KEY_RIGHTCTRL: + qkbd_state_modifier_update(kbd, KEY_LEFTCTRL, KEY_RIGHTCTRL, QKBD_MOD_CTRL); break; - case Q_KEY_CODE_ALT: - qkbd_state_modifier_update(kbd, Q_KEY_CODE_ALT, Q_KEY_CODE_ALT, + case KEY_LEFTALT: + qkbd_state_modifier_update(kbd, KEY_LEFTALT, KEY_LEFTALT, QKBD_MOD_ALT); break; - case Q_KEY_CODE_ALT_R: - qkbd_state_modifier_update(kbd, Q_KEY_CODE_ALT_R, Q_KEY_CODE_ALT_R, + case KEY_RIGHTALT: + qkbd_state_modifier_update(kbd, KEY_RIGHTALT, KEY_RIGHTALT, QKBD_MOD_ALTGR); break; - case Q_KEY_CODE_CAPS_LOCK: + case KEY_CAPSLOCK: if (down) { change_bit(QKBD_MOD_CAPSLOCK, kbd->mods); } break; - case Q_KEY_CODE_NUM_LOCK: + case KEY_NUMLOCK: if (down) { change_bit(QKBD_MOD_NUMLOCK, kbd->mods); } @@ -99,7 +106,7 @@ void qkbd_state_key_event(QKbdState *kbd, QKeyCode qcode= , bool down) =20 /* send to guest */ if (qemu_console_is_graphic(kbd->con)) { - qemu_input_event_send_key_qcode(kbd->con, qcode, down); + qemu_input_event_send_key_linux(kbd->con, lnx, down); if (kbd->key_delay_ms) { qemu_input_event_send_key_delay(kbd->key_delay_ms); } @@ -108,11 +115,11 @@ void qkbd_state_key_event(QKbdState *kbd, QKeyCode qc= ode, bool down) =20 void qkbd_state_lift_all_keys(QKbdState *kbd) { - int qcode; + unsigned int lnx; =20 - for (qcode =3D 0; qcode < Q_KEY_CODE__MAX; qcode++) { - if (test_bit(qcode, kbd->keys)) { - qkbd_state_key_event(kbd, qcode, false); + for (lnx =3D 0; lnx < KEY_CNT; lnx++) { + if (test_bit(lnx, kbd->keys)) { + qkbd_state_key_event(kbd, lnx, false); } } } diff --git a/ui/keymaps.c b/ui/keymaps.c index 6822c097be7..a448efab320 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -257,7 +257,8 @@ int keysym2scancode(kbd_layout_t *k, int keysym, for (i =3D 0; i < keysym2code->count; i++) { QKeyCode qcode =3D qemu_input_key_number_to_qcode (keysym2code->keycodes[i]); - if (kbd && qkbd_state_key_get(kbd, qcode)) { + unsigned int lnx =3D qemu_input_map_qcode_to_linux[qcode]; + if (kbd && qkbd_state_key_get(kbd, lnx)) { return keysym2code->keycodes[i]; } } diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c index 2286df4223d..fdbdc427dc9 100644 --- a/ui/sdl2-input.c +++ b/ui/sdl2-input.c @@ -41,7 +41,8 @@ void sdl2_process_key(struct sdl2_console *scon, qcode =3D qemu_input_map_usb_to_qcode[ev->keysym.scancode]; trace_sdl2_process_key(ev->keysym.scancode, qcode, ev->type =3D=3D SDL_KEYDOWN ? "down" : "up"); - qkbd_state_key_event(scon->kbd, qcode, ev->type =3D=3D SDL_KEYDOWN); + qkbd_state_key_event(scon->kbd, qemu_input_map_qcode_to_linux[qcode], + ev->type =3D=3D SDL_KEYDOWN); =20 if (QEMU_IS_TEXT_CONSOLE(con)) { QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(con); diff --git a/ui/vnc.c b/ui/vnc.c index 92b62f62127..f521d9f2ad4 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1799,8 +1799,11 @@ static void pointer_event(VncState *vs, int button_m= ask, int x, int y) =20 static void press_key(VncState *vs, QKeyCode qcode) { - qkbd_state_key_event(vs->vd->kbd, qcode, true); - qkbd_state_key_event(vs->vd->kbd, qcode, false); + qkbd_state_key_event(vs->vd->kbd, qemu_input_map_qcode_to_linux[qcode], + true); + + qkbd_state_key_event(vs->vd->kbd, qemu_input_map_qcode_to_linux[qcode], + false); } =20 static void vnc_led_state_change(VncState *vs) @@ -1907,7 +1910,8 @@ static void do_key_event(VncState *vs, int down, int = keycode, int sym) } } =20 - qkbd_state_key_event(vs->vd->kbd, qcode, down); + qkbd_state_key_event(vs->vd->kbd, qemu_input_map_qcode_to_linux[qcode], + down); if (QEMU_IS_TEXT_CONSOLE(vs->vd->dcl.con)) { QemuTextConsole *con =3D QEMU_TEXT_CONSOLE(vs->vd->dcl.con); bool numlock =3D qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_NUM= LOCK); diff --git a/ui/cocoa.m b/ui/cocoa.m index 98394cdc507..ee53e7c72ed 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -767,7 +767,8 @@ - (void) setFullGrab:(id)sender } =20 - (void) toggleKey: (int)keycode { - qkbd_state_key_event(kbd, keycode, !qkbd_state_key_get(kbd, keycode)); + unsigned int lnx =3D qemu_input_map_qcode_to_linux[keycode]; + qkbd_state_key_event(kbd, lnx, !qkbd_state_key_get(kbd, lnx)); } =20 // Does the work of sending input to the monitor @@ -889,34 +890,62 @@ - (bool) handleEventLocked:(NSEvent *)event */ if (!!(modifiers & NSEventModifierFlagCapsLock) !=3D qkbd_state_modifier_get(kbd, QKBD_MOD_CAPSLOCK)) { - qkbd_state_key_event(kbd, Q_KEY_CODE_CAPS_LOCK, true); - qkbd_state_key_event(kbd, Q_KEY_CODE_CAPS_LOCK, false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_CAPS= _LOCK], + true); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_CAPS= _LOCK], + false); } =20 if (!(modifiers & NSEventModifierFlagShift)) { - qkbd_state_key_event(kbd, Q_KEY_CODE_SHIFT, false); - qkbd_state_key_event(kbd, Q_KEY_CODE_SHIFT_R, false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_SHIF= T], + false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_SHIF= T_R], + false); } if (!(modifiers & NSEventModifierFlagControl)) { - qkbd_state_key_event(kbd, Q_KEY_CODE_CTRL, false); - qkbd_state_key_event(kbd, Q_KEY_CODE_CTRL_R, false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_CTRL= ], + false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_CTRL= _R], + false); } if (!(modifiers & NSEventModifierFlagOption)) { if (swap_opt_cmd) { - qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false); - qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_= META_L], + false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_= META_R], + false); } else { - qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false); - qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_= ALT], + false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_= ALT_R], + false); } } if (!(modifiers & NSEventModifierFlagCommand)) { if (swap_opt_cmd) { - qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false); - qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_= ALT], + false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_= ALT_R], + false); } else { - qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false); - qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_= META_L], + false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[Q_KEY_CODE_= META_R], + false); } } =20 @@ -1023,7 +1052,9 @@ - (bool) handleEventLocked:(NSEvent *)event } =20 if (qemu_console_is_graphic(dcl.con)) { - qkbd_state_key_event(kbd, keycode, true); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[keycode= ], + true); } else { [self handleMonitorInput: event]; } @@ -1038,7 +1069,9 @@ - (bool) handleEventLocked:(NSEvent *)event } =20 if (qemu_console_is_graphic(dcl.con)) { - qkbd_state_key_event(kbd, keycode, false); + qkbd_state_key_event(kbd, + qemu_input_map_qcode_to_linux[keycode= ], + false); } return true; case NSEventTypeScrollWheel: --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364844; cv=none; d=zohomail.com; s=zohoarc; b=bbWNBr5K03+OmZS3ue54qlHmq9OLur+30tmoX7JpWOzDQQQ/Tr/+1WbudAk07SYlQyrwgbJGzB97yctv/KoWkDGDq4uEfgJfkMc/37PC5qZjspgN1xKBeLl2OnM8PxVCqD5tBzo5uBzWVr6VpaoYsjM3lwwU84ivo5+7OEOv/Ss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364844; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DBHFQLtRMrdfnvQtSsd7u7e5jcNyISFb5lV/307G3wI=; b=hfTc3OSXLxYFp71rlAOOJVX6P98tZ51cmXWKJIkWlOGq/Q289ldcGtkoGp+nhQnhss41g8zV3BIbn9CcPKDNFCBUFE1yJTqehOlYo2oSUhQA3bctZqS1cwm4Ba84LUhxSl7SN0mYQjmu1LceCBfm+Eg7xE8UX9dpQ/Y7ZClXAQc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364844373233.53549488342662; Thu, 21 May 2026 05:00:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ23W-0007Rn-B4; Thu, 21 May 2026 07:59:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23O-00075d-4L for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23L-0004GQ-Od for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:04 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-hp989bNNNv6a2sfM0PAmWQ-1; Thu, 21 May 2026 07:59:01 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 149121800359; Thu, 21 May 2026 11:59:00 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EB74E19560B0; Thu, 21 May 2026 11:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DBHFQLtRMrdfnvQtSsd7u7e5jcNyISFb5lV/307G3wI=; b=gtuWVkyTaT7Rn+5B66WKlLyNMhZ8LRdJDYYSAtB7ccpUn6UJKSyQEwZzfNvWuqw+XEDJzA pVpUE6BFhXbHa1clU+rgPyyAav7B+RTuhafsqAa4SeShI2d/nYTu+gM+zA73DbZA5W++bn Z2XH9hspPEujXlpxT4rd1sLtUKt/LkI= X-MC-Unique: hp989bNNNv6a2sfM0PAmWQ-1 X-Mimecast-MFC-AGG-ID: hp989bNNNv6a2sfM0PAmWQ_1779364740 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , Jan Kiszka , Peter Maydell , qemu-arm@nongnu.org (open list:Musicpal) Subject: [PULL 16/38] hw/arm/musicpal: Use Linux key codes Date: Thu, 21 May 2026 15:56:53 +0400 Message-ID: <20260521115717.1701482-17-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364846226158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-8-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- hw/arm/musicpal.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index c8985a58f99..e2630243eb7 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -24,6 +24,7 @@ #include "hw/core/ptimer.h" #include "hw/core/qdev-properties.h" #include "hw/block/flash.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/console.h" #include "hw/i2c/i2c.h" #include "hw/i2c/bitbang_i2c.h" @@ -1069,40 +1070,39 @@ static void musicpal_key_event(DeviceState *dev, Qe= muConsole *src, QemuInputEvent *evt) { musicpal_key_state *s =3D MUSICPAL_KEY(dev); - int qcode =3D qemu_input_linux_to_qcode(evt->key.key); uint32_t event =3D 0; int i; =20 - switch (qcode) { - case Q_KEY_CODE_UP: + switch (evt->key.key) { + case KEY_UP: event =3D MP_KEY_WHEEL_NAV | MP_KEY_WHEEL_NAV_INV; break; =20 - case Q_KEY_CODE_DOWN: + case KEY_DOWN: event =3D MP_KEY_WHEEL_NAV; break; =20 - case Q_KEY_CODE_LEFT: + case KEY_LEFT: event =3D MP_KEY_WHEEL_VOL | MP_KEY_WHEEL_VOL_INV; break; =20 - case Q_KEY_CODE_RIGHT: + case KEY_RIGHT: event =3D MP_KEY_WHEEL_VOL; break; =20 - case Q_KEY_CODE_F: + case KEY_F: event =3D MP_KEY_BTN_FAVORITS; break; =20 - case Q_KEY_CODE_TAB: + case KEY_TAB: event =3D MP_KEY_BTN_VOLUME; break; =20 - case Q_KEY_CODE_RET: + case KEY_ENTER: event =3D MP_KEY_BTN_NAVIGATION; break; =20 - case Q_KEY_CODE_M: + case KEY_M: event =3D MP_KEY_BTN_MENU; break; } --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364821; cv=none; d=zohomail.com; s=zohoarc; b=IS73DKayqzuWnthfDGw4UmwNkqPoTVuG9FMjSqHt+gVfV/5XNclz46Q+07sidZSxiBaz19D9Q0US0cFCD46s42V8WLIxGTZs78qodbUVxLwFQXMvGfp6l+0vyo8udy9xsYI70fB+6rCxPMKrwvQ8WhEPMsJHKK/2dHoS1kz9Jig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364821; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Fh+6O/vHguV/OcDLo0aBOnAZWtT7udU3z87vtg+xsfM=; b=b8yyC38M99YoB12MG8358j7SlyZhj9xPUMBcLZqiEJzuocX1NW+EU1HRUxhA4d1vH7kWmUtdd6Vj7UzBI8Grhx5Ufprk01D3BkGoOztgiJ1VcJVCjRLb+09ET2Fq7rIvX5lS9sI5419XD4gYg5QCHpl0P+GvsaHsQmReAF6SCms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364821853374.753175667352; Thu, 21 May 2026 05:00:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ23c-0007fG-LX; Thu, 21 May 2026 07:59:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23W-0007S8-44 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23U-0004I6-F4 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:13 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-8xPxHU5LPcmDPIM_1v549w-1; Thu, 21 May 2026 07:59:06 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E14021956096; Thu, 21 May 2026 11:59:05 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 65C1919560AB; Thu, 21 May 2026 11:59:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fh+6O/vHguV/OcDLo0aBOnAZWtT7udU3z87vtg+xsfM=; b=Ir6aVS2FWNWVqKduH5LmvZcYZaKWs+PJ7HO+IN1NnmWGScfzwvUwPsT850aDCBCMazJCVT XbURoa77R4mLEy7VzpHE/4KY4k56o5+bnlBkOs/2BV1xBP+3Ld9y6AKh3VEJWFJeVMwRCb LQRDOgm4fP6OUWgflG0PCNz01WMmF+c= X-MC-Unique: 8xPxHU5LPcmDPIM_1v549w-1 X-Mimecast-MFC-AGG-ID: 8xPxHU5LPcmDPIM_1v549w_1779364746 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Subject: [PULL 17/38] hw/char/escc: Use Linux key codes Date: Thu, 21 May 2026 15:56:54 +0400 Message-ID: <20260521115717.1701482-18-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364823322158501 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-9-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- hw/char/escc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/char/escc.c b/hw/char/escc.c index 39483ca03bf..7aae627fb48 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -30,6 +30,7 @@ #include "migration/vmstate.h" #include "qemu/module.h" #include "hw/char/escc.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/console.h" =20 #include "qemu/cutils.h" @@ -804,7 +805,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuC= onsole *src, trace_escc_sunkbd_event_in(qcode, QKeyCode_str(qcode), evt->key.down); =20 - if (qcode =3D=3D Q_KEY_CODE_CAPS_LOCK) { + if (evt->key.key =3D=3D KEY_CAPSLOCK) { if (evt->key.down) { s->caps_lock_mode ^=3D 1; if (s->caps_lock_mode =3D=3D 2) { @@ -818,7 +819,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuC= onsole *src, } } =20 - if (qcode =3D=3D Q_KEY_CODE_NUM_LOCK) { + if (evt->key.key =3D=3D KEY_NUMLOCK) { if (evt->key.down) { s->num_lock_mode ^=3D 1; if (s->num_lock_mode =3D=3D 2) { @@ -832,11 +833,11 @@ static void sunkbd_handle_event(DeviceState *dev, Qem= uConsole *src, } } =20 - if (qcode >=3D qemu_input_map_qcode_to_sun_len) { + if (evt->key.key >=3D qemu_input_map_linux_to_sun_len) { return; } =20 - keycode =3D qemu_input_map_qcode_to_sun[qcode]; + keycode =3D qemu_input_map_linux_to_sun[evt->key.key]; if (!evt->key.down) { keycode |=3D 0x80; } --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364792; cv=none; d=zohomail.com; s=zohoarc; b=gBqXR3Uhsytk9M9sqeSLghc0fCb/c3Gw/+vJdunvjd9D9aCBysjGC5SYYqamci3tySMNvahTx32e2zg2AW0FYuldR74/HpZHRRmG/23ILFtTC3/VjA8fi0db4KbjlqqpIIlgnMW4sbPQP1Df7EIYtXcqDOivKqQNhw5119NvMMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364792; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GzvGw9HB+8PugB6Z8oQMMVKJExk0hOER2A6QhEDEAZg=; b=alHV3954emcMEIGtkMi4As+2kqsrR2MSBTNnsv/m15Y6axBozyClzjZ4MGf8wgWGzA0V5ewSQinY+QA+pPqoYcSNnXYRMqJbGOJ7cOdsSozEtcFfQJEvPCtihJBuFG32gxvjesTSteJt9B9dYEfuYHWgoEv08OnYU6eDi+iM3nA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364792295135.12038891353473; Thu, 21 May 2026 04:59:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ23i-0007rL-E7; Thu, 21 May 2026 07:59:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23b-0007fn-CA for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23Z-0004It-M0 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:19 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-365-LgVvz8qJOzCdQFPmXR0TxA-1; Thu, 21 May 2026 07:59:12 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 451921800451; Thu, 21 May 2026 11:59:11 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F149E1800347; Thu, 21 May 2026 11:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GzvGw9HB+8PugB6Z8oQMMVKJExk0hOER2A6QhEDEAZg=; b=gsJ1Z+LLIkBw50RkC/mMtGUNqJtVu0VJWdzWca7KqspemUW+aWqcW2pPIz5ID2E88SoDN6 hzU+Yf/FmEMTQPzl03hQT6rxlPN6rFHUBWNWWJUhqKlMickcddaQjya8YqAXeB5YoXK9nd sHaA4WpvD7if5p7CakLGMXAkg9O+8Ng= X-MC-Unique: LgVvz8qJOzCdQFPmXR0TxA-1 X-Mimecast-MFC-AGG-ID: LgVvz8qJOzCdQFPmXR0TxA_1779364751 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org (open list:X86 Xen CPUs) Subject: [PULL 18/38] hw/display/xenfb: Use Linux key codes Date: Thu, 21 May 2026 15:56:55 +0400 Message-ID: <20260521115717.1701482-19-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364793664154100 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-10-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- hw/display/xenfb.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index 218f37f0740..ae302b217fe 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -191,29 +191,14 @@ static int xenfb_send_position(struct XenInput *xenfb, return xenfb_kbd_event(xenfb, &event); } =20 -/* - * Send a key event from the client to the guest OS - * QEMU gives us a QCode. - * We have to turn this into a Linux Input layer keycode. - * - * Wish we could just send scancodes straight to the guest which - * already has code for dealing with this... - */ +/* Send a key event from the client to the guest OS */ static void xenfb_key_event(DeviceState *dev, QemuConsole *src, QemuInputEvent *evt) { struct XenInput *xenfb =3D (struct XenInput *)dev; - int qcode =3D qemu_input_linux_to_qcode(evt->key.key); - int lnx; =20 - if (qcode < qemu_input_map_qcode_to_linux_len) { - lnx =3D qemu_input_map_qcode_to_linux[qcode]; - - if (lnx) { - trace_xenfb_key_event(xenfb, lnx, evt->key.down); - xenfb_send_key(xenfb, evt->key.down, lnx); - } - } + trace_xenfb_key_event(xenfb, evt->key.key, evt->key.down); + xenfb_send_key(xenfb, evt->key.down, evt->key.key); } =20 /* --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364876; cv=none; d=zohomail.com; s=zohoarc; b=ZrwS75wjhupA8i2WUUFhlZGLJRf0Rqno5DDY3ciN/3GS4bugXMkr/4Fd7GD8KAGSop8/pZa9HbZyWp5k7LQhfheSPlcLaiXjaDpoegGOkwkybY7yhKwPL/MsZ9tWvzde67eBGR0/WAQdgiQq/E6nI7tFIfuNUxO40sbN8E08N6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364876; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Zo0YQ9yFnRrPLPhdsusmg3bFo1tciFst6Tk8dOGgPcU=; b=AT419qTOh65FshI+ylkgrEGxdnqqw9rXjnEbqIYwK+GVkPhFblIwriG0Ri3qCgL3GmWSp3yXUzycGt3b/WMcv3uDjcPEIJ6GdegVAiMb0PcI072nOTjj2lrJYCyIubSe3qMj2imnpaBSppHmSyOLildwO/f9ht8cGviP1GJE75g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364876238558.2245320044377; Thu, 21 May 2026 05:01:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ243-0008D2-Fz; Thu, 21 May 2026 07:59:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23k-0007wZ-Ds for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23i-0004K4-4k for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:28 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-247-5WGS-ChON66XuFGwC3E6nQ-1; Thu, 21 May 2026 07:59:17 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 96F9A18005BA; Thu, 21 May 2026 11:59:16 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7840B1681; Thu, 21 May 2026 11:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zo0YQ9yFnRrPLPhdsusmg3bFo1tciFst6Tk8dOGgPcU=; b=V9ORfBqXK/uToa140ZStt64xd314OQrMjQ7myTvGmB1ReUpDe9qVHVmPDOy/vu38KFBdti DAvkN17T7H+VmoEWKtL6xlgw9aRIFVB43euM6Qx1HNmVlMv7XSCbfRkpDwjjdQ6rCTxIn2 6ZryxAOPqlL2+Boj2WV/hmrklihBWeQ= X-MC-Unique: 5WGS-ChON66XuFGwC3E6nQ-1 X-Mimecast-MFC-AGG-ID: 5WGS-ChON66XuFGwC3E6nQ_1779364756 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , Mark Cave-Ayland , qemu-ppc@nongnu.org (open list:Old World (g3beige)) Subject: [PULL 19/38] hw/input/adb-kbd: Use Linux key codes Date: Thu, 21 May 2026 15:56:56 +0400 Message-ID: <20260521115717.1701482-20-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UPPERCASE_50_75=0.008 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364877782154100 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-11-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- hw/input/adb-kbd.c | 242 ++++++++++++++++++++++----------------------- 1 file changed, 120 insertions(+), 122 deletions(-) diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c index 060481d0db6..c4ef9ebb90c 100644 --- a/hw/input/adb-kbd.c +++ b/hw/input/adb-kbd.c @@ -26,6 +26,7 @@ #include "hw/input/adb.h" #include "migration/vmstate.h" #include "qemu/module.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/input.h" #include "hw/input/adb-keys.h" #include "adb-internal.h" @@ -55,124 +56,122 @@ struct ADBKeyboardClass { /* The adb keyboard doesn't have every key imaginable */ #define NO_KEY 0xff =20 -int qcode_to_adb_keycode[] =3D { +int linux_to_adb_keycode[] =3D { /* Make sure future additions are automatically set to NO_KEY */ - [0 ... 0xff] =3D NO_KEY, - - [Q_KEY_CODE_SHIFT] =3D ADB_KEY_LEFT_SHIFT, - [Q_KEY_CODE_SHIFT_R] =3D ADB_KEY_RIGHT_SHIFT, - [Q_KEY_CODE_ALT] =3D ADB_KEY_LEFT_OPTION, - [Q_KEY_CODE_ALT_R] =3D ADB_KEY_RIGHT_OPTION, - [Q_KEY_CODE_CTRL] =3D ADB_KEY_LEFT_CONTROL, - [Q_KEY_CODE_CTRL_R] =3D ADB_KEY_RIGHT_CONTROL, - [Q_KEY_CODE_META_L] =3D ADB_KEY_COMMAND, - [Q_KEY_CODE_META_R] =3D ADB_KEY_COMMAND, - [Q_KEY_CODE_SPC] =3D ADB_KEY_SPACEBAR, - - [Q_KEY_CODE_ESC] =3D ADB_KEY_ESC, - [Q_KEY_CODE_1] =3D ADB_KEY_1, - [Q_KEY_CODE_2] =3D ADB_KEY_2, - [Q_KEY_CODE_3] =3D ADB_KEY_3, - [Q_KEY_CODE_4] =3D ADB_KEY_4, - [Q_KEY_CODE_5] =3D ADB_KEY_5, - [Q_KEY_CODE_6] =3D ADB_KEY_6, - [Q_KEY_CODE_7] =3D ADB_KEY_7, - [Q_KEY_CODE_8] =3D ADB_KEY_8, - [Q_KEY_CODE_9] =3D ADB_KEY_9, - [Q_KEY_CODE_0] =3D ADB_KEY_0, - [Q_KEY_CODE_MINUS] =3D ADB_KEY_MINUS, - [Q_KEY_CODE_EQUAL] =3D ADB_KEY_EQUAL, - [Q_KEY_CODE_BACKSPACE] =3D ADB_KEY_DELETE, - [Q_KEY_CODE_TAB] =3D ADB_KEY_TAB, - [Q_KEY_CODE_Q] =3D ADB_KEY_Q, - [Q_KEY_CODE_W] =3D ADB_KEY_W, - [Q_KEY_CODE_E] =3D ADB_KEY_E, - [Q_KEY_CODE_R] =3D ADB_KEY_R, - [Q_KEY_CODE_T] =3D ADB_KEY_T, - [Q_KEY_CODE_Y] =3D ADB_KEY_Y, - [Q_KEY_CODE_U] =3D ADB_KEY_U, - [Q_KEY_CODE_I] =3D ADB_KEY_I, - [Q_KEY_CODE_O] =3D ADB_KEY_O, - [Q_KEY_CODE_P] =3D ADB_KEY_P, - [Q_KEY_CODE_BRACKET_LEFT] =3D ADB_KEY_LEFT_BRACKET, - [Q_KEY_CODE_BRACKET_RIGHT] =3D ADB_KEY_RIGHT_BRACKET, - [Q_KEY_CODE_RET] =3D ADB_KEY_RETURN, - [Q_KEY_CODE_A] =3D ADB_KEY_A, - [Q_KEY_CODE_S] =3D ADB_KEY_S, - [Q_KEY_CODE_D] =3D ADB_KEY_D, - [Q_KEY_CODE_F] =3D ADB_KEY_F, - [Q_KEY_CODE_G] =3D ADB_KEY_G, - [Q_KEY_CODE_H] =3D ADB_KEY_H, - [Q_KEY_CODE_J] =3D ADB_KEY_J, - [Q_KEY_CODE_K] =3D ADB_KEY_K, - [Q_KEY_CODE_L] =3D ADB_KEY_L, - [Q_KEY_CODE_SEMICOLON] =3D ADB_KEY_SEMICOLON, - [Q_KEY_CODE_APOSTROPHE] =3D ADB_KEY_APOSTROPHE, - [Q_KEY_CODE_GRAVE_ACCENT] =3D ADB_KEY_GRAVE_ACCENT, - [Q_KEY_CODE_BACKSLASH] =3D ADB_KEY_BACKSLASH, - [Q_KEY_CODE_Z] =3D ADB_KEY_Z, - [Q_KEY_CODE_X] =3D ADB_KEY_X, - [Q_KEY_CODE_C] =3D ADB_KEY_C, - [Q_KEY_CODE_V] =3D ADB_KEY_V, - [Q_KEY_CODE_B] =3D ADB_KEY_B, - [Q_KEY_CODE_N] =3D ADB_KEY_N, - [Q_KEY_CODE_M] =3D ADB_KEY_M, - [Q_KEY_CODE_COMMA] =3D ADB_KEY_COMMA, - [Q_KEY_CODE_DOT] =3D ADB_KEY_PERIOD, - [Q_KEY_CODE_SLASH] =3D ADB_KEY_FORWARD_SLASH, - [Q_KEY_CODE_ASTERISK] =3D ADB_KEY_KP_MULTIPLY, - [Q_KEY_CODE_CAPS_LOCK] =3D ADB_KEY_CAPS_LOCK, - - [Q_KEY_CODE_F1] =3D ADB_KEY_F1, - [Q_KEY_CODE_F2] =3D ADB_KEY_F2, - [Q_KEY_CODE_F3] =3D ADB_KEY_F3, - [Q_KEY_CODE_F4] =3D ADB_KEY_F4, - [Q_KEY_CODE_F5] =3D ADB_KEY_F5, - [Q_KEY_CODE_F6] =3D ADB_KEY_F6, - [Q_KEY_CODE_F7] =3D ADB_KEY_F7, - [Q_KEY_CODE_F8] =3D ADB_KEY_F8, - [Q_KEY_CODE_F9] =3D ADB_KEY_F9, - [Q_KEY_CODE_F10] =3D ADB_KEY_F10, - [Q_KEY_CODE_F11] =3D ADB_KEY_F11, - [Q_KEY_CODE_F12] =3D ADB_KEY_F12, - [Q_KEY_CODE_PRINT] =3D ADB_KEY_F13, - [Q_KEY_CODE_SYSRQ] =3D ADB_KEY_F13, - [Q_KEY_CODE_SCROLL_LOCK] =3D ADB_KEY_F14, - [Q_KEY_CODE_PAUSE] =3D ADB_KEY_F15, - - [Q_KEY_CODE_NUM_LOCK] =3D ADB_KEY_KP_CLEAR, - [Q_KEY_CODE_KP_EQUALS] =3D ADB_KEY_KP_EQUAL, - [Q_KEY_CODE_KP_DIVIDE] =3D ADB_KEY_KP_DIVIDE, - [Q_KEY_CODE_KP_MULTIPLY] =3D ADB_KEY_KP_MULTIPLY, - [Q_KEY_CODE_KP_SUBTRACT] =3D ADB_KEY_KP_SUBTRACT, - [Q_KEY_CODE_KP_ADD] =3D ADB_KEY_KP_PLUS, - [Q_KEY_CODE_KP_ENTER] =3D ADB_KEY_KP_ENTER, - [Q_KEY_CODE_KP_DECIMAL] =3D ADB_KEY_KP_PERIOD, - [Q_KEY_CODE_KP_0] =3D ADB_KEY_KP_0, - [Q_KEY_CODE_KP_1] =3D ADB_KEY_KP_1, - [Q_KEY_CODE_KP_2] =3D ADB_KEY_KP_2, - [Q_KEY_CODE_KP_3] =3D ADB_KEY_KP_3, - [Q_KEY_CODE_KP_4] =3D ADB_KEY_KP_4, - [Q_KEY_CODE_KP_5] =3D ADB_KEY_KP_5, - [Q_KEY_CODE_KP_6] =3D ADB_KEY_KP_6, - [Q_KEY_CODE_KP_7] =3D ADB_KEY_KP_7, - [Q_KEY_CODE_KP_8] =3D ADB_KEY_KP_8, - [Q_KEY_CODE_KP_9] =3D ADB_KEY_KP_9, - - [Q_KEY_CODE_UP] =3D ADB_KEY_UP, - [Q_KEY_CODE_DOWN] =3D ADB_KEY_DOWN, - [Q_KEY_CODE_LEFT] =3D ADB_KEY_LEFT, - [Q_KEY_CODE_RIGHT] =3D ADB_KEY_RIGHT, - - [Q_KEY_CODE_HELP] =3D ADB_KEY_HELP, - [Q_KEY_CODE_INSERT] =3D ADB_KEY_HELP, - [Q_KEY_CODE_DELETE] =3D ADB_KEY_FORWARD_DELETE, - [Q_KEY_CODE_HOME] =3D ADB_KEY_HOME, - [Q_KEY_CODE_END] =3D ADB_KEY_END, - [Q_KEY_CODE_PGUP] =3D ADB_KEY_PAGE_UP, - [Q_KEY_CODE_PGDN] =3D ADB_KEY_PAGE_DOWN, - - [Q_KEY_CODE_POWER] =3D ADB_KEY_POWER + [0 ... KEY_MAX] =3D NO_KEY, + + [KEY_LEFTSHIFT] =3D ADB_KEY_LEFT_SHIFT, + [KEY_RIGHTSHIFT] =3D ADB_KEY_RIGHT_SHIFT, + [KEY_LEFTALT] =3D ADB_KEY_LEFT_OPTION, + [KEY_RIGHTALT] =3D ADB_KEY_RIGHT_OPTION, + [KEY_LEFTCTRL] =3D ADB_KEY_LEFT_CONTROL, + [KEY_RIGHTCTRL] =3D ADB_KEY_RIGHT_CONTROL, + [KEY_LEFTMETA] =3D ADB_KEY_COMMAND, + [KEY_RIGHTMETA] =3D ADB_KEY_COMMAND, + [KEY_SPACE] =3D ADB_KEY_SPACEBAR, + + [KEY_ESC] =3D ADB_KEY_ESC, + [KEY_1] =3D ADB_KEY_1, + [KEY_2] =3D ADB_KEY_2, + [KEY_3] =3D ADB_KEY_3, + [KEY_4] =3D ADB_KEY_4, + [KEY_5] =3D ADB_KEY_5, + [KEY_6] =3D ADB_KEY_6, + [KEY_7] =3D ADB_KEY_7, + [KEY_8] =3D ADB_KEY_8, + [KEY_9] =3D ADB_KEY_9, + [KEY_0] =3D ADB_KEY_0, + [KEY_MINUS] =3D ADB_KEY_MINUS, + [KEY_EQUAL] =3D ADB_KEY_EQUAL, + [KEY_BACKSPACE] =3D ADB_KEY_DELETE, + [KEY_TAB] =3D ADB_KEY_TAB, + [KEY_Q] =3D ADB_KEY_Q, + [KEY_W] =3D ADB_KEY_W, + [KEY_E] =3D ADB_KEY_E, + [KEY_R] =3D ADB_KEY_R, + [KEY_T] =3D ADB_KEY_T, + [KEY_Y] =3D ADB_KEY_Y, + [KEY_U] =3D ADB_KEY_U, + [KEY_I] =3D ADB_KEY_I, + [KEY_O] =3D ADB_KEY_O, + [KEY_P] =3D ADB_KEY_P, + [KEY_LEFTBRACE] =3D ADB_KEY_LEFT_BRACKET, + [KEY_RIGHTBRACE] =3D ADB_KEY_RIGHT_BRACKET, + [KEY_ENTER] =3D ADB_KEY_RETURN, + [KEY_A] =3D ADB_KEY_A, + [KEY_S] =3D ADB_KEY_S, + [KEY_D] =3D ADB_KEY_D, + [KEY_F] =3D ADB_KEY_F, + [KEY_G] =3D ADB_KEY_G, + [KEY_H] =3D ADB_KEY_H, + [KEY_J] =3D ADB_KEY_J, + [KEY_K] =3D ADB_KEY_K, + [KEY_L] =3D ADB_KEY_L, + [KEY_SEMICOLON] =3D ADB_KEY_SEMICOLON, + [KEY_APOSTROPHE] =3D ADB_KEY_APOSTROPHE, + [KEY_GRAVE] =3D ADB_KEY_GRAVE_ACCENT, + [KEY_BACKSLASH] =3D ADB_KEY_BACKSLASH, + [KEY_Z] =3D ADB_KEY_Z, + [KEY_X] =3D ADB_KEY_X, + [KEY_C] =3D ADB_KEY_C, + [KEY_V] =3D ADB_KEY_V, + [KEY_B] =3D ADB_KEY_B, + [KEY_N] =3D ADB_KEY_N, + [KEY_M] =3D ADB_KEY_M, + [KEY_COMMA] =3D ADB_KEY_COMMA, + [KEY_DOT] =3D ADB_KEY_PERIOD, + [KEY_SLASH] =3D ADB_KEY_FORWARD_SLASH, + [KEY_CAPSLOCK] =3D ADB_KEY_CAPS_LOCK, + + [KEY_F1] =3D ADB_KEY_F1, + [KEY_F2] =3D ADB_KEY_F2, + [KEY_F3] =3D ADB_KEY_F3, + [KEY_F4] =3D ADB_KEY_F4, + [KEY_F5] =3D ADB_KEY_F5, + [KEY_F6] =3D ADB_KEY_F6, + [KEY_F7] =3D ADB_KEY_F7, + [KEY_F8] =3D ADB_KEY_F8, + [KEY_F9] =3D ADB_KEY_F9, + [KEY_F10] =3D ADB_KEY_F10, + [KEY_F11] =3D ADB_KEY_F11, + [KEY_F12] =3D ADB_KEY_F12, + [KEY_SYSRQ] =3D ADB_KEY_F13, + [KEY_SCROLLLOCK] =3D ADB_KEY_F14, + [KEY_PAUSE] =3D ADB_KEY_F15, + + [KEY_NUMLOCK] =3D ADB_KEY_KP_CLEAR, + [KEY_KPEQUAL] =3D ADB_KEY_KP_EQUAL, + [KEY_KPSLASH] =3D ADB_KEY_KP_DIVIDE, + [KEY_KPASTERISK] =3D ADB_KEY_KP_MULTIPLY, + [KEY_KPMINUS] =3D ADB_KEY_KP_SUBTRACT, + [KEY_KPPLUS] =3D ADB_KEY_KP_PLUS, + [KEY_KPENTER] =3D ADB_KEY_KP_ENTER, + [KEY_KPDOT] =3D ADB_KEY_KP_PERIOD, + [KEY_KP0] =3D ADB_KEY_KP_0, + [KEY_KP1] =3D ADB_KEY_KP_1, + [KEY_KP2] =3D ADB_KEY_KP_2, + [KEY_KP3] =3D ADB_KEY_KP_3, + [KEY_KP4] =3D ADB_KEY_KP_4, + [KEY_KP5] =3D ADB_KEY_KP_5, + [KEY_KP6] =3D ADB_KEY_KP_6, + [KEY_KP7] =3D ADB_KEY_KP_7, + [KEY_KP8] =3D ADB_KEY_KP_8, + [KEY_KP9] =3D ADB_KEY_KP_9, + + [KEY_UP] =3D ADB_KEY_UP, + [KEY_DOWN] =3D ADB_KEY_DOWN, + [KEY_LEFT] =3D ADB_KEY_LEFT, + [KEY_RIGHT] =3D ADB_KEY_RIGHT, + + [KEY_HELP] =3D ADB_KEY_HELP, + [KEY_INSERT] =3D ADB_KEY_HELP, + [KEY_DELETE] =3D ADB_KEY_FORWARD_DELETE, + [KEY_HOME] =3D ADB_KEY_HOME, + [KEY_END] =3D ADB_KEY_END, + [KEY_PAGEUP] =3D ADB_KEY_PAGE_UP, + [KEY_PAGEDOWN] =3D ADB_KEY_PAGE_DOWN, + + [KEY_POWER] =3D ADB_KEY_POWER }; =20 static void adb_kbd_put_keycode(void *opaque, int keycode) @@ -309,14 +308,13 @@ static void adb_keyboard_event(DeviceState *dev, Qemu= Console *src, QemuInputEvent *evt) { KBDState *s =3D (KBDState *)dev; - int qcode, keycode; + int keycode; =20 - qcode =3D qemu_input_linux_to_qcode(evt->key.key); - if (qcode >=3D ARRAY_SIZE(qcode_to_adb_keycode)) { + if (evt->key.key >=3D ARRAY_SIZE(linux_to_adb_keycode)) { return; } - /* FIXME: take handler into account when translating qcode */ - keycode =3D qcode_to_adb_keycode[qcode]; + /* FIXME: take handler into account when translating evt->key.key */ + keycode =3D linux_to_adb_keycode[evt->key.key]; if (keycode =3D=3D NO_KEY) { /* We don't want to send this to the gue= st */ trace_adb_device_kbd_no_key(); return; --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364867; cv=none; d=zohomail.com; s=zohoarc; b=YxiuY25PS3ZeKlUJW477mizbN0OY2H8MbFfyMV/yO7AX7Hps4ZVU3YnNApIeRHZxfCe7ZZk8QmcUiRl5cJU/7g9EG76O50ps+iZOl0l0rxPpGvdgiFEMp/Vcg/FLjUQx/xoE6PTI1oD22X4OD0m/16EpIBOMgptwmkoa9fin8sg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364867; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6ZuJuyP+yulK3pXOupJruJevwsXzQpEBwt3g6MkXAjg=; b=oKLsR8x0Loqn3SZUoWRLhg/ekrdymj5RKE5OA6lmqizpHyqjIsl6zSzAe+pTCvVDIjpV2Dl5suirRteLJzot5EzRx3EqUoko962M1JD/zGbvCG6cTt+raO733SvCUEYnqCUeDKvsE6fWSE2BIyPlbWgKGCuk5UVv7czTxH6akuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364867763997.2699291803266; Thu, 21 May 2026 05:01:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ24T-00007f-4D; Thu, 21 May 2026 08:00:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23s-000873-EV for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23l-0004Pk-21 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:34 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-rOdkexFLP7iHZZaoCzL73w-1; Thu, 21 May 2026 07:59:23 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 08DEB19560B8; Thu, 21 May 2026 11:59:22 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0A73B300019F; Thu, 21 May 2026 11:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6ZuJuyP+yulK3pXOupJruJevwsXzQpEBwt3g6MkXAjg=; b=ieRVVgIikU5KYMgH9Y5yYQM88HZgycfM1smE+eisviK4IlXcizuWYmNERuGEYzSh7onVgz rCLMQh0hdVfd3nLPRa4IvoXCvfWThGWwgbIhF7P+BKymxeKde09YsiA71uUAFPITn2dewl FlD5N+MIrLSNPBxPbeO49pEmw99pV/8= X-MC-Unique: rOdkexFLP7iHZZaoCzL73w-1 X-Mimecast-MFC-AGG-ID: rOdkexFLP7iHZZaoCzL73w_1779364762 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki Subject: [PULL 20/38] hw/input/hid: Use Linux key codes Date: Thu, 21 May 2026 15:56:57 +0400 Message-ID: <20260521115717.1701482-21-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364869713154100 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-12-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- hw/input/hid.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/input/hid.c b/hw/input/hid.c index 013840562f6..467ba8f14f3 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -224,11 +224,10 @@ static void hid_keyboard_event(DeviceState *dev, Qemu= Console *src, QemuInputEvent *evt) { HIDState *hs =3D (HIDState *)dev; - int qcode =3D qemu_input_linux_to_qcode(evt->key.key); int scancodes[3], i, count; int slot; =20 - count =3D qemu_input_qcode_to_scancode(qcode, evt->key.down, + count =3D qemu_input_linux_to_scancode(evt->key.key, evt->key.down, scancodes); if (hs->n + count > QUEUE_LENGTH) { trace_hid_kbd_queue_full(); --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364938; cv=none; d=zohomail.com; s=zohoarc; b=AxdJ4sVswsfWxEaHWp6b1WwzQ3tFrA6LVZqSj5Op6FrAMMiKMWQN8qjppZc7z9DADYJUyGoQU1KZ2Opu7Llc0eIVYGJaEXhUCATKW7carFA7S/krCfjONawlB3mGL7spxPOoCkJEw6GPPy3dnoI8qB2XnL8CKlf1xuLtpf9PnUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364938; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YQ54XMaiAgfFL8G0tzhmo5Nowz0ljDTt98jhBbihl7Q=; b=Q4puT/Z0/oSDx+RwbRmuMYGYNR08EJiTy55qd0W2KcUXbK0PQWbXAAVJqvp17yB7g9gAW+DNPHUrFWNCNCVhHZ7FEKuuebia6AMQfEkV6K/roBul6e36DqNScFZY67T5Q4OD9BD8iSEYP2lbJHq43VcLClzVx8lOsyMFTkIfJQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364938099397.4868268083495; Thu, 21 May 2026 05:02:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25J-00019T-M7; Thu, 21 May 2026 08:01:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23v-00088T-4x for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23o-0004X4-GG for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:37 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-LLJEPJ45OWaXQ_kTmtInjg-1; Thu, 21 May 2026 07:59:28 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4A43419560B4; Thu, 21 May 2026 11:59:27 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 446E11684; Thu, 21 May 2026 11:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YQ54XMaiAgfFL8G0tzhmo5Nowz0ljDTt98jhBbihl7Q=; b=K+acDEXAdC3BzIiSqa5/+o58shUFsK4xh30itnDYnaAcWXURaFeLcpuYwZ73rzS5bGk1M7 dyAISUZ5x7gva055uym2YB5lTwj2xmtOJgfRBQ4tLRbrWrujHREP5hMkY1IcVhB5HimpVt 6usEAwCNWt5z2nZMUrulBmM/xfCbET0= X-MC-Unique: LLJEPJ45OWaXQ_kTmtInjg-1 X-Mimecast-MFC-AGG-ID: LLJEPJ45OWaXQ_kTmtInjg_1779364767 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki Subject: [PULL 21/38] hw/input/ps2: Use Linux key codes Date: Thu, 21 May 2026 15:56:58 +0400 Message-ID: <20260521115717.1701482-22-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364941812154100 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-13-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- hw/input/ps2.c | 51 +++++++++++++++++++++---------------------- hw/input/trace-events | 2 +- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 93c3c737205..f2523ff4bc7 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -28,6 +28,7 @@ #include "hw/core/sysbus.h" #include "hw/input/ps2.h" #include "migration/vmstate.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/console.h" #include "ui/input.h" #include "system/reset.h" @@ -123,20 +124,20 @@ static uint8_t translate_table[256] =3D { 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, }; =20 -static unsigned int ps2_modifier_bit(QKeyCode key) +static unsigned int ps2_modifier_bit(unsigned int key) { switch (key) { - case Q_KEY_CODE_CTRL: + case KEY_LEFTCTRL: return MOD_CTRL_L; - case Q_KEY_CODE_CTRL_R: + case KEY_RIGHTCTRL: return MOD_CTRL_R; - case Q_KEY_CODE_SHIFT: + case KEY_LEFTSHIFT: return MOD_SHIFT_L; - case Q_KEY_CODE_SHIFT_R: + case KEY_RIGHTSHIFT: return MOD_SHIFT_R; - case Q_KEY_CODE_ALT: + case KEY_LEFTALT: return MOD_ALT_L; - case Q_KEY_CODE_ALT_R: + case KEY_RIGHTALT: return MOD_ALT_R; default: return 0; @@ -313,7 +314,6 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, QemuInputEvent *evt) { PS2KbdState *s =3D (PS2KbdState *)dev; - int qcode; uint16_t keycode =3D 0; int mod; =20 @@ -324,10 +324,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuC= onsole *src, =20 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); assert(evt->type =3D=3D INPUT_EVENT_KIND_KEY); - qcode =3D qemu_input_linux_to_qcode(evt->key.key); =20 - mod =3D ps2_modifier_bit(qcode); - trace_ps2_keyboard_event(s, qcode, evt->key.down, mod, + mod =3D ps2_modifier_bit(evt->key.key); + trace_ps2_keyboard_event(s, evt->key.key, evt->key.down, mod, s->modifiers, s->scancode_set, s->translate); if (evt->key.down) { s->modifiers |=3D mod; @@ -336,7 +335,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, } =20 if (s->scancode_set =3D=3D 1) { - if (qcode =3D=3D Q_KEY_CODE_PAUSE) { + if (evt->key.key =3D=3D KEY_PAUSE) { if (s->modifiers & (MOD_CTRL_L | MOD_CTRL_R)) { if (evt->key.down) { ps2_put_keycode(s, 0xe0); @@ -354,7 +353,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0xc5); } } - } else if (qcode =3D=3D Q_KEY_CODE_PRINT) { + } else if (evt->key.key =3D=3D KEY_SYSRQ) { if (s->modifiers & MOD_ALT_L) { if (evt->key.down) { ps2_put_keycode(s, 0xb8); @@ -401,12 +400,12 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, ps2_put_keycode(s, 0xaa); } } - } else if ((qcode =3D=3D Q_KEY_CODE_LANG1 || qcode =3D=3D Q_KEY_CO= DE_LANG2) + } else if ((evt->key.key =3D=3D KEY_HANGEUL || evt->key.key =3D=3D= KEY_HANJA) && !evt->key.down) { /* Ignore release for these keys */ } else { - if (qcode < qemu_input_map_qcode_to_atset1_len) { - keycode =3D qemu_input_map_qcode_to_atset1[qcode]; + if (evt->key.key < qemu_input_map_linux_to_atset1_len) { + keycode =3D qemu_input_map_linux_to_atset1[evt->key.key]; } if (keycode) { if (keycode & 0xff00) { @@ -418,11 +417,11 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, ps2_put_keycode(s, keycode & 0xff); } else { qemu_log_mask(LOG_UNIMP, - "ps2: ignoring key with qcode %d\n", qcode); + "ps2: ignoring key %u\n", evt->key.key); } } } else if (s->scancode_set =3D=3D 2) { - if (qcode =3D=3D Q_KEY_CODE_PAUSE) { + if (evt->key.key =3D=3D KEY_PAUSE) { if (s->modifiers & (MOD_CTRL_L | MOD_CTRL_R)) { if (evt->key.down) { ps2_put_keycode(s, 0xe0); @@ -443,7 +442,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0x77); } } - } else if (qcode =3D=3D Q_KEY_CODE_PRINT) { + } else if (evt->key.key =3D=3D KEY_SYSRQ) { if (s->modifiers & MOD_ALT_L) { if (evt->key.down) { ps2_put_keycode(s, 0xf0); @@ -499,12 +498,12 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, ps2_put_keycode(s, 0x12); } } - } else if ((qcode =3D=3D Q_KEY_CODE_LANG1 || qcode =3D=3D Q_KEY_CO= DE_LANG2) && + } else if ((evt->key.key =3D=3D KEY_HANGEUL || evt->key.key =3D=3D= KEY_HANJA) && !evt->key.down) { /* Ignore release for these keys */ } else { - if (qcode < qemu_input_map_qcode_to_atset2_len) { - keycode =3D qemu_input_map_qcode_to_atset2[qcode]; + if (evt->key.key < qemu_input_map_linux_to_atset2_len) { + keycode =3D qemu_input_map_linux_to_atset2[evt->key.key]; } if (keycode) { if (keycode & 0xff00) { @@ -516,12 +515,12 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, ps2_put_keycode(s, keycode & 0xff); } else { qemu_log_mask(LOG_UNIMP, - "ps2: ignoring key with qcode %d\n", qcode); + "ps2: ignoring key %u\n", evt->key.key); } } } else if (s->scancode_set =3D=3D 3) { - if (qcode < qemu_input_map_qcode_to_atset3_len) { - keycode =3D qemu_input_map_qcode_to_atset3[qcode]; + if (evt->key.key < qemu_input_map_linux_to_atset3_len) { + keycode =3D qemu_input_map_linux_to_atset3[evt->key.key]; } if (keycode) { /* FIXME: break code should be configured on a key by key basi= s */ @@ -531,7 +530,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, keycode); } else { qemu_log_mask(LOG_UNIMP, - "ps2: ignoring key with qcode %d\n", qcode); + "ps2: ignoring key %u\n", evt->key.key); } } } diff --git a/hw/input/trace-events b/hw/input/trace-events index 1484625565b..43900914be2 100644 --- a/hw/input/trace-events +++ b/hw/input/trace-events @@ -30,7 +30,7 @@ pckbd_kbd_write_data(uint64_t val) "0x%02"PRIx64 =20 # ps2.c ps2_put_keycode(void *opaque, int keycode) "%p keycode 0x%02x" -ps2_keyboard_event(void *opaque, int qcode, int down, unsigned int modifie= r, unsigned int modifiers, int set, int xlate) "%p qcode %d down %d modifie= r 0x%x modifiers 0x%x set %d xlate %d" +ps2_keyboard_event(void *opaque, unsigned int lnx, int down, unsigned int = modifier, unsigned int modifiers, int set, int xlate) "%p lnx %u down %d mo= difier 0x%x modifiers 0x%x set %d xlate %d" ps2_read_data(void *opaque) "%p" ps2_set_ledstate(void *s, int ledstate) "%p ledstate %d" ps2_reset_keyboard(void *s) "%p" --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364876; cv=none; d=zohomail.com; s=zohoarc; b=krBM4A7j9ckYPlceS8sddhUJoDKYp+Iz+8myz8lUAGjceEHVE/DwKBdny9XlQZx/+3J8xwQrWYZ3WGYqlIvPNamWgMdOPFkvUs5wQB+LLL8tLIS+1TTqYXQlg9myESAkvwz87SiCICbxTX6z5lsKDo+y3biXPPokDyHYGs9BJks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364876; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=T0U31hilbffMwpa0BEq59ZjijcKzDLFO9G55VI/Gf/k=; b=AL3HhHTvbJTEIMLj7Qxu1jKZpUjAnhqa81VW1yH5AJtHHVcmLRoouMR4FAwMwToPXqoCXxyvoP69ft/j4hjhL36Ya+2R/6vbt4s4lUC2CMJHXYZKbYlgS0SURz3PTJZi0hgewYyLsDfhGG8FZE2F9Z3++09/4IinazINLIqnOzA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364876904816.5072299940507; Thu, 21 May 2026 05:01:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ24v-0000o7-0w; Thu, 21 May 2026 08:00:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ243-0008Dn-39 for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ23z-0004jY-Bx for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:46 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-312-uIDWFvsnMbKr2aOBzspkdQ-1; Thu, 21 May 2026 07:59:36 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3157C195605E; Thu, 21 May 2026 11:59:34 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C41FA1800352; Thu, 21 May 2026 11:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T0U31hilbffMwpa0BEq59ZjijcKzDLFO9G55VI/Gf/k=; b=P8cpgta61eahwDAPKLfpsw+mex3C/sq6S0m/OEx9gzp49wDrEKi5vUyS/xRKJKLqv9ahIB YMklb4CjZGJQdoFQFUI3w0ow/E33UR8F63wATrm0zdEqKW9fzrWh8njbw1mLZY6I8MA74b 5q3GuFh7S25FQM7z2t4TCFWSN+QV/LM= X-MC-Unique: uIDWFvsnMbKr2aOBzspkdQ-1 X-Mimecast-MFC-AGG-ID: uIDWFvsnMbKr2aOBzspkdQ_1779364774 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , "Michael S. Tsirkin" , Gerd Hoffmann Subject: [PULL 22/38] hw/input/virtio-input: Use Linux key codes Date: Thu, 21 May 2026 15:56:59 +0400 Message-ID: <20260521115717.1701482-23-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364878664154100 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-14-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- hw/input/virtio-input-hid.c | 40 +++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 1d2e922567a..75fe45d89a2 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -83,23 +83,13 @@ static void virtio_input_handle_event(DeviceState *dev,= QemuConsole *src, { VirtIOInput *vinput =3D VIRTIO_INPUT(dev); virtio_input_event event; - int qcode; =20 switch (evt->type) { case INPUT_EVENT_KIND_KEY: - qcode =3D qemu_input_linux_to_qcode(evt->key.key); - 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(qemu_input_map_qcode_to_linux[qcod= e]); - event.value =3D cpu_to_le32(evt->key.down ? 1 : 0); - virtio_input_send(vinput, &event); - } else { - if (evt->key.down) { - fprintf(stderr, "%s: unmapped key: %d [%s]\n", __func__, - qcode, QKeyCode_str(qcode)); - } - } + event.type =3D cpu_to_le16(EV_KEY); + event.code =3D cpu_to_le16(evt->key.key); + event.value =3D cpu_to_le32(evt->key.down ? 1 : 0); + virtio_input_send(vinput, &event); break; case INPUT_EVENT_KIND_BTN: if ((evt->btn.button =3D=3D INPUT_BUTTON_WHEEL_UP || @@ -293,12 +283,28 @@ static void virtio_keyboard_init(Object *obj) { VirtIOInputHID *vhid =3D VIRTIO_INPUT_HID(obj); VirtIOInput *vinput =3D VIRTIO_INPUT(obj); + virtio_input_config ext =3D { + .select =3D VIRTIO_INPUT_CFG_EV_BITS, + .subsel =3D EV_KEY, + .size =3D DIV_ROUND_UP(KEY_REPLY, 8) + }; + unsigned int i; =20 vhid->handler =3D &virtio_keyboard_handler; virtio_input_init_config(vinput, virtio_keyboard_config); - virtio_input_extend_config(vinput, qemu_input_map_qcode_to_linux, - qemu_input_map_qcode_to_linux_len, - VIRTIO_INPUT_CFG_EV_BITS, EV_KEY); + + /* + * Cover as many keys as possible since we cannot tell what keys the h= ost + * supports. This follows Linux xen-kbdfront's approach: + * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/= diff/drivers/input/xen-kbdfront.c?id=3D4ee36dc08e5c4d16d078f59acd6d9d536f97= 18dd + * + * Stop before KEY_REPLY for migration compatibility. + */ + for (i =3D KEY_ESC; i < KEY_REPLY; i++) { + ext.u.bitmap[i / 8] |=3D (1 << (i % 8)); + } + + virtio_input_add_config(vinput, &ext); } =20 static const TypeInfo virtio_keyboard_info =3D { --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364914; cv=none; d=zohomail.com; s=zohoarc; b=FpCqarB96csJonZ0PJcWfGMqVAmVtyWbrhEj1hApco7Rbv+8eitw6ywIrDeQB0Esao+mYnGZJ8XXx3hJjctWrQPmy+C5ncce3DunkKH0Ug+AXo76WjYTlI9D4b8n9P47K2UsdrCamGnkBte2ZvaoCcBJht4/VV7Icb+9go1otlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364914; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=97IDxt5ABrrAZRFp6P2Tjgy9nMAKPgPJxl//lYafjqE=; b=S7Jr9gMs2m6EH96D9Q7tjQ6ihZm0uLYH3Ht6LQoBFFzIMQCFQs6Rkg7Qp5La4ucC3QKAlzU+u7g1buF/sooUKjtE7yNyoTB5LM9pkcU7Q0hSmtWgSa1B86FqlVPYXxPabLtaLi76ixXxH8Nr2v18eD/kkv4ll8HTRKFo5DT6kHE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364914506707.2954747141705; Thu, 21 May 2026 05:01:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25K-0001AC-Ul; Thu, 21 May 2026 08:01:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ248-00005q-T3 for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ242-0004n7-RP for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:48 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-K47gBb3AOZqqGasccUNEGQ-1; Thu, 21 May 2026 07:59:40 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7E64119560A6; Thu, 21 May 2026 11:59:39 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8351519560AB; Thu, 21 May 2026 11:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=97IDxt5ABrrAZRFp6P2Tjgy9nMAKPgPJxl//lYafjqE=; b=gERpOvNw7a0pkJ/9u61xmgyp7fL00te1WkFieZ6IQfgBhSCvFE4hA+IcQW2MDMwr9+6J9d oIjktnMQIj+VyXvl30VnY1wDUoI3T3r21kRZxg6Hl4Z9zFzNycMLE2EJgmyTMIhVCwXarr nenQ3Lpd5hey5y1eNxVDCw34eY4n3mo= X-MC-Unique: K47gBb3AOZqqGasccUNEGQ-1 X-Mimecast-MFC-AGG-ID: K47gBb3AOZqqGasccUNEGQ_1779364779 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , Thomas Huth Subject: [PULL 23/38] hw/m68k/next-kbd: Use Linux key codes Date: Thu, 21 May 2026 15:57:00 +0400 Message-ID: <20260521115717.1701482-24-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364915939158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-15-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- hw/m68k/next-kbd.c | 118 ++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/hw/m68k/next-kbd.c b/hw/m68k/next-kbd.c index 7efbd806b7c..7be5ab2fb79 100644 --- a/hw/m68k/next-kbd.c +++ b/hw/m68k/next-kbd.c @@ -31,6 +31,7 @@ #include "qemu/log.h" #include "hw/core/sysbus.h" #include "hw/m68k/next-cube.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/console.h" #include "migration/vmstate.h" #include "qom/object.h" @@ -165,59 +166,59 @@ static const MemoryRegionOps kbd_ops =3D { .endianness =3D DEVICE_BIG_ENDIAN, }; =20 -static const int qcode_to_nextkbd_keycode[] =3D { - [Q_KEY_CODE_ESC] =3D 0x49, - [Q_KEY_CODE_1] =3D 0x4a, - [Q_KEY_CODE_2] =3D 0x4b, - [Q_KEY_CODE_3] =3D 0x4c, - [Q_KEY_CODE_4] =3D 0x4d, - [Q_KEY_CODE_5] =3D 0x50, - [Q_KEY_CODE_6] =3D 0x4f, - [Q_KEY_CODE_7] =3D 0x4e, - [Q_KEY_CODE_8] =3D 0x1e, - [Q_KEY_CODE_9] =3D 0x1f, - [Q_KEY_CODE_0] =3D 0x20, - [Q_KEY_CODE_MINUS] =3D 0x1d, - [Q_KEY_CODE_EQUAL] =3D 0x1c, - [Q_KEY_CODE_BACKSPACE] =3D 0x1b, - - [Q_KEY_CODE_Q] =3D 0x42, - [Q_KEY_CODE_W] =3D 0x43, - [Q_KEY_CODE_E] =3D 0x44, - [Q_KEY_CODE_R] =3D 0x45, - [Q_KEY_CODE_T] =3D 0x48, - [Q_KEY_CODE_Y] =3D 0x47, - [Q_KEY_CODE_U] =3D 0x46, - [Q_KEY_CODE_I] =3D 0x06, - [Q_KEY_CODE_O] =3D 0x07, - [Q_KEY_CODE_P] =3D 0x08, - [Q_KEY_CODE_RET] =3D 0x2a, - [Q_KEY_CODE_A] =3D 0x39, - [Q_KEY_CODE_S] =3D 0x3a, - - [Q_KEY_CODE_D] =3D 0x3b, - [Q_KEY_CODE_F] =3D 0x3c, - [Q_KEY_CODE_G] =3D 0x3d, - [Q_KEY_CODE_H] =3D 0x40, - [Q_KEY_CODE_J] =3D 0x3f, - [Q_KEY_CODE_K] =3D 0x3e, - [Q_KEY_CODE_L] =3D 0x2d, - [Q_KEY_CODE_SEMICOLON] =3D 0x2c, - [Q_KEY_CODE_APOSTROPHE] =3D 0x2b, - [Q_KEY_CODE_GRAVE_ACCENT] =3D 0x26, - [Q_KEY_CODE_Z] =3D 0x31, - [Q_KEY_CODE_X] =3D 0x32, - [Q_KEY_CODE_C] =3D 0x33, - [Q_KEY_CODE_V] =3D 0x34, - - [Q_KEY_CODE_B] =3D 0x35, - [Q_KEY_CODE_N] =3D 0x37, - [Q_KEY_CODE_M] =3D 0x36, - [Q_KEY_CODE_COMMA] =3D 0x2e, - [Q_KEY_CODE_DOT] =3D 0x2f, - [Q_KEY_CODE_SLASH] =3D 0x30, - - [Q_KEY_CODE_SPC] =3D 0x38, +static const int linux_to_nextkbd_keycode[] =3D { + [KEY_ESC] =3D 0x49, + [KEY_1] =3D 0x4a, + [KEY_2] =3D 0x4b, + [KEY_3] =3D 0x4c, + [KEY_4] =3D 0x4d, + [KEY_5] =3D 0x50, + [KEY_6] =3D 0x4f, + [KEY_7] =3D 0x4e, + [KEY_8] =3D 0x1e, + [KEY_9] =3D 0x1f, + [KEY_0] =3D 0x20, + [KEY_MINUS] =3D 0x1d, + [KEY_EQUAL] =3D 0x1c, + [KEY_BACKSPACE] =3D 0x1b, + + [KEY_Q] =3D 0x42, + [KEY_W] =3D 0x43, + [KEY_E] =3D 0x44, + [KEY_R] =3D 0x45, + [KEY_T] =3D 0x48, + [KEY_Y] =3D 0x47, + [KEY_U] =3D 0x46, + [KEY_I] =3D 0x06, + [KEY_O] =3D 0x07, + [KEY_P] =3D 0x08, + [KEY_ENTER] =3D 0x2a, + [KEY_A] =3D 0x39, + [KEY_S] =3D 0x3a, + + [KEY_D] =3D 0x3b, + [KEY_F] =3D 0x3c, + [KEY_G] =3D 0x3d, + [KEY_H] =3D 0x40, + [KEY_J] =3D 0x3f, + [KEY_K] =3D 0x3e, + [KEY_L] =3D 0x2d, + [KEY_SEMICOLON] =3D 0x2c, + [KEY_APOSTROPHE] =3D 0x2b, + [KEY_GRAVE] =3D 0x26, + [KEY_Z] =3D 0x31, + [KEY_X] =3D 0x32, + [KEY_C] =3D 0x33, + [KEY_V] =3D 0x34, + + [KEY_B] =3D 0x35, + [KEY_N] =3D 0x37, + [KEY_M] =3D 0x36, + [KEY_COMMA] =3D 0x2e, + [KEY_DOT] =3D 0x2f, + [KEY_SLASH] =3D 0x30, + + [KEY_SPACE] =3D 0x38, }; =20 static void nextkbd_put_keycode(NextKBDState *s, int keycode) @@ -246,15 +247,14 @@ static void nextkbd_event(DeviceState *dev, QemuConso= le *src, QemuInputEvent *evt) { NextKBDState *s =3D NEXTKBD(dev); - int qcode, keycode; + int keycode; =20 - qcode =3D qemu_input_linux_to_qcode(evt->key.key); - if (qcode >=3D ARRAY_SIZE(qcode_to_nextkbd_keycode)) { + if (evt->key.key >=3D ARRAY_SIZE(linux_to_nextkbd_keycode)) { return; } =20 /* Shift key currently has no keycode, so handle separately */ - if (qcode =3D=3D Q_KEY_CODE_SHIFT) { + if (evt->key.key =3D=3D KEY_LEFTSHIFT) { if (evt->key.down) { s->shift |=3D KD_LSHIFT; } else { @@ -262,7 +262,7 @@ static void nextkbd_event(DeviceState *dev, QemuConsole= *src, } } =20 - if (qcode =3D=3D Q_KEY_CODE_SHIFT_R) { + if (evt->key.key =3D=3D KEY_RIGHTSHIFT) { if (evt->key.down) { s->shift |=3D KD_RSHIFT; } else { @@ -270,7 +270,7 @@ static void nextkbd_event(DeviceState *dev, QemuConsole= *src, } } =20 - keycode =3D qcode_to_nextkbd_keycode[qcode]; + keycode =3D linux_to_nextkbd_keycode[evt->key.key]; if (!keycode) { return; } --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365068; cv=none; d=zohomail.com; s=zohoarc; b=NspTuyTyMOnyRRUXcxiP2KoyyMjElz4ochw4tPr5mHmLJd1ns+Lco5JcmK3fNnoBl74dXjDUmaY1D8yT5yp6s89NA06muF/8MyMHGTXnzRf6awvrYkiXw5FrpMDhDg/492m3X80HVfPKiYyp9HFFSTQuUzJNVFksWEqsTthCJOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365068; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NerBL8YhWwt1E/m5BbUsyQi59AL6gFH7Lahx7RmXUec=; b=ZuYLGXz0LvOF0F5Qj6A3AVMvZHpYk7OVghuatihFr62q64BG01+22TzvU5Cib49eX9so9sbFE2Sdy7iy440xc2xBg1yiaIdDhW1xlzC/Sj2saQgHhOt9rsS17Rajj1iahMi7pqZEsDOxlYi8KXc1GljZpcWhwV0ed2a1a0rrg4U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365068255820.2826267809605; Thu, 21 May 2026 05:04:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25z-0003Ns-8N; Thu, 21 May 2026 08:01:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ249-00005s-OG for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ244-0004tB-TK for qemu-devel@nongnu.org; Thu, 21 May 2026 07:59:53 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-400-axRMBSj4MoC6ElkqC2opfA-1; Thu, 21 May 2026 07:59:45 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7D5E019560A5; Thu, 21 May 2026 11:59:44 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 825B930001BE; Thu, 21 May 2026 11:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NerBL8YhWwt1E/m5BbUsyQi59AL6gFH7Lahx7RmXUec=; b=VVny8AHQhf/f/tJvZlztK8iVFekO+sSB/isUDMXH2mfOA2eQblkg5hdXtuZGnI5yBb3bke En7nZH2ny2akncje0hv9SMuMjKryKvyg33ksKF09MLGL4kNRYuZqz1MEPQkydmnsRfFPVQ BeC/qrCHQ6XLBOcrasReyqvT+ORN1NA= X-MC-Unique: axRMBSj4MoC6ElkqC2opfA-1 X-Mimecast-MFC-AGG-ID: axRMBSj4MoC6ElkqC2opfA_1779364784 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PULL 24/38] replay: Use Linux key codes Date: Thu, 21 May 2026 15:57:01 +0400 Message-ID: <20260521115717.1701482-25-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365071538154100 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-16-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- replay/replay-input.c | 20 +++----------------- replay/replay.c | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/replay/replay-input.c b/replay/replay-input.c index acf0993c728..c86e00af0ef 100644 --- a/replay/replay-input.c +++ b/replay/replay-input.c @@ -23,8 +23,7 @@ void replay_save_input_event(QemuInputEvent *evt) =20 switch (evt->type) { case INPUT_EVENT_KIND_KEY: - replay_put_dword(KEY_VALUE_KIND_QCODE); - replay_put_dword(qemu_input_linux_to_qcode(evt->key.key)); + replay_put_dword(evt->key.key); replay_put_byte(evt->key.down); break; case INPUT_EVENT_KIND_BTN: @@ -55,25 +54,12 @@ void replay_save_input_event(QemuInputEvent *evt) QemuInputEvent *replay_read_input_event(void) { QemuInputEvent *evt =3D g_new(QemuInputEvent, 1); - int qcode; =20 evt->type =3D replay_get_dword(); switch (evt->type) { case INPUT_EVENT_KIND_KEY: - switch (replay_get_dword()) { - case KEY_VALUE_KIND_NUMBER: - qcode =3D qemu_input_key_number_to_qcode(replay_get_qword()); - evt->key.down =3D replay_get_byte(); - break; - case KEY_VALUE_KIND_QCODE: - qcode =3D (QKeyCode)replay_get_dword(); - evt->key.down =3D replay_get_byte(); - break; - default: - g_assert_not_reached(); - } - evt->key.key =3D qcode < qemu_input_map_qcode_to_linux_len ? - qemu_input_map_qcode_to_linux[qcode] : 0; + evt->key.key =3D replay_get_dword(); + evt->key.down =3D replay_get_byte(); break; case INPUT_EVENT_KIND_BTN: evt->btn.button =3D (InputButton)replay_get_dword(); diff --git a/replay/replay.c b/replay/replay.c index 2e5c6fa82ea..14437b32566 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -22,7 +22,7 @@ =20 /* Current version of the replay mechanism. Increase it when file format changes. */ -#define REPLAY_VERSION 0xe0200d +#define REPLAY_VERSION 0xe0200e /* Size of replay log header */ #define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint64_t)) =20 --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364869; cv=none; d=zohomail.com; s=zohoarc; b=Gy5FPu+ADzvkk42F+hWEEh0qcsKVajfi+zTRtm2SuiZpT5ua8StDzrJuMywiaDbyJdIrGfYYxyKBQxjZWX4YcZhVBJpMyojBD9dPM1pqOPmnQXlw86FtX+89UjFdypJgwd0MBsMOCSy3m4c16edLORfkbl47XDtfL70TkmD4370= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364869; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i9poQTDTaxKmyym8x3VBqC5ljx/O722hhW1bSKyHHpE=; b=Mqkm5LF4pckssGeGtOTc3qRvr7MWCw2FYeENiL83yOia0p35D53pefeep+GTCICJztraWynE75fqkF1BO1vFNPcHXVCK+Jl4s9Qf9UdO+C1RJ2P4SE+/oGTF3fuIsfrPLaL/ZS0xqqtmwIZVIzHWs59SSejeXGkfxsrA05535ek= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364869758536.0977731583167; Thu, 21 May 2026 05:01:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25C-0000tT-KV; Thu, 21 May 2026 08:01:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24J-0000BA-Ei for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24E-00051O-0Z for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:00 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-211-Yxj3nnFGMcSj3Ve4k1_WFw-1; Thu, 21 May 2026 07:59:51 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B19DC180060D; Thu, 21 May 2026 11:59:50 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C7467300019F; Thu, 21 May 2026 11:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i9poQTDTaxKmyym8x3VBqC5ljx/O722hhW1bSKyHHpE=; b=JDtpSHU9ubi3L81Z++UQvy82QhSVu3FQQNT3KJJ/IHIlZjYZhpwSKEgmzjyAmVPC9f2zUO vLY4drj9JyGaKz0mQ+rfCeZD3zA0fwEorbNxr7bLFuKot0xbgqy/tY9YZf3tTsnj0Y/Ojq +bFnQ7rRKGrWVTFc/GIIsJEG2iZ+eY4= X-MC-Unique: Yxj3nnFGMcSj3Ve4k1_WFw-1 X-Mimecast-MFC-AGG-ID: Yxj3nnFGMcSj3Ve4k1_WFw_1779364790 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 25/38] ui/cocoa: Use Linux key codes Date: Thu, 21 May 2026 15:57:02 +0400 Message-ID: <20260521115717.1701482-26-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364871671154100 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-17-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/cocoa.m | 328 ++++++++++++++++++++++++----------------------------- 1 file changed, 148 insertions(+), 180 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index ee53e7c72ed..c5e639ab98d 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -30,6 +30,7 @@ =20 #include "qemu/help-texts.h" #include "qemu-main.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/clipboard.h" #include "ui/console.h" #include "ui/input.h" @@ -140,124 +141,124 @@ static bool bool_with_bql(BoolCodeBlock block) return val; } =20 -// Mac to QKeyCode conversion -static const int mac_to_qkeycode_map[] =3D { - [kVK_ANSI_A] =3D Q_KEY_CODE_A, - [kVK_ANSI_B] =3D Q_KEY_CODE_B, - [kVK_ANSI_C] =3D Q_KEY_CODE_C, - [kVK_ANSI_D] =3D Q_KEY_CODE_D, - [kVK_ANSI_E] =3D Q_KEY_CODE_E, - [kVK_ANSI_F] =3D Q_KEY_CODE_F, - [kVK_ANSI_G] =3D Q_KEY_CODE_G, - [kVK_ANSI_H] =3D Q_KEY_CODE_H, - [kVK_ANSI_I] =3D Q_KEY_CODE_I, - [kVK_ANSI_J] =3D Q_KEY_CODE_J, - [kVK_ANSI_K] =3D Q_KEY_CODE_K, - [kVK_ANSI_L] =3D Q_KEY_CODE_L, - [kVK_ANSI_M] =3D Q_KEY_CODE_M, - [kVK_ANSI_N] =3D Q_KEY_CODE_N, - [kVK_ANSI_O] =3D Q_KEY_CODE_O, - [kVK_ANSI_P] =3D Q_KEY_CODE_P, - [kVK_ANSI_Q] =3D Q_KEY_CODE_Q, - [kVK_ANSI_R] =3D Q_KEY_CODE_R, - [kVK_ANSI_S] =3D Q_KEY_CODE_S, - [kVK_ANSI_T] =3D Q_KEY_CODE_T, - [kVK_ANSI_U] =3D Q_KEY_CODE_U, - [kVK_ANSI_V] =3D Q_KEY_CODE_V, - [kVK_ANSI_W] =3D Q_KEY_CODE_W, - [kVK_ANSI_X] =3D Q_KEY_CODE_X, - [kVK_ANSI_Y] =3D Q_KEY_CODE_Y, - [kVK_ANSI_Z] =3D Q_KEY_CODE_Z, - - [kVK_ANSI_0] =3D Q_KEY_CODE_0, - [kVK_ANSI_1] =3D Q_KEY_CODE_1, - [kVK_ANSI_2] =3D Q_KEY_CODE_2, - [kVK_ANSI_3] =3D Q_KEY_CODE_3, - [kVK_ANSI_4] =3D Q_KEY_CODE_4, - [kVK_ANSI_5] =3D Q_KEY_CODE_5, - [kVK_ANSI_6] =3D Q_KEY_CODE_6, - [kVK_ANSI_7] =3D Q_KEY_CODE_7, - [kVK_ANSI_8] =3D Q_KEY_CODE_8, - [kVK_ANSI_9] =3D Q_KEY_CODE_9, - - [kVK_ANSI_Grave] =3D Q_KEY_CODE_GRAVE_ACCENT, - [kVK_ANSI_Minus] =3D Q_KEY_CODE_MINUS, - [kVK_ANSI_Equal] =3D Q_KEY_CODE_EQUAL, - [kVK_Delete] =3D Q_KEY_CODE_BACKSPACE, - [kVK_CapsLock] =3D Q_KEY_CODE_CAPS_LOCK, - [kVK_Tab] =3D Q_KEY_CODE_TAB, - [kVK_Return] =3D Q_KEY_CODE_RET, - [kVK_ANSI_LeftBracket] =3D Q_KEY_CODE_BRACKET_LEFT, - [kVK_ANSI_RightBracket] =3D Q_KEY_CODE_BRACKET_RIGHT, - [kVK_ANSI_Backslash] =3D Q_KEY_CODE_BACKSLASH, - [kVK_ANSI_Semicolon] =3D Q_KEY_CODE_SEMICOLON, - [kVK_ANSI_Quote] =3D Q_KEY_CODE_APOSTROPHE, - [kVK_ANSI_Comma] =3D Q_KEY_CODE_COMMA, - [kVK_ANSI_Period] =3D Q_KEY_CODE_DOT, - [kVK_ANSI_Slash] =3D Q_KEY_CODE_SLASH, - [kVK_Space] =3D Q_KEY_CODE_SPC, - - [kVK_ANSI_Keypad0] =3D Q_KEY_CODE_KP_0, - [kVK_ANSI_Keypad1] =3D Q_KEY_CODE_KP_1, - [kVK_ANSI_Keypad2] =3D Q_KEY_CODE_KP_2, - [kVK_ANSI_Keypad3] =3D Q_KEY_CODE_KP_3, - [kVK_ANSI_Keypad4] =3D Q_KEY_CODE_KP_4, - [kVK_ANSI_Keypad5] =3D Q_KEY_CODE_KP_5, - [kVK_ANSI_Keypad6] =3D Q_KEY_CODE_KP_6, - [kVK_ANSI_Keypad7] =3D Q_KEY_CODE_KP_7, - [kVK_ANSI_Keypad8] =3D Q_KEY_CODE_KP_8, - [kVK_ANSI_Keypad9] =3D Q_KEY_CODE_KP_9, - [kVK_ANSI_KeypadDecimal] =3D Q_KEY_CODE_KP_DECIMAL, - [kVK_ANSI_KeypadEnter] =3D Q_KEY_CODE_KP_ENTER, - [kVK_ANSI_KeypadPlus] =3D Q_KEY_CODE_KP_ADD, - [kVK_ANSI_KeypadMinus] =3D Q_KEY_CODE_KP_SUBTRACT, - [kVK_ANSI_KeypadMultiply] =3D Q_KEY_CODE_KP_MULTIPLY, - [kVK_ANSI_KeypadDivide] =3D Q_KEY_CODE_KP_DIVIDE, - [kVK_ANSI_KeypadEquals] =3D Q_KEY_CODE_KP_EQUALS, - [kVK_ANSI_KeypadClear] =3D Q_KEY_CODE_NUM_LOCK, - - [kVK_UpArrow] =3D Q_KEY_CODE_UP, - [kVK_DownArrow] =3D Q_KEY_CODE_DOWN, - [kVK_LeftArrow] =3D Q_KEY_CODE_LEFT, - [kVK_RightArrow] =3D Q_KEY_CODE_RIGHT, - - [kVK_Help] =3D Q_KEY_CODE_INSERT, - [kVK_Home] =3D Q_KEY_CODE_HOME, - [kVK_PageUp] =3D Q_KEY_CODE_PGUP, - [kVK_PageDown] =3D Q_KEY_CODE_PGDN, - [kVK_End] =3D Q_KEY_CODE_END, - [kVK_ForwardDelete] =3D Q_KEY_CODE_DELETE, - - [kVK_Escape] =3D Q_KEY_CODE_ESC, +// Mac to Linux conversion +static const unsigned int mac_to_linux_map[] =3D { + [kVK_ANSI_A] =3D KEY_A, + [kVK_ANSI_B] =3D KEY_B, + [kVK_ANSI_C] =3D KEY_C, + [kVK_ANSI_D] =3D KEY_D, + [kVK_ANSI_E] =3D KEY_E, + [kVK_ANSI_F] =3D KEY_F, + [kVK_ANSI_G] =3D KEY_G, + [kVK_ANSI_H] =3D KEY_H, + [kVK_ANSI_I] =3D KEY_I, + [kVK_ANSI_J] =3D KEY_J, + [kVK_ANSI_K] =3D KEY_K, + [kVK_ANSI_L] =3D KEY_L, + [kVK_ANSI_M] =3D KEY_M, + [kVK_ANSI_N] =3D KEY_N, + [kVK_ANSI_O] =3D KEY_O, + [kVK_ANSI_P] =3D KEY_P, + [kVK_ANSI_Q] =3D KEY_Q, + [kVK_ANSI_R] =3D KEY_R, + [kVK_ANSI_S] =3D KEY_S, + [kVK_ANSI_T] =3D KEY_T, + [kVK_ANSI_U] =3D KEY_U, + [kVK_ANSI_V] =3D KEY_V, + [kVK_ANSI_W] =3D KEY_W, + [kVK_ANSI_X] =3D KEY_X, + [kVK_ANSI_Y] =3D KEY_Y, + [kVK_ANSI_Z] =3D KEY_Z, + + [kVK_ANSI_0] =3D KEY_0, + [kVK_ANSI_1] =3D KEY_1, + [kVK_ANSI_2] =3D KEY_2, + [kVK_ANSI_3] =3D KEY_3, + [kVK_ANSI_4] =3D KEY_4, + [kVK_ANSI_5] =3D KEY_5, + [kVK_ANSI_6] =3D KEY_6, + [kVK_ANSI_7] =3D KEY_7, + [kVK_ANSI_8] =3D KEY_8, + [kVK_ANSI_9] =3D KEY_9, + + [kVK_ANSI_Grave] =3D KEY_GRAVE, + [kVK_ANSI_Minus] =3D KEY_MINUS, + [kVK_ANSI_Equal] =3D KEY_EQUAL, + [kVK_Delete] =3D KEY_BACKSPACE, + [kVK_CapsLock] =3D KEY_CAPSLOCK, + [kVK_Tab] =3D KEY_TAB, + [kVK_Return] =3D KEY_ENTER, + [kVK_ANSI_LeftBracket] =3D KEY_LEFTBRACE, + [kVK_ANSI_RightBracket] =3D KEY_RIGHTBRACE, + [kVK_ANSI_Backslash] =3D KEY_BACKSLASH, + [kVK_ANSI_Semicolon] =3D KEY_SEMICOLON, + [kVK_ANSI_Quote] =3D KEY_APOSTROPHE, + [kVK_ANSI_Comma] =3D KEY_COMMA, + [kVK_ANSI_Period] =3D KEY_DOT, + [kVK_ANSI_Slash] =3D KEY_SLASH, + [kVK_Space] =3D KEY_SPACE, + + [kVK_ANSI_Keypad0] =3D KEY_KP0, + [kVK_ANSI_Keypad1] =3D KEY_KP1, + [kVK_ANSI_Keypad2] =3D KEY_KP2, + [kVK_ANSI_Keypad3] =3D KEY_KP3, + [kVK_ANSI_Keypad4] =3D KEY_KP4, + [kVK_ANSI_Keypad5] =3D KEY_KP5, + [kVK_ANSI_Keypad6] =3D KEY_KP6, + [kVK_ANSI_Keypad7] =3D KEY_KP7, + [kVK_ANSI_Keypad8] =3D KEY_KP8, + [kVK_ANSI_Keypad9] =3D KEY_KP9, + [kVK_ANSI_KeypadDecimal] =3D KEY_KPDOT, + [kVK_ANSI_KeypadEnter] =3D KEY_KPENTER, + [kVK_ANSI_KeypadPlus] =3D KEY_KPPLUS, + [kVK_ANSI_KeypadMinus] =3D KEY_KPMINUS, + [kVK_ANSI_KeypadMultiply] =3D KEY_KPASTERISK, + [kVK_ANSI_KeypadDivide] =3D KEY_KPSLASH, + [kVK_ANSI_KeypadEquals] =3D KEY_KPEQUAL, + [kVK_ANSI_KeypadClear] =3D KEY_NUMLOCK, + + [kVK_UpArrow] =3D KEY_UP, + [kVK_DownArrow] =3D KEY_DOWN, + [kVK_LeftArrow] =3D KEY_LEFT, + [kVK_RightArrow] =3D KEY_RIGHT, + + [kVK_Help] =3D KEY_INSERT, + [kVK_Home] =3D KEY_HOME, + [kVK_PageUp] =3D KEY_PAGEUP, + [kVK_PageDown] =3D KEY_PAGEDOWN, + [kVK_End] =3D KEY_END, + [kVK_ForwardDelete] =3D KEY_DELETE, + + [kVK_Escape] =3D KEY_ESC, =20 /* The Power key can't be used directly because the operating system u= ses * it. This key can be emulated by using it in place of another key su= ch as * F1. Don't forget to disable the real key binding. */ - /* [kVK_F1] =3D Q_KEY_CODE_POWER, */ - - [kVK_F1] =3D Q_KEY_CODE_F1, - [kVK_F2] =3D Q_KEY_CODE_F2, - [kVK_F3] =3D Q_KEY_CODE_F3, - [kVK_F4] =3D Q_KEY_CODE_F4, - [kVK_F5] =3D Q_KEY_CODE_F5, - [kVK_F6] =3D Q_KEY_CODE_F6, - [kVK_F7] =3D Q_KEY_CODE_F7, - [kVK_F8] =3D Q_KEY_CODE_F8, - [kVK_F9] =3D Q_KEY_CODE_F9, - [kVK_F10] =3D Q_KEY_CODE_F10, - [kVK_F11] =3D Q_KEY_CODE_F11, - [kVK_F12] =3D Q_KEY_CODE_F12, - [kVK_F13] =3D Q_KEY_CODE_PRINT, - [kVK_F14] =3D Q_KEY_CODE_SCROLL_LOCK, - [kVK_F15] =3D Q_KEY_CODE_PAUSE, + /* [kVK_F1] =3D KEY_POWER, */ + + [kVK_F1] =3D KEY_F1, + [kVK_F2] =3D KEY_F2, + [kVK_F3] =3D KEY_F3, + [kVK_F4] =3D KEY_F4, + [kVK_F5] =3D KEY_F5, + [kVK_F6] =3D KEY_F6, + [kVK_F7] =3D KEY_F7, + [kVK_F8] =3D KEY_F8, + [kVK_F9] =3D KEY_F9, + [kVK_F10] =3D KEY_F10, + [kVK_F11] =3D KEY_F11, + [kVK_F12] =3D KEY_F12, + [kVK_F13] =3D KEY_SYSRQ, + [kVK_F14] =3D KEY_SCROLLLOCK, + [kVK_F15] =3D KEY_PAUSE, =20 // JIS keyboards only - [kVK_JIS_Yen] =3D Q_KEY_CODE_YEN, - [kVK_JIS_Underscore] =3D Q_KEY_CODE_RO, - [kVK_JIS_KeypadComma] =3D Q_KEY_CODE_KP_COMMA, - [kVK_JIS_Eisu] =3D Q_KEY_CODE_MUHENKAN, - [kVK_JIS_Kana] =3D Q_KEY_CODE_HENKAN, + [kVK_JIS_Yen] =3D KEY_YEN, + [kVK_JIS_Underscore] =3D KEY_RO, + [kVK_JIS_KeypadComma] =3D KEY_KPCOMMA, + [kVK_JIS_Eisu] =3D KEY_MUHENKAN, + [kVK_JIS_Kana] =3D KEY_HENKAN, =20 /* * The eject and volume keys can't be used here because they are handl= ed at @@ -265,13 +266,13 @@ static bool bool_with_bql(BoolCodeBlock block) */ }; =20 -static int cocoa_keycode_to_qemu(int keycode) +static unsigned int cocoa_keycode_to_linux(int keycode) { - if (ARRAY_SIZE(mac_to_qkeycode_map) <=3D keycode) { + if (ARRAY_SIZE(mac_to_linux_map) <=3D keycode) { error_report("(cocoa) warning unknown keycode 0x%x", keycode); return 0; } - return mac_to_qkeycode_map[keycode]; + return mac_to_linux_map[keycode]; } =20 /* Displays an alert dialog box with the specified message */ @@ -766,9 +767,8 @@ - (void) setFullGrab:(id)sender CFRelease(tapEventsSrc); } =20 -- (void) toggleKey: (int)keycode { - unsigned int lnx =3D qemu_input_map_qcode_to_linux[keycode]; - qkbd_state_key_event(kbd, lnx, !qkbd_state_key_get(kbd, lnx)); +- (void) toggleKey: (unsigned int)keycode { + qkbd_state_key_event(kbd, keycode, !qkbd_state_key_get(kbd, keycode)); } =20 // Does the work of sending input to the monitor @@ -848,7 +848,7 @@ - (bool) handleEventLocked:(NSEvent *)event /* Return true if we handled the event, false if it should be given to= OSX */ COCOA_DEBUG("QemuCocoaView: handleEvent\n"); InputButton button; - int keycode =3D 0; + unsigned int keycode; NSUInteger modifiers =3D [event modifierFlags]; =20 /* @@ -890,62 +890,34 @@ - (bool) handleEventLocked:(NSEvent *)event */ if (!!(modifiers & NSEventModifierFlagCapsLock) !=3D qkbd_state_modifier_get(kbd, QKBD_MOD_CAPSLOCK)) { - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_CAPS= _LOCK], - true); - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_CAPS= _LOCK], - false); + qkbd_state_key_event(kbd, KEY_CAPSLOCK, true); + qkbd_state_key_event(kbd, KEY_CAPSLOCK, false); } =20 if (!(modifiers & NSEventModifierFlagShift)) { - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_SHIF= T], - false); - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_SHIF= T_R], - false); + qkbd_state_key_event(kbd, KEY_LEFTSHIFT, false); + qkbd_state_key_event(kbd, KEY_RIGHTSHIFT, false); } if (!(modifiers & NSEventModifierFlagControl)) { - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_CTRL= ], - false); - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_CTRL= _R], - false); + qkbd_state_key_event(kbd, KEY_LEFTCTRL, false); + qkbd_state_key_event(kbd, KEY_RIGHTCTRL, false); } if (!(modifiers & NSEventModifierFlagOption)) { if (swap_opt_cmd) { - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_= META_L], - false); - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_= META_R], - false); + qkbd_state_key_event(kbd, KEY_LEFTMETA, false); + qkbd_state_key_event(kbd, KEY_RIGHTMETA, false); } else { - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_= ALT], - false); - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_= ALT_R], - false); + qkbd_state_key_event(kbd, KEY_LEFTALT, false); + qkbd_state_key_event(kbd, KEY_RIGHTALT, false); } } if (!(modifiers & NSEventModifierFlagCommand)) { if (swap_opt_cmd) { - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_= ALT], - false); - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_= ALT_R], - false); + qkbd_state_key_event(kbd, KEY_LEFTALT, false); + qkbd_state_key_event(kbd, KEY_RIGHTALT, false); } else { - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_= META_L], - false); - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_= META_R], - false); + qkbd_state_key_event(kbd, KEY_LEFTMETA, false); + qkbd_state_key_event(kbd, KEY_RIGHTMETA, false); } } =20 @@ -954,34 +926,34 @@ - (bool) handleEventLocked:(NSEvent *)event switch ([event keyCode]) { case kVK_Shift: if (!!(modifiers & NSEventModifierFlagShift)) { - [self toggleKey:Q_KEY_CODE_SHIFT]; + [self toggleKey:KEY_LEFTSHIFT]; } break; =20 case kVK_RightShift: if (!!(modifiers & NSEventModifierFlagShift)) { - [self toggleKey:Q_KEY_CODE_SHIFT_R]; + [self toggleKey:KEY_RIGHTSHIFT]; } break; =20 case kVK_Control: if (!!(modifiers & NSEventModifierFlagControl)) { - [self toggleKey:Q_KEY_CODE_CTRL]; + [self toggleKey:KEY_LEFTCTRL]; } break; =20 case kVK_RightControl: if (!!(modifiers & NSEventModifierFlagControl)) { - [self toggleKey:Q_KEY_CODE_CTRL_R]; + [self toggleKey:KEY_RIGHTCTRL]; } break; =20 case kVK_Option: if (!!(modifiers & NSEventModifierFlagOption)) { if (swap_opt_cmd) { - [self toggleKey:Q_KEY_CODE_META_L]; + [self toggleKey:KEY_LEFTMETA]; } else { - [self toggleKey:Q_KEY_CODE_ALT]; + [self toggleKey:KEY_LEFTALT]; } } break; @@ -989,9 +961,9 @@ - (bool) handleEventLocked:(NSEvent *)event case kVK_RightOption: if (!!(modifiers & NSEventModifierFlagOption)) { if (swap_opt_cmd) { - [self toggleKey:Q_KEY_CODE_META_R]; + [self toggleKey:KEY_RIGHTMETA]; } else { - [self toggleKey:Q_KEY_CODE_ALT_R]; + [self toggleKey:KEY_RIGHTALT]; } } break; @@ -1002,9 +974,9 @@ - (bool) handleEventLocked:(NSEvent *)event !!(modifiers & NSEventModifierFlagCommand) && left_command_key_enabled) { if (swap_opt_cmd) { - [self toggleKey:Q_KEY_CODE_ALT]; + [self toggleKey:KEY_LEFTALT]; } else { - [self toggleKey:Q_KEY_CODE_META_L]; + [self toggleKey:KEY_LEFTMETA]; } } break; @@ -1013,16 +985,16 @@ - (bool) handleEventLocked:(NSEvent *)event if (isMouseGrabbed && !!(modifiers & NSEventModifierFlagCommand)) { if (swap_opt_cmd) { - [self toggleKey:Q_KEY_CODE_ALT_R]; + [self toggleKey:KEY_RIGHTALT]; } else { - [self toggleKey:Q_KEY_CODE_META_R]; + [self toggleKey:KEY_RIGHTMETA]; } } break; } return true; case NSEventTypeKeyDown: - keycode =3D cocoa_keycode_to_qemu([event keyCode]); + keycode =3D cocoa_keycode_to_linux([event keyCode]); =20 // forward command key combos to the host UI unless the mouse = is grabbed if (!isMouseGrabbed && ([event modifierFlags] & NSEventModifie= rFlagCommand)) { @@ -1052,15 +1024,13 @@ - (bool) handleEventLocked:(NSEvent *)event } =20 if (qemu_console_is_graphic(dcl.con)) { - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[keycode= ], - true); + qkbd_state_key_event(kbd, keycode, true); } else { [self handleMonitorInput: event]; } return true; case NSEventTypeKeyUp: - keycode =3D cocoa_keycode_to_qemu([event keyCode]); + keycode =3D cocoa_keycode_to_linux([event keyCode]); =20 // don't pass the guest a spurious key-up if we treated this // command-key combo as a host UI action @@ -1069,9 +1039,7 @@ - (bool) handleEventLocked:(NSEvent *)event } =20 if (qemu_console_is_graphic(dcl.con)) { - qkbd_state_key_event(kbd, - qemu_input_map_qcode_to_linux[keycode= ], - false); + qkbd_state_key_event(kbd, keycode, false); } return true; case NSEventTypeScrollWheel: --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364957; cv=none; d=zohomail.com; s=zohoarc; b=QTuibjhBhtOLQWChLzpVobp8zFDbNbKIql57V4HGJDbQwyfS2kfeZhk7MPoreBhxX/pbbFfQYu8FbneE5r9TgINcV+rvnYTrflq+ZWd8n2uTTh7rpNzmqduhvLdhrXF6Oj23Hnqt6QXaZqX/OMP8f/iFwal1Y6w4JfDrwyEsMFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364957; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dCK5DNh3LVvKqOCn+8V9JDLnRLBNdd/SI6lBAcoZbH0=; b=OlKGtVCrNs6JvdZ+6MB/FlsMNWFwZZI/MXF1hr/ztbqS7devadR3IP74ZYzrUavTcQzzKctRkbaWxi5Dt+KtU2J9/4cuAYSLg1JoU8DtMlAlxnPXuXAHdqIls8iBXRjpvp/YQJuaXKvSrhkel874Q1+783urbm5XoApY/MD/A18= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364957260265.82281063926155; Thu, 21 May 2026 05:02:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25O-0001Wd-9r; Thu, 21 May 2026 08:01:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24K-0000CH-US for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24J-00051f-5V for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:04 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-298-44h4eWfMNpW2aI-gQqeaOg-1; Thu, 21 May 2026 07:59:57 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5642918002C9; Thu, 21 May 2026 11:59:56 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0E2A21681; Thu, 21 May 2026 11:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dCK5DNh3LVvKqOCn+8V9JDLnRLBNdd/SI6lBAcoZbH0=; b=NMahJ8Jd4cf2JVPl+EU60PMISAiSrx48AC5L3LgIfpfkU/59llYKuHxNmeGDZfx6o5kwqk gI9JhonClKR+Ktr1Y1NdX9QaTJRpnKeNBpz+MX1U66m0dWxKHGN9RmJl8RFGCXBNCIU/D3 pFDoO/4cQNpODiRAsiCFUMuo8TCq3j4= X-MC-Unique: 44h4eWfMNpW2aI-gQqeaOg-1 X-Mimecast-MFC-AGG-ID: 44h4eWfMNpW2aI-gQqeaOg_1779364796 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 26/38] ui/dbus: Use Linux key codes Date: Thu, 21 May 2026 15:57:03 +0400 Message-ID: <20260521115717.1701482-27-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364957962158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-18-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/dbus-console.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 24f4542f312..21eceb24362 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -339,11 +339,11 @@ dbus_kbd_press(DBusDisplayConsole *ddc, GDBusMethodInvocation *invocation, guint arg_keycode) { - QKeyCode qcode =3D qemu_input_key_number_to_qcode(arg_keycode); + unsigned int lnx =3D qemu_input_key_number_to_linux(arg_keycode); =20 trace_dbus_kbd_press(arg_keycode); =20 - qkbd_state_key_event(ddc->kbd, qemu_input_map_qcode_to_linux[qcode], t= rue); + qkbd_state_key_event(ddc->kbd, lnx, true); =20 qemu_dbus_display1_keyboard_complete_press(ddc->iface_kbd, invocation); =20 @@ -355,11 +355,11 @@ dbus_kbd_release(DBusDisplayConsole *ddc, GDBusMethodInvocation *invocation, guint arg_keycode) { - QKeyCode qcode =3D qemu_input_key_number_to_qcode(arg_keycode); + unsigned int lnx =3D qemu_input_key_number_to_linux(arg_keycode); =20 trace_dbus_kbd_release(arg_keycode); =20 - qkbd_state_key_event(ddc->kbd, qemu_input_map_qcode_to_linux[qcode], f= alse); + qkbd_state_key_event(ddc->kbd, lnx, false); =20 qemu_dbus_display1_keyboard_complete_release(ddc->iface_kbd, invocatio= n); =20 --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365103; cv=none; d=zohomail.com; s=zohoarc; b=EOlLkCp7BbFQOCGSZMmkDOeu3PS7Zauh7QBZBwLkX/LWS4j6P8l5mqOHv/XrUvFTagzEZ4oxWxNKoGcrGlQNjzOEDB1PeIgoE0jOS5qIVGmOsIK88v1CEZBQhvAvRKyzUEqTV0mFdaJIKiBCVZD4fHkZDVQXWa/Miui4NCfMcFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365103; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=X1k9ze6YWErIgmVSMwxO43L2UxMS0Nawp0xFT0NHEbY=; b=eyVVtP+QYQyJ05kq7atIymWmcjt44Wt36C3uoxOPZJUB/X2JzEclZ5eLigSLSJPi1v9/zHaZ0HB/0YLALUz+UmojwpcbsmK7jZB9Cj6XTzwU9N5DVuh1z7TjQzAiu5UpsMHLF8ls3NnoutEyLLuBDp71q3EI+lgewQeR/Z7vstQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365103653866.9628162382659; Thu, 21 May 2026 05:05:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25Q-0001rN-Pu; Thu, 21 May 2026 08:01:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24Q-0000IE-91 for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24N-0005En-UN for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:09 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-1zfzQo-jOQiPC3Sb4j4V_g-1; Thu, 21 May 2026 08:00:02 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B151018005B4; Thu, 21 May 2026 12:00:01 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9AF8C300019F; Thu, 21 May 2026 12:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X1k9ze6YWErIgmVSMwxO43L2UxMS0Nawp0xFT0NHEbY=; b=JbKmQdjn4IKnCQgbDXTnZeDPJQEGvPdLlcLs/0oN3hvOye/IXrsFOyzNzGp9pS9Wua4hEs ccPsTC9egGA68Q5rhpcQmmtH8kS7XqHOcUmhyPFEs7/hW2j8YB3E6cS/bhd1gUtvs0HKqk Up11KyyfNf2k5zc69355Qd29dVk4J1M= X-MC-Unique: 1zfzQo-jOQiPC3Sb4j4V_g-1 X-Mimecast-MFC-AGG-ID: 1zfzQo-jOQiPC3Sb4j4V_g_1779364801 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 27/38] ui/gtk: Use Linux key codes Date: Thu, 21 May 2026 15:57:04 +0400 Message-ID: <20260521115717.1701482-28-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365106656158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-19-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/x_keymap.h | 3 ++- ui/gtk.c | 51 ++++++++++++++++++++++++++++--------------------- ui/x_keymap.c | 24 ++++++++++++----------- ui/trace-events | 2 +- 4 files changed, 45 insertions(+), 35 deletions(-) diff --git a/ui/x_keymap.h b/ui/x_keymap.h index 0395e335fff..0d58459dd21 100644 --- a/ui/x_keymap.h +++ b/ui/x_keymap.h @@ -27,6 +27,7 @@ =20 #include =20 -const guint16 *qemu_xkeymap_mapping_table(Display *dpy, size_t *maplen); +const guint16 *qemu_xkeymap_mapping_table(Display *dpy, size_t *maplen, + bool *evdev); =20 #endif diff --git a/ui/gtk.c b/ui/gtk.c index 757ee80fa6a..9f9b2416c8a 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -55,6 +55,7 @@ #include =20 #include "trace.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/input.h" #include "system/runstate.h" #include "system/system.h" @@ -120,6 +121,7 @@ =20 static const guint16 *keycode_map; static size_t keycode_maplen; +static bool keycode_xorgevdev; =20 struct VCChardev { Chardev parent; @@ -1211,39 +1213,42 @@ static gboolean gd_touch_event(GtkWidget *widget, G= dkEventTouch *touch, return TRUE; } =20 -static const guint16 *gd_get_keymap(size_t *maplen) +static const guint16 *gd_get_keymap(size_t *maplen, bool *xorgevdev) { GdkDisplay *dpy =3D gdk_display_get_default(); =20 + *maplen =3D 0; + *xorgevdev =3D false; + #ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY(dpy)) { trace_gd_keymap_windowing("x11"); return qemu_xkeymap_mapping_table( - gdk_x11_display_get_xdisplay(dpy), maplen); + gdk_x11_display_get_xdisplay(dpy), maplen, xorgevdev); } #endif =20 #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY(dpy)) { trace_gd_keymap_windowing("wayland"); - *maplen =3D qemu_input_map_xorgevdev_to_qcode_len; - return qemu_input_map_xorgevdev_to_qcode; + *xorgevdev =3D true; + return NULL; } #endif =20 #ifdef GDK_WINDOWING_WIN32 if (GDK_IS_WIN32_DISPLAY(dpy)) { trace_gd_keymap_windowing("win32"); - *maplen =3D qemu_input_map_atset1_to_qcode_len; - return qemu_input_map_atset1_to_qcode; + *maplen =3D qemu_input_map_atset1_to_linux_len; + return qemu_input_map_atset1_to_linux; } #endif =20 #ifdef GDK_WINDOWING_QUARTZ if (GDK_IS_QUARTZ_DISPLAY(dpy)) { trace_gd_keymap_windowing("quartz"); - *maplen =3D qemu_input_map_osx_to_qcode_len; - return qemu_input_map_osx_to_qcode; + *maplen =3D qemu_input_map_osx_to_linux_len; + return qemu_input_map_osx_to_linux; } #endif =20 @@ -1253,8 +1258,8 @@ static const guint16 *gd_get_keymap(size_t *maplen) g_warning("experimental: using broadway, x11 virtual keysym\n" "mapping - with very limited support. See also\n" "https://bugzilla.gnome.org/show_bug.cgi?id=3D700105"); - *maplen =3D qemu_input_map_x11_to_qcode_len; - return qemu_input_map_x11_to_qcode; + *maplen =3D qemu_input_map_x11_to_linux_len; + return qemu_input_map_x11_to_linux; } #endif =20 @@ -1269,8 +1274,11 @@ static const guint16 *gd_get_keymap(size_t *maplen) } =20 =20 -static int gd_map_keycode(int scancode) +static unsigned int gd_map_keycode(int scancode) { + if (keycode_xorgevdev) { + return scancode < 8 ? KEY_RESERVED : scancode - 8; + } if (!keycode_map) { return 0; } @@ -1307,12 +1315,12 @@ static gboolean gd_text_key_down(GtkWidget *widget, QemuTextConsole *con =3D QEMU_TEXT_CONSOLE(vc->gfx.dcl.con); =20 if (key->keyval =3D=3D GDK_KEY_Delete) { - qemu_text_console_put_qcode(con, Q_KEY_CODE_DELETE, false); + qemu_text_console_put_linux(con, KEY_DELETE, false); } else if (key->length) { qemu_text_console_put_string(con, key->string, key->length); } else { - int qcode =3D gd_map_keycode(gd_get_keycode(key)); - qemu_text_console_put_qcode(con, qcode, false); + unsigned int lnx =3D gd_map_keycode(gd_get_keycode(key)); + qemu_text_console_put_linux(con, lnx, false); } return TRUE; } @@ -1320,7 +1328,8 @@ static gboolean gd_text_key_down(GtkWidget *widget, static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *op= aque) { VirtualConsole *vc =3D opaque; - int keycode, qcode; + int keycode; + unsigned int lnx; =20 #ifdef G_OS_WIN32 /* on windows, we ought to ignore the reserved key event? */ @@ -1343,20 +1352,18 @@ static gboolean gd_key_event(GtkWidget *widget, Gdk= EventKey *key, void *opaque) || key->hardware_keycode =3D=3D VK_PAUSE #endif ) { - qkbd_state_key_event(vc->gfx.kbd, - qemu_input_map_qcode_to_linux[Q_KEY_CODE_PAUS= E], + qkbd_state_key_event(vc->gfx.kbd, KEY_PAUSE, key->type =3D=3D GDK_KEY_PRESS); return TRUE; } =20 keycode =3D gd_get_keycode(key); - qcode =3D gd_map_keycode(keycode); + lnx =3D gd_map_keycode(keycode); =20 - trace_gd_key_event(vc->label, keycode, qemu_input_map_qcode_to_linux[q= code], + trace_gd_key_event(vc->label, keycode, lnx, (key->type =3D=3D GDK_KEY_PRESS) ? "down" : "up"); =20 - qkbd_state_key_event(vc->gfx.kbd, qemu_input_map_qcode_to_linux[qcode], - key->type =3D=3D GDK_KEY_PRESS); + qkbd_state_key_event(vc->gfx.kbd, lnx, key->type =3D=3D GDK_KEY_PRESS); =20 return TRUE; } @@ -2660,7 +2667,7 @@ static void early_gtk_display_init(DisplayOptions *op= ts) #endif } =20 - keycode_map =3D gd_get_keymap(&keycode_maplen); + keycode_map =3D gd_get_keymap(&keycode_maplen, &keycode_xorgevdev); =20 #if defined(CONFIG_VTE) type_register_static(&char_gd_vc_type_info); diff --git a/ui/x_keymap.c b/ui/x_keymap.c index 2ce7b899615..f7dc2edb91d 100644 --- a/ui/x_keymap.c +++ b/ui/x_keymap.c @@ -52,11 +52,12 @@ static gboolean check_for_xquartz(Display *dpy) return match; } =20 -const guint16 *qemu_xkeymap_mapping_table(Display *dpy, size_t *maplen) +const guint16 *qemu_xkeymap_mapping_table(Display *dpy, size_t *maplen, + bool *evdev) { XkbDescPtr desc; const gchar *keycodes =3D NULL; - const guint16 *map; + const guint16 *map =3D NULL; =20 /* There is no easy way to determine what X11 server * and platform & keyboard driver is in use. Thus we @@ -81,24 +82,26 @@ const guint16 *qemu_xkeymap_mapping_table(Display *dpy,= size_t *maplen) XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True); } =20 + *maplen =3D 0; + *evdev =3D false; + if (check_for_xwin(dpy)) { trace_xkeymap_keymap("xwin"); - *maplen =3D qemu_input_map_xorgxwin_to_qcode_len; - map =3D qemu_input_map_xorgxwin_to_qcode; + *maplen =3D qemu_input_map_xorgxwin_to_linux_len; + map =3D qemu_input_map_xorgxwin_to_linux; } else if (check_for_xquartz(dpy)) { trace_xkeymap_keymap("xquartz"); - *maplen =3D qemu_input_map_xorgxquartz_to_qcode_len; - map =3D qemu_input_map_xorgxquartz_to_qcode; + *maplen =3D qemu_input_map_xorgxquartz_to_linux_len; + map =3D qemu_input_map_xorgxquartz_to_linux; } else if ((keycodes && g_str_has_prefix(keycodes, "evdev")) || (XKeysymToKeycode(dpy, XK_Page_Up) =3D=3D 0x70)) { trace_xkeymap_keymap("evdev"); - *maplen =3D qemu_input_map_xorgevdev_to_qcode_len; - map =3D qemu_input_map_xorgevdev_to_qcode; + *evdev =3D true; } else if ((keycodes && g_str_has_prefix(keycodes, "xfree86")) || (XKeysymToKeycode(dpy, XK_Page_Up) =3D=3D 0x63)) { trace_xkeymap_keymap("kbd"); - *maplen =3D qemu_input_map_xorgkbd_to_qcode_len; - map =3D qemu_input_map_xorgkbd_to_qcode; + *maplen =3D qemu_input_map_xorgkbd_to_linux_len; + map =3D qemu_input_map_xorgkbd_to_linux; } else { trace_xkeymap_keymap("NULL"); g_warning("Unknown X11 keycode mapping '%s'.\n" @@ -110,7 +113,6 @@ const guint16 *qemu_xkeymap_mapping_table(Display *dpy,= size_t *maplen) " - xprop -root\n" " - xdpyinfo\n", keycodes ? keycodes : ""); - map =3D NULL; } if (keycodes) { XFree((void *)keycodes); diff --git a/ui/trace-events b/ui/trace-events index 1c0d96a92c3..237f5a65af2 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -22,7 +22,7 @@ ppm_save(int fd, void *image) "fd=3D%d image=3D%p" # gtk.c gd_switch(const char *tab, int width, int height) "tab=3D%s, width=3D%d, h= eight=3D%d" gd_update(const char *tab, int x, int y, int w, int h) "tab=3D%s, x=3D%d, = y=3D%d, w=3D%d, h=3D%d" -gd_key_event(const char *tab, int gdk_keycode, int qkeycode, const char *a= ction) "tab=3D%s, translated GDK keycode %d to QKeyCode %d (%s)" +gd_key_event(const char *tab, int gdk_keycode, unsigned int lnx, const cha= r *action) "tab=3D%s, translated GDK keycode %d to Linux %u (%s)" gd_grab(const char *tab, const char *device, const char *reason) "tab=3D%s= , dev=3D%s, reason=3D%s" gd_ungrab(const char *tab, const char *device) "tab=3D%s, dev=3D%s" gd_keymap_windowing(const char *name) "backend=3D%s" --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364920; cv=none; d=zohomail.com; s=zohoarc; b=XbaQEVD1iqpIUJZ0VnsWck58fxeP0C8makVIKFjBk37GSaTwd3anyKw/2WgR8Gb5lKiRBaV8y6YFCqzcpX/j3B/OlbC19KCIhITz4K693Ic56u7Ydnt0eL2dpw6qyHE9OTCNeEd1fYJ7wERlzLFLI8/9j3m4eR6WjTKPsRSfnik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364920; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gDKvwn/SyrZXV3rhYL87Uo01VJytNE345XYube1Q1xU=; b=nMy6PIhdI6xLXuKq4kgnOdBp/szkq08fxLSRgHBLUFicpYD+2VO4FbpZSBWx3sCuPPAZtrKNLEO+eWK9ZKNoYgbZ6BBS5cGkjKHJZsCWJyAl+9ev8TyTOCU3Ic+YJPSEH/RgxIg7vB+foxS84XHCCfQr/kM8aeyoaC2XRVYRH4c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364920488413.7680886985943; Thu, 21 May 2026 05:02:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25M-0001EU-6r; Thu, 21 May 2026 08:01:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24Y-0000T0-Bm for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24W-0005HG-QO for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:18 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-523-LnMSCsEiMF292slF3T5YCQ-1; Thu, 21 May 2026 08:00:08 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C96F18005B8; Thu, 21 May 2026 12:00:07 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F2651800576; Thu, 21 May 2026 12:00:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gDKvwn/SyrZXV3rhYL87Uo01VJytNE345XYube1Q1xU=; b=KgTGGQPHue54LGm2olKT8eL4sW0czx/MQIlyDJthEW60VD45JMlhsoAHLDvAW2WicCP2Gg Hqk67oBcoYn8yJW3jE8WJJhjB6aar2uxQPdY2JSlQhmKxVX6T/XWalmkS9P2yJxPmrVMcr X6jI5Gqt8xdgn92BTCo0lPgSWh+wLlA= X-MC-Unique: LnMSCsEiMF292slF3T5YCQ-1 X-Mimecast-MFC-AGG-ID: LnMSCsEiMF292slF3T5YCQ_1779364807 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 28/38] ui/input-barrier: Use Linux key codes Date: Thu, 21 May 2026 15:57:05 +0400 Message-ID: <20260521115717.1701482-29-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364921693158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-20-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/input-barrier.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ui/input-barrier.c b/ui/input-barrier.c index 042f63cc5a1..d07027114af 100644 --- a/ui/input-barrier.c +++ b/ui/input-barrier.c @@ -84,11 +84,11 @@ static const char *cmd_names[] =3D { =20 static kbd_layout_t *kbd_layout; =20 -static int input_barrier_to_qcode(uint16_t keyid, uint16_t keycode) +static unsigned int input_barrier_to_linux(uint16_t keyid, uint16_t keycod= e) { /* keycode is optional, if it is not provided use keyid */ - if (keycode && keycode <=3D qemu_input_map_xorgkbd_to_qcode_len) { - return qemu_input_map_xorgkbd_to_qcode[keycode]; + if (keycode && keycode <=3D qemu_input_map_xorgkbd_to_linux_len) { + return qemu_input_map_xorgkbd_to_linux[keycode]; } =20 if (keyid >=3D 0xE000 && keyid <=3D 0xEFFF) { @@ -99,10 +99,10 @@ static int input_barrier_to_qcode(uint16_t keyid, uint1= 6_t keycode) if (kbd_layout) { keycode =3D keysym2scancode(kbd_layout, keyid, NULL, false); =20 - return qemu_input_key_number_to_qcode(keycode); + return qemu_input_key_number_to_linux(keycode); } =20 - return qemu_input_map_x11_to_qcode[keyid]; + return qemu_input_map_x11_to_linux[keyid]; } =20 static int input_barrier_to_mouse(uint8_t buttonid) @@ -431,23 +431,23 @@ static gboolean writecmd(InputBarrier *ib, struct bar= rierMsg *msg) =20 /* keyboard */ case barrierCmdDKeyDown: - qemu_input_event_send_key_qcode(NULL, - input_barrier_to_qcode(msg->key.keyid, msg->key.bu= tton), + qemu_input_event_send_key_linux(NULL, + input_barrier_to_linux(msg->key.keyid, msg->key.bu= tton), true); break; case barrierCmdDKeyRepeat: for (i =3D 0; i < msg->repeat.repeat; i++) { - qemu_input_event_send_key_qcode(NULL, - input_barrier_to_qcode(msg->repeat.keyid, msg->repeat.bu= tton), + qemu_input_event_send_key_linux(NULL, + input_barrier_to_linux(msg->repeat.keyid, msg->repeat.bu= tton), false); - qemu_input_event_send_key_qcode(NULL, - input_barrier_to_qcode(msg->repeat.keyid, msg->repeat.bu= tton), + qemu_input_event_send_key_linux(NULL, + input_barrier_to_linux(msg->repeat.keyid, msg->repeat.bu= tton), true); } break; case barrierCmdDKeyUp: - qemu_input_event_send_key_qcode(NULL, - input_barrier_to_qcode(msg->key.keyid, msg->key.bu= tton), + qemu_input_event_send_key_linux(NULL, + input_barrier_to_linux(msg->key.keyid, msg->key.bu= tton), false); break; default: --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365011; cv=none; d=zohomail.com; s=zohoarc; b=JFYvPxvFL1tr3k1T+LYy6XplzoSCu5umrjfxWUtizBVQ+cQBhXn34FxuvvV9QQ1sLuWcjFbARowz9jH1AJTLfuYHAemnMAtN7oygkk+E5/6H+FNoqb/LhSrn0FKEUf3IBblz/F5ccaZsgP+RqS224SKskAy7vxCDg7IJSOIsEZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365011; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P//1lSfTwWASDwdT7cXVvkeoU6XXunKppQjodyXsuCY=; b=XJCxt7+IwvGSsZC1gPspiU58D4Hnyo802r78MQsuHq9+zq28qIW1NFwMP8tNtjLWwLUbLUHu/KH6qLPj6YcvPFRsTEheCjOwSY9EnBtOpK63KrwCllreq+TRb07YUSHimYwxu2umU8BE0D+58/RtlXXLdDkOaAJ+vhghswScaHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365011689457.10887970842634; Thu, 21 May 2026 05:03:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25O-0001bl-QI; Thu, 21 May 2026 08:01:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24a-0000V7-DO for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24Y-0005HO-9e for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:19 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-501-2eD6iYGoPfiZbXaqmQZOhw-1; Thu, 21 May 2026 08:00:13 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A6CEF18005BE; Thu, 21 May 2026 12:00:12 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 905F419560A3; Thu, 21 May 2026 12:00:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P//1lSfTwWASDwdT7cXVvkeoU6XXunKppQjodyXsuCY=; b=cBmEnHUxhy+VDD3cjsXWhBnGSgAtdTX29ivTyOwzmQKfwx0BXzqxvnh9uTpuv+z/SLKXJh TfnbopnA6xQR0afXfiG1llrkKpqZcgQmjS8vPcGoE1pFFl0hr2N6Y5RzCTwh4CcFI9oZ1t UshG4eXgTyoQNy32jB9ofegqbM4alGk= X-MC-Unique: 2eD6iYGoPfiZbXaqmQZOhw-1 X-Mimecast-MFC-AGG-ID: 2eD6iYGoPfiZbXaqmQZOhw_1779364812 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 29/38] ui/input-legacy: Use Linux key codes Date: Thu, 21 May 2026 15:57:06 +0400 Message-ID: <20260521115717.1701482-30-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365013696158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-21-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/input-legacy.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/ui/input-legacy.c b/ui/input-legacy.c index e2b48dd8f0a..193c9ae2ef9 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -71,23 +71,11 @@ int index_from_key(const char *key, size_t key_length) return i; } =20 -static KeyValue *copy_key_value(KeyValue *src) -{ - KeyValue *dst =3D g_new(KeyValue, 1); - memcpy(dst, src, sizeof(*src)); - if (dst->type =3D=3D KEY_VALUE_KIND_NUMBER) { - QKeyCode code =3D qemu_input_key_number_to_qcode(dst->u.number.dat= a); - dst->type =3D KEY_VALUE_KIND_QCODE; - dst->u.qcode.data =3D code; - } - return dst; -} - void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_tim= e, Error **errp) { KeyValueList *p; - KeyValue **up =3D NULL; + unsigned int *up =3D NULL; int count =3D 0; =20 if (!has_hold_time) { @@ -95,15 +83,15 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_tim= e, int64_t hold_time, } =20 for (p =3D keys; p !=3D NULL; p =3D p->next) { - qemu_input_event_send_key(NULL, copy_key_value(p->value), true); - qemu_input_event_send_key_delay(hold_time); up =3D g_realloc(up, sizeof(*up) * (count+1)); - up[count] =3D copy_key_value(p->value); + up[count] =3D qemu_input_key_value_to_linux(p->value); + qemu_input_event_send_key_linux(NULL, up[count], true); + qemu_input_event_send_key_delay(hold_time); count++; } while (count) { count--; - qemu_input_event_send_key(NULL, up[count], false); + qemu_input_event_send_key_linux(NULL, up[count], false); qemu_input_event_send_key_delay(hold_time); } g_free(up); --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365068; cv=none; d=zohomail.com; s=zohoarc; b=Xclmu5EVelVZFNU3/z11XUVrpZ1VH47b7DR8G5j2bvZH0dvYfhHD15YF9wChRbc9JPg3YQ3dkcx85f2dJK9HuJudk8GavJf0OhhXS14RohgJcfV/rBC4b88LcZPRW7r7YYIyt+AncJHc16w1vGLf9x3zLAgIiHsIht436GF2AsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365068; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sBZPAL2OmLnFOXytxhEUqPKK0xQUtQHNqYgdlRra34U=; b=eINP8/I++MNhKnnuqMmg5ftSFtdge4yqI7zx1tSEnQxRDjharKsEjnSbsmjHL5r9AWEd4/AM0ZE5+RMo8PawW9nrezgFdKJW3o/IubDCboYJovbgYMR2KY/4LYJBd4VC5QSfCVcxp34wIguylcc+j+NCr0jOzG9uI3Bk6xIjaPs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177936506821910.102186613108756; Thu, 21 May 2026 05:04:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25T-0002G9-MD; Thu, 21 May 2026 08:01:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24l-0000ks-0O for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24e-0005Ht-BX for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:25 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-103-CAkTix-HMFWf2Vuuk_k46A-1; Thu, 21 May 2026 08:00:19 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D30C11956054; Thu, 21 May 2026 12:00:17 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CAC9819560AB; Thu, 21 May 2026 12:00:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sBZPAL2OmLnFOXytxhEUqPKK0xQUtQHNqYgdlRra34U=; b=fLC5rZQ3DnUd9S92awDg8gyleOKukNIidtoyieKR7KIQ2efWZpBDrDUExm8u98OV+SmiVt LY8ujbZ0TPi5pliEEiM/A1hiGUI44cpGdvs2ktg+3lcOxLLo+c/2mGUDlyMrI/OsYVNm3r jW2uef3IUAdHGStMPXKMZIybcXOrXzc= X-MC-Unique: CAkTix-HMFWf2Vuuk_k46A-1 X-Mimecast-MFC-AGG-ID: CAkTix-HMFWf2Vuuk_k46A_1779364817 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 30/38] ui/input-linux: Use Linux key codes Date: Thu, 21 May 2026 15:57:07 +0400 Message-ID: <20260521115717.1701482-31-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365068893158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-22-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/input-linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/input-linux.c b/ui/input-linux.c index 74bc8511428..f4eee1ffd7e 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -166,8 +166,7 @@ static void input_linux_handle_keyboard(InputLinux *il, =20 /* send event to guest when grab is active */ if (il->grab_active && !input_linux_should_skip(il, event)) { - int qcode =3D qemu_input_linux_to_qcode(event->code); - qemu_input_event_send_key_qcode(NULL, qcode, event->value); + qemu_input_event_send_key_linux(NULL, event->code, event->valu= e); } =20 /* hotkey -> record switch request ... */ --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365102; cv=none; d=zohomail.com; s=zohoarc; b=RW2HcLSbuxGm3a4r8KWTwrM6sV/LnuRKM18wBu2wg4S2fa1WlCf0/+LmfM/sIRUt6wbNiR4MYbWy/oj9d85uKVVuboBlPs43jj/3B8MraYDAtHYSXbo9CZRwu566VLAH+8ORG+TLLgtajzwll9Wse8v6lcvjDVGZN5dEBaJiaiI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365102; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iwE4iTcBWb64Ub5rQet8X4bkTzR6yTjGdriwiUrqn4Q=; b=OKWKTAXNtuicvyHiLCJoNCslW0s+963N9g0g4pPk7ZPJtBnemz+IdGLDscleJyHK7f2zeQ8kG7utOUQtLVmv7nsIKvMj/DYruPBG9dAp75XmuOml95xEWryi81jwX/SluUI52jwqRf8Vi0prXTAKz7v0D1WxWHvp3yoHHbRn/O4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365102618866.3679305592838; Thu, 21 May 2026 05:05:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25Q-0001o4-7n; Thu, 21 May 2026 08:01:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24n-0000ot-E2 for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24l-0005IP-7G for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:32 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-JX9X_MmMOR2q0CVxG5Cy4A-1; Thu, 21 May 2026 08:00:24 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1C74C19560AA; Thu, 21 May 2026 12:00:23 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 230EB19560AB; Thu, 21 May 2026 12:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iwE4iTcBWb64Ub5rQet8X4bkTzR6yTjGdriwiUrqn4Q=; b=Q6Z7M+nBbWuI5qp7Yn0i0LvMyL4cPG7WSTOWL4gsoLf4/0fhmIimSJwy9VbNobVLICgNZL ovycJOYYQfhQhaIN1EmWpyd0c/EEI+AorDuR3imsaRP1snyJT0mtO4GMbtyTdxiDq3H8Bp JMo9C0MsEOdQtQbYqYqCmrZq3gszLWw= X-MC-Unique: JX9X_MmMOR2q0CVxG5Cy4A-1 X-Mimecast-MFC-AGG-ID: JX9X_MmMOR2q0CVxG5Cy4A_1779364823 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 31/38] ui/keymaps: Use Linux key codes Date: Thu, 21 May 2026 15:57:08 +0400 Message-ID: <20260521115717.1701482-32-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365103890158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-23-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/keymaps.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/keymaps.c b/ui/keymaps.c index a448efab320..d145b5dd3a8 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -255,9 +255,8 @@ int keysym2scancode(kbd_layout_t *k, int keysym, * On keyup: Try find a key which is actually down. */ for (i =3D 0; i < keysym2code->count; i++) { - QKeyCode qcode =3D qemu_input_key_number_to_qcode + unsigned int lnx =3D qemu_input_key_number_to_linux (keysym2code->keycodes[i]); - unsigned int lnx =3D qemu_input_map_qcode_to_linux[qcode]; if (kbd && qkbd_state_key_get(kbd, lnx)) { return keysym2code->keycodes[i]; } --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365000; cv=none; d=zohomail.com; s=zohoarc; b=Ulb3OVZC1KksK8lSoyCRNFeSIafjPtcK3zDwKgrOQBey8sFN6bpWJvNn1URGuElo2cMlPgRnfh/o/4pWaO2H6McRMHrxVbUloqC/RSjxtgFuojMEa2RY8GHtBMJkY2nbpIIXHqnBk9YzYiMOf+jYb42u7BTn06IwCHfZkUTgBlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365000; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r2P4H/6PC/PtAzXZKuJPQilzhN2AYohJ5V5fNf5KF9A=; b=H9m9YeseczJO7Cgkv95bCSAs2A54SsQS8RgHiNTxKEf1Ylx9895MgdacoWGxRCemYGUAh9QafmmHkUkC87vsB7j5Mrjao6xZPYlSujENESr/KEsPnSpbIO4avMFSVHhyMTqo8pMCc9deZ0XMpHVgaMzOmMJKlxIx3JJ24O1r1Eg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365000700944.9820477099865; Thu, 21 May 2026 05:03:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25S-00023o-3K; Thu, 21 May 2026 08:01:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24t-0000rB-4m for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24p-0005Ip-Sr for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:38 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-dmZoFh_iPRuKDPkh1kkfxA-1; Thu, 21 May 2026 08:00:30 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C16A21956060; Thu, 21 May 2026 12:00:28 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7A51719560AB; Thu, 21 May 2026 12:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r2P4H/6PC/PtAzXZKuJPQilzhN2AYohJ5V5fNf5KF9A=; b=Wyqi843WAHXzIYDPwu/MWlZptcayQIP0YxUdhaYrkwUl2PIjlcag3TEvN2ABUDWkSV2VWr 6wXMTCGMxi+urgYSoq5ylkeZUg7Tf9S21q4+8OPHLegcjupm7UPz6sJg4kZ81ZYU+OZDgE CUNfjPhZOmhi4/1f41J8a6CyWgXM1WA= X-MC-Unique: dmZoFh_iPRuKDPkh1kkfxA-1 X-Mimecast-MFC-AGG-ID: dmZoFh_iPRuKDPkh1kkfxA_1779364828 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 32/38] ui/sdl2: Use Linux key codes Date: Thu, 21 May 2026 15:57:09 +0400 Message-ID: <20260521115717.1701482-33-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365001141158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-24-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/sdl2-input.c | 18 +++++++++--------- ui/trace-events | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c index fdbdc427dc9..7bebc3f3e5c 100644 --- a/ui/sdl2-input.c +++ b/ui/sdl2-input.c @@ -24,6 +24,7 @@ /* Ported SDL 1.2 code to 2.0 by Dave Airlie. */ =20 #include "qemu/osdep.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/console.h" #include "ui/input.h" #include "ui/sdl2.h" @@ -32,28 +33,27 @@ void sdl2_process_key(struct sdl2_console *scon, SDL_KeyboardEvent *ev) { - int qcode; + unsigned int lnx; QemuConsole *con =3D scon->dcl.con; =20 - if (ev->keysym.scancode >=3D qemu_input_map_usb_to_qcode_len) { + if (ev->keysym.scancode >=3D qemu_input_map_usb_to_linux_len) { return; } - qcode =3D qemu_input_map_usb_to_qcode[ev->keysym.scancode]; - trace_sdl2_process_key(ev->keysym.scancode, qcode, + lnx =3D qemu_input_map_usb_to_linux[ev->keysym.scancode]; + trace_sdl2_process_key(ev->keysym.scancode, lnx, ev->type =3D=3D SDL_KEYDOWN ? "down" : "up"); - qkbd_state_key_event(scon->kbd, qemu_input_map_qcode_to_linux[qcode], - ev->type =3D=3D SDL_KEYDOWN); + qkbd_state_key_event(scon->kbd, lnx, ev->type =3D=3D SDL_KEYDOWN); =20 if (QEMU_IS_TEXT_CONSOLE(con)) { QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(con); bool ctrl =3D qkbd_state_modifier_get(scon->kbd, QKBD_MOD_CTRL); if (ev->type =3D=3D SDL_KEYDOWN) { - switch (qcode) { - case Q_KEY_CODE_RET: + switch (lnx) { + case KEY_ENTER: qemu_text_console_put_keysym(s, '\n'); break; default: - qemu_text_console_put_qcode(s, qcode, ctrl); + qemu_text_console_put_linux(s, lnx, ctrl); break; } } diff --git a/ui/trace-events b/ui/trace-events index 237f5a65af2..339a61f3415 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -135,7 +135,7 @@ input_event_mtt(int conidx, const char *axis, int value= ) "con %d, axis %s, value input_event_sync(void) "" =20 # sdl2-input.c -sdl2_process_key(int sdl_scancode, int qcode, const char *action) "transla= ted SDL scancode %d to QKeyCode %d (%s)" +sdl2_process_key(int sdl_scancode, unsigned int lnx, const char *action) "= translated SDL scancode %d to Linux scancode %u (%s)" =20 # spice-display.c qemu_spice_add_memslot(int qid, uint32_t slot_id, unsigned long virt_start= , unsigned long virt_end, int async) "%d %u: host virt 0x%lx - 0x%lx async= =3D%d" --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365070; cv=none; d=zohomail.com; s=zohoarc; b=KqgBcu6/sk2ZX7w97yCq2O2sRd+dY5+fyNGC+lgDJiLPZp86uBctrlmpHwcnnshgcLQKdG9MpYsyl6m/sN/x6kOSmYYy3b1D2UbZgxoqB+fGW+byai5w+HG95l+VELfQ3jayfYWCXKVD+IneINi3FSoV9fqzkm5QL5JZwlYWqTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365070; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eo/torMXRmw2KXbPEuUYi8EP3nU9GnWFaWfOmb/VO6s=; b=ZqAnzcnZagjglJyq9rYhOTV3Fw0jZHrKR2ODEmzDzUTjsBy/FngMIpcpC+1zD80xm66ZIv+NkqEuRCy4GLGVy1xVy36mUyvkD8UEccDjPuu0DLWZHrIQTsTVvOSKJ4ChtqXqcR7DgwNpPrafNg7E8aenee9jELSEoEBRiAA5P+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177936507023524.464018566368622; Thu, 21 May 2026 05:04:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25T-0002Gn-RF; Thu, 21 May 2026 08:01:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24v-0000tP-2H for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24s-0005J4-VT for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:40 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-l3D9jmiRNiu5lWSJaH9bZQ-1; Thu, 21 May 2026 08:00:36 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 479A319560BE; Thu, 21 May 2026 12:00:34 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F29BD1800357; Thu, 21 May 2026 12:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eo/torMXRmw2KXbPEuUYi8EP3nU9GnWFaWfOmb/VO6s=; b=D62shcI76wCA6SXtJq/nHZXqfCfO/D6DRR5sck25NKhrfqaBxD+eHmbNKlWocamNJiXei4 hntmQctxpo91A+7YuYcSg04ELxzIZqGwy7utNGbBTHFo3no1gYYhRNcZL50wDRBGr5f+Q+ MEPazYT65HVSUoCUw2FExSdZGf8ypPc= X-MC-Unique: l3D9jmiRNiu5lWSJaH9bZQ-1 X-Mimecast-MFC-AGG-ID: l3D9jmiRNiu5lWSJaH9bZQ_1779364834 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 33/38] ui/spice: Use Linux key codes Date: Thu, 21 May 2026 15:57:10 +0400 Message-ID: <20260521115717.1701482-34-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365071209158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-25-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/spice-input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/spice-input.c b/ui/spice-input.c index a5c5d78474e..f0bb915fd77 100644 --- a/ui/spice-input.c +++ b/ui/spice-input.c @@ -20,6 +20,7 @@ #include #include =20 +#include "standard-headers/linux/input-event-codes.h" #include "ui/qemu-spice.h" #include "ui/console.h" #include "keymaps.h" @@ -61,7 +62,7 @@ static void kbd_push_key(SpiceKbdInstance *sin, uint8_t s= cancode) if (scancode =3D=3D pauseseq[kbd->pauseseq]) { kbd->pauseseq++; if (kbd->pauseseq =3D=3D G_N_ELEMENTS(pauseseq)) { - qemu_input_event_send_key_qcode(NULL, Q_KEY_CODE_PAUSE, true); + qemu_input_event_send_key_linux(NULL, KEY_PAUSE, true); kbd->pauseseq =3D 0; } return; --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365065; cv=none; d=zohomail.com; s=zohoarc; b=ZKA9fbeTDrrQ5cNqf+a59rUXERqWvIYluORPEOKMG1UqaTLFaDxSHpavIoL0i5Sf4N5JCBBf5UO74y7erlWAwjz8EPTtfKtOdZXp0EpTyJXmRgjODcRZOYdaQXkAiT51vSqxr/MHbtGpIbtvE4j8tPShnthYz1g6y2bKeV5dd3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365065; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Hd0xYnHBvyjtVBtRC55QRg5lDeTSmz6H7RfmG0DsJr0=; b=f0PnMEqc812/0r8IyV1K+E6et7kswqhbHfyXPS+wWTT/+p/C7+RtVU9+AmkGV0+1Uul5tYh8f4V3GdjDgQ525ieuw+KY70aVNPqEyC6rpatCwbsmE5wCEcO0n1Vm7mNJqzLqKDlgEB6tQ+2fFQ86ZFByxq2T2g4fPAZ7EHpxopA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365065327587.1983920507083; Thu, 21 May 2026 05:04:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25S-00022d-0f; Thu, 21 May 2026 08:01:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ251-0000w1-2Q for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ24z-0005JX-36 for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:46 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-EdSrxksnMw6-k2E7ndOSkg-1; Thu, 21 May 2026 08:00:40 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A4FDE180044D; Thu, 21 May 2026 12:00:39 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 48EE01800576; Thu, 21 May 2026 12:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hd0xYnHBvyjtVBtRC55QRg5lDeTSmz6H7RfmG0DsJr0=; b=P3butxpKb7lufq+X13XBI5wwPm3bm6sE16NdpCuIXC7+Q8zUnKMdcU0CnELJDaBW/rijxW KBZv91orR6pdXn+of9SWnTsvXwy2Yi1Dco38YHxVpKD0xUuXYsETfCJpo26/nc3A+muxj0 RCHDD0YxZlfVGVTX+xPNDWDK4XFs10k= X-MC-Unique: EdSrxksnMw6-k2E7ndOSkg-1 X-Mimecast-MFC-AGG-ID: EdSrxksnMw6-k2E7ndOSkg_1779364839 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 34/38] ui/vnc: Use Linux key codes Date: Thu, 21 May 2026 15:57:11 +0400 Message-ID: <20260521115717.1701482-35-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365067507154100 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-26-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- ui/vnc.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index f521d9f2ad4..9042816ae6f 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -43,6 +43,7 @@ #include "qapi/qapi-events-ui.h" #include "qapi/error.h" #include "qapi/qapi-commands-ui.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/console.h" #include "ui/input.h" #include "crypto/hash.h" @@ -1797,13 +1798,10 @@ static void pointer_event(VncState *vs, int button_= mask, int x, int y) qemu_input_event_sync(); } =20 -static void press_key(VncState *vs, QKeyCode qcode) +static void press_key(VncState *vs, unsigned int lnx) { - qkbd_state_key_event(vs->vd->kbd, qemu_input_map_qcode_to_linux[qcode], - true); - - qkbd_state_key_event(vs->vd->kbd, qemu_input_map_qcode_to_linux[qcode], - false); + qkbd_state_key_event(vs->vd->kbd, lnx, true); + qkbd_state_key_event(vs->vd->kbd, lnx, false); } =20 static void vnc_led_state_change(VncState *vs) @@ -1844,15 +1842,15 @@ static void kbd_leds(void *opaque, int ledstate) =20 static void do_key_event(VncState *vs, int down, int keycode, int sym) { - QKeyCode qcode =3D qemu_input_key_number_to_qcode(keycode); + unsigned int lnx =3D qemu_input_key_number_to_linux(keycode); =20 /* QEMU console switch */ - switch (qcode) { - case Q_KEY_CODE_1 ... Q_KEY_CODE_9: /* '1' to '9' keys */ + switch (lnx) { + case KEY_1 ... KEY_9: /* '1' to '9' keys */ if (down && qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_CTRL) && qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_ALT)) { - QemuConsole *con =3D qemu_console_lookup_by_index(qcode - Q_KE= Y_CODE_1); + QemuConsole *con =3D qemu_console_lookup_by_index(lnx - KEY_1); if (con) { qemu_console_unregister_listener(&vs->vd->dcl); qkbd_state_switch_console(vs->vd->kbd, con); @@ -1877,12 +1875,12 @@ static void do_key_event(VncState *vs, int down, in= t keycode, int sym) if (keysym_is_numlock(vs->vd->kbd_layout, sym & 0xFFFF)) { if (!qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_NUMLOCK)) { trace_vnc_key_sync_numlock(true); - press_key(vs, Q_KEY_CODE_NUM_LOCK); + press_key(vs, KEY_NUMLOCK); } } else { if (qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_NUMLOCK)) { trace_vnc_key_sync_numlock(false); - press_key(vs, Q_KEY_CODE_NUM_LOCK); + press_key(vs, KEY_NUMLOCK); } } } @@ -1900,18 +1898,17 @@ static void do_key_event(VncState *vs, int down, in= t keycode, int sym) if (capslock) { if (uppercase =3D=3D shift) { trace_vnc_key_sync_capslock(false); - press_key(vs, Q_KEY_CODE_CAPS_LOCK); + press_key(vs, KEY_CAPSLOCK); } } else { if (uppercase !=3D shift) { trace_vnc_key_sync_capslock(true); - press_key(vs, Q_KEY_CODE_CAPS_LOCK); + press_key(vs, KEY_CAPSLOCK); } } } =20 - qkbd_state_key_event(vs->vd->kbd, qemu_input_map_qcode_to_linux[qcode], - down); + qkbd_state_key_event(vs->vd->kbd, lnx, down); if (QEMU_IS_TEXT_CONSOLE(vs->vd->dcl.con)) { QemuTextConsole *con =3D QEMU_TEXT_CONSOLE(vs->vd->dcl.con); bool numlock =3D qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_NUM= LOCK); --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365080; cv=none; d=zohomail.com; s=zohoarc; b=FGmVlaMuK95cbaMnys6eBYVPyou7guTxe6kYQypTCWhTHad9HxwrhdmDtWtEQYeYBycI8yIdUbZNnyy8OQAYqh6FfaQ5RPWr0Xiy+AuZmJ8YLDq/5wNtQgAR5/132I0O9aItCZ488mxyGXSzuxX/DjiUtqqbuPaVqqLEkKDIfyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365080; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vjoBPmei4647K9iNewDWHgX2To85h2zBJDJVBwfPIWo=; b=R/b03BXMOgXWRgCD+bZ7FiLcuXq2UJaL+wWtYog9JSSPxbI/0NWuSzL86Qouo/hUbdOt0XoEfO8qwnuYwvWuod7jK9HR8cLQtwLamwdI8SjmAxbydfw4P6PmQpwI/TFEFUDXCViboZ+iUCpcMJCHxvCpJ/TSlSBFcuwzgqndexM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365080671191.17868856439043; Thu, 21 May 2026 05:04:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25Q-0001mN-63; Thu, 21 May 2026 08:01:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ254-0000wg-LX for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ253-0005Jo-2a for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:50 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-ce1O40caOi2UexbAsiLCBQ-1; Thu, 21 May 2026 08:00:46 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C8E7519560A2; Thu, 21 May 2026 12:00:44 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CEF2F1800576; Thu, 21 May 2026 12:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vjoBPmei4647K9iNewDWHgX2To85h2zBJDJVBwfPIWo=; b=aeNAFpPQ+4gOVLD/dHwI9ThqFztehiHi1z3HzRkRQors5guvzw2/11FMCOJwx17LlUVW+/ 0F/goSbSSwSTEV+ZB51UiO3INmsYfo6hM7wEMVuplt6dYbpV/6ZZJMlLDeY43PP/qXbIFX c3c59+7F2Im+PLlipYJ2nm3U2YX7oMs= X-MC-Unique: ce1O40caOi2UexbAsiLCBQ-1 X-Mimecast-MFC-AGG-ID: ce1O40caOi2UexbAsiLCBQ_1779364844 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki Subject: [PULL 35/38] qemu-keymap: Use Linux key codes Date: Thu, 21 May 2026 15:57:12 +0400 Message-ID: <20260521115717.1701482-36-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365081629158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-27-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- qemu-keymap.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/qemu-keymap.c b/qemu-keymap.c index d4dccf456ef..d63b6be8ce3 100644 --- a/qemu-keymap.c +++ b/qemu-keymap.c @@ -11,6 +11,7 @@ */ #include "qemu/osdep.h" #include "qemu/notify.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/input.h" =20 #include @@ -32,19 +33,17 @@ static FILE *outfile; =20 /* -----------------------------------------------------------------------= - */ =20 -static uint32_t qcode_to_number(uint32_t qcode) +static uint32_t linux_to_number(uint32_t lnx) { - KeyValue keyvalue; uint32_t number; =20 - keyvalue.type =3D KEY_VALUE_KIND_QCODE; - keyvalue.u.qcode.data =3D qcode; - number =3D qemu_input_key_value_to_number(&keyvalue); + assert(lnx < qemu_input_map_linux_to_qnum_len); + number =3D qemu_input_map_linux_to_qnum[lnx]; assert(number !=3D 0); return number; } =20 -static void print_sym(xkb_keysym_t sym, uint32_t qcode, const char *mod) +static void print_sym(xkb_keysym_t sym, uint32_t lnx, const char *mod) { char name[64]; =20 @@ -54,7 +53,7 @@ static void print_sym(xkb_keysym_t sym, uint32_t qcode, c= onst char *mod) xkb_keysym_get_name(sym, name, sizeof(name)); =20 /* TODO: make ui/keymap.c parser accept QKeyCode names */ - fprintf(outfile, "%s 0x%02x%s\n", name, qcode_to_number(qcode), mod); + fprintf(outfile, "%s 0x%02x%s\n", name, linux_to_number(lnx), mod); } =20 static void walk_map(struct xkb_keymap *map, xkb_keycode_t code, void *dat= a) @@ -84,37 +83,37 @@ static void walk_map(struct xkb_keymap *map, xkb_keycod= e_t code, void *data) fprintf(outfile, "# evdev %d (0x%x), QKeyCode \"%s\", number 0x%x\n", evdev, evdev, QKeyCode_str(qcode), - qcode_to_number(qcode)); + linux_to_number(evdev)); =20 /* * check which modifier states generate which keysyms */ xkb_state_update_mask(state, 0, 0, 0, 0, 0, 0); kbase =3D xkb_state_key_get_one_sym(state, code); - print_sym(kbase, qcode, ""); + print_sym(kbase, evdev, ""); =20 xkb_state_update_mask(state, 0, 0, numlock, 0, 0, 0); knumlock =3D xkb_state_key_get_one_sym(state, code); if (kbase !=3D knumlock) { - print_sym(knumlock, qcode, " numlock"); + print_sym(knumlock, evdev, " numlock"); } =20 xkb_state_update_mask(state, shift, 0, 0, 0, 0, 0); kshift =3D xkb_state_key_get_one_sym(state, code); if (kbase !=3D kshift && knumlock !=3D kshift) { - print_sym(kshift, qcode, " shift"); + print_sym(kshift, evdev, " shift"); } =20 xkb_state_update_mask(state, altgr, 0, 0, 0, 0, 0); kaltgr =3D xkb_state_key_get_one_sym(state, code); if (kbase !=3D kaltgr) { - print_sym(kaltgr, qcode, " altgr"); + print_sym(kaltgr, evdev, " altgr"); } =20 xkb_state_update_mask(state, altgr | shift, 0, 0, 0, 0, 0); kaltgrshift =3D xkb_state_key_get_one_sym(state, code); if (kshift !=3D kaltgrshift && kaltgr !=3D kaltgrshift) { - print_sym(kaltgrshift, qcode, " shift altgr"); + print_sym(kaltgrshift, evdev, " shift altgr"); } } =20 @@ -251,16 +250,16 @@ int main(int argc, char *argv[]) "# keysyms. So append them here.\n" "#\n" "\n"); - print_sym(XKB_KEY_Print, Q_KEY_CODE_SYSRQ, ""); - print_sym(XKB_KEY_Sys_Req, Q_KEY_CODE_SYSRQ, ""); - print_sym(XKB_KEY_Execute, Q_KEY_CODE_SYSRQ, ""); + print_sym(XKB_KEY_Print, KEY_SYSRQ, ""); + print_sym(XKB_KEY_Sys_Req, KEY_SYSRQ, ""); + print_sym(XKB_KEY_Execute, KEY_SYSRQ, ""); =20 - print_sym(XKB_KEY_KP_Decimal, Q_KEY_CODE_KP_DECIMAL, " numlock"); - print_sym(XKB_KEY_KP_Separator, Q_KEY_CODE_KP_DECIMAL, " numlock"); + print_sym(XKB_KEY_KP_Decimal, KEY_KPDOT, " numlock"); + print_sym(XKB_KEY_KP_Separator, KEY_KPDOT, " numlock"); =20 - print_sym(XKB_KEY_Alt_R, Q_KEY_CODE_ALT_R, ""); - print_sym(XKB_KEY_ISO_Level3_Shift, Q_KEY_CODE_ALT_R, ""); - print_sym(XKB_KEY_Mode_switch, Q_KEY_CODE_ALT_R, ""); + print_sym(XKB_KEY_Alt_R, KEY_RIGHTALT, ""); + print_sym(XKB_KEY_ISO_Level3_Shift, KEY_RIGHTALT, ""); + print_sym(XKB_KEY_Mode_switch, KEY_RIGHTALT, ""); =20 fprintf(outfile, "\n" --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365108; cv=none; d=zohomail.com; s=zohoarc; b=H6st+yfmbQw6lagj3ciCDxqjSimh3kbMulNhbuBZ/uPJyGWX2ciZE3UPcPmt8g+m8+EiLqdSK8Cf7gAM3zM7bf/lz167Y5f0wHskfskQ2lwDGJF0EMG+CfPx/shCZ+VPGw4oOFffLBkeOPhzhqVaNK6iL5QIjKLcRwTx7GJEPxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365108; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UdZWigP5uZAwHMBLPXk0fe2c8i/1vmI9qWN6XT/+9pE=; b=Ly2LbBy4VVmnOiOQsYJyR0inlRf7lK1bwBKdLs6hx1cgCr0ad+fuZF8U+3fflOUeP8u4SXdx2UnKshqj9Uc8MUIjeHch/BH4zjAsbZZ8YPHpyECByZGUvBwPT2bh6HyC05Pug3bO8WL/dFUVuWLaPSbLAQ+dhsHj7G340JMxSE0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365108084665.9079729180513; Thu, 21 May 2026 05:05:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25V-0002Rf-1c; Thu, 21 May 2026 08:01:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ25I-000147-AO for qemu-devel@nongnu.org; Thu, 21 May 2026 08:01:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ259-0005Kh-Lj for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:56 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-458-moHQMt-0PgGDHdyWZtNuAQ-1; Thu, 21 May 2026 08:00:51 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 64C7F1956061; Thu, 21 May 2026 12:00:50 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 151AB19560A3; Thu, 21 May 2026 12:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UdZWigP5uZAwHMBLPXk0fe2c8i/1vmI9qWN6XT/+9pE=; b=GZPmAaNB3y6uNWkMUeJCVAVEOUuC1ft3TW9W2GJi6KcA7trEStxJWpc6jgZruzcSTt9Ywh CbpYHFF8feasfU0FVYxQmFco06wBoS9t7jzHbWwfgTJk76Ek/cWBf1zAJzxXF+v34KA5Ho 9l5YwuSpyEUAHLss6EzoUQuRAWJZrAo= X-MC-Unique: moHQMt-0PgGDHdyWZtNuAQ-1 X-Mimecast-MFC-AGG-ID: moHQMt-0PgGDHdyWZtNuAQ_1779364850 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 36/38] ui/console: Remove qemu_text_console_put_qcode() Date: Thu, 21 May 2026 15:57:13 +0400 Message-ID: <20260521115717.1701482-37-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365110818154100 From: Akihiko Odaki It is no longer used. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-28-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- include/ui/console.h | 1 - ui/console.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 691040f5948..a31c5a4995c 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -108,7 +108,6 @@ bool qemu_mouse_set(int index, Error **errp); #define QEMU_KEY_CTRL_PAGEDOWN 0xe407 =20 void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym); -bool qemu_text_console_put_qcode(QemuTextConsole *s, int qcode, bool ctrl); bool qemu_text_console_put_linux(QemuTextConsole *s, unsigned int lnx, bool ctrl); void qemu_text_console_put_string(QemuTextConsole *s, const char *str, int= len); diff --git a/ui/console.c b/ui/console.c index 2dcb4660fbf..a7c977d0c44 100644 --- a/ui/console.c +++ b/ui/console.c @@ -328,12 +328,6 @@ static const int ctrl_linux_to_keysym[] =3D { [KEY_PAGEDOWN] =3D QEMU_KEY_CTRL_PAGEDOWN, }; =20 -bool qemu_text_console_put_qcode(QemuTextConsole *s, int qcode, bool ctrl) -{ - unsigned int lnx =3D qemu_input_map_qcode_to_linux[qcode]; - return qemu_text_console_put_linux(s, lnx, ctrl); -} - bool qemu_text_console_put_linux(QemuTextConsole *s, unsigned int lnx, bool ctrl) { --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779364921; cv=none; d=zohomail.com; s=zohoarc; b=AlnDa1W7U9PgOK+wonI7GbsvXH2Iffrm79xdIyRtwLEF9Bonm2k5j2nwRAfW0j3dVIrndPQ8sViuvKyrUoKIvLRWkBmbyvweqJAsBOeQO2q0Naqup39iKozGv9Q+CV4fUVINyDvwnKDk66v2qtq9DMYaSzL9z408r7wgYz2bJcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779364921; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wMKHnD0kVwDZLeOgTTp7vD15iCZ6M7vbOvET2Qvd84w=; b=DgesAVxn+GW7xG1Dxl8L2ZG2lORZgJ9kcPTcEZ4RXt+EomJ16+NKdhycm7YmJQpEyVJ7l4HAdA/3+JBUbZrehiV/VcvUuLR2VC8AsdzrrxooKmXqa2cu89zqrt7zKsXdvOH4V/M5cvXvx0eHP6N+BSO85sVfwkzev8oJGRWGk90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779364921206368.2238050422545; Thu, 21 May 2026 05:02:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25S-00027k-PB; Thu, 21 May 2026 08:01:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ25P-0001i6-8K for qemu-devel@nongnu.org; Thu, 21 May 2026 08:01:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ25I-0005LC-0g for qemu-devel@nongnu.org; Thu, 21 May 2026 08:01:10 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-Zw_OxqhoNuSnwYMm5BiZEg-1; Thu, 21 May 2026 08:00:57 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 49DEE1956055; Thu, 21 May 2026 12:00:56 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E07F530001BE; Thu, 21 May 2026 12:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wMKHnD0kVwDZLeOgTTp7vD15iCZ6M7vbOvET2Qvd84w=; b=HdvHOuThoBry6ApErHJrDydcbC2CBXvgp4uMzZA+nArtUrU5QSPhY1ris0j9XreVJezdDB orv5TBUADp4HAsWA6SlbZAGqJZUes+qF+ZtN8mHZqR69xBEx6aRACK6eSeKZPpCgrIgkj1 SNRfZJ98TMMizMDZS/j/i0ukUTWGzX8= X-MC-Unique: Zw_OxqhoNuSnwYMm5BiZEg-1 X-Mimecast-MFC-AGG-ID: Zw_OxqhoNuSnwYMm5BiZEg_1779364856 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 37/38] ui/input: Remove unused QKeyCode helpers and keymaps Date: Thu, 21 May 2026 15:57:14 +0400 Message-ID: <20260521115717.1701482-38-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779364923321154100 From: Akihiko Odaki Their users have migrated to Linux key codes. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-29-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- include/ui/input.h | 50 ------------------------------------------ tools/qemu-vnc/input.c | 6 ----- ui/input-keymap.c | 39 -------------------------------- ui/input.c | 16 -------------- ui/meson.build | 15 ------------- 5 files changed, 126 deletions(-) diff --git a/include/ui/input.h b/include/ui/input.h index e76dd4b172a..ea2d944a7ed 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -58,18 +58,13 @@ void qemu_input_event_send_impl(QemuConsole *src, QemuI= nputEvent *evt); void qemu_input_event_sync(void); void qemu_input_event_sync_impl(void); =20 -void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down); void qemu_input_event_send_key_linux(QemuConsole *src, unsigned int lnx, bool down); void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down= ); -void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool do= wn); void qemu_input_event_send_key_delay(uint32_t delay_ms); int qemu_input_key_number_to_qcode(unsigned int nr); unsigned int qemu_input_key_number_to_linux(unsigned int nr); -int qemu_input_key_value_to_number(const KeyValue *value); -int qemu_input_key_value_to_qcode(const KeyValue *value); unsigned int qemu_input_key_value_to_linux(const KeyValue *value); -int qemu_input_qcode_to_scancode(QKeyCode qcode, bool down, int *codes); int qemu_input_linux_to_scancode(unsigned int lnx, bool down, int *codes); int qemu_input_linux_to_qcode(unsigned int lnx); =20 @@ -109,96 +104,51 @@ void qemu_input_check_mode_change(void); void qemu_add_mouse_mode_change_notifier(Notifier *notify); void qemu_remove_mouse_mode_change_notifier(Notifier *notify); =20 -extern const guint qemu_input_map_atset1_to_qcode_len; -extern const guint16 qemu_input_map_atset1_to_qcode[]; - extern const guint qemu_input_map_atset1_to_linux_len; extern const guint16 qemu_input_map_atset1_to_linux[]; =20 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_linux_to_atset1_len; extern const guint16 qemu_input_map_linux_to_atset1[]; =20 -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_linux_to_atset2_len; extern const guint16 qemu_input_map_linux_to_atset2[]; =20 -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_linux_to_atset3_len; extern const guint16 qemu_input_map_linux_to_atset3[]; =20 extern const guint qemu_input_map_qcode_to_linux_len; extern const guint16 qemu_input_map_qcode_to_linux[]; =20 -extern const guint qemu_input_map_qcode_to_qnum_len; -extern const guint16 qemu_input_map_qcode_to_qnum[]; - extern const guint qemu_input_map_linux_to_qnum_len; extern const guint16 qemu_input_map_linux_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_linux_to_sun_len; extern const guint16 qemu_input_map_linux_to_sun[]; =20 -extern const guint qemu_input_map_qnum_to_qcode_len; -extern const guint16 qemu_input_map_qnum_to_qcode[]; - extern const guint qemu_input_map_qnum_to_linux_len; extern const guint16 qemu_input_map_qnum_to_linux[]; =20 -extern const guint qemu_input_map_usb_to_qcode_len; -extern const guint16 qemu_input_map_usb_to_qcode[]; - extern const guint qemu_input_map_usb_to_linux_len; extern const guint16 qemu_input_map_usb_to_linux[]; =20 -extern const guint qemu_input_map_win32_to_qcode_len; -extern const guint16 qemu_input_map_win32_to_qcode[]; - extern const guint qemu_input_map_win32_to_linux_len; extern const guint16 qemu_input_map_win32_to_linux[]; =20 -extern const guint qemu_input_map_x11_to_qcode_len; -extern const guint16 qemu_input_map_x11_to_qcode[]; - extern const guint qemu_input_map_x11_to_linux_len; extern const guint16 qemu_input_map_x11_to_linux[]; =20 -extern const guint qemu_input_map_xorgevdev_to_qcode_len; -extern const guint16 qemu_input_map_xorgevdev_to_qcode[]; - -extern const guint qemu_input_map_xorgkbd_to_qcode_len; -extern const guint16 qemu_input_map_xorgkbd_to_qcode[]; - extern const guint qemu_input_map_xorgkbd_to_linux_len; extern const guint16 qemu_input_map_xorgkbd_to_linux[]; =20 -extern const guint qemu_input_map_xorgxquartz_to_qcode_len; -extern const guint16 qemu_input_map_xorgxquartz_to_qcode[]; - extern const guint qemu_input_map_xorgxquartz_to_linux_len; extern const guint16 qemu_input_map_xorgxquartz_to_linux[]; =20 -extern const guint qemu_input_map_xorgxwin_to_qcode_len; -extern const guint16 qemu_input_map_xorgxwin_to_qcode[]; - extern const guint qemu_input_map_xorgxwin_to_linux_len; extern const guint16 qemu_input_map_xorgxwin_to_linux[]; =20 -extern const guint qemu_input_map_osx_to_qcode_len; -extern const guint16 qemu_input_map_osx_to_qcode[]; - extern const guint qemu_input_map_osx_to_linux_len; extern const guint16 qemu_input_map_osx_to_linux[]; =20 diff --git a/tools/qemu-vnc/input.c b/tools/qemu-vnc/input.c index 90e2e79d1ea..6fb73b31248 100644 --- a/tools/qemu-vnc/input.c +++ b/tools/qemu-vnc/input.c @@ -81,12 +81,6 @@ void qemu_input_event_send_key_delay(uint32_t delay_ms) { } =20 -void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool do= wn) -{ - unsigned int lnx =3D qemu_input_map_qcode_to_linux[q]; - qemu_input_event_send_key_linux(src, lnx, down); -} - void qemu_input_event_send_key_linux(QemuConsole *src, unsigned int lnx, bool down) { diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 2b77ef09fd6..ec2a1fbc1a9 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -4,36 +4,21 @@ =20 #include "standard-headers/linux/input.h" =20 -#include "ui/input-keymap-atset1-to-qcode.c.inc" #include "ui/input-keymap-atset1-to-linux.c.inc" #include "ui/input-keymap-linux-to-qcode.c.inc" -#include "ui/input-keymap-qcode-to-atset1.c.inc" #include "ui/input-keymap-linux-to-atset1.c.inc" -#include "ui/input-keymap-qcode-to-atset2.c.inc" #include "ui/input-keymap-linux-to-atset2.c.inc" -#include "ui/input-keymap-qcode-to-atset3.c.inc" #include "ui/input-keymap-linux-to-atset3.c.inc" #include "ui/input-keymap-qcode-to-linux.c.inc" -#include "ui/input-keymap-qcode-to-qnum.c.inc" #include "ui/input-keymap-linux-to-qnum.c.inc" -#include "ui/input-keymap-qcode-to-sun.c.inc" #include "ui/input-keymap-linux-to-sun.c.inc" -#include "ui/input-keymap-qnum-to-qcode.c.inc" #include "ui/input-keymap-qnum-to-linux.c.inc" -#include "ui/input-keymap-usb-to-qcode.c.inc" #include "ui/input-keymap-usb-to-linux.c.inc" -#include "ui/input-keymap-win32-to-qcode.c.inc" #include "ui/input-keymap-win32-to-linux.c.inc" -#include "ui/input-keymap-x11-to-qcode.c.inc" #include "ui/input-keymap-x11-to-linux.c.inc" -#include "ui/input-keymap-xorgevdev-to-qcode.c.inc" -#include "ui/input-keymap-xorgkbd-to-qcode.c.inc" #include "ui/input-keymap-xorgkbd-to-linux.c.inc" -#include "ui/input-keymap-xorgxquartz-to-qcode.c.inc" #include "ui/input-keymap-xorgxquartz-to-linux.c.inc" -#include "ui/input-keymap-xorgxwin-to-qcode.c.inc" #include "ui/input-keymap-xorgxwin-to-linux.c.inc" -#include "ui/input-keymap-osx-to-qcode.c.inc" #include "ui/input-keymap-osx-to-linux.c.inc" =20 int qemu_input_linux_to_qcode(unsigned int lnx) @@ -44,19 +29,6 @@ int qemu_input_linux_to_qcode(unsigned int lnx) return qemu_input_map_linux_to_qcode[lnx]; } =20 -int qemu_input_key_value_to_number(const KeyValue *value) -{ - if (value->type =3D=3D KEY_VALUE_KIND_QCODE) { - if (value->u.qcode.data >=3D qemu_input_map_qcode_to_qnum_len) { - return 0; - } - return qemu_input_map_qcode_to_qnum[value->u.qcode.data]; - } else { - assert(value->type =3D=3D KEY_VALUE_KIND_NUMBER); - return value->u.number.data; - } -} - int qemu_input_key_number_to_qcode(unsigned int nr) { return qemu_input_linux_to_qcode(qemu_input_key_number_to_linux(nr)); @@ -70,11 +42,6 @@ unsigned int qemu_input_key_number_to_linux(unsigned int= nr) return qemu_input_map_qnum_to_linux[nr]; } =20 -int qemu_input_key_value_to_qcode(const KeyValue *value) -{ - return qemu_input_linux_to_qcode(qemu_input_key_value_to_linux(value)); -} - unsigned int qemu_input_key_value_to_linux(const KeyValue *value) { switch (value->type) { @@ -89,12 +56,6 @@ unsigned int qemu_input_key_value_to_linux(const KeyValu= e *value) } } =20 -int qemu_input_qcode_to_scancode(QKeyCode qcode, bool down, int *codes) -{ - return qemu_input_linux_to_scancode(qemu_input_map_qcode_to_linux[qcod= e], - down, codes); -} - int qemu_input_linux_to_scancode(unsigned int lnx, bool down, int *codes) { int keycode =3D lnx < qemu_input_map_linux_to_qnum_len ? diff --git a/ui/input.c b/ui/input.c index 68c7ac6f1cc..c013cd9f7e0 100644 --- a/ui/input.c +++ b/ui/input.c @@ -365,14 +365,6 @@ void qemu_input_event_sync(void) replay_input_sync_event(); } =20 -void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) -{ - unsigned int lnx =3D qemu_input_key_value_to_linux(key); - - g_free(key); - qemu_input_event_send_key_linux(src, lnx, down); -} - void qemu_input_event_send_key_linux(QemuConsole *src, unsigned int lnx, bool down) { @@ -399,14 +391,6 @@ void qemu_input_event_send_key_number(QemuConsole *src= , int num, bool down) qemu_input_event_send_key_linux(src, lnx, down); } =20 -void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool do= wn) -{ - KeyValue *key =3D g_new0(KeyValue, 1); - key->type =3D KEY_VALUE_KIND_QCODE; - key->u.qcode.data =3D q; - qemu_input_event_send_key(src, key, down); -} - void qemu_input_event_send_key_delay(uint32_t delay_ms) { if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { diff --git a/ui/meson.build b/ui/meson.build index 1504e27248f..bb01f0728e2 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -1,34 +1,19 @@ keymaps =3D [ - ['atset1', 'qcode'], ['atset1', 'linux'], ['linux', 'qcode'], - ['qcode', 'atset1'], ['linux', 'atset1'], - ['qcode', 'atset2'], ['linux', 'atset2'], - ['qcode', 'atset3'], ['linux', 'atset3'], ['qcode', 'linux'], - ['qcode', 'qnum'], ['linux', 'qnum'], - ['qcode', 'sun'], ['linux', 'sun'], - ['qnum', 'qcode'], ['qnum', 'linux'], - ['usb', 'qcode'], ['usb', 'linux'], - ['win32', 'qcode'], ['win32', 'linux'], - ['x11', 'qcode'], ['x11', 'linux'], - ['xorgevdev', 'qcode'], - ['xorgkbd', 'qcode'], ['xorgkbd', 'linux'], - ['xorgxquartz', 'qcode'], ['xorgxquartz', 'linux'], - ['xorgxwin', 'qcode'], ['xorgxwin', 'linux'], - ['osx', 'qcode'], ['osx', 'linux'], ] =20 --=20 2.54.0 From nobody Sat May 30 17:45:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365004; cv=none; d=zohomail.com; s=zohoarc; b=LjAcQOKhB5ier6X5DhjTS0DQXro6k+rZq3q1ii6Ohw2S1Uw5si7OWImxSp4GhnMl4rnXC0chnAXdYlt7dHIuSrO8LMAvE+QjD79IGi25Ut2F06jitVmh946aKnweE3tlUr5pWy1n1sGdcSr8x3QimFoxObO2FgaiFQGegAyV74E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365004; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0mYuBzXaQnyYQD4vVCzWnr5MNADED1nGMSMkQhk5NIw=; b=iQmAWZTyYlfvAXFgAdN8IaEGZFtLGL2+e3Bxdy0bF7DUb+Kxm3oY9Q15EfPCQqCsbcLcv9KYvdf5I2lxd3A1q/mL124FPV13HapScYPV8pCE8fSPJNJ6bRSd1JJKJflEpg06bsGJK3+vDG6A6JCYWILr6hVOrkXuelxVviTFC5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365004533370.31349383644647; Thu, 21 May 2026 05:03:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ263-0003RF-HC; Thu, 21 May 2026 08:01:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ25N-0001W7-MD for qemu-devel@nongnu.org; Thu, 21 May 2026 08:01:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ25L-0005Lt-KJ for qemu-devel@nongnu.org; Thu, 21 May 2026 08:01:09 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-391-NNKgCZQbOku4oUVrM19wEg-1; Thu, 21 May 2026 08:01:03 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1390F1956052; Thu, 21 May 2026 12:01:02 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A5F5D18004A3; Thu, 21 May 2026 12:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0mYuBzXaQnyYQD4vVCzWnr5MNADED1nGMSMkQhk5NIw=; b=PdNNlmlPjCTWnFyaSsS/xUyGvj3ZC9KCt4Q69v2YqtukaaWMmR/7OqtF9Oj5ivpu7ynZcr Uc6wIUSvEAykYrpMaNn40nzuzFjuLA+aAIzvzsaDgh+sjKj2KfCQkwsA8LWbuVmai1HzB2 rORZ6i7R84AcmjetgaZmWJZmLoOS1t0= X-MC-Unique: NNKgCZQbOku4oUVrM19wEg-1 X-Mimecast-MFC-AGG-ID: NNKgCZQbOku4oUVrM19wEg_1779364862 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Dongwon Kim , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 38/38] ui/gtk: Fix focus loss on re-attachment with single VC Date: Thu, 21 May 2026 15:57:15 +0400 Message-ID: <20260521115717.1701482-39-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365006445154100 From: Dongwon Kim When QEMU is launched with a single virtual console (e.g., using --nodefaults), detaching and then closing the detached window leaves the main window's notebook without an active focus target which makes keyboard unfunctional on re-attached VC. Fix this by explicitly calling gtk_widget_grab_focus on the active VC's focus widget during the window close handler. Cc: Marc-Andr=C3=A9 Lureau Cc: Philippe Mathieu-Daud=C3=A9 Cc: Daniel P. Berrang=C3=A9 Signed-off-by: Dongwon Kim Message-ID: <20260520002645.1910740-1-dongwon.kim@intel.com> Reviewed-by: Marc-Andr=C3=A9 Lureau --- ui/gtk.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index 9f9b2416c8a..4f706c6bbb2 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1483,6 +1483,11 @@ static gboolean gd_tab_window_close(GtkWidget *widge= t, GdkEvent *event, vc->gfx.ectx =3D NULL; } #endif + + if (vc =3D=3D gd_vc_find_by_menu(s)) { + gtk_widget_grab_focus(vc->focus); + } + return TRUE; } =20 --=20 2.54.0