All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ui/input: fix event emitting of repeated combined keys
@ 2014-09-26  8:45 Amos Kong
  0 siblings, 0 replies; only message in thread
From: Amos Kong @ 2014-09-26  8:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel, aliguori, lcapitulino

Currently we emit press events of combined keys first, then emit
release events by reverse order. But it doesn't match with physical
keyboard if the keys contain continued & repeated keys.

For example, (qemu) sendkey a-b-b

Current emited events: (actually the second 'presse b' and 'release b'
can't be identified by guest, the interval is too short)
  press a
  press b
  press b
  release b
  release b
  release a

Correct events order of physical keyboard:
  press a
  press b
  release b
  press b
  release b
  release a

This patch fixed the event order if keys contain continued & repeated
keys. This patch based on another sendkey fix:
http://lists.nongnu.org/archive/html/qemu-devel/2014-09/msg05149.html

Signed-off-by: Amos Kong <akong@redhat.com>
---
 ui/input-legacy.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index 1e1f14c..e6ea7a2 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -95,6 +95,14 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time,
     for (p = keys; p != NULL; p = p->next) {
         qemu_input_event_send_key(NULL, copy_key_value(p->value), true);
         qemu_input_event_send_key_delay(hold_time);
+
+        /* release event will be emitted immediately if next key is repeated */
+        if (p->next && p->value->kind == p->next->value->kind &&
+            p->value->qcode == p->next->value->qcode) {
+            qemu_input_event_send_key(NULL, copy_key_value(p->value), false);
+            qemu_input_event_send_key_delay(hold_time);
+        }
+
         count++;
     }
     while (count--) {
@@ -102,8 +110,11 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time,
         for (p = keys; p != NULL && i < count; p = p->next) {
             i++;
         }
-        qemu_input_event_send_key(NULL, copy_key_value(p->value), false);
-        qemu_input_event_send_key_delay(hold_time);
+        if (!(p->next && p->value->kind == p->next->value->kind &&
+              p->value->qcode == p->next->value->qcode)) {
+            qemu_input_event_send_key(NULL, copy_key_value(p->value), false);
+            qemu_input_event_send_key_delay(hold_time);
+        }
     }
 }
 
-- 
1.9.3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-09-26  8:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-26  8:45 [Qemu-devel] [PATCH] ui/input: fix event emitting of repeated combined keys Amos Kong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.