summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2014-11-27 10:02:35 +0100
committerGerd Hoffmann <kraxel@redhat.com>2015-01-22 12:19:48 +0100
commitba4d26064e8c42711a1a6eb287cedac75deb1478 (patch)
tree498d68f621d36185fdd2039003b7ad56c1041fb1 /hw
parent4083ae311d51edf93e2e163f4af2b22a1d0952cc (diff)
downloadqemu-ba4d26064e8c42711a1a6eb287cedac75deb1478.zip
hid: handle full ptr queues in post_load
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Tested-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/input/hid.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/hw/input/hid.c b/hw/input/hid.c
index 148c003bb2..ad1855528d 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -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;
}