Skip to content

Commit

Permalink
test alternative method
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazer committed May 21, 2024
1 parent 02878a2 commit 82ef899
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/platform/windows/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ namespace platf {
}

void
abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) {
abs_mouse2(input_t &input, const touch_port_t &touch_port, float x, float y) {
INPUT i {};

i.type = INPUT_MOUSE;
Expand All @@ -528,14 +528,25 @@ namespace platf {
send_input(i);
}

void
abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) {
INPUT i {};
i.type = INPUT_MOUSE;
auto &mi = i.mi;
mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
mi.dx = (x * 65535) / GetSystemMetrics(SM_CXSCREEN);
mi.dy = (y * 65535) / GetSystemMetrics(SM_CYSCREEN);
send_input(i);
}

void
move_mouse(input_t &input, int deltaX, int deltaY) {
INPUT i {};

i.type = INPUT_MOUSE;
auto &mi = i.mi;

mi.dwFlags = MOUSEEVENTF_MOVE;
mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_MOVE_NOCOALESCE;
mi.dx = deltaX;
mi.dy = deltaY;

Expand All @@ -544,6 +555,7 @@ namespace platf {

util::point_t
get_mouse_loc(input_t &input) {
syncThreadDesktop();
POINT p;
if (!GetCursorPos(&p)) {
return util::point_t { 0.0, 0.0 };
Expand Down

0 comments on commit 82ef899

Please sign in to comment.