From patchwork Thu Jul 27 17:46:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 9867425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 747DD6038C for ; Thu, 27 Jul 2017 17:47:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 607A128864 for ; Thu, 27 Jul 2017 17:47:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D71828865; Thu, 27 Jul 2017 17:47:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E4C762885B for ; Thu, 27 Jul 2017 17:47:41 +0000 (UTC) Received: from localhost ([::1]:44190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1damsr-0007Oi-KH for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Jul 2017 13:47:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dams9-0007O3-M4 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 13:46:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dams4-0002RH-V6 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 13:46:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50048) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dams4-0002QI-OZ for qemu-devel@nongnu.org; Thu, 27 Jul 2017 13:46:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE443C0D473F for ; Thu, 27 Jul 2017 17:46:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AE443C0D473F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=berrange@redhat.com Received: from t460.redhat.com (ovpn-117-133.ams2.redhat.com [10.36.117.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id B81C44D751; Thu, 27 Jul 2017 17:46:44 +0000 (UTC) From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 18:46:40 +0100 Message-Id: <20170727174640.30359-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 27 Jul 2017 17:46:47 +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] ui: correctly detect spice PAUSE scancode sequence 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The SPICE input code is currently detcting 0xe1 0x1d 0x45 as the PAUSE key make sequence and 0xe1 0x9d 0xc5 as the break sequence. This is incorrect, because all 6 scancodes together are the make sequence, and there is no break sequence. Signed-off-by: Daniel P. Berrange --- ui/spice-input.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/ui/spice-input.c b/ui/spice-input.c index cda9976469..3d41aa1831 100644 --- a/ui/spice-input.c +++ b/ui/spice-input.c @@ -50,6 +50,7 @@ static const SpiceKbdInterface kbd_interface = { static void kbd_push_key(SpiceKbdInstance *sin, uint8_t scancode) { + static const uint8_t pauseseq[] = { 0xe1, 0x1d, 0x45, 0xe1, 0x9d, 0xc5 }; QemuSpiceKbd *kbd = container_of(sin, QemuSpiceKbd, sin); int keycode; bool up; @@ -58,32 +59,25 @@ static void kbd_push_key(SpiceKbdInstance *sin, uint8_t scancode) kbd->emul0 = true; return; } - keycode = scancode & ~SCANCODE_UP; - up = scancode & SCANCODE_UP; - if (kbd->emul0) { - kbd->emul0 = false; - keycode |= SCANCODE_GREY; - } - if (scancode == SCANCODE_EMUL1) { + if (scancode == pauseseq[kbd->pauseseq]) { kbd->pauseseq++; - return; - } else if (kbd->pauseseq == 1) { - if (keycode == 0x1d) { - kbd->pauseseq++; - return; - } else { - kbd->pauseseq = 0; - } - } else if (kbd->pauseseq == 2) { - if (keycode == 0x45) { - qemu_input_event_send_key_qcode(NULL, Q_KEY_CODE_PAUSE, !up); + if (kbd->pauseseq == G_N_ELEMENTS(pauseseq)) { + qemu_input_event_send_key_qcode(NULL, Q_KEY_CODE_PAUSE, true); kbd->pauseseq = 0; - return; } + return; + } else { kbd->pauseseq = 0; } + keycode = scancode & ~SCANCODE_UP; + up = scancode & SCANCODE_UP; + if (kbd->emul0) { + kbd->emul0 = false; + keycode |= SCANCODE_GREY; + } + qemu_input_event_send_key_number(NULL, keycode, !up); }