Commit 6fd31a8 1 parent 8e0cc92 commit 6fd31a8 Copy full SHA for 6fd31a8
File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,25 @@ void moveMouse(MMPoint point)
66
66
CGEventRef move = CGEventCreateMouseEvent (NULL , kCGEventMouseMoved ,
67
67
CGPointFromMMPoint (point ),
68
68
kCGMouseButtonLeft );
69
+
70
+
71
+ /**
72
+ * The next few lines are a workaround for games not detecting mouse moves.
73
+ * See this issue for more information:
74
+ * https://github.com/octalmage/robotjs/issues/159
75
+ */
76
+ CGEventRef get = CGEventCreate (NULL );
77
+ CGPoint mouse = CGEventGetLocation (get );
78
+
79
+ // Calculate the deltas.
80
+ int64_t deltaX = point .x - mouse .x ;
81
+ int64_t deltaY = point .y - mouse .y ;
82
+
83
+ CGEventSetIntegerValueField (move , kCGMouseEventDeltaY , deltaX );
84
+ CGEventSetIntegerValueField (move , kCGMouseEventDeltaX , deltaY );
85
+
69
86
CGEventPost (kCGSessionEventTap , move );
87
+ CFRelease (get );
70
88
CFRelease (move );
71
89
#elif defined(USE_X11 )
72
90
Display * display = XGetMainDisplay ();
You can’t perform that action at this time.
0 commit comments