[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/14] vmmouse: use explicit code
From: |
marcandre . lureau |
Subject: |
[PULL 05/14] vmmouse: use explicit code |
Date: |
Tue, 12 Sep 2023 14:46:39 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
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 99b84a3817..91320afa2f 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.41.0
- [PULL 00/14] Ui patches, marcandre . lureau, 2023/09/12
- [PULL 01/14] docs: vhost-user-gpu: add protocol changes for dmabuf modifiers, marcandre . lureau, 2023/09/12
- [PULL 02/14] contrib/vhost-user-gpu: add support for sending dmabuf modifiers, marcandre . lureau, 2023/09/12
- [PULL 03/14] vhost-user-gpu: support dmabuf modifiers, marcandre . lureau, 2023/09/12
- [PULL 04/14] vmmouse: replace DPRINTF with tracing, marcandre . lureau, 2023/09/12
- [PULL 05/14] vmmouse: use explicit code,
marcandre . lureau <=
- [PULL 06/14] ui/vc: remove kbd_put_keysym() and update function calls, marcandre . lureau, 2023/09/12
- [PULL 07/14] ui/vc: rename kbd_put to qemu_text_console functions, marcandre . lureau, 2023/09/12
- [PULL 08/14] ui/console: remove redundant format field, marcandre . lureau, 2023/09/12
- [PULL 09/14] ui/vc: preliminary QemuTextConsole changes before split, marcandre . lureau, 2023/09/12
- [PULL 10/14] ui/vc: split off the VC part from console.c, marcandre . lureau, 2023/09/12
- [PULL 11/14] ui/console: move DisplaySurface to its own header, marcandre . lureau, 2023/09/12
- [PULL 12/14] virtio-gpu/win32: set the destroy function on load, marcandre . lureau, 2023/09/12
- [PULL 13/14] ui: fix crash when there are no active_console, marcandre . lureau, 2023/09/12