From 6a1f060a8c907cdb37a2890db2bbc7a7c66d1904 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Sat, 8 Mar 2025 15:02:39 -0800 Subject: [PATCH] Refactor: simplify mouse movement implementation for Windows, use setCursorPos instead of mouse_event --- mouse/mouse_c.h | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/mouse/mouse_c.h b/mouse/mouse_c.h index 0f4ee86..adf8b7d 100644 --- a/mouse/mouse_c.h +++ b/mouse/mouse_c.h @@ -96,25 +96,7 @@ void moveMouse(MMPointInt32 point){ XSync(display, false); #elif defined(IS_WINDOWS) - // Mouse motion is now done using SendInput with MOUSEINPUT. - // We use Absolute mouse positioning - #define MOUSE_COORD_TO_ABS(coord, width_or_height) ( \ - ((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1)) - - MMRectInt32 rect = getScreenRect(1); - int32_t x = MOUSE_COORD_TO_ABS(point.x - rect.origin.x, rect.size.w); - int32_t y = MOUSE_COORD_TO_ABS(point.y - rect.origin.y, rect.size.h); - - INPUT mouseInput; - mouseInput.type = INPUT_MOUSE; - mouseInput.mi.dx = x; - mouseInput.mi.dy = y; - mouseInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_VIRTUALDESK; - mouseInput.mi.time = 0; // System will provide the timestamp - - mouseInput.mi.dwExtraInfo = 0; - mouseInput.mi.mouseData = 0; - SendInput(1, &mouseInput, sizeof(mouseInput)); + SetCursorPos(point.x, point.y); #endif }