From 165fd82294090ea970e90c1b5436a5a98dc58eb9 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 17 May 2020 18:37:47 +0200 Subject: Include virtual screen origin offset in mouse normalization --- backends/wininput.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backends/wininput.c b/backends/wininput.c index 0f35364..f044a7c 100644 --- a/backends/wininput.c +++ b/backends/wininput.c @@ -1,5 +1,5 @@ #define BACKEND_NAME "wininput" -//#define DEBUG +#define DEBUG #include #include "wininput.h" @@ -262,9 +262,8 @@ static channel* wininput_channel(instance* inst, char* spec, uint8_t flags){ //for some reason, sendinput only takes "normalized absolute coordinates", which are never again used in the API static void wininput_mouse_normalize(long* x, long* y){ - //TODO this needs to take a possible origin offset into account - long normalized_x = (double) (*x) * (65535.0f / (double) cfg.virtual_width); - long normalized_y = (double) (*y) * (65535.0f / (double) cfg.virtual_height); + long normalized_x = (double) (*x + cfg.virtual_x) * (65535.0f / (double) cfg.virtual_width); + long normalized_y = (double) (*y + cfg.virtual_y) * (65535.0f / (double) cfg.virtual_height); *x = normalized_x; *y = normalized_y; -- cgit v1.2.3