From nobody Sat May 30 17:45:57 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=1779371778; cv=none; d=zohomail.com; s=zohoarc; b=MizwlZ1pFoHHmZpFiwDFpthC0/Qj0v9a2BESgwMI1ikJmbuOVjE4G+uiqcHnHMKVJ3+mxOjsng0VileSkH8xwXNmtxo2PbmZ8Xa5rNwM+/q36aDmd1u3SgZdPSfGY+neu0qHgBBwWwgE1E5vHsSj7Q67qOniHoKK8vlizGDkEgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371778; 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=JrdTeF7yarq6kIz88OoacXt1CJlXmMDKg3JPg42oWNlGyLnmrCSOqKRFMFXH9bWhmo3iUy/PG1n7pVYG4FGzKrKwkNrQ+XE/3x0Q0TNZ4r4s6K+GZkNLggCAVMzYk+1rVeUceWYTuk33uo16w8KoWHhokwhBk7RM+AX/zK+s+EM= 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 1779371778725437.9212458411033; Thu, 21 May 2026 06:56:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3sl-0005GR-99; Thu, 21 May 2026 09:56: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 1wQ3si-0004hj-GJ for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:12 -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 1wQ3sg-0000dQ-MN for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:12 -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-544-IJGGQiADM36vXgcDlUA7aQ-1; Thu, 21 May 2026 09:56:06 -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 715591800614; Thu, 21 May 2026 13:56:05 +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 280541800352; Thu, 21 May 2026 13:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371769; 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=Lt0M9sFKyfzlUl2cKB2lKLGqpA1TPYCHwU0Cem8s6rul0PSqAS//+B7enhAt7nyd53OzLD UhHm0/I6nL/rzKrcQ+S+k5IsEDKW5KnuMbNLc1Hz+HuSztMnACywVInEAj3BqNwFX/abrU yV7BE7YPD2Bd4+DaUA9bl9LbnttWJE4= X-MC-Unique: IJGGQiADM36vXgcDlUA7aQ-1 X-Mimecast-MFC-AGG-ID: IJGGQiADM36vXgcDlUA7aQ_1779371765 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 v2 01/38] ui/vt100: Standardize on uint8_t for "ch" byte variables Date: Thu, 21 May 2026 17:55:12 +0400 Message-ID: <20260521135551.1752945-2-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: -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: 1779371834817158500 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:57 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=1779371872; cv=none; d=zohomail.com; s=zohoarc; b=emQ7QN+CP2dsZXBUpMunHneEW8GgeZ15hg8aCKQPx+93dXYModfpsPBN/GHpK1jShN7K2tBZOPjeN94bHesVKUW37sv0go0CanaOwLl0VulgGAu3cIMIqWt4OBIv0xJbr6O6vdrjoFyy05pBMExoaLdUKkhHE1gOJsFBRvj6cEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371872; 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=NayNTtjKAx1mmXvUNgDsHiUzLp5vpF+qgQ/9nuD33WKdqMpBpHb52dptdI+Zf/EIL4EeFb7sTA9qORazg2qhN+Sg4Scac2TT5Bl6qa6Kmgekh3JpW5829OLPT/REVVN9O58fSOJWZ5Rfzc1gaEqtSvBhp8LYpw/iV2n+rnwOIc8= 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 1779371872434510.17471082802206; Thu, 21 May 2026 06: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 1wQ3sp-0005oq-PH; Thu, 21 May 2026 09:56:19 -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 1wQ3sl-0005Ns-FD for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:15 -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 1wQ3sk-0000eG-0C for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:15 -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-580-J0aeYBCjPe2GoqfYafAJGA-1; Thu, 21 May 2026 09:56:11 -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 C9D3419560AA; Thu, 21 May 2026 13:56:10 +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 9ADE71800673; Thu, 21 May 2026 13:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371773; 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=Ts3GIQt32F+f5Qgqn7XQHzibBswVhJHUL0flf8IL/3spxO6JBclZVu0nSukHKNHUFI3LHp Q8G/OAxpxZdVSCU3zyGWO2ybF4xR3W5Cyn6MAnLTIppmFkLOahPyTv3CzK9dxL7LXO+UzS 38rfD/hnidHqH1+xnhQkjs7Sa3DA204= X-MC-Unique: J0aeYBCjPe2GoqfYafAJGA-1 X-Mimecast-MFC-AGG-ID: J0aeYBCjPe2GoqfYafAJGA_1779371770 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 v2 02/38] ui/vt100: Take byte as uint8_t in bh_utf8_decode() Date: Thu, 21 May 2026 17:55:13 +0400 Message-ID: <20260521135551.1752945-3-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371874628154100 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:57 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=1779371986; cv=none; d=zohomail.com; s=zohoarc; b=fySPpPoSG49+WoPPlN1iN/5yFNl5uFJElytpVpHeDkhE5dqzvYUaLzhn0+YHHiiPW3oex78dErVunmRlWcIyP8VYeVclzJta3dP/h2uqjRrdfdeZhQzkIdl+DjYEfP5tyThMd4mGtaug836UFoVbbpuGm60jIyZe6Bb2fgTY02c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371986; 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=LdRnjqC0RDscw0p0orcXZcOP3Y3SvfIwOXdJgj5OCQ8rBA8e+jcwQogyT1xh3FrLMYrt1fgQFQuh81eWSSNd9pflL6ioAYG8NG57Zgtm+ljBKJUMhmBWkSXHpCZT146Q/OflyKb9qvxPeLy7vK5uRkndUXJK9xDvyDImY3oztuU= 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 1779371986569246.01424622252068; Thu, 21 May 2026 06:59:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3t8-000723-7X; Thu, 21 May 2026 09:56: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 1wQ3sv-0006kY-C2 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:25 -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 1wQ3sr-0000jQ-ON for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:25 -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-203-LA33XelINUOM_yswFO8KPA-1; Thu, 21 May 2026 09:56:17 -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 B0CF6180060D; Thu, 21 May 2026 13:56:16 +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 0445819560A3; Thu, 21 May 2026 13:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371781; 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=Oczf63NZHAnJGb4cTBPvuJetUqntj5zJLlb4VTHqU+AngNbDSPRPIdlxV7JUuEmFnHRUOI RhDHTOrWkCJy2k5jLvRuy9tZlVS6FP+Vjwipee0x+kyiIWVYq54P+qA57MDc3vWeZJ1yHE txGZ+wXg/Kna7oGgWOl8o5nuiY2AWYg= X-MC-Unique: LA33XelINUOM_yswFO8KPA-1 X-Mimecast-MFC-AGG-ID: LA33XelINUOM_yswFO8KPA_1779371776 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 03/38] ui/vt100: add vt100_fini() check Date: Thu, 21 May 2026 17:55:14 +0400 Message-ID: <20260521135551.1752945-4-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372002011158500 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:57 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=1779371891; cv=none; d=zohomail.com; s=zohoarc; b=KLWtayQIaoc1pTBQ5XkSIjRL/aAdzRsgeX/Z10fFRWezivq08I6x/yD05vHAeH4lSEYKdOFNdnnlGeQilbHN/Pdrk2MeNObATyDnRHdlmzg22kayu8wj2bjfmn/nk9XAe/oCPhMoadqooVRpLI+WB8Ul5NVqx3fSGNEHiBAW8Ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371891; 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=fInuIn1XDosNuWrzGZxE5JNVDYMwoBp2CfTij2KyfyIadGrrKQngATmlBSJSsJIRj3T4i/3z6rnmt8ZMTtQTuN9K57wpeRyEYf23YjkMuDnz+ih++1L01NtwR1yin6ppixhEOTh1QAGK2A7SktTas4S7TzYOOB0oMkpMtiySFUE= 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 1779371891710447.0571835819187; Thu, 21 May 2026 06:58:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3tA-00077v-8D; Thu, 21 May 2026 09:56:40 -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 1wQ3sx-0006nR-2n for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56: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 1wQ3sv-0000jp-0t for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:26 -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-643-K9M8oG4gOd6YC3ZxwF1tow-1; Thu, 21 May 2026 09:56:23 -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 2359D1800344; Thu, 21 May 2026 13:56:22 +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 196CF19560A3; Thu, 21 May 2026 13:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371784; 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=K+hTgk1D3L6vviJX73AlamqWPHip1WVHFQp69U1G8E1B7WXA7qobw1GJztmpqxVrNqPHYr jy+Y1H7N/21JupnRfAJrdWSwdjjSwwCUo9uUZXGWmTZ/8+3VuWLwbAr4rRb1L8o1R60RHC bzd3KeRHbpo7gCt7CcY6M8k89fOogM0= X-MC-Unique: K9M8oG4gOd6YC3ZxwF1tow-1 X-Mimecast-MFC-AGG-ID: K9M8oG4gOd6YC3ZxwF1tow_1779371782 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 v2 04/38] ui/vnc: fix OOB read access in VNC SASL mechname array Date: Thu, 21 May 2026 17:55:15 +0400 Message-ID: <20260521135551.1752945-5-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371977938158500 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:57 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=1779371867; cv=none; d=zohomail.com; s=zohoarc; b=KslVXzmwdz7dpq1y8f7egEqS3sBLovcU0po+LIBP3LFZ5c0NUjK0J/oyMJvdT/Y+HSXB/bmMoOqNo6pYMW/T5q/4z54bv//bAFrCq4Hfo78qNY/G6KS7PaGjPW3whjiw5xx/1ETifBAcv/aqJl+MGJWChwJwa+F1+Mh7BeJC03Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371867; 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=cC449dIfiM15GL5pa4uoaM+GIZFcaI+TuOwGkGn9b/a+26af5FR2Ndhk0+6jlp5KixQIJS4DZzRIacP55dULR3rjSFSk0WM3K4f0qjz5sh5xKYLpcZaS/Atxt8Zk8duMEim8941yvES+wuqb3yjTOHJQIJnq8oX9JyOnTXY368Q= 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 177937186790243.515769287823105; Thu, 21 May 2026 06:57:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3tA-0007Dd-Iz; Thu, 21 May 2026 09:56:40 -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 1wQ3t3-00071Y-Hx for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:34 -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 1wQ3t0-0000kv-DG for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:33 -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-352-h7YwFr9OPwSFvKd_F60ElA-1; Thu, 21 May 2026 09:56:28 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 95FDA18002F3; Thu, 21 May 2026 13:56:27 +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 656A5300019F; Thu, 21 May 2026 13:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371789; 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=AALiCW8lI17R/Ishb4QsZ/ZYmAVcw3nrEam2M95eRAtZO/nDKQUPXqogsK/7JZ22Bi1buo vNK/x4VEeAMBPA44vgJbm15g9176chfnPuM3u2YwUV6mE/v8Z54mNw3YP/c0R4toiVDaY5 Yphkuj3JVGT/KbhsupOc5OvDVIMcLvA= X-MC-Unique: h7YwFr9OPwSFvKd_F60ElA-1 X-Mimecast-MFC-AGG-ID: h7YwFr9OPwSFvKd_F60ElA_1779371787 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 v2 05/38] ui/vnc: fix OOB write in VNC stats array Date: Thu, 21 May 2026 17:55:16 +0400 Message-ID: <20260521135551.1752945-6-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371871079154100 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:57 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=1779371874; cv=none; d=zohomail.com; s=zohoarc; b=UNM6Jh7VzK0Qgfd1pzOMZUqq4kp3hkd7FKI4Miz9fzfy4s+8cv2ZcWBr87ttgeN3fMbXVitPMYrWNU/Em3Al6VpPS/dB1syUYeTiz8aKaZFGtaati/D3jYenDIQEXiZVzSgKBmg3N+e0E0HCQ1gtOJb6u6G6xUAgKh96T125hkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371874; 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=ozfM5pL0zGVFmVkgCjhOy/HxIy8dJ9DpdHwS2nKdBUE=; b=U9BAwyQ18B/bxtMny67Q6ZqT2hxr2bKghUOJYftqq/bHZFqoJNIEW60fusYL7V2XHvuF9W2az3o9Zn8EKjXe1miiFA99cTHvO0PJrR0/Yi/t1TTKxdLPzJxfRzqwL2bXPtqshmWgBkJhjTSTZdMVIa65F8vjzg5bYKyfKQtK2H0= 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 1779371874053835.364784522282; Thu, 21 May 2026 06:57:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3tE-0007il-Kf; Thu, 21 May 2026 09:56: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 1wQ3tA-0007BO-7x for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56: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 1wQ3t8-0000lv-Og for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:39 -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-627-PZicMMnwMdWrvDQBrLlQIw-1; Thu, 21 May 2026 09:56:34 -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 D99751800622; Thu, 21 May 2026 13:56:32 +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 DEFEB300019F; Thu, 21 May 2026 13:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371798; 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=ozfM5pL0zGVFmVkgCjhOy/HxIy8dJ9DpdHwS2nKdBUE=; b=bPi4pRIRhPD3qmYuPydE7qezt5dXDsiCtYJ8cRDQ7YcswIyQUQCiMXmmSCknVJMJA1Ap4R p4Nyxvo3Rb9i8sR7pQwikBdf4CobvgSv4CEalQQ/PFRkYj7eOf+vVALVIyNJuW4HqsFk3t bT8Qa5jUFq0IRqEnp0kwrCI48oQNRU0= X-MC-Unique: PZicMMnwMdWrvDQBrLlQIw-1 X-Mimecast-MFC-AGG-ID: PZicMMnwMdWrvDQBrLlQIw_1779371793 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 v2 06/38] ui/vnc: fix OOB write in lossy rect worker code Date: Thu, 21 May 2026 17:55:17 +0400 Message-ID: <20260521135551.1752945-7-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371928082158500 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..375ab207950 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:57 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=1779371868; cv=none; d=zohomail.com; s=zohoarc; b=abxse7ero8OLxmG2NANry/RWhfxvbgj9LHLfQI/4n3RNihwiU07g1IHBte1m6vozCh8xSc29AuPA/RSTo5sC9oH3a3aIBCqoAlAQ2iXSOgmwKuUCo8u0Fka05oOlOq2wfCCo7UDKSY4e1Zn1huwnCjOOxpPGMn15LMBaLzVspGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371868; 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=On8Mk9gAu5U17ABZAtKCiAmhp1/KVZmi53Z/Hu/36xQ=; b=KWBgQKDIaorCV1I4vsIMSHqN5ihmJ3VfxAw8TiGKmDMm3imAvLYQ7yN/FhQWqfydilIJzOH8dd3evGdqmHYTg2+Za3VDhR/E9hoDuRbQwu03bMfHATZNwYLj0bGnrX1h6YmrjjumiHvnsPnN+nNd/I1+/5tRF4xk+vtz2v1KU30= 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 1779371868956445.6527181278959; Thu, 21 May 2026 06:57:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3u3-0008LA-Jc; Thu, 21 May 2026 09:57:35 -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 1wQ3tF-00083V-OQ for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:50 -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 1wQ3tD-0000me-V7 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:45 -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-155-5ZCTX9SZPyukMCd3B5fd_w-1; Thu, 21 May 2026 09:56: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 51524195604F; Thu, 21 May 2026 13:56:38 +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 086B219560A3; Thu, 21 May 2026 13:56:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371803; 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=On8Mk9gAu5U17ABZAtKCiAmhp1/KVZmi53Z/Hu/36xQ=; b=hdh/bvlNi5TD/OlCLOn8svhcHpX7T/sWIs3+nGq3eM4sz+AITMJFVK93Vwt3t21Hluf1Gl 05xS+nWkF0B0l04C0luWANd4TN1VmII1h1DJNhzRgeFQaKxYd83Iq58/CqM1FKKJmSTScR XwSLe5cxfYmpjKMVZ3eTs5MVOMjTyCI= X-MC-Unique: 5ZCTX9SZPyukMCd3B5fd_w-1 X-Mimecast-MFC-AGG-ID: 5ZCTX9SZPyukMCd3B5fd_w_1779371798 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 v2 07/38] ui/vnc: fix OOB read updating VNC update frequency stats Date: Thu, 21 May 2026 17:55:18 +0400 Message-ID: <20260521135551.1752945-8-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371927476158500 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 375ab207950..2159bb35d54 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:57 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=1779371875; cv=none; d=zohomail.com; s=zohoarc; b=dTBlvo1+2J88r/+VdwAKN2VWcV8rR2IVkF8gCV6DjXEI5IiN5HyAkYJC6Q8a32+HCoH0n7HKejBOIH/yXY0lINn+pc1rddlLQhseosigoQ6F3qZXS7K1mmMO1AgMWJLIwI/S9I9TmXF6BzTZMYcPIw79lq5Thn8hMFmNm7JJfCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371875; 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=YcuTTzr7NcXcTF53F5rmTs/drpWI5sevZ/GbF4GPr+J80yPtZ4EJWhHQ6woo3AEXwur1+7QBNsA2DY4+xzWVNIxmoesdNCd6ww8Vq3xsV6Z9ggVUhQs6KmvOLZCAcXAtKJFRr+ZCLEdBtR8dtB8GyDroFBkyYFRDQVCCtzqkPBo= 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 1779371875158725.4251231113006; Thu, 21 May 2026 06:57:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3u5-00007j-Kl; Thu, 21 May 2026 09:57:37 -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 1wQ3tN-00088N-5Z for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:57 -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 1wQ3tK-0000nE-Bk for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:51 -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-587-ojfDwKoeM-GD0ZiHJSEbtA-1; Thu, 21 May 2026 09:56:46 -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 D2CCE195608D; Thu, 21 May 2026 13:56:43 +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 89B4019560A3; Thu, 21 May 2026 13:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371809; 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=dDFIE12xmPELBZXNMGGYE2hUBBZTUtionowUftXUP8QPKs6M6SW8IupSwUjyaev2UvAeDi mG2Wlh9BfBdiqgXa1Z7xIDh+1XFvecug+l78tzUPT1enbohxxi9d59ye3uHyXSMzxCoHbR 6Qs9jGaihchk6H7eQ7jxJ3DmPkGgQfQ= X-MC-Unique: ojfDwKoeM-GD0ZiHJSEbtA-1 X-Mimecast-MFC-AGG-ID: ojfDwKoeM-GD0ZiHJSEbtA_1779371804 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 v2 08/38] ui: fix validation of VNC extended clipboard data length Date: Thu, 21 May 2026 17:55:19 +0400 Message-ID: <20260521135551.1752945-9-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371937114158500 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:58 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=1779372000; cv=none; d=zohomail.com; s=zohoarc; b=BKiWp5tyDYuIyfHi/DsU85HV2tQDyqxis7iVC1zs3TAABluyd2zWrIWZXOBq6Cg4GeeyP4yQRnMJ+io7tcFKLpI+Bd/sJvKLtMHcV8EgWKe/MQCXtXSfBVmbKnrHbBRwuRwvGpjV448RNIKrE8yFtm+8eLx3zlWvgRcfji+baZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372000; 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=KeNiTdkHQdgDYZVfhY1M4YmalitnxgxmVRXsvdCL3LFZQGiUz+HMG4Okuj6tgGfDwBBRnYFxSpnEFndQIEESitCVlxyjr0U2hOespIAhEQdSi01RgYQqzgCsKlpy6Hk/ke9O9kElbWGrL0J0pOE4t35J0XNP2G04mYLHIkH1Eq0= 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 1779372000828833.5114501564559; Thu, 21 May 2026 07:00:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3u8-0000L8-El; Thu, 21 May 2026 09:57:40 -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 1wQ3tT-0008Bm-TV for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57: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 1wQ3tR-0000tQ-7O for qemu-devel@nongnu.org; Thu, 21 May 2026 09:56:59 -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-102-4FEXOXU8PuSzqWFVrhfUzA-1; Thu, 21 May 2026 09:56:52 -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 209A418002E9; Thu, 21 May 2026 13:56:50 +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 030781800357; Thu, 21 May 2026 13:56:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371815; 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=SJztJAySk613ijx33SmVZ72+7AUVP7tCPku155YnDRt40Ejf+6jp3y/Tc57QOkq3kxfhhC 7puZrc/WDudgqBb0bHE8InXnrR8sVAmQevg6ub8weTMk0aUxVU7OTJJEKjKVy/ZEz1jXwH uawDQ84qYkzmzpwjCczCGFLMw5bnikM= X-MC-Unique: 4FEXOXU8PuSzqWFVrhfUzA-1 X-Mimecast-MFC-AGG-ID: 4FEXOXU8PuSzqWFVrhfUzA_1779371810 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 v2 09/38] ui/input: Introduce QemuInputEvent typedef Date: Thu, 21 May 2026 17:55:20 +0400 Message-ID: <20260521135551.1752945-10-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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=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: 1779372003503154100 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:58 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=1779371867; cv=none; d=zohomail.com; s=zohoarc; b=j3J8C8BU+7OBYg4H/uEiE5gPQfS4P2CP1IrWG7yCoyM09qh4HY+HVyAwvXHXs/M4BRQSPV1KRf3W5Vb0/f2rADkva6ZAsrjPjXo8a/vBa5fHQUEM8SGbejkugI+q56K4kWj0f5OHQOXow1kj9AmCcEErF7e7ChVfjjw6oa+6EQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371867; 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=VWNTifMKMCBkA9DJqI4Fd3GBkVUWxe6+uzienR9kQOBvTw9f+kiL4U0K2SeMa1e8cop6z+sg3dmnE8mYu5l3D9HzUnjQWzBAukH0FZGTq9gRzdd3jN5osqFQBvQPfzEngJIwsCoAo/Q+JFhQtTkWGIM9cHg7lagSU2Pl+O76rtI= 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 1779371867667171.59965238122572; Thu, 21 May 2026 06:57:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3u6-00009c-5R; Thu, 21 May 2026 09:57:38 -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 1wQ3td-0008Cs-GW for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:16 -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 1wQ3tY-0000vD-UW for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57: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-96-7UTPuN5LMCu8QkYU6seKBQ-1; Thu, 21 May 2026 09:56:59 -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 E625618005B2; Thu, 21 May 2026 13:56:56 +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 8FB2E1800357; Thu, 21 May 2026 13:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371823; 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=FwAPlq16MmHbKb4R9hKFXkHrr4r7gz1p12L8S3GoZ4a/k6yVY5+4qFxrdFqOyfavUX7dKN 56zi4Z/YSogNBMN47+s/SSaDpB5YKvop2seCYtUZUjUEZ9QXgTCneLZlbBJfQfewdV0mOf 2UqXLkEXJSMKgSGAC3HTqgmGHYXA0/U= X-MC-Unique: 7UTPuN5LMCu8QkYU6seKBQ-1 X-Mimecast-MFC-AGG-ID: 7UTPuN5LMCu8QkYU6seKBQ_1779371817 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 , 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:Old World (g3beige)) Subject: [PULL v2 10/38] ui/input: Remove QAPI wrappers from QemuInputEvent Date: Thu, 21 May 2026 17:55:21 +0400 Message-ID: <20260521135551.1752945-11-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371872277154100 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:58 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=1779371907; cv=none; d=zohomail.com; s=zohoarc; b=DlZ3wTxCDG4ISeN1M3YQcypTje/rbCAvSaoRS8jTQ8wOKp8cZmFAUF+S3sOJby2DGctO87t5VBB5LfQ31VpH9Zrnpl9hvPs4AADbj+sLNeM8hJXKgJyfzKGRQWDKfQTWT7Q9scFyebhCtTA7PSJ8dFUjbA0z/L1oWywXRfuDqII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371907; 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=I1Y8Rf3/5+tLIL+aVCWe+cYiNlTWE0sdpoeWYfbNp12jkIty0cyqc7RVg7ryx/N9VmvWaM9NdPRN+32BiF+1zXTZwiiZHU6fEmzp1B2lrnY07H2ha1vmmFByUdrBRkTwuFTq6ajXrXNkvZzvmRuEoP+XYtKFntfCJ2mg99G/Ihc= 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 1779371907752629.2036821835161; Thu, 21 May 2026 06:58:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uB-0000mH-0s; Thu, 21 May 2026 09:57:43 -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 1wQ3tm-0008Ek-8t for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:22 -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 1wQ3tk-0000wx-10 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:18 -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-456-_BVxeU23ObSMKjAcJnxa7A-1; Thu, 21 May 2026 09:57:07 -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 D8A2219560BB; Thu, 21 May 2026 13:57:02 +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 31110300019F; Thu, 21 May 2026 13:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371834; 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=V62WMIVe+6hPVhERJTKnP6xzi/+Bud+9WA4IbNzduPo2keZQwbXhSBkSm+S/OOJnXmtXoC nDPIQzJwznYuwB9T+d3/GOg/Rl0oCLlgBJWpzPzfzcJGGEQa+pEymzAw5tJoF7VVbnekcF bkTbjb9kA2t5ySVHIUktRyLzJfvJCZM= X-MC-Unique: _BVxeU23ObSMKjAcJnxa7A-1 X-Mimecast-MFC-AGG-ID: _BVxeU23ObSMKjAcJnxa7A_1779371823 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:Old World (g3beige)) Subject: [PULL v2 11/38] ui/input: Store QKeyCode directly in QemuInputKeyEvent Date: Thu, 21 May 2026 17:55:22 +0400 Message-ID: <20260521135551.1752945-12-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371986536158500 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:58 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=1779371886; cv=none; d=zohomail.com; s=zohoarc; b=LFqYGeBAbhGlrXcGu0IJlzSHFmaIXo5UOMpJXAyXkjHJotzfBFEl4UPt1N+e0Mv3zoC0+RMrp7JHvWqHyPQ9Hze/kTHWlsaBQ8OjCXI5d3JyuheHk2KuSnhT+3mDpnMCNUl96mcUysKNvKffDVjSbGuJHImAPEZH2+pGiycav4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371886; 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=LX66qV84JqIBM3ZBRM6Npw+9uNFdR8j1Xv0MBqoUGA6Lnd+RF7uXn4tSDoxZUrVTKe9MXggBWQ7Xvx1rjocljNYl4hG+lrt4JYNNf5Bk3NpMGhMlrXIBTuQaURA/bvBNmBxBnqmgw+Q8EgO/12BxlczKd/PlhoCrQHSAvD4EhaY= 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 1779371886238643.9002610712615; Thu, 21 May 2026 06:58:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uB-0000pJ-OG; Thu, 21 May 2026 09:57:43 -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 1wQ3tz-0008Kj-98 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:33 -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 1wQ3tv-0000yX-10 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:31 -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-213-Ua1niQ4ePgK1YrIvDMbuJQ-1; Thu, 21 May 2026 09:57:22 -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 2FE4B1955F39; Thu, 21 May 2026 13:57:09 +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 222A019560A3; Thu, 21 May 2026 13:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371846; 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=M0YXBdwyVfN32WDYbg23GZuVeKJ0vq7yAGn6gFDlu6JjdIcTrC64DYStR3Ow6r0QV8nHwW uzIfCWq0xw08/W2D0Bw21Cjsw1qhb9GzShus+AknIVMwsBa1l+VUcg43gFeP1a01ClH+lU j3ZgrI+96v83Nb8WWdYr4p1ZF2U3ptA= X-MC-Unique: Ua1niQ4ePgK1YrIvDMbuJQ-1 X-Mimecast-MFC-AGG-ID: Ua1niQ4ePgK1YrIvDMbuJQ_1779371829 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 v2 12/38] ui/input: Use Linux key codes for internal key events Date: Thu, 21 May 2026 17:55:23 +0400 Message-ID: <20260521135551.1752945-13-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371948029158500 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:58 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=1779372052; cv=none; d=zohomail.com; s=zohoarc; b=DrVe8l4OcSIrw8p6VFho+erJndAstsTRql0w/M1Y7MWvmK0hCP2gjwd9zhGyWfgRk/7zkaKvvGk8W/8Ylh4J1G+IPIQk3Vd9psVmRJgRbB2OWuB64h6bxvg+j6FpZ2hkqGfRQxrp4WscHEhNo7FonoH2cYnn9kTVpwgDlZLmh40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372052; 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=WEb14p1ada0Lfu75kd+Wvjey3/B0uS/uMSy2BhUENVNaplZ2M6mS5K8rC+C3exDoXcQExa9fwjNx1He5WkDNlrZOpEP1jMiwEXadoYmZ3Ib8zddQeSuQ2yhKNJUwWcGbSTJkEKVfSy5mUrPzYTysQLzY+4ifGxPVQZwtnc+LG/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 1779372052116976.1650470801628; Thu, 21 May 2026 07:00:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uC-0000qH-3L; Thu, 21 May 2026 09: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 1wQ3tt-0008IQ-Rk for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:30 -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 1wQ3ts-0000xx-C1 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:25 -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-446-KmmbQxfvNCSPXJjeZxmZxA-1; Thu, 21 May 2026 09:57:18 -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 5097F19560B0; Thu, 21 May 2026 13:57:14 +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 53AE81800347; Thu, 21 May 2026 13:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371843; 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=JYNoQuf/gvepQJjORB9DqmHZMu2paWNS0Qsd51lgvl9UCRs1ZX7NO9nZDe9MaJuCdI0b8k GLxOiYKTq0TxwK8JCnUFUnNr2TldLoNYiuIgvK6ueHuLRXZRIep0vo3pu2ljk/23gpYjEL 2xD2dhVPF5EzkkJoG07eQ7eimY5Gn9k= X-MC-Unique: KmmbQxfvNCSPXJjeZxmZxA-1 X-Mimecast-MFC-AGG-ID: KmmbQxfvNCSPXJjeZxmZxA_1779371834 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 v2 13/38] ui/input: Prohibit sending KEY_RESERVED Date: Thu, 21 May 2026 17:55:24 +0400 Message-ID: <20260521135551.1752945-14-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372526759158500 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:58 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=1779371908; cv=none; d=zohomail.com; s=zohoarc; b=NZF7I89BVe/Sif8xV4QnN671pnZCKQffD8xIiu+N+bGkNzswpvtRe8s497RHOY/Hcdt03RbHjwuZCweGZfGgsL9gLJ5fOYH1bNdFSBzGSb4i9aVLWyj7XJS2cgyERZm9hiaX0ejCdvE4Krzll3qCG6Q3n5tBE/1B9xAgSe5gUeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371908; 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=mr0naZO9b/qhKvyTl5Dvg1QxJB54/GStW6sw5EWckIarIn3SThuF4q3MVIe52fDTh8W4RbYw1S1JnCzj+4KI7Bi294/7BGXGqVZRw2md/Q/nDh1qw4UmIEpcaHxasZPgCSb8+VOfF1Z3KZkqxYJy8yFv+NCpoaDgBqhe57VzldU= 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 1779371908802280.95878324054877; Thu, 21 May 2026 06:58:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uD-0001B6-JI; Thu, 21 May 2026 09:57: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 1wQ3tz-0008Kg-EO for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57: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 1wQ3tu-0000y9-QO for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:29 -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-232-O2ghp4cgNuKJG-XoWBa_sA-1; Thu, 21 May 2026 09:57:20 -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 B61C41956096; Thu, 21 May 2026 13:57:19 +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 6C3D61956053; Thu, 21 May 2026 13:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371845; 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=Bz/dpm5U+ikUF57VJoAd3PUIg3eIV16E4l3dnb4qN85BuwEItbuTgpyPZDQ54O0rT+hZ2x 744fObfDc6Ye4ZQBymDmiouYGYcPimT3nD+NomzJX3RRqxez4DDc7BWzOyEBcXPiVR2Jiy Cyc3NVT1+O207klDHFZDCAxxYame810= X-MC-Unique: O2ghp4cgNuKJG-XoWBa_sA-1 X-Mimecast-MFC-AGG-ID: O2ghp4cgNuKJG-XoWBa_sA_1779371839 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 v2 14/38] ui/console: Add qemu_text_console_put_linux() Date: Thu, 21 May 2026 17:55:25 +0400 Message-ID: <20260521135551.1752945-15-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371988952158500 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:58 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=1779371889; cv=none; d=zohomail.com; s=zohoarc; b=XkrnUlnpyr+srNzJ2x3D7XdCMZ3z1H0tr0R+pNIWjQRDNdwJMUTX/x2mnwoDo9yShy7vB5Rtkzg1gZlPoQxZyHF4NJJsFeOVRqbtFmA9pOt0E+FEeu8+eqlNcSEf71Ph3eqFOunNipXKeHi0hqgoNUw1LX/kETWqmGBGtwcbdiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371889; 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=6Y0k1FSs5g7fmhpLsIU8sGFTaHs3mCtMSaytU1AsWjU=; b=kk1YhJLhEUAG8st+cnfdK799t/vnMt+dHyNsLnvrMUl2cCVdp3/HcVjt2SY+Qnz5wvl+GDAuUHqnKMkJNIB3Z2UMkzRI20ZdzhDiUKHQwklZ1ybAiQ757qMiSbdkk/rRfp5AC9MYRe+qZnQEbgxmO6qNjcVajfcEsF0PhVhoO6w= 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 177937188967174.90346358945771; Thu, 21 May 2026 06:58:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uG-0001fO-Oj; Thu, 21 May 2026 09:57: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 1wQ3u7-0000KQ-2i for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:39 -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 1wQ3u4-0000zs-IF for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57: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-654-U3RbWbRwOpCRTAwlkgkX7w-1; Thu, 21 May 2026 09:57:26 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 85E2C19560B7; Thu, 21 May 2026 13:57:25 +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 D7DE81800576; Thu, 21 May 2026 13:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371855; 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=6Y0k1FSs5g7fmhpLsIU8sGFTaHs3mCtMSaytU1AsWjU=; b=JJtC97EtcE2fx6h6g33mHwZ0B4luwluMEjHsMaasueBOW77Y2e4+QvUfRlLk3WK/+mBFKC Eb3g7kQ2pEP7dZ0qUmAh6d8FqBxb2jNdarV4rUtZ+9fqQqBpzFCxINXhotHaIIy1SMLaGm cPWF4bEIHHQ9Joltz7ROI3ury2BwXJg= X-MC-Unique: U3RbWbRwOpCRTAwlkgkX7w-1 X-Mimecast-MFC-AGG-ID: U3RbWbRwOpCRTAwlkgkX7w_1779371845 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 v2 15/38] ui/kbd-state: Use Linux key codes Date: Thu, 21 May 2026 17:55:26 +0400 Message-ID: <20260521135551.1752945-16-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371892144154100 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 2159bb35d54..0a8c5ab0d2d 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:58 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=1779372002; cv=none; d=zohomail.com; s=zohoarc; b=YPMhKn6ziBfHnhJOlnRhrZeLnJRNW2vVHyH6K+ozUJRszu1YNEc6JurtIW3YI7i5IoyVk60pFlPkMCsp3pb1TDr8XpiBH9HWVcFVXnjx9w/V/Pi7UqY5cU9sWzgtEtR8tVTMm1Sl0aMC9zgZ2iYYMsiwXOAld6oWGivI+djSx/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372002; 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=Wq6bIkbGT7pyc4/01BxyrXiYtAnhO76o0ZdqXaEJTPOQoScL7HGKheU50jB34VnyvOYax0MON/JVTESe7THzy2Akby5C082RXsO7Cos/hkZDXsStT7WZYUnaCwDyQIhVO5OBCxBlkXodsWllc/y1Ip43GOuXLZQD9S/GCYiwD/Q= 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 1779372002377743.4088474803441; Thu, 21 May 2026 07:00:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uC-0000vY-9M; Thu, 21 May 2026 09: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 1wQ3u8-0000Wx-5Q for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57: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 1wQ3u6-00010C-4p for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:39 -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-286-MYz7K9w1PBKv5Fh5va0kYg-1; Thu, 21 May 2026 09:57:32 -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 E7A0618002FA; Thu, 21 May 2026 13:57:30 +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 D4CF91687; Thu, 21 May 2026 13:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371857; 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=hMtk0qv6PTESz6SUX+lLzXZtzNrP1wu9pmm5f1qoec7SPwIsk0A5ylLpiedjtnI+tQl6Jh XSHYjX39iWBagVQXlPs8Z5GG8NRpf1HhucST1MbKk7I7KH+JXgGRzhG/k+t0qPqSnhPMnf qSu/4QDcDphPKFS/aP8xsD87blL59Z4= X-MC-Unique: MYz7K9w1PBKv5Fh5va0kYg-1 X-Mimecast-MFC-AGG-ID: MYz7K9w1PBKv5Fh5va0kYg_1779371851 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 v2 16/38] hw/arm/musicpal: Use Linux key codes Date: Thu, 21 May 2026 17:55:27 +0400 Message-ID: <20260521135551.1752945-17-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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=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: 1779372012238158500 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:58 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=1779372082; cv=none; d=zohomail.com; s=zohoarc; b=gPu9qsAS33Jpoap6X5rmoE02oC4SyDxpQ42+GXD8w8k6nPUwqDB6qRYMVy4V26oer+EEwG5HLmC8FqS/8+W2sojzTW2CPMihucWJ2+GznrmyBmroXx3oKLL5ydD/g4uE6gj0WjzGZRoIIi2kPzCKhoUHEkLvp3OY18LyST/J0UQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372082; 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=EJ3ytfFMupNPvnKG2tOBqiq+qwiBfRtF/X3Mr+vQJ+0YwYvIB15bySY8iJZvzF8geHloP9myhD06xfwHXS8jJuyvWCcYG4HLdXQFwFjpOBxXenrrNiIkpCorNUg75o5MfrrOs7IMcrmnx+KahvX4BliRkXX60ZqCJZsterN7vtM= 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 1779372082174543.2372034614266; Thu, 21 May 2026 07:01:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uJ-0001my-FO; Thu, 21 May 2026 09: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 1wQ3u9-0000ex-SR for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:42 -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 1wQ3u8-00010p-8Z for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:41 -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-157-kGBeKMLWP7-DAKzY8pQ85g-1; Thu, 21 May 2026 09:57:37 -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 534C21955D96; Thu, 21 May 2026 13:57:36 +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 F21321956056; Thu, 21 May 2026 13:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371859; 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=QOGGDUR4MqO1TGSoDp2bqP2FZ2ntoqGvdnp/zhO355hhPWWxMus57Rtu3oRfxRZvVJpKhW yA3RHePB6gcAuWQnDc0Evyf10vO3WAD3fYC14LXLjjlhqf6aHQAGoIdXJnVDCtb2oxdvc1 2yJ/SdAOiINfy3Db50bywAsfOmF4eKs= X-MC-Unique: kGBeKMLWP7-DAKzY8pQ85g-1 X-Mimecast-MFC-AGG-ID: kGBeKMLWP7-DAKzY8pQ85g_1779371856 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 v2 17/38] hw/char/escc: Use Linux key codes Date: Thu, 21 May 2026 17:55:28 +0400 Message-ID: <20260521135551.1752945-18-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372889561158500 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:58 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=1779371986; cv=none; d=zohomail.com; s=zohoarc; b=A3qQ7SidVEq/mYZgcKl8bwRp5Kurom7KFmZIm62ixlJXRg0CWzHmXg0d1jXOGmozvP8lf25tC4syOtkqwZBjmpTQ6fZ20xs3Rp8UYGW5j+8c+6tm6WY9xthckj27lTJz4hF7e7QHSTjVAwNQ4p2s2CaZlR69m9vTBikBYtjuXo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371986; 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=HG1DHrWG8LYUHPFPIVJCwZcUc6c7ExvAcwPfMwS1ElFHWMZN+/SJXavkgzEMAzye5+VTo98PO/BK6CCIn+tOmaR2ruGXa0p2d0218VwmHkiL75eybEB0mp+xZnSa6tZ1sapsL6IjqTLDEFvZVmuYJdUPloTSUhTsnE5BN/5g7rY= 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 17793719864031009.3248479735076; Thu, 21 May 2026 06:59:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uL-00028F-RD; Thu, 21 May 2026 09:57:54 -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 1wQ3uI-0001mJ-Cg for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:50 -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 1wQ3uG-00012q-2C for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:50 -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-569-QIUWvFt0OjW9aurBGJgIEg-1; Thu, 21 May 2026 09:57:42 -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 96BC818002CF; Thu, 21 May 2026 13:57:41 +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 8CE361684; Thu, 21 May 2026 13:57:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371867; 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=ccUcurf7or3LFT3tXKWkhktBBk1Wntluab2+ozMsnrKbad29MHNOGgmskjvg12Z5R44Li/ /+eFAHgRAxyB+m32l7UnqCVh40Z8/BvzUMBGMa2ZBlBpUwocZDAvgLM0BjXtxiQPP2dJQd rxojaEMpy1dwoQ5tRXhMFn73C7BGAHc= X-MC-Unique: QIUWvFt0OjW9aurBGJgIEg-1 X-Mimecast-MFC-AGG-ID: QIUWvFt0OjW9aurBGJgIEg_1779371861 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 v2 18/38] hw/display/xenfb: Use Linux key codes Date: Thu, 21 May 2026 17:55:29 +0400 Message-ID: <20260521135551.1752945-19-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371988241154100 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:58 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=1779371918; cv=none; d=zohomail.com; s=zohoarc; b=mzR1PK7hFf935u4USBDl9sW4Y89dCwm7jYqkP77/1TrIDA8bsZjfeMzn1zz2AfrlBpns10ztIyS2uVbyP6yIRnVM/jU/SNkFmT9tv9mZsr/3QrS7HIVYnc1zkz+7+SPOeZw566p+UQwvIMCLsV0YYhN9E6nyDI5zJvIBB9XoJPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371918; 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=dBM9oUxx7F2j0taSMi//RlU3h4yRi4ebTMi1LY/z1DjQ0La6hpkBBDP+elCD9NFA91bNqdNmp+/u+Ko0mGxPTjXmWTngdGqyyzue+60zJi+dCcA7rgwG1HuWLH0p9dmR5uQxylIerHiDL7YdSMKMAQiEi6gamp8P/8KBzbG5K0k= 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 1779371918699801.8853509967137; Thu, 21 May 2026 06:58:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uO-0002dN-KJ; Thu, 21 May 2026 09:57:56 -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 1wQ3uM-0002EP-12 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:54 -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 1wQ3uJ-00015x-Ej for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:53 -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-340-wvLxylbAMZ-NZx--lc_2-w-1; Thu, 21 May 2026 09:57:48 -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 F375118002EF; Thu, 21 May 2026 13: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 A966A1685; Thu, 21 May 2026 13:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371870; 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=ImUXcB4eWUtFiSQT1ZNdmdMx8wJT60u0gMCodOItri1F/MNLT8kpE9/rqi8WCPSZcNjeRH WxCpyfJPpzwRVGqr8XGO5FBMbQZIyFvXtsuUzaG5dNDcfyDDpkQrbRqKeglFLZr8PVyLSz jmcmPnlOCl+dKkG9QA++nnBZy0L2Elk= X-MC-Unique: wvLxylbAMZ-NZx--lc_2-w-1 X-Mimecast-MFC-AGG-ID: wvLxylbAMZ-NZx--lc_2-w_1779371867 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 v2 19/38] hw/input/adb-kbd: Use Linux key codes Date: Thu, 21 May 2026 17:55:30 +0400 Message-ID: <20260521135551.1752945-20-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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, 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: 1779371998255158500 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:58 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=1779371896; cv=none; d=zohomail.com; s=zohoarc; b=mVWIgvhgwuqoJszhDvsSgZQSHEhtw0TkpDj8ZIixm+PMRumIqm/vsK64ePPvucirgPmwvNss0HvrQBf0tbEGTPJy23fn6asqV8iM8g0FUgfyjtBQ4N6xZi7TJE+o0o6tTO1vX7cJ+zByu+Q8sZO7RFgvNtEDyw2OWZhJJIT7y38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371896; 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=USvkjbk7uectxpiEYnQLSa3yhqEI9e16vUfbIdyTmDQYhA1yqmXObpBhhijL9uBfbxf0aphRtPMz3ku3agjaOqGWXtN+EbBUgZ0PINct0gEkk49t5OqekwynGKZW0tkbiAcMOtI0jCQBt7e3c65oI0F0x4BLWWPmFnTzgJuH+yA= 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 1779371896626111.39388372964345; Thu, 21 May 2026 06:58:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uU-0003Hh-5U; Thu, 21 May 2026 09:58:02 -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 1wQ3uS-00035d-8I for qemu-devel@nongnu.org; Thu, 21 May 2026 09: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 1wQ3uQ-0001MI-K6 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:57:59 -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-693-Mmw2jtISMhu__N37u1MgZQ-1; Thu, 21 May 2026 09:57:53 -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 2B96A18002F4; Thu, 21 May 2026 13:57:52 +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 332721800352; Thu, 21 May 2026 13:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371877; 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=AO0YclbmVQ0cWbHiUgsNOni3ykehhV07qwz9jjuzgIrqtez/hPLyyDahRR9RSmKwupBnrt Nk2+aUX7Ym4kZIMG0H0/nWSiNE9cMePoB1HTJ+k69BjUzbKQYtaDjAqGnyTZOMwUmpM8QC zJpiRIFILq/Fdkz+raxAMXo6RE4F1tQ= X-MC-Unique: Mmw2jtISMhu__N37u1MgZQ-1 X-Mimecast-MFC-AGG-ID: Mmw2jtISMhu__N37u1MgZQ_1779371872 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki Subject: [PULL v2 20/38] hw/input/hid: Use Linux key codes Date: Thu, 21 May 2026 17:55:31 +0400 Message-ID: <20260521135551.1752945-21-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371901545154100 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:58 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=1779371949; cv=none; d=zohomail.com; s=zohoarc; b=j6JEXBNtGvhYfoGrgfxm9zogTRlZC5mbsMIJKKjHrtwIiLksmc4uneqmAzOteTVaT4gIzMfFoXYBnKydcryfy9R7ZR9WL1xs+yS639z8nTXkjkfoH4ZUfZK5UlxqvEsma5L71/TrSVWCxucZaS9WAvWIRF/iGM9S91SWlBjOr3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371949; 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=bsZDBzpsBup2FS4ADiz4j44qTi1YeN7/JVpZzM3SjyR+j3z8NymGj9fhCCTAw/KNK3+ViAGyxiKzT31nMnlMOfOzTNy3sHjw1HkMUeYBkBPSTwRDhaCky0QyOhFmGpiylGuzCGlyb73M/9pOXICLDuERAa/AuR9C2GcKH/jRXTY= 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 1779371949969543.8058015275236; Thu, 21 May 2026 06:59:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3ua-0003x1-HO; Thu, 21 May 2026 09:58: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 1wQ3uX-0003b3-3B for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:05 -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 1wQ3uU-0001Zh-RX for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:04 -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-407-70XnbHzlOUCfUiEvheR2SQ-1; Thu, 21 May 2026 09:57:58 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8EB6819560A2; Thu, 21 May 2026 13:57:57 +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 967FD1800352; Thu, 21 May 2026 13:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371882; 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=Ib27vMTOGmsJI0PvtkjpUtoWf2hagrfcxrHZj9vHmr19Wg9h3cEUcqIxC96CXAF+KPfe5+ R3jbPMVRmvnVDPr86aoNg2M/BatcTF+sUj910lNNtjHh4kCUDX8W5Q9gQ3M+CdA3RPO7f/ /7ZN45rtQ8Und8fYZc2YhmLDH/tqjD4= X-MC-Unique: 70XnbHzlOUCfUiEvheR2SQ-1 X-Mimecast-MFC-AGG-ID: 70XnbHzlOUCfUiEvheR2SQ_1779371877 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki Subject: [PULL v2 21/38] hw/input/ps2: Use Linux key codes Date: Thu, 21 May 2026 17:55:32 +0400 Message-ID: <20260521135551.1752945-22-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 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: 1779371999669158501 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:58 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=1779371913; cv=none; d=zohomail.com; s=zohoarc; b=kaqa+wWYXnZOcJ/AuhQwFewQIkvG1i4/n7HQCaGgTaQXvWaVRW2AGNW+B2nIxAyniEzHSjjmanHadEYjFR2nD/6rfQme/yqFrWuGdIYhKw9cEuT3+youD6K5pBDRq/NK9Rq22hymY2o3L0SB4yW9K3X5jHRoC6Jxg47Srk2jxIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371913; 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=UjKlBTvENH8nX0quq+VfkscM/tKS9VeDBgxpAa2xSN+jOsgrO5caGpn4kNZbgKPPgFV9FrnIZcPMBuXbV4ExB3wZb7g27fcQQ3ymnhNiZjW4zdXBRJ+DZoS8i3xtBauKy1azUEKwnxYG+diJieYbOviZXG+xLkbGROfYCsA1i8I= 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 1779371913758650.8111930496431; Thu, 21 May 2026 06:58:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3ug-0004oe-I9; Thu, 21 May 2026 09:58: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 1wQ3ud-0004PP-4c for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58: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 1wQ3ua-0001wi-VD for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58: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-73-jTBtgIygMICGuhwAHKzN2Q-1; Thu, 21 May 2026 09:58:05 -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 370F41955F29; Thu, 21 May 2026 13:58:03 +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 E1656300019F; Thu, 21 May 2026 13:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371887; 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=IKD0/N/MdNsFbOp5d8WGsknru1Ylc2e+3x0a6tJaTWHg0v0Qz4m25Yv7UHGylUhx1IJEGH rNlhMeeF+R9oXi4eAEe7/w9nt/s+3lREdmayRq6t4uRi09IIpDlbZcDs3HjXISM25G8pVR lidtScd8FF+GwiT3udV+9zvfF9fcIlI= X-MC-Unique: jTBtgIygMICGuhwAHKzN2Q-1 X-Mimecast-MFC-AGG-ID: jTBtgIygMICGuhwAHKzN2Q_1779371883 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , "Michael S. Tsirkin" , Gerd Hoffmann Subject: [PULL v2 22/38] hw/input/virtio-input: Use Linux key codes Date: Thu, 21 May 2026 17:55:33 +0400 Message-ID: <20260521135551.1752945-23-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371997478158500 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:58 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=1779372007; cv=none; d=zohomail.com; s=zohoarc; b=Fpb4+iXQQMu+AU/iRTyLWmj7l3M/veaAcTIe18UKoTudSKGYUMElB83KP8e1lZii1c7t06wT40fWTOtX+WdgY6p368+ghh6zAQBmndBaIfkmws1U+88F4WkCnzY80kAaT2wOscOuNFsHJIeH48zjh99yBZIEgez+1W/Te/EDmrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372007; 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=XsmvPsTvJnrSVNSjHmttwfZjyO7e8jFr9Oa8PkR+dBlUXCfwbT8IMoub9PvuXM7ly38vI3/C+3+COZd4448cwUsDeBqYww86Va3Ok64ORwmw2EB+GYlWdyFcgvkcY+ATle5T2ri5HXfYi2GevF5gn79YXbk6joPyXcZvb2k2IsQ= 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 17793720078151017.5919889784923; Thu, 21 May 2026 07:00:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3us-0005Ta-9I; Thu, 21 May 2026 09:58: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 1wQ3um-00058c-FH for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:21 -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 1wQ3uk-0002Hl-Nv for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:20 -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-361-JfJP8dxaPWW4OmJP3daOWA-1; Thu, 21 May 2026 09:58:10 -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 800CC180056E; Thu, 21 May 2026 13:58:08 +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 87BF61684; Thu, 21 May 2026 13:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371897; 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=AslxClYHxSyHE82V/U2pYc/2oGJ/nZBiCWZYFJn4EsPnre7yjruc4m+6c6pAW+LRveW9tN yGWsS639us3XSUBHhbSZHNAZDclIBZtXYevt/IuOhEyurxdpoI7RdP7owFQqce605aAPEZ AGpe1l/ZedO5wslPa5U9igJmqufv2rI= X-MC-Unique: JfJP8dxaPWW4OmJP3daOWA-1 X-Mimecast-MFC-AGG-ID: JfJP8dxaPWW4OmJP3daOWA_1779371888 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki , Thomas Huth Subject: [PULL v2 23/38] hw/m68k/next-kbd: Use Linux key codes Date: Thu, 21 May 2026 17:55:34 +0400 Message-ID: <20260521135551.1752945-24-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372047633158500 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:58 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=1779372018; cv=none; d=zohomail.com; s=zohoarc; b=A7o0vjsQtQ4JLipoTLxvStg9xNSp1eizAbXT3zdTV5p1ZFKWpDKR99A8v3o7DfurXRNo2PQIKzSYq5ZdogquokPhbJHnSFbkxSlMAkcN09XI+ONd1hB98EFQtZ81xl9mJoKXAYjtgH586PZAUjqMLTuTR8Dzs6ynGh8Ytc85I34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372018; 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=ZvG9w1p3nSruDyu7/27j+7/gvuf/PJr8R1IOGv+lurMtSEBreuE+xdbzl6djEf3ijzOQ4YWOOYikPMnMJdgICly75vmG0W/sdz6tmmwZzJUqFt7CFBocVwq+cx0kYUEVgLnTmqxCmMrFVFLQoNik4R+IBDEWbQOB8ZNELHGvkMk= 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 1779372018725740.6227516715779; Thu, 21 May 2026 07:00:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3uu-0005s4-4z; Thu, 21 May 2026 09:58:28 -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 1wQ3un-00059T-R2 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:22 -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 1wQ3ul-0002MJ-Ry for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:21 -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-625-bowIpwYTMKyem2_kZnRJyg-1; Thu, 21 May 2026 09:58:15 -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 EBCD218002D0; Thu, 21 May 2026 13:58:13 +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 D819D1800347; Thu, 21 May 2026 13:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371898; 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=UuwuXq7vr3XrCyBb7WVY8mWHM/Ft2DDzAi9NImCA++04qWo2LFVJXCszGUhkPF3nvZU83j td4OF7n9yFSmQAFwj78+TvMKz12q/WRDZwIPlJC9Oj7TSTnqIlfBJUBtx6vRZbh+C9UCkB /Dp6EY+DaDvWPrEJwrm4psyhkB8lGUg= X-MC-Unique: bowIpwYTMKyem2_kZnRJyg-1 X-Mimecast-MFC-AGG-ID: bowIpwYTMKyem2_kZnRJyg_1779371894 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 v2 24/38] replay: Use Linux key codes Date: Thu, 21 May 2026 17:55:35 +0400 Message-ID: <20260521135551.1752945-25-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372135814158500 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:58 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=1779371990; cv=none; d=zohomail.com; s=zohoarc; b=KSlGIyVKuky6/NCxvPFrbQtwVOPzyMM2yKjU8ZmIxsw0nXxkWYgizoqMIawcgc8p0JaJJntpY3nOHWtytIfqKmoMGj+w9/oXsf87GCPIY49Tsrpkkava3TLn3flVrk5o8GJjPW8/+4g207ZawREhZ4MYbQjeypBO1+sW3CnT/AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371990; 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=kw/lgiEuL+ln09dij4yQTnQooYOp5Id8cA9/Iil0+QyqxErTXqSFpRyKllW+lRu7eLzbWV8zE1ZCOpam/4eBB1DHEZIzMgjgXHtxQcVxWgdoArfiR9qpBl3f85kk1EPP+GZwVqp2sS7J4JPjoWJK1YfRtCIIjXfl6nYxp0BUAHQ= 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 177937199023569.4655862993369; Thu, 21 May 2026 06: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 1wQ3uy-0006Nx-06; Thu, 21 May 2026 09:58:32 -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 1wQ3uv-00066l-9i for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:29 -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 1wQ3us-0002UJ-EM for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:28 -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-70-aWl9QcUcNBm4DVOxy3Gqsw-1; Thu, 21 May 2026 09:58:24 -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 EDDB01956054; Thu, 21 May 2026 13:58:19 +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 3B6821800352; Thu, 21 May 2026 13:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371905; 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=YQsvZy0cQHKZhErwj/o+QkITgawLeue/xtetnfzSrhSgRmj1U8qFGxe3aIwciSdbKg9hVB mc4qoU/vHryjqlMdrOFJ61S2y4BpIdyv8shQz+AIe2384rc9cetSDthutZE/K3fnjXenTQ TyMVGjVe0ZXB5mOC0FiSMPWKnwJKyYE= X-MC-Unique: aWl9QcUcNBm4DVOxy3Gqsw-1 X-Mimecast-MFC-AGG-ID: aWl9QcUcNBm4DVOxy3Gqsw_1779371900 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 v2 25/38] ui/cocoa: Use Linux key codes Date: Thu, 21 May 2026 17:55:36 +0400 Message-ID: <20260521135551.1752945-26-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779371992286154100 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:58 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=1779371992; cv=none; d=zohomail.com; s=zohoarc; b=IzGRnB9D/zGFLq1uRckKVcYzSYvYlGLGJdv8jHWlUerfeUZcmTuk95bwXlTMRwbIqplXwfZglkH7daMHWErvBVJ7C6GA+FjPEqtPvXQnoc8NQeXW4NP/0gWgymaOwLKr4SlrstqGEWsWarzfHvBG0BuE1m0G9WdU3ticN+Yow6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371992; 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=AS2PI63XzU5rjZU7724D23pG0qaw4zHzK8w83ulPBMs4LSiyBe7iPYVjhpQXuGONt51iv0i27MPgjcEcbQClS82j6h+jrvnLNsfTh1miajPm52PAJT6ngdpOD3Ss3gkTg2aUybr79z1aMrGIvdu1ug+W8ZZgxbh3B1NjYp73yJQ= 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 1779371992711990.0906501804204; Thu, 21 May 2026 06: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 1wQ3v1-00070s-7k; Thu, 21 May 2026 09:58:35 -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 1wQ3uw-0006Kf-Sl for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58: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 1wQ3uv-0002Ur-1V for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:30 -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-245-axvSDQwDNzOMJetFLgbkMQ-1; Thu, 21 May 2026 09:58:26 -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 848E418002FA; Thu, 21 May 2026 13:58:25 +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 3C60319560A3; Thu, 21 May 2026 13:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371908; 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=OjQftxw+rJyQ5GDe7KKGOMcnjvbnu6VV3PudQEtpFHun3i8G2VHbDH6y/OgnXAfsTOrGD4 zI+e2xaznzKOvsraDom3LOhFI86NpyJ2+T4siyn/gvFZ3RRtOBL6x4XZg/AMhhInw10gOb 3gw2B9QWSmkPRU0Gly1eDgw5PuOZ0WI= X-MC-Unique: axvSDQwDNzOMJetFLgbkMQ-1 X-Mimecast-MFC-AGG-ID: axvSDQwDNzOMJetFLgbkMQ_1779371905 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 v2 26/38] ui/dbus: Use Linux key codes Date: Thu, 21 May 2026 17:55:37 +0400 Message-ID: <20260521135551.1752945-27-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372004635158500 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:58 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=1779372010; cv=none; d=zohomail.com; s=zohoarc; b=jbuArlzZ5DpKrUUqs8hYdIwPTncy3+om++GVgx4jjTzGxktZ+3ZYfQbG7euAUml+/e6k2EfUeKvDPEMwurdapW8kcfIzfk1AFIHD9LWDlLcbKQAnVzG6r8Y+6cT9Q58pycPk/ec3gBL7MbHX2BlU1a8qCROqhUt3i3GCTMjQsB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372010; 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=CfL9TNM7J0fMFXh3lcZEqGpW3GVpkgWRCwtfaGOoFhF/8Ho5C4T9hW0kS34JGjDCwCQ54HjrTvZelff0bCXVYXhG/JVzNwW09GL6Rr3LKY4UiTTKe96TMwbxsG3ZIWINzPysb0UBiyrHg16iQfsAluxr+Qb/XE0qrtyHtbLEzhA= 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 1779372010882345.22988479408605; Thu, 21 May 2026 07:00:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3wQ-0000fT-A4; Thu, 21 May 2026 10:00:02 -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 1wQ3vE-0007TR-Me for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:51 -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 1wQ3vC-0002Xq-Ij for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:48 -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-578-xgOaE0xoMSO7sqOAStTxfA-1; Thu, 21 May 2026 09:58:31 -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 DEB341800451; Thu, 21 May 2026 13:58:30 +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 89DBE1956056; Thu, 21 May 2026 13:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371924; 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=X3c4VXWd+vkZkuBO/DcmplYwXmWSLrKMAVYrabIxUTHM4OlFJBt79m2H+vwTvaa9Kiy6a4 mM33zuL3DMcy//9CfbQCGt+IRlXFrM4171xey2xKu5Pd7WPm5q2Bazr5i/Dmt4c/5aqieH XKiO12y3PIkyjHcR8EwLMwrUMk2sg7s= X-MC-Unique: xgOaE0xoMSO7sqOAStTxfA-1 X-Mimecast-MFC-AGG-ID: xgOaE0xoMSO7sqOAStTxfA_1779371911 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 v2 27/38] ui/gtk: Use Linux key codes Date: Thu, 21 May 2026 17:55:38 +0400 Message-ID: <20260521135551.1752945-28-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372014793154100 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:58 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=1779371999; cv=none; d=zohomail.com; s=zohoarc; b=DeQ8wjOp0aXcHy3WztnX+hc/y+QW6OYKQd1ZWV5v2Xcdy/yKkDM1l38Y2CEAskeWn/Av/9Uk3kMyDy2Afp95LGY6TZ497/qBMQv4gRpv+1ANXHMT5jwaOmsYv2yDIIAQLE1r+Yjv8pWwRr5iJl7b791CHHsoqKZaKQ+g8VX2v98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371999; 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=mOMycI0OQOQ5dWEFVNPNX31JKgEtw7eVr5Iwi11Py5299N3EhwDbcf7a+1nMiFH+hJebDF4AK42wu5cpLuiSrgGTzD54ze5Hqxv+K36YPlOYR91Ew7NifjFwzKO/069pIQz6F9PUHaLCgevrS5gSYDxeEqelHKLBqgs6tUHSx04= 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 1779371999662326.62630027219075; Thu, 21 May 2026 06:59:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3vQ-0007Yx-9v; Thu, 21 May 2026 09:59:00 -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 1wQ3v9-0007SD-IQ for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:45 -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 1wQ3v6-0002We-G0 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:43 -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-583-g2UdaNEAO6eKnTzRs5SnhQ-1; Thu, 21 May 2026 09:58:38 -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 8466018002C7; Thu, 21 May 2026 13:58:36 +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 332FC1689; Thu, 21 May 2026 13:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371919; 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=Tct0Gql93ucBX4uLCHqFVVI/OCZxTpX/Wrt4gvvwCRbKpq1Vn6IDk/c/7s1i5tPoZ9tdeO zQrao+NEzNB65rfqLCMHqXQEzDPAXLDGp4ohR7TLTnd4fdxjHHMBoo03JaAuTDAZPEeFjY 2SX+Oj6zlCMsLCiR782yN8rZD/7a8EA= X-MC-Unique: g2UdaNEAO6eKnTzRs5SnhQ-1 X-Mimecast-MFC-AGG-ID: g2UdaNEAO6eKnTzRs5SnhQ_1779371916 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 v2 28/38] ui/input-barrier: Use Linux key codes Date: Thu, 21 May 2026 17:55:39 +0400 Message-ID: <20260521135551.1752945-29-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372002677154100 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:58 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=1779372015; cv=none; d=zohomail.com; s=zohoarc; b=LBLAYwOM+Rq5lzphC1o4QKFBGdq0iwde3G+lfTmyy0QRRmEqobIT5nO113rRla+z80dpwwpetv9pjkVGCxnGg+V6ej5MiGAn1aV2e3olspRm8A0r5pM/+RSANkmbbIF5iQGsEKTeL7P7RpsRddWe3Ac/ueOfb7jfXebMNM/GoMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372015; 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=K1Rs2q1u+JQFMB/c31RoC1JeuMqpoJPNe4wRALHdAvCigSKDJB4+TgjHyipCrqPhvM68mmPlWmIAuuxfT4fQRu7gL6fzP2t9gGSOnpypfnDFkCJBfF+4rOBWv7eFOM0ZnmPwHYXtO3fx4NuV3lFats86d+RieQyUUGIIie1hSSU= 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 1779372015707749.6118002319237; Thu, 21 May 2026 07: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 1wQ3wT-0000yu-Ez; Thu, 21 May 2026 10:00: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 1wQ3vJ-0007UX-MJ for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58: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 1wQ3vI-0002YY-7E for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:53 -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-144-5gnN3nH9Or2PnCekkS6TtA-1; Thu, 21 May 2026 09:58:42 -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 AFE7D1955F18; Thu, 21 May 2026 13:58:41 +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 B333D176C; Thu, 21 May 2026 13:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371931; 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=IXKWttwkOC5IF82mBLzPt5zWRjhgEKrD65z7VE8QHk9E6YKNTqGRoNPNTQ4JiR7RjuTg8y 9E3EwBjB9EqHzFaZ3eP0hxQ1VNwwlbPGVkmcdWsumXCj5F3avaWtiNe16I+KBB3pQMbM3V KvconPxRs7C6SAN+hOHxCgieDD2J1RA= X-MC-Unique: 5gnN3nH9Or2PnCekkS6TtA-1 X-Mimecast-MFC-AGG-ID: 5gnN3nH9Or2PnCekkS6TtA_1779371921 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 v2 29/38] ui/input-legacy: Use Linux key codes Date: Thu, 21 May 2026 17:55:40 +0400 Message-ID: <20260521135551.1752945-30-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372102400158500 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:58 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=1779371988; cv=none; d=zohomail.com; s=zohoarc; b=PNQ/dlbTkNZ+r0J8RzK4YMO6rswYmv+FECubL2ERNlKBGOeziEM8rQpym+KS0unovW9vXn8LKRxoyOEhpdayA0GtVLJLWWzLnecvgQDP74wbdl1NPm+KhutiEcWwPeVyhBmdcFblqWnsRM7yQHcGF9x4fB9rdjMw1GPjaMTld6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779371988; 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=O/+UGbtHoWCNsDcSaLvrppYHJ0G3YdzpyQ4H4/Mk3hACCCb5BbMdk7ar+sDVRF3EC1NF+E3Dl9jX1lV12RsO41vvpxeQVueuZFwMXYQBs9slJnmItZQlBv1WGc0mLu07ydsbR1JEfolW3/6hqCZ0OHvlz9ST7sZ61EOk1bHDfek= 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 1779371988245727.5387722416493; Thu, 21 May 2026 06:59:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3vj-0007oQ-3S; Thu, 21 May 2026 09:59:24 -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 1wQ3vO-0007V4-0l for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:58 -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 1wQ3vM-0002Yt-Mp for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58:57 -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-281-vARaGS7gOPeuKNsHX-Wl8Q-1; Thu, 21 May 2026 09:58:48 -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 40B5918002EE; Thu, 21 May 2026 13:58:47 +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 D4DE11803A8F; Thu, 21 May 2026 13:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371935; 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=fkwOgc6n7T8yJbCCaN5wNmU68w69hni2vzJIFqc3yygyFMcTcDev+BDBpHwOlX5xgAjQfM B4MloaCfvpSUN5hEMJNLReM7w9UNQePP5NGTQLx9TIfvb2OQKrhxRQnSJKlF0Rse7weEBp YF4KsjBpT9mcOvrrTn5J/s0qqXvU/+A= X-MC-Unique: vARaGS7gOPeuKNsHX-Wl8Q-1 X-Mimecast-MFC-AGG-ID: vARaGS7gOPeuKNsHX-Wl8Q_1779371927 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 v2 30/38] ui/input-linux: Use Linux key codes Date: Thu, 21 May 2026 17:55:41 +0400 Message-ID: <20260521135551.1752945-31-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372002894158500 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:58 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=1779372022; cv=none; d=zohomail.com; s=zohoarc; b=mNiRvNFB78fr9PQ4WzUIr3896XhpiF+EL6SQjAj+bepkEJUXvt+uXBKTis7QhUzmfT5z7VcUL/gM7lFcwBBgrquJUQjzHxy/FtPzF47s8COvDbCWGNAjWns9htmWhsUj1SMfsR/TApBHMRNZuHYm6eXeTn48GEFlJqfvtnuzB6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372022; 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=forBXnZzO0KaTnmzJi2/90vkW78PSx+Yq9f503WzbWvIvqh5zpz7KNwIY81BG6BJAMIHnaiKqxiCwj8vW0nLZCpLbd6iooblSqTGWh/FDxIYxQNtjR4srvnjo0q2czoUvmkDYn4zAwjh9sSQCSxFgaaGW3itTd4B9nlaZ78kBfE= 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 177937202265531.686182597360812; Thu, 21 May 2026 07:00:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3wL-0008Vb-Md; Thu, 21 May 2026 09:59:59 -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 1wQ3vP-0007YY-EP for qemu-devel@nongnu.org; Thu, 21 May 2026 09: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 1wQ3vN-0002Z0-Li for qemu-devel@nongnu.org; Thu, 21 May 2026 09:58: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-641-r3GqQzt6ObiHAqDDGsGU5w-1; Thu, 21 May 2026 09:58:54 -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 2E1701955F54; Thu, 21 May 2026 13:58:53 +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 C4F351687; Thu, 21 May 2026 13:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371937; 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=EJyHj2GIWKujVl3c8ozcqewdwHm8Zbviv+XgOs1wn+KEH27oJtzDKSyI2E5x6b1pzhMAQX PA3TvJrAnzXSWQvSZqlgrckiEHP8HC0BvH7/ZL9XwA49DQbKJMQC1dwFWr+wI7BHDlQQdD ca/zllNGtK1DXGxqXPz5tkWuvqkSPFU= X-MC-Unique: r3GqQzt6ObiHAqDDGsGU5w-1 X-Mimecast-MFC-AGG-ID: r3GqQzt6ObiHAqDDGsGU5w_1779371933 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 v2 31/38] ui/keymaps: Use Linux key codes Date: Thu, 21 May 2026 17:55:42 +0400 Message-ID: <20260521135551.1752945-32-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372224301158500 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:58 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=1779372011; cv=none; d=zohomail.com; s=zohoarc; b=RFcT8U7TNuQaAfORjcQu9k7Rjm0fRZd593HCUE7aHMhlcQYyfroCQTGtKAQnNCBB6tQA5ayRTOaN9egMf+Cy0tMtuPbs33Pfa1O8DmFfxKH5Lcr2wJs4KiqGs+HOZzwQ16x0t5WzkxMhlWXdVBYrFzl3ejFBjyR0mj6NjXsYLxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372011; 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=OiRBcCmCPek/d9sipgFvS4PSGAC2VfNjdBOWgt4n1QS++aERz6S6wSkVqOsaoqSfkrVoBhQwhbUhj4S8sKQJHJ5A7paToW7N2pe9ZT/fq4myOnocGcKyHtZYHl+Z5eGcOutcgaoVDdeluhw8sKG6PTuEez13zgJ63FgIW0H+fB0= 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 1779372011093917.0873793498754; Thu, 21 May 2026 07:00:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3wF-0008Jh-97; Thu, 21 May 2026 09:59: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 1wQ3vb-00080e-SS for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:17 -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 1wQ3vZ-0002cK-Ju for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59: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-612-9RxgiOUSP3ihEW4Pak6E3A-1; Thu, 21 May 2026 09:58:59 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9B18718002D7; Thu, 21 May 2026 13:58:58 +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 A039830001BE; Thu, 21 May 2026 13:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371947; 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=AbqdpUsTndOlxQgmT+QM6PSBiXhXBz67lobkXQFSYnYr/qARdzusqdOZ+nfaFgskPhsqNA XpfYiqSxt/DN1oxhLwni7d5PN02HBh0c7qk0STHro+e/pBOFMYLFg8tg+PqYrjzwTkEryJ GzS6QctpdD3yO54PjNy+JRjYaqbN0uk= X-MC-Unique: 9RxgiOUSP3ihEW4Pak6E3A-1 X-Mimecast-MFC-AGG-ID: 9RxgiOUSP3ihEW4Pak6E3A_1779371938 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 v2 32/38] ui/sdl2: Use Linux key codes Date: Thu, 21 May 2026 17:55:43 +0400 Message-ID: <20260521135551.1752945-33-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372061151158500 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:58 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=1779372053; cv=none; d=zohomail.com; s=zohoarc; b=C/gpcmeBYVGSHf2szRp+vJjeQb8AB7Rr6SzATPaPMaBgnf8tyuLl/JaGLsD/loMYm+yDrIjZJmoT/E3de5ZvGdvPZZ21NM2egKoUnRUuKOv5qIQE1HXuS6QjLlVMsIWri3H72fx8Wdt9/l3YQIlM0r049OA0fH34nqHP4cRI8LE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372053; 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=hH/c5Z/cJrBxh3oo8wI1SqSWaoHwkmkomga2Za3KwWx3ZLfGA1ZJWHoXIuTknOEcCdmbCD3sa6yFxn0OhYreTrpvIUjsHfgz52/AxXuG8d+EJ4e6GGGdKGwK4tPdXVrGv3yr2eVsGGVs5rIK6Q7Yf32+JJj2VfmN5FUPofuURdU= 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 1779372053117891.5028799714449; Thu, 21 May 2026 07:00:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3wV-0001EE-GZ; Thu, 21 May 2026 10:00: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 1wQ3vb-00080f-Te for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:17 -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 1wQ3vZ-0002cR-K4 for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:11 -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-582-wSWbHJ5cPg2dVJUXnqBrrA-1; Thu, 21 May 2026 09:59:05 -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 3D0931800621; Thu, 21 May 2026 13:59:04 +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 D0FDF19560A3; Thu, 21 May 2026 13:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371948; 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=Ae6iAMmSCr+i2kHGVRMWGYGr619u1tKPzs+kRZbgA9jNzmjG7dljLmWH8l9y/QFC5VOoV7 RwlgzOFv3FfEErsmIKW88rmGsSP6JTNVHE/ouXI7z7kClWW2niDpDbR14DxpsAi3xT2E/g qFJEvq+eQPdVkyPvIZDPeEni9FJrY98= X-MC-Unique: wSWbHJ5cPg2dVJUXnqBrrA-1 X-Mimecast-MFC-AGG-ID: wSWbHJ5cPg2dVJUXnqBrrA_1779371944 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 v2 33/38] ui/spice: Use Linux key codes Date: Thu, 21 May 2026 17:55:44 +0400 Message-ID: <20260521135551.1752945-34-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372755099158500 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:58 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=1779372052; cv=none; d=zohomail.com; s=zohoarc; b=Ej+AMSI8BRYtOjgGClLlDGBCKXyMS5qD3IuJmvr99QHMl8iGKRguI9FkLi8miZInfl44mMUViPqLW7Xu6XwW8Ptmu2AtGd5aRj4Qq6+jV3gUXMiLF1X7fVmF/VoOXrhF/5gqcWSEhrmd/dcbeB7FJL1oywMiwd72BRYwZDCRQhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372052; 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=g94Ow2QyOD5rLGMqiOQCeqylQJwirq+95O2mVjLQVMk=; b=ktYxifg1pgsSYS+Jmt3Yx76hkZBKUsCxOAq/ejiIz9FutiVrzHgK4zcvfX7iF/8HPViKWcEJsJjtvdVgvjHTjYX1ahyTz39qdbPQB9n4PCH0209RXKcDIUIvQjjn4uDGvlveAI3Hz9ekp/e/UJM9fIWisdCnWGj70zE4bJwAfgc= 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 1779372052389579.1118920795147; Thu, 21 May 2026 07:00:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3wU-00014X-5U; Thu, 21 May 2026 10:00: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 1wQ3vf-00081J-7v for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:19 -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 1wQ3vd-0002gD-DA for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:14 -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-626-9xsrOfZVMPSbiJnOs82VhA-1; Thu, 21 May 2026 09:59:11 -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 2D58F18002F3; Thu, 21 May 2026 13:59:10 +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 ACE021800347; Thu, 21 May 2026 13:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371952; 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=g94Ow2QyOD5rLGMqiOQCeqylQJwirq+95O2mVjLQVMk=; b=Ffw+6ObXRAkkfFMH76VRWniyosyArNw315UrZ+b2cH/4ZQaaFTJjW8pntd8sFhbFfW0S50 DPnbWMa8GeXfVjcOVe3BQYIpubYXO2gagnq4TAsAAFbTA/K7m46fC3nE5uxIf8DluTN7Av 3apCoMkxtwMlqsikhRrzd5QLlZJWPjY= X-MC-Unique: 9xsrOfZVMPSbiJnOs82VhA-1 X-Mimecast-MFC-AGG-ID: 9xsrOfZVMPSbiJnOs82VhA_1779371950 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 v2 34/38] ui/vnc: Use Linux key codes Date: Thu, 21 May 2026 17:55:45 +0400 Message-ID: <20260521135551.1752945-35-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372643349158500 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 0a8c5ab0d2d..253b1a9f634 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:58 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=1779372030; cv=none; d=zohomail.com; s=zohoarc; b=n5xRC6VAP4snXJyCWaK48tJmJlB8IzUEcxi6wuW31n7DMEza5p6LJdwBGp2bZbK9OfTdd1XoRvQRw09zjUWA0b2kYJlyTLRl0oF0w/PCuTuyVmySh5rjBa4owVuLxyYZTJY/++iFNH8zoKmVByeo7WX8fFQQIu7DoXP0Ii3PKPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372030; 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=Nerak93p48MH6oAkbX+CD1pjc7JmCD5kvVgAa5cZbua1PdzAVdprRCCm6xDJZWcENZ7kQ8stYI9Q7PZRAMmIA9J9bq/xs/0GhWZDRdBFikfyakc9MYg+F9lugrD0bHlI7TXdeANCiED2JgS6DfclO4LO7r+OMjouozBgczzDxTo= 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 1779372030577875.6898131541678; Thu, 21 May 2026 07:00:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3wV-0001EY-J6; Thu, 21 May 2026 10:00: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 1wQ3vn-00082T-VI for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:30 -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 1wQ3vm-0002il-8O for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:23 -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-304-CmQZ4LOcNzmG3PK0em6-UQ-1; Thu, 21 May 2026 09:59:17 -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 50B6918005BE; Thu, 21 May 2026 13:59:15 +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 578461800352; Thu, 21 May 2026 13:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371960; 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=cZxiyNm+9qjBUjN5hcbUEAf0E7GYa+64ecLX+8ofIKdKr22F2U7927KuDTzNbsA516RUtf fVceWmwRvJPm0qqe96owKu3ZSzTKz0L6pMKkLkt7q9Zi++5qWj/DZz1h9lOUNwnDsl/6Ho dJdyvh9tdK+Qf98J62b7Mvt/sEGiQLg= X-MC-Unique: CmQZ4LOcNzmG3PK0em6-UQ-1 X-Mimecast-MFC-AGG-ID: CmQZ4LOcNzmG3PK0em6-UQ_1779371955 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki Subject: [PULL v2 35/38] qemu-keymap: Use Linux key codes Date: Thu, 21 May 2026 17:55:46 +0400 Message-ID: <20260521135551.1752945-36-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: -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: 1779372313937158500 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:58 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=1779372013; cv=none; d=zohomail.com; s=zohoarc; b=gNB9syMs2bOqosFTxW997X8nWXKeTJnhB5CiU5fKbarrhn4gMad2SXX8DUiy/TFwRIdPiiyksWBIToH/kWVDfYbYG4MMzdBZHD1PdkAP29sZOX2+ZiN4753rSdTxR/VXhjlhuDkWPEuexzwvqB2ci3P6E5i3u8ZYvqq2kTThU4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372013; 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=V9LCTZRBKRcITPSP6nhRKOOYsMililKYMWEC1RjpFYyd6tDPv7vmq0X5RUIRS8H/tkln5fu6vttL0m9TW857vXebXKF2S68YMDzd3MFrqnPy7OB9HEo5NcmdQgjdY1v/JqzlYAc5Cyg9XthKvZ3U19fo5K/bHZTLAC+rh7hich4= 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 1779372013100812.7651627642421; Thu, 21 May 2026 07:00:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3wQ-0000hN-Pn; Thu, 21 May 2026 10:00:02 -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 1wQ3w3-00084K-5p for qemu-devel@nongnu.org; Thu, 21 May 2026 09: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 1wQ3w1-0002k7-Dp for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:38 -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-606-HEPAhHQcMoOixgCwfRsZSg-1; Thu, 21 May 2026 09:59:21 -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 A9E77195609D; Thu, 21 May 2026 13:59:20 +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 AA2491800357; Thu, 21 May 2026 13:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371975; 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=SN1eLJ8FfY7huvBSAwAp3kJ4jDvA7vxL1XbnfyEQ70+C/qMaENM0t4rzQ87Rr2dy7Ij/tK Ba4jBc117mZc3NAiK+R/eigS0CPzYyYsizAgPDcBnA8NaJ6BYs2TSeuKnA2nxw5zdrxBZI yElNkkjBu4Abrl5zdQoWfNtswPrJhEU= X-MC-Unique: HEPAhHQcMoOixgCwfRsZSg-1 X-Mimecast-MFC-AGG-ID: HEPAhHQcMoOixgCwfRsZSg_1779371960 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 v2 36/38] ui/console: Remove qemu_text_console_put_qcode() Date: Thu, 21 May 2026 17:55:47 +0400 Message-ID: <20260521135551.1752945-37-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372066881158500 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:58 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=1779372083; cv=none; d=zohomail.com; s=zohoarc; b=YSuWg0Z4+GaA3i237gNRyqn5bIeLdGoADkgn9iMakyC0UsP68DisOVoKnFNwntHFTdD8rH9jGviWNvKj9uG7c5pTlBrC3+JgSD2HLBE27QnfU35EzOQpkdMAbFBrmLeVQM5MgqvOpXfFNSajMiVwrp+nT4XGh90dLkTvwT2yJMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372083; 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=Q2ykM0eg2MFse+ouLhUn8mvtA4Y55bEnZk97U9Vx4hhP28OOZfOtSn7P9eEenH6OjcwfBi5aS/Coba5S0k9Ko5T7qu2f5hzFZP91PRyZEBrmQY5AXjVVSVJ/G2ZnPs2sls5klztIxZJhhuMFFyg4dUAe0UfFoRv1A+77666KzL8= 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 1779372083329128.8448846100922; Thu, 21 May 2026 07:01:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3wR-0000lD-5A; Thu, 21 May 2026 10:00: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 1wQ3w1-00083n-VS for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:39 -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 1wQ3vw-0002jc-4x for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:34 -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-90-Jm9XGy3cN9-ipTwBymjWDQ-1; Thu, 21 May 2026 09:59:27 -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 2558D18002F3; Thu, 21 May 2026 13:59:26 +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 2AAE91956053; Thu, 21 May 2026 13:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371970; 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=ILtWJegBwgrRJ0TgkYJ9777jBuXVlAtuKkoSLD+30z0aQsCpH/0bT/v6JqzmDbI933bXwQ jvi2LWWUb1NRgX4ztnWc6YOExLIFWlzm0EwNlOBa0nuYuY/6w34q/DqMC2hR0EYkD7Akwy 3q8JmEHYReWcsvLx8qLEniny3xbY7Jc= X-MC-Unique: Jm9XGy3cN9-ipTwBymjWDQ-1 X-Mimecast-MFC-AGG-ID: Jm9XGy3cN9-ipTwBymjWDQ_1779371966 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 v2 37/38] ui/input: Remove unused QKeyCode helpers and keymaps Date: Thu, 21 May 2026 17:55:48 +0400 Message-ID: <20260521135551.1752945-38-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372096389154100 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:58 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=1779372053; cv=none; d=zohomail.com; s=zohoarc; b=ex4qtxe5sIgl5DRUC5DkGkhjBDA1XN93zRtg8sapLZ+WUlEAYn9xjr8fR//e7WP+xIY7sXCxMXeDok+9/0wxHZ0exAGMK1w3qgmjqrL4HJSFitfKeDiwAaoS82cScLb85JGLcPR12Fb0ICQ1VK8aW9OFMiBSXac7GETLhEvKKfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372053; 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=ARD1Ezsvi+6PlohsCDbWk9EJRJqjhx3s0Iq1IEZ7m3+ZPba8q65zAj0QoFoZFnAls/Ggb/TPsoBNfYemD2XkOJHA0fsLpS8rjFNIX+eBScY3xZvbp1FD6rjVG659CMDWlJ8A+YRVtu/y/7kBu2D9CgxyN5VdQm/neJy17OGhiTI= 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 1779372053027910.119129488755; Thu, 21 May 2026 07:00:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ3wX-0001V5-8p; Thu, 21 May 2026 10:00:09 -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 1wQ3w3-00084O-AE for qemu-devel@nongnu.org; Thu, 21 May 2026 09: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 1wQ3w1-0002kG-OH for qemu-devel@nongnu.org; Thu, 21 May 2026 09:59:39 -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-426-ApxjsIGmO-upF8ce-ahG7g-1; Thu, 21 May 2026 09:59:32 -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 C8358180061A; Thu, 21 May 2026 13:59:31 +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 7859819560A3; Thu, 21 May 2026 13:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779371976; 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=QMfByN4AqoTgn+6N1rf2Aa4BdqTRPjAP1O/XRW4tphcDXN1NZjJetnTPOHEJOhlIIfHypc ONzzjw8pDLgIDlVqi7Q5VZiMtzbRA/Ku3xe8SryxEI0jy+OgFe9p9sLEZrXYqeAQvBTNL/ zy/JVbUSZPkhr1+27xJubFiX+3xgimA= X-MC-Unique: ApxjsIGmO-upF8ce-ahG7g-1 X-Mimecast-MFC-AGG-ID: ApxjsIGmO-upF8ce-ahG7g_1779371971 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 v2 38/38] ui/gtk: Fix focus loss on re-attachment with single VC Date: Thu, 21 May 2026 17:55:49 +0400 Message-ID: <20260521135551.1752945-39-marcandre.lureau@redhat.com> In-Reply-To: <20260521135551.1752945-1-marcandre.lureau@redhat.com> References: <20260521135551.1752945-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: 1779372066627154100 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