]> Git Repo - qemu.git/commitdiff
hid: handle full ptr queues in post_load
authorGerd Hoffmann <[email protected]>
Thu, 27 Nov 2014 09:02:35 +0000 (10:02 +0100)
committerGerd Hoffmann <[email protected]>
Thu, 22 Jan 2015 11:19:48 +0000 (12:19 +0100)
Cc: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Tested-by: Gonglei <[email protected]>
Reviewed-by: Gonglei <[email protected]>
hw/input/hid.c

index 148c003bb29d91f940f024e099b64c8c8581b167..ad1855528d96592e046df6f02ec3054afdd645d6 100644 (file)
@@ -514,6 +514,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;
 }
 
This page took 0.027518 seconds and 4 git commands to generate.