From nobody Mon Aug 24 21:51:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779365080; cv=none; d=zohomail.com; s=zohoarc; b=FGmVlaMuK95cbaMnys6eBYVPyou7guTxe6kYQypTCWhTHad9HxwrhdmDtWtEQYeYBycI8yIdUbZNnyy8OQAYqh6FfaQ5RPWr0Xiy+AuZmJ8YLDq/5wNtQgAR5/132I0O9aItCZ488mxyGXSzuxX/DjiUtqqbuPaVqqLEkKDIfyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779365080; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vjoBPmei4647K9iNewDWHgX2To85h2zBJDJVBwfPIWo=; b=R/b03BXMOgXWRgCD+bZ7FiLcuXq2UJaL+wWtYog9JSSPxbI/0NWuSzL86Qouo/hUbdOt0XoEfO8qwnuYwvWuod7jK9HR8cLQtwLamwdI8SjmAxbydfw4P6PmQpwI/TFEFUDXCViboZ+iUCpcMJCHxvCpJ/TSlSBFcuwzgqndexM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779365080671191.17868856439043; Thu, 21 May 2026 05:04:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ25Q-0001mN-63; Thu, 21 May 2026 08:01:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ254-0000wg-LX for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ253-0005Jo-2a for qemu-devel@nongnu.org; Thu, 21 May 2026 08:00:50 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-ce1O40caOi2UexbAsiLCBQ-1; Thu, 21 May 2026 08:00:46 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C8E7519560A2; Thu, 21 May 2026 12:00:44 +0000 (UTC) Received: from localhost (unknown [10.44.24.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CEF2F1800576; Thu, 21 May 2026 12:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779364848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vjoBPmei4647K9iNewDWHgX2To85h2zBJDJVBwfPIWo=; b=aeNAFpPQ+4gOVLD/dHwI9ThqFztehiHi1z3HzRkRQors5guvzw2/11FMCOJwx17LlUVW+/ 0F/goSbSSwSTEV+ZB51UiO3INmsYfo6hM7wEMVuplt6dYbpV/6ZZJMlLDeY43PP/qXbIFX c3c59+7F2Im+PLlipYJ2nm3U2YX7oMs= X-MC-Unique: ce1O40caOi2UexbAsiLCBQ-1 X-Mimecast-MFC-AGG-ID: ce1O40caOi2UexbAsiLCBQ_1779364844 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Akihiko Odaki Subject: [PULL 35/38] qemu-keymap: Use Linux key codes Date: Thu, 21 May 2026 15:57:12 +0400 Message-ID: <20260521115717.1701482-36-marcandre.lureau@redhat.com> In-Reply-To: <20260521115717.1701482-1-marcandre.lureau@redhat.com> References: <20260521115717.1701482-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779365081629158500 From: Akihiko Odaki QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260520-input-v3-27-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp> --- qemu-keymap.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/qemu-keymap.c b/qemu-keymap.c index d4dccf456ef..d63b6be8ce3 100644 --- a/qemu-keymap.c +++ b/qemu-keymap.c @@ -11,6 +11,7 @@ */ #include "qemu/osdep.h" #include "qemu/notify.h" +#include "standard-headers/linux/input-event-codes.h" #include "ui/input.h" =20 #include @@ -32,19 +33,17 @@ static FILE *outfile; =20 /* -----------------------------------------------------------------------= - */ =20 -static uint32_t qcode_to_number(uint32_t qcode) +static uint32_t linux_to_number(uint32_t lnx) { - KeyValue keyvalue; uint32_t number; =20 - keyvalue.type =3D KEY_VALUE_KIND_QCODE; - keyvalue.u.qcode.data =3D qcode; - number =3D qemu_input_key_value_to_number(&keyvalue); + assert(lnx < qemu_input_map_linux_to_qnum_len); + number =3D qemu_input_map_linux_to_qnum[lnx]; assert(number !=3D 0); return number; } =20 -static void print_sym(xkb_keysym_t sym, uint32_t qcode, const char *mod) +static void print_sym(xkb_keysym_t sym, uint32_t lnx, const char *mod) { char name[64]; =20 @@ -54,7 +53,7 @@ static void print_sym(xkb_keysym_t sym, uint32_t qcode, c= onst char *mod) xkb_keysym_get_name(sym, name, sizeof(name)); =20 /* TODO: make ui/keymap.c parser accept QKeyCode names */ - fprintf(outfile, "%s 0x%02x%s\n", name, qcode_to_number(qcode), mod); + fprintf(outfile, "%s 0x%02x%s\n", name, linux_to_number(lnx), mod); } =20 static void walk_map(struct xkb_keymap *map, xkb_keycode_t code, void *dat= a) @@ -84,37 +83,37 @@ static void walk_map(struct xkb_keymap *map, xkb_keycod= e_t code, void *data) fprintf(outfile, "# evdev %d (0x%x), QKeyCode \"%s\", number 0x%x\n", evdev, evdev, QKeyCode_str(qcode), - qcode_to_number(qcode)); + linux_to_number(evdev)); =20 /* * check which modifier states generate which keysyms */ xkb_state_update_mask(state, 0, 0, 0, 0, 0, 0); kbase =3D xkb_state_key_get_one_sym(state, code); - print_sym(kbase, qcode, ""); + print_sym(kbase, evdev, ""); =20 xkb_state_update_mask(state, 0, 0, numlock, 0, 0, 0); knumlock =3D xkb_state_key_get_one_sym(state, code); if (kbase !=3D knumlock) { - print_sym(knumlock, qcode, " numlock"); + print_sym(knumlock, evdev, " numlock"); } =20 xkb_state_update_mask(state, shift, 0, 0, 0, 0, 0); kshift =3D xkb_state_key_get_one_sym(state, code); if (kbase !=3D kshift && knumlock !=3D kshift) { - print_sym(kshift, qcode, " shift"); + print_sym(kshift, evdev, " shift"); } =20 xkb_state_update_mask(state, altgr, 0, 0, 0, 0, 0); kaltgr =3D xkb_state_key_get_one_sym(state, code); if (kbase !=3D kaltgr) { - print_sym(kaltgr, qcode, " altgr"); + print_sym(kaltgr, evdev, " altgr"); } =20 xkb_state_update_mask(state, altgr | shift, 0, 0, 0, 0, 0); kaltgrshift =3D xkb_state_key_get_one_sym(state, code); if (kshift !=3D kaltgrshift && kaltgr !=3D kaltgrshift) { - print_sym(kaltgrshift, qcode, " shift altgr"); + print_sym(kaltgrshift, evdev, " shift altgr"); } } =20 @@ -251,16 +250,16 @@ int main(int argc, char *argv[]) "# keysyms. So append them here.\n" "#\n" "\n"); - print_sym(XKB_KEY_Print, Q_KEY_CODE_SYSRQ, ""); - print_sym(XKB_KEY_Sys_Req, Q_KEY_CODE_SYSRQ, ""); - print_sym(XKB_KEY_Execute, Q_KEY_CODE_SYSRQ, ""); + print_sym(XKB_KEY_Print, KEY_SYSRQ, ""); + print_sym(XKB_KEY_Sys_Req, KEY_SYSRQ, ""); + print_sym(XKB_KEY_Execute, KEY_SYSRQ, ""); =20 - print_sym(XKB_KEY_KP_Decimal, Q_KEY_CODE_KP_DECIMAL, " numlock"); - print_sym(XKB_KEY_KP_Separator, Q_KEY_CODE_KP_DECIMAL, " numlock"); + print_sym(XKB_KEY_KP_Decimal, KEY_KPDOT, " numlock"); + print_sym(XKB_KEY_KP_Separator, KEY_KPDOT, " numlock"); =20 - print_sym(XKB_KEY_Alt_R, Q_KEY_CODE_ALT_R, ""); - print_sym(XKB_KEY_ISO_Level3_Shift, Q_KEY_CODE_ALT_R, ""); - print_sym(XKB_KEY_Mode_switch, Q_KEY_CODE_ALT_R, ""); + print_sym(XKB_KEY_Alt_R, KEY_RIGHTALT, ""); + print_sym(XKB_KEY_ISO_Level3_Shift, KEY_RIGHTALT, ""); + print_sym(XKB_KEY_Mode_switch, KEY_RIGHTALT, ""); =20 fprintf(outfile, "\n" --=20 2.54.0