[PATCH] Input: vmmouse - add macros to enable vmmouse relative mode

From: Zongmin Zhou
Date: Thu Apr 13 2023 - 04:59:23 EST


Add macros to enable request relative mode.

Change the REL_Y value passed by input_report_rel function,
to match the direction of mouse movement.

Signed-off-by: Zongmin Zhou<zhouzongmin@xxxxxxxxxx>
---
drivers/input/mouse/vmmouse.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
index ea9eff7c8099..f39ce21f7af9 100644
--- a/drivers/input/mouse/vmmouse.c
+++ b/drivers/input/mouse/vmmouse.c
@@ -21,6 +21,12 @@
#include "psmouse.h"
#include "vmmouse.h"

+/*
+ * Enable this to request relative mode.
+ * Defaut to absolute mode.
+ */
+//#define VMMOUSE_RELATIVE_MODE
+
#define VMMOUSE_PROTO_MAGIC 0x564D5868U

/*
@@ -184,7 +190,7 @@ static psmouse_ret_t vmmouse_report_events(struct psmouse *psmouse)
if (status & VMMOUSE_RELATIVE_PACKET) {
pref_dev = rel_dev;
input_report_rel(rel_dev, REL_X, (s32)x);
- input_report_rel(rel_dev, REL_Y, -(s32)y);
+ input_report_rel(rel_dev, REL_Y, (s32)y);
} else {
pref_dev = abs_dev;
input_report_abs(abs_dev, ABS_X, x);
@@ -304,8 +310,13 @@ static int vmmouse_enable(struct psmouse *psmouse)
VMMOUSE_CMD(ABSPOINTER_RESTRICT, VMMOUSE_RESTRICT_CPL0,
dummy1, dummy2, dummy3, dummy4);

+#ifdef VMMOUSE_RELATIVE_MODE
+ VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_REQUEST_RELATIVE,
+ dummy1, dummy2, dummy3, dummy4);
+#else
VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_REQUEST_ABSOLUTE,
dummy1, dummy2, dummy3, dummy4);
+#endif

return 0;
}
--
2.34.1


No virus found
Checked by Hillstone Network AntiVirus