ps2: fix sending of PAUSE/BREAK scancodes
PATCH v2 1/1 ps2: fix sending of PAUSE/BREAK scancodes
The processing of the scancodes for PAUSE/BREAK has been broken since the conversion to qcodes in:
commit 8c10e0baf0260b59a4e984744462a18016662e3e
Author: Hervé Poussineau <[email protected]>
Date: Thu Sep 15 22:06:26 2016 +0200
ps2: use QEMU qcodes instead of scancodes
When using a VNC client, with the raw scancode extension, the client will send a scancode of 0xc6 for both PAUSE and BREAK. There is mistakenly no entry in the qcode_to_number table for this scancode, so ps2_keyboard_event() just generates a log message and discards the scancode
When using a SPICE client, it will also send 0xc6 for BREAK, but will send 0xe1 0x1d 0x45 0xe1 0x9d 0xc5 for PAUSE. There is no entry in the qcode_to_number table for the scancode 0xe1 because it is a special XT keyboard prefix not mapping to any QKeyCode. Again ps2_keyboard_event() just generates a log message and discards the scancode. The following 0x1d, 0x45, 0x9d, 0xc5 scancodes get handled correctly. Rather than trying to handle 3 byte sequences of scancodes in the PS/2 driver, special case the SPICE input code so that it captures the 3 byte pause sequence and turns it into a Pause QKeyCode.
---
Changed in v2:
- Put the pause hack in spice code instead of ps2 code
ui/input-keymap.c | 1 + ui/keymaps.h | 1 + ui/spice-input.c | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+)
ui/input-keymap.c +1 -0
@@ -98,6 +98,7 @@ static const int qcode_to_number[] = { [Q_KEY_CODE_KP_ENTER] = 0x9c, [Q_KEY_CODE_KP_DECIMAL] = 0x53, [Q_KEY_CODE_SYSRQ] = 0x54, + [Q_KEY_CODE_PAUSE] = 0xc6, [Q_KEY_CODE_KP_0] = 0x52, [Q_KEY_CODE_KP_1] = 0x4f,
ui/keymaps.h +1 -0
@@ -59,6 +59,7 @@ typedef struct {/* "grey" keys will usually need a 0xe0 prefix */ #define SCANCODE_GREY 0x80#define SCANCODE_EMUL0 0xE0 +#define SCANCODE_EMUL1 0xE1/* "up" flag */ #define SCANCODE_UP 0x80
ui/spice-input.c +20 -0
@@ -32,6 +32,7 @@ typedef struct QemuSpiceKbd {SpiceKbdInstance sin;int ledstate;bool emul0; +size_t pauseseq; } QemuSpiceKbd;static void kbd_push_key (SpiceKbdInstance *sin,uint8_t frag);
@@ -64,6 +65,25 @@ 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); }
Signature · 1 line
2.13.3
Quoted 87 lines · Daniel P. Berrange
The processing of the scancodes for PAUSE/BREAK has been broken since the conversion to qcodes in:
commit
8c10e0baf0260b59a4e984744462a18016662e3e
Author: Hervé Poussineau <[email protected]>
Date: Thu Sep 15 22:06:26 2016 +0200ps2: use QEMU qcodes instead of scancodes
When using a VNC client, with the raw scancode extension, the client will send a scancode of
0xc6for both PAUSE and BREAK. There is mistakenly no entry in theqcode_to_numbertable for this scancode, sops2_keyboard_event()just generates a log message and discards the scancodeWhen using a SPICE client, it will also send
0xc6for BREAK, but will send0xe10x1d0x450xe10x9d0xc5for PAUSE. There is no entry in theqcode_to_numbertable for the scancode0xe1because it is a special XT keyboard prefix not mapping to any QKeyCode. Againps2_keyboard_event()just generates a log message and discards the scancode. The following0x1d,0x45,0x9d,0xc5scancodes get handled correctly. Rather than trying to handle 3 byte sequences of scancodes in the PS/2 driver, special case the SPICE input code so that it captures the 3 byte pause sequence and turns it into a Pause QKeyCode.Signed-off-by Daniel P. Berrange <[email protected]>---
Changed in v2:
- Put the pause hack in spice code instead of ps2 code
ui/input-keymap.c | 1 + ui/keymaps.h | 1 + ui/spice-input.c | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+)ui/input-keymap.c +1
-0@@ -98,6 +98,7 @@ static const int qcode_to_number[] = { [Q_KEY_CODE_KP_ENTER] = 0x9c, [Q_KEY_CODE_KP_DECIMAL] = 0x53, [Q_KEY_CODE_SYSRQ] = 0x54, + [Q_KEY_CODE_PAUSE] = 0xc6, [Q_KEY_CODE_KP_0] = 0x52, [Q_KEY_CODE_KP_1] = 0x4f,ui/keymaps.h +1
-0@@ -59,6 +59,7 @@ typedef struct {/* "grey" keys will usually need a 0xe0 prefix */ #define SCANCODE_GREY 0x80#define SCANCODE_EMUL0 0xE0 +#define SCANCODE_EMUL1 0xE1/* "up" flag */ #define SCANCODE_UP 0x80ui/spice-input.c +10
-0@@ -32,6 +32,7 @@ typedef struct QemuSpiceKbd {SpiceKbdInstance sin;int ledstate;bool emul0; +size_t pauseseq; } QemuSpiceKbd;static void kbd_push_key (SpiceKbdInstance *sin,uint8_t frag);@@ -64,6 +65,25 @@ 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 ;
ui/spice-input.c static void kbd_push_key(SpiceKbdInstance *sin, uint8_t scancode) · line 86
Quoted 10 lines
ui/spice-input.c +10
-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 ; + } +
Actually self-nack, this captures the 0xe1 0x1d 0x45 separately from 0xe1 0x9d 0xc5, where as in fact the entire 6 byte sequence is the PAUSE make code, and there is no break code.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|