aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZongmin Zhou <zhouzongmin@kylinos.cn>2023-04-13 16:15:26 +0800
committerMarc-André Lureau <marcandre.lureau@redhat.com>2023-08-07 15:50:31 +0400
commitfdd649538e6c6c9ef99082cb74cc36dbb6b9f953 (patch)
treee7912f21a6285bbcb2cb8e70e38ee339bb134e52
parent8a64609eea8cb2bac015968c4b62da5bce266e22 (diff)
hw/i386/vmmouse:add relative packet flag for button status
The buttons value use macros instead of direct numbers. If request relative mode, have to add this for guest vmmouse driver to judge this is a relative packet. otherwise,vmmouse driver will not match the condition 'status & VMMOUSE_RELATIVE_PACKET', and can't report events on the correct(relative) input device, result to relative mode unuseful. Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn> Message-ID: <20230413081526.2229916-1-zhouzongmin@kylinos.cn> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r--hw/i386/vmmouse.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c
index a56c185f15..6cd624bd09 100644
--- a/hw/i386/vmmouse.c
+++ b/hw/i386/vmmouse.c
@@ -44,6 +44,12 @@
#define VMMOUSE_VERSION 0x3442554a
+#define VMMOUSE_RELATIVE_PACKET 0x00010000
+
+#define VMMOUSE_LEFT_BUTTON 0x20
+#define VMMOUSE_RIGHT_BUTTON 0x10
+#define VMMOUSE_MIDDLE_BUTTON 0x08
+
#ifdef DEBUG_VMMOUSE
#define DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__)
#else
@@ -103,15 +109,18 @@ static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_
x, y, dz, buttons_state);
if ((buttons_state & MOUSE_EVENT_LBUTTON))
- buttons |= 0x20;
+ buttons |= VMMOUSE_LEFT_BUTTON;
if ((buttons_state & MOUSE_EVENT_RBUTTON))
- buttons |= 0x10;
+ buttons |= VMMOUSE_RIGHT_BUTTON;
if ((buttons_state & MOUSE_EVENT_MBUTTON))
- buttons |= 0x08;
+ buttons |= VMMOUSE_MIDDLE_BUTTON;
if (s->absolute) {
x <<= 1;
y <<= 1;
+ } else{
+ /* add for guest vmmouse driver to judge this is a relative packet. */
+ buttons |= VMMOUSE_RELATIVE_PACKET;
}
s->queue[s->nb_queue++] = buttons;