// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://www. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #include "../base/types.h" #include "mouse_init.h" //Global delays. int mouseDelay = 10; // int keyboardDelay = 10; // int CheckMouseButton(const char * const b, MMMouseButton * const button){ // if (!button) return -1; // if (strcmp(b, "left") == 0) // { // *button = LEFT_BUTTON; // } // else if (strcmp(b, "right") == 0) // { // *button = RIGHT_BUTTON; // } // else if (strcmp(b, "middle") == 0) // { // *button = CENTER_BUTTON; // } // else // { // return -2; // } // return 0; // } int aMoveMouse(size_t x, size_t y){ MMPoint point; //int x =103; //int y =104; point = MMPointMake(x, y); moveMouse(point); return 0; } int aDragMouse(size_t x, size_t y){ // const size_t x=10; // const size_t y=20; MMMouseButton button = LEFT_BUTTON; MMPoint point; point = MMPointMake(x, y); dragMouse(point, button); microsleep(mouseDelay); // printf("%s\n","gyp-----"); return 0; } int aMoveMouseSmooth(size_t x, size_t y){ MMPoint point; point = MMPointMake(x, y); smoothlyMoveMouse(point); microsleep(mouseDelay); return 0; } MMPoint aGetMousePos(){ MMPoint pos = getMousePos(); //Return object with .x and .y. // printf("%zu\n%zu\n", pos.x, pos.y ); return pos; } int aMouseClick(){ MMMouseButton button = LEFT_BUTTON; bool doubleC = false; if (!doubleC){ clickMouse(button); }else{ doubleClick(button); } microsleep(mouseDelay); return 0; } int aMouseToggle(char* d,MMMouseButton button){ // MMMouseButton button = LEFT_BUTTON; bool down = false; if (strcmp(d, "down") == 0){ down = true; }else if (strcmp(d, "up") == 0){ down = false; }else{ return 1; } toggleMouse(down, button); microsleep(mouseDelay); return 0; } int aSetMouseDelay(size_t val){ // int val=10; mouseDelay = val; return 0; } int aScrollMouse(size_t scrollMagnitude,char *s){ // int scrollMagnitude = 20; MMMouseWheelDirection scrollDirection; if (strcmp(s, "up") == 0){ scrollDirection = DIRECTION_UP; }else if (strcmp(s, "down") == 0){ scrollDirection = DIRECTION_DOWN; }else{ // return "Invalid scroll direction specified."; return 1; } scrollMouse(scrollMagnitude, scrollDirection); microsleep(mouseDelay); return 0; }