From ba4d26064e8c42711a1a6eb287cedac75deb1478 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 27 Nov 2014 10:02:35 +0100 Subject: hid: handle full ptr queues in post_load Cc: Dr. David Alan Gilbert Signed-off-by: Gerd Hoffmann Tested-by: Gonglei Reviewed-by: Gonglei --- hw/input/hid.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'hw/input') diff --git a/hw/input/hid.c b/hw/input/hid.c index 148c003..ad18555 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; } -- cgit v1.1