From 1e63fb7db453a9ca137adc6e71e62f7b00b945b4 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann <kraxel@redhat.com> Date: Wed, 30 Aug 2017 13:27:25 +0200 Subject: [PATCH 2/4] ui: correctly detect spice PAUSE scancode sequence RH-Author: Gerd Hoffmann <kraxel@redhat.com> Message-id: <20170830132725.21925-3-kraxel@redhat.com> Patchwork-id: 76149 O-Subject: [RHV-7.4 qemu-kvm-rhev PATCH v3 2/2] ui: correctly detect spice PAUSE scancode sequence Bugzilla: 1482389 RH-Acked-by: John Snow <jsnow@redhat.com> RH-Acked-by: Laszlo Ersek <lersek@redhat.com> RH-Acked-by: Stefan Hajnoczi <stefanha@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> (cherry picked from commit e92316ad3074aaf13bced21f03c98969ca6f73a9) Signed-off-by: Miroslav Rezanina <mrezanin@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 4ea8fc6..4d17272 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); } -- 1.8.3.1