All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RfC PATCH] hid: handle full ptr queues in post_load
@ 2014-11-27  9:04 Gerd Hoffmann
  2014-11-27  9:25 ` Gonglei
  0 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2014-11-27  9:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann, Dr. David Alan Gilbert

Cc: Gonglei <arei.gonglei@huawei.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/input/hid.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/hw/input/hid.c b/hw/input/hid.c
index 8f6fbb3..6fb963f 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -519,6 +519,27 @@ static int hid_post_load(void *opaque, int version_id)
     HIDState *s = opaque;
 
     hid_set_next_idle(s);
+
+    if (s->n == QUEUE_LENGTH && (s->kind == HID_TABLET ||
+                                 s->kind == HID_MOUSE)) {
+        /*
+         * Handle ptr device migration from old qemu with full queue.
+         *
+         * Throw away everything but the last event, so we propagate
+         * at least the current button state to the guest.  Also keep
+         * current position for the tablet, signal "no motion" for the
+         * mouse.
+         */
+        HIDPointerEvent evt;
+        evt = s->ptr.queue[(s->head+s->n) & QUEUE_MASK];
+        if (s->kind == HID_MOUSE) {
+            evt.xdx = 0;
+            evt.ydy = 0;
+        }
+        s->ptr.queue[0] = evt;
+        s->head = 0;
+        s->n = 1;
+    }
     return 0;
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-27 12:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-27  9:04 [Qemu-devel] [RfC PATCH] hid: handle full ptr queues in post_load Gerd Hoffmann
2014-11-27  9:25 ` Gonglei
2014-11-27 11:04   ` Gerd Hoffmann
2014-11-27 11:16     ` Gonglei
2014-11-27 11:19       ` Gerd Hoffmann
2014-11-27 11:22         ` Gonglei
2014-11-27 12:28           ` Gonglei

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.