From 67a6fcb2b06846dd37296bb901ad93a0cd87ee67 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 1 Aug 2023 13:35:43 +0400 Subject: [PATCH] vmmouse: use explicit code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It's weird to shift x & y without obvious reason. Let's make this more explicit and future-proof. Signed-off-by: Marc-André Lureau --- hw/i386/vmmouse.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index 99b84a3817b..91320afa2f6 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -52,6 +52,11 @@ #define VMMOUSE_RIGHT_BUTTON 0x10 #define VMMOUSE_MIDDLE_BUTTON 0x08 +#define VMMOUSE_MIN_X 0 +#define VMMOUSE_MIN_Y 0 +#define VMMOUSE_MAX_X 0xFFFF +#define VMMOUSE_MAX_Y 0xFFFF + #define TYPE_VMMOUSE "vmmouse" OBJECT_DECLARE_SIMPLE_TYPE(VMMouseState, VMMOUSE) @@ -112,8 +117,12 @@ static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_ buttons |= VMMOUSE_MIDDLE_BUTTON; if (s->absolute) { - x <<= 1; - y <<= 1; + x = qemu_input_scale_axis(x, + INPUT_EVENT_ABS_MIN, INPUT_EVENT_ABS_MAX, + VMMOUSE_MIN_X, VMMOUSE_MAX_X); + y = qemu_input_scale_axis(y, + INPUT_EVENT_ABS_MIN, INPUT_EVENT_ABS_MAX, + VMMOUSE_MIN_Y, VMMOUSE_MAX_Y); } else{ /* add for guest vmmouse driver to judge this is a relative packet. */ buttons |= VMMOUSE_RELATIVE_PACKET; -- 2.39.5