diff mbox series

[PULL,02/14] ps2: fix mouse stream corruption

Message ID 20210526140627.381857-3-kraxel@redhat.com
State New
Headers show
Series [PULL,01/14] hw/input: expand trace info reported for ps2 device | expand

Commit Message

Gerd Hoffmann May 26, 2021, 2:06 p.m. UTC
From: Volker RĂ¼melin <vr_qemu@t-online.de>

Commit 7abe7eb294 "ps2: Fix mouse stream corruption due to lost data"
added code to avoid mouse stream corruptions but the calculation of
the needed free queue size was wrong. Fix this.

To reproduce, open a text file with the vim 7.3 32 bit for DOS exe-
cutable in a FreeDOS client started with -display sdl and move the
mouse around for a few seconds. You will quickly see erratic mouse
movements and unexpected mouse clicks. CuteMouse (ctmouse.exe) in
FreeDOS doesn't try to re-sync the mouse stream.

Fixes: 7abe7eb294 ("ps2: Fix mouse stream corruption due to lost data")
Signed-off-by: Volker RĂ¼melin <vr_qemu@t-online.de>
Message-Id: <20210525181441.27768-1-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/input/ps2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 5352e417a408..7a3fb2b9f639 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -646,7 +646,8 @@  void ps2_keyboard_set_translation(void *opaque, int mode)
 
 static int ps2_mouse_send_packet(PS2MouseState *s)
 {
-    const int needed = 3 + (s->mouse_type - 2);
+    /* IMPS/2 and IMEX send 4 bytes, PS2 sends 3 bytes */
+    const int needed = s->mouse_type ? 4 : 3;
     unsigned int b;
     int dx1, dy1, dz1;