add drag and move mouse multiple screens support

This commit is contained in:
vcaesar 2019-11-30 14:28:38 -04:00
parent a3da8915b9
commit 4df22c5baa
4 changed files with 26 additions and 26 deletions

View File

@ -35,24 +35,24 @@ int mouseDelay = 10;
// return 0;
// }
int move_mouse(size_t x, size_t y){
MMPoint point;
int move_mouse(int32_t x, int32_t y){
MMSignedPoint point;
// int x = 103;
// int y = 104;
point = MMPointMake(x, y);
point = MMSignedPointMake(x, y);
moveMouse(point);
return 0;
}
int drag_mouse(size_t x, size_t y, MMMouseButton button){
int drag_mouse(int32_t x, int32_t y, MMMouseButton button){
// const size_t x = 10;
// const size_t y = 20;
// MMMouseButton button = LEFT_BUTTON;
MMPoint point;
point = MMPointMake(x, y);
MMSignedPoint point;
point = MMSignedPointMake(x, y);
dragMouse(point, button);
microsleep(mouseDelay);

View File

@ -65,13 +65,13 @@ typedef int MMMouseWheelDirection;
/* Immediately moves the mouse to the given point on-screen.
* It is up to the caller to ensure that this point is within the
* screen boundaries. */
void moveMouse(MMPoint point);
void moveMouse(MMSignedPoint point);
/* Like moveMouse, moves the mouse to the given point on-screen, but marks
* the event as the mouse being dragged on platforms where it is supported.
* It is up to the caller to ensure that this point is within the screen
* boundaries. */
void dragMouse(MMPoint point, const MMMouseButton button);
void dragMouse(MMSignedPoint point, const MMMouseButton button);
/* Smoothly moves the mouse from the current position to the given point.
* deadbeef_srand() should be called before using this function.

View File

@ -66,7 +66,7 @@
* @param event The mouse move event (by ref).
* @param point The new mouse x and y.
*/
void calculateDeltas(CGEventRef *event, MMPoint point){
void calculateDeltas(CGEventRef *event, MMSignedPoint point){
/**
* The next few lines are a workaround for games not detecting mouse moves.
* See this issue for more information:
@ -91,10 +91,10 @@ void calculateDeltas(CGEventRef *event, MMPoint point){
* Move the mouse to a specific point.
* @param point The coordinates to move the mouse to (x, y).
*/
void moveMouse(MMPoint point){
void moveMouse(MMSignedPoint point){
#if defined(IS_MACOSX)
CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved,
CGPointFromMMPoint(point),
CGPointFromMMSignedPoint(point),
kCGMouseButtonLeft);
calculateDeltas(&move, point);
@ -129,7 +129,7 @@ void moveMouse(MMPoint point){
#endif
}
void dragMouse(MMPoint point, const MMMouseButton button){
void dragMouse(MMSignedPoint point, const MMMouseButton button){
#if defined(IS_MACOSX)
const CGEventType dragType = MMMouseDragToCGEventType(button);
CGEventRef drag = CGEventCreateMouseEvent(NULL, dragType,
@ -432,7 +432,7 @@ bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed){
return false;
}
moveMouse(pos);
moveMouse(MMSignedPointMake((int32_t)pos.x, (int32_t)pos.y));
/* Wait 1 - 3 milliseconds. */
microsleep(DEADBEEF_UNIFORM(lowSpeed, highSpeed));

View File

@ -359,8 +359,8 @@ func MoveMouse(x, y int) {
// Move move the mouse
func Move(x, y int) {
cx := C.size_t(x)
cy := C.size_t(y)
cx := C.int32_t(x)
cy := C.int32_t(y)
C.move_mouse(cx, cy)
}
@ -373,8 +373,8 @@ func DragMouse(x, y int, args ...string) {
func Drag(x, y int, args ...string) {
var button C.MMMouseButton = C.LEFT_BUTTON
cx := C.size_t(x)
cy := C.size_t(y)
cx := C.int32_t(x)
cy := C.int32_t(y)
if len(args) > 0 {
button = CheckMouse(args[0])