summary refs log tree commit diff stats
path: root/ui/spice-input.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-07-28 14:20:17 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-07-28 14:20:17 +0100
commit762971738c1857ab83ff68d0429bcca066e2dfb2 (patch)
tree4dbe4fba48b46d63e5a0b145bce81138209ce47c /ui/spice-input.c
parent871a0f7ad2b9560c5f7d640125c5be95ca23ca7f (diff)
parentef58430d5daeac4c18e4072f5860e25700aa8af6 (diff)
downloadfocaccia-qemu-762971738c1857ab83ff68d0429bcca066e2dfb2.tar.gz
focaccia-qemu-762971738c1857ab83ff68d0429bcca066e2dfb2.zip
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20170728-pull-request' into staging
ui: more keymap fixes for 2.10

# gpg: Signature made Fri 28 Jul 2017 13:59:01 BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/ui-20170728-pull-request:
  ui: add pause key to linux_to_qcode
  ui: drop ac_search and ac_stop
  ui: correctly detect spice PAUSE scancode sequence

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'ui/spice-input.c')
-rw-r--r--ui/spice-input.c32
1 files 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);
 }