73 lines
2.8 KiB
Diff
73 lines
2.8 KiB
Diff
|
From 1f28270024d1d94fbd6121969b80ce378d0455a8 Mon Sep 17 00:00:00 2001
|
||
|
From: Hans de Goede <hdegoede@redhat.com>
|
||
|
Date: Thu, 18 Oct 2012 17:16:09 +0200
|
||
|
Subject: [PATCH 16/21] channel-inputs: Fix sending 00 scancodes to guests
|
||
|
with scancode cap
|
||
|
|
||
|
The code for handling single key up / down events in spice-server is:
|
||
|
SpiceMsgcKeyDown *key_down = (SpiceMsgcKeyDown *)buf;
|
||
|
uint8_t *now = (uint8_t *)&key_down->code;
|
||
|
uint8_t *end = now + sizeof(key_down->code);
|
||
|
for (; now < end && *now; now++) {
|
||
|
kbd_push_scan(keyboard, *now);
|
||
|
}
|
||
|
|
||
|
Notice the *now, which makes sure that no scancodes with the value 0 get
|
||
|
send! But the new SPICE_MSGC_INPUTS_KEY_SCANCODE in the server does:
|
||
|
|
||
|
uint8_t *code = (uint8_t *)buf;
|
||
|
for (i = 0; i < size; i++) {
|
||
|
kbd_push_scan(keyboard, code[i]);
|
||
|
}
|
||
|
|
||
|
And thus will push any 0 bytes in the buffer. Resulting in these message
|
||
|
in the guest:
|
||
|
|
||
|
atkbd serio0: Unknown key pressed (translated set 2, code 0x0 on isa0060/serio0).
|
||
|
atkbd serio0: Use 'setkeycodes 00 <keycode>' to make it known.
|
||
|
|
||
|
Rather then making the server skip 0 bytes I believe it is better to just
|
||
|
make spice-gtk not send these in the first place, which is what this patch
|
||
|
does.
|
||
|
|
||
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
||
|
---
|
||
|
gtk/channel-inputs.c | 19 +++++++++++++++----
|
||
|
1 file changed, 15 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/gtk/channel-inputs.c b/gtk/channel-inputs.c
|
||
|
index c907948..ee86dc2 100644
|
||
|
--- a/gtk/channel-inputs.c
|
||
|
+++ b/gtk/channel-inputs.c
|
||
|
@@ -537,12 +537,23 @@ void spice_inputs_key_press_and_release(SpiceInputsChannel *input_channel, guint
|
||
|
|
||
|
if (spice_channel_test_capability(channel, SPICE_INPUTS_CAP_KEY_SCANCODE)) {
|
||
|
SpiceMsgOut *msg;
|
||
|
- guint16 *code;
|
||
|
+ guint16 code;
|
||
|
+ guint8 *buf;
|
||
|
|
||
|
msg = spice_msg_out_new(channel, SPICE_MSGC_INPUTS_KEY_SCANCODE);
|
||
|
- code = (guint16*)spice_marshaller_reserve_space(msg->marshaller, 2 * sizeof(guint16));
|
||
|
- *code++ = spice_make_scancode(scancode, FALSE);
|
||
|
- *code = spice_make_scancode(scancode, TRUE);
|
||
|
+ if (scancode < 0x100) {
|
||
|
+ buf = (guint8*)spice_marshaller_reserve_space(msg->marshaller, 2);
|
||
|
+ buf[0] = spice_make_scancode(scancode, FALSE);
|
||
|
+ buf[1] = spice_make_scancode(scancode, TRUE);
|
||
|
+ } else {
|
||
|
+ buf = (guint8*)spice_marshaller_reserve_space(msg->marshaller, 4);
|
||
|
+ code = spice_make_scancode(scancode, FALSE);
|
||
|
+ buf[0] = code & 0xff;
|
||
|
+ buf[1] = code >> 8;
|
||
|
+ code = spice_make_scancode(scancode, TRUE);
|
||
|
+ buf[2] = code & 0xff;
|
||
|
+ buf[3] = code >> 8;
|
||
|
+ }
|
||
|
spice_msg_out_send(msg);
|
||
|
} else {
|
||
|
CHANNEL_DEBUG(channel, "The server doesn't support atomic press and release");
|
||
|
--
|
||
|
1.7.12.1
|
||
|
|