Skip to content

Commit

Permalink
Include virtual screen origin offset in mouse normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
cbdevnet committed May 17, 2020
1 parent 100b8f2 commit 165fd82
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions backends/wininput.c
@@ -1,5 +1,5 @@
#define BACKEND_NAME "wininput"
//#define DEBUG
#define DEBUG

#include <string.h>
#include "wininput.h"
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 165fd82

Please sign in to comment.