From patchwork Thu Feb 1 18:00:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 868335 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zXSgF6b8Zz9s75 for ; Fri, 2 Feb 2018 05:04:25 +1100 (AEDT) Received: from localhost ([::1]:51707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehJDj-0007dt-Ur for incoming@patchwork.ozlabs.org; Thu, 01 Feb 2018 13:04:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehJAI-0005c0-Ri for qemu-devel@nongnu.org; Thu, 01 Feb 2018 13:00:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehJAF-0003W9-QN for qemu-devel@nongnu.org; Thu, 01 Feb 2018 13:00:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehJAF-0003VR-JX for qemu-devel@nongnu.org; Thu, 01 Feb 2018 13:00:47 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A599C8B10F; Thu, 1 Feb 2018 18:00:46 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id D95CE5D6A6; Thu, 1 Feb 2018 18:00:35 +0000 (UTC) From: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Thu, 1 Feb 2018 18:00:33 +0000 Message-Id: <20180201180033.14255-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 01 Feb 2018 18:00:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1] ui: fix mixup between qnum and qcode in SDL1 key handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The previous commit: commit 2ec78706d188df7d3dab43d07b19b05ef7800a44 Author: Daniel P. Berrange Date: Wed Jan 17 16:47:15 2018 +0000 ui: convert GTK and SDL1 frontends to keycodemapdb changed the x_keymap.c keymap so that its target was qcodes instead of qnums. It updated the GTK frontend to take account of this change, but forgot to update the SDL1 frontend. Thus the SDL frontend was getting qcodes but dispatching them as if they were qnums. IOW, keyboard input was completely hosed with SDL1. Since the keyboard layout tables are still all based on qnums, it is easier to just keep SDL1 using qnums as it will be deleted in a few releases time. Reported-by: BALATON Zoltan Signed-off-by: Daniel P. Berrangé Tested-by: BALATON Zoltan --- ui/sdl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/sdl.c b/ui/sdl.c index c8f102bb9f..a6bff301eb 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -242,6 +242,7 @@ static const guint16 *sdl_get_keymap(size_t *maplen) static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) { + int qcode; if (!keycode_map) { return 0; } @@ -249,7 +250,13 @@ static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) return 0; } - return keycode_map[ev->keysym.scancode]; + qcode = keycode_map[ev->keysym.scancode]; + + if (qcode > qemu_input_map_qcode_to_qnum_len) { + return 0; + } + + return qemu_input_map_qcode_to_qnum[qcode]; } static void reset_keys(void)