qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: berrange@redhat.com, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 1/3] ui: correctly detect spice PAUSE scancode sequence
Date: Fri, 28 Jul 2017 14:59:33 +0200	[thread overview]
Message-ID: <20170728125935.18167-2-kraxel@redhat.com> (raw)
In-Reply-To: <20170728125935.18167-1-kraxel@redhat.com>

From: "Daniel P. Berrange" <berrange@redhat.com>

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 <berrange@redhat.com>
Message-id: 20170727174640.30359-1-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 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,6 +59,18 @@ static void kbd_push_key(SpiceKbdInstance *sin, uint8_t scancode)
         kbd->emul0 = true;
         return;
     }
+
+    if (scancode == pauseseq[kbd->pauseseq]) {
+        kbd->pauseseq++;
+        if (kbd->pauseseq == G_N_ELEMENTS(pauseseq)) {
+            qemu_input_event_send_key_qcode(NULL, Q_KEY_CODE_PAUSE, true);
+            kbd->pauseseq = 0;
+        }
+        return;
+    } else {
+        kbd->pauseseq = 0;
+    }
+
     keycode = scancode & ~SCANCODE_UP;
     up = scancode & SCANCODE_UP;
     if (kbd->emul0) {
@@ -65,25 +78,6 @@ static void kbd_push_key(SpiceKbdInstance *sin, uint8_t scancode)
         keycode |= SCANCODE_GREY;
     }
 
-    if (scancode == SCANCODE_EMUL1) {
-        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);
-            kbd->pauseseq = 0;
-            return;
-        }
-        kbd->pauseseq = 0;
-    }
-
     qemu_input_event_send_key_number(NULL, keycode, !up);
 }
 
-- 
2.9.3

  reply	other threads:[~2017-07-28 12:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-28 12:59 [Qemu-devel] [PULL 0/3] Ui 20170728 patches Gerd Hoffmann
2017-07-28 12:59 ` Gerd Hoffmann [this message]
2017-07-28 12:59 ` [Qemu-devel] [PULL 2/3] ui: drop ac_search and ac_stop Gerd Hoffmann
2017-07-28 12:59 ` [Qemu-devel] [PULL 3/3] ui: add pause key to linux_to_qcode Gerd Hoffmann
2017-07-28 13:20 ` [Qemu-devel] [PULL 0/3] Ui 20170728 patches Gerd Hoffmann
2017-07-28 13:25   ` Daniel P. Berrange
2017-07-28 14:32 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170728125935.18167-2-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).