mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
rename type names make clearer
This commit is contained in:
parent
4df22c5baa
commit
772a43de44
36
base/types.h
36
base/types.h
@ -16,12 +16,12 @@ struct _MMPoint {
|
|||||||
|
|
||||||
typedef struct _MMPoint MMPoint;
|
typedef struct _MMPoint MMPoint;
|
||||||
|
|
||||||
struct _MMSignedPoint {
|
struct _MMPointInt32 {
|
||||||
int32_t x;
|
int32_t x;
|
||||||
int32_t y;
|
int32_t y;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _MMSignedPoint MMSignedPoint;
|
typedef struct _MMPointInt32 MMPointInt32;
|
||||||
|
|
||||||
struct _MMSize {
|
struct _MMSize {
|
||||||
size_t width;
|
size_t width;
|
||||||
@ -30,12 +30,12 @@ struct _MMSize {
|
|||||||
|
|
||||||
typedef struct _MMSize MMSize;
|
typedef struct _MMSize MMSize;
|
||||||
|
|
||||||
struct _MMSignedSize {
|
struct _MMSizeInt32 {
|
||||||
int32_t w;
|
int32_t w;
|
||||||
int32_t h;
|
int32_t h;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _MMSignedSize MMSignedSize;
|
typedef struct _MMSizeInt32 MMSizeInt32;
|
||||||
|
|
||||||
|
|
||||||
struct _MMRect {
|
struct _MMRect {
|
||||||
@ -45,12 +45,12 @@ struct _MMRect {
|
|||||||
|
|
||||||
typedef struct _MMRect MMRect;
|
typedef struct _MMRect MMRect;
|
||||||
|
|
||||||
struct _MMSignedRect {
|
struct _MMRectInt32 {
|
||||||
MMSignedPoint origin;
|
MMPointInt32 origin;
|
||||||
MMSignedSize size;
|
MMSizeInt32 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _MMSignedRect MMSignedRect;
|
typedef struct _MMRectInt32 MMRectInt32;
|
||||||
|
|
||||||
H_INLINE MMPoint MMPointMake(size_t x, size_t y)
|
H_INLINE MMPoint MMPointMake(size_t x, size_t y)
|
||||||
{
|
{
|
||||||
@ -60,9 +60,9 @@ H_INLINE MMPoint MMPointMake(size_t x, size_t y)
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
H_INLINE MMSignedPoint MMSignedPointMake(int32_t x, int32_t y)
|
H_INLINE MMPointInt32 MMPointInt32Make(int32_t x, int32_t y)
|
||||||
{
|
{
|
||||||
MMSignedPoint point;
|
MMPointInt32 point;
|
||||||
point.x = x;
|
point.x = x;
|
||||||
point.y = y;
|
point.y = y;
|
||||||
return point;
|
return point;
|
||||||
@ -76,9 +76,9 @@ H_INLINE MMSize MMSizeMake(size_t width, size_t height)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
H_INLINE MMSignedSize MMSignedSizeMake(int32_t w, int32_t h)
|
H_INLINE MMSizeInt32 MMSizeInt32Make(int32_t w, int32_t h)
|
||||||
{
|
{
|
||||||
MMSignedSize size;
|
MMSizeInt32 size;
|
||||||
size.w = w;
|
size.w = w;
|
||||||
size.h = h;
|
size.h = h;
|
||||||
return size;
|
return size;
|
||||||
@ -92,11 +92,11 @@ H_INLINE MMRect MMRectMake(size_t x, size_t y, size_t width, size_t height)
|
|||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
H_INLINE MMSignedRect MMSignedRectMake(int32_t x, int32_t y, int32_t w, int32_t h)
|
H_INLINE MMRectInt32 MMRectInt32Make(int32_t x, int32_t y, int32_t w, int32_t h)
|
||||||
{
|
{
|
||||||
MMSignedRect rect;
|
MMRectInt32 rect;
|
||||||
rect.origin = MMSignedPointMake(x, y);
|
rect.origin = MMPointInt32Make(x, y);
|
||||||
rect.size = MMSignedSizeMake(w, h);
|
rect.size = MMSizeInt32Make(w, h);
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,8 +108,8 @@ H_INLINE MMSignedRect MMSignedRectMake(int32_t x, int32_t y, int32_t w, int32_t
|
|||||||
#define CGPointFromMMPoint(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
|
#define CGPointFromMMPoint(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
|
||||||
#define MMPointFromCGPoint(p) MMPointMake((size_t)(p).x, (size_t)(p).y)
|
#define MMPointFromCGPoint(p) MMPointMake((size_t)(p).x, (size_t)(p).y)
|
||||||
|
|
||||||
#define CGPointFromMMSignedPoint(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
|
#define CGPointFromMMPointInt32(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
|
||||||
#define MMSignedPointFromCGPoint(p) MMPointMake((int32_t)(p).x, (int32_t)(p).y)
|
#define MMPointInt32FromCGPoint(p) MMPointMake((int32_t)(p).x, (int32_t)(p).y)
|
||||||
|
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@ int mouseDelay = 10;
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
int move_mouse(int32_t x, int32_t y){
|
int move_mouse(int32_t x, int32_t y){
|
||||||
MMSignedPoint point;
|
MMPointInt32 point;
|
||||||
// int x = 103;
|
// int x = 103;
|
||||||
// int y = 104;
|
// int y = 104;
|
||||||
point = MMSignedPointMake(x, y);
|
point = MMPointInt32Make(x, y);
|
||||||
moveMouse(point);
|
moveMouse(point);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -51,8 +51,8 @@ int drag_mouse(int32_t x, int32_t y, MMMouseButton button){
|
|||||||
// const size_t y = 20;
|
// const size_t y = 20;
|
||||||
// MMMouseButton button = LEFT_BUTTON;
|
// MMMouseButton button = LEFT_BUTTON;
|
||||||
|
|
||||||
MMSignedPoint point;
|
MMPointInt32 point;
|
||||||
point = MMSignedPointMake(x, y);
|
point = MMPointInt32Make(x, y);
|
||||||
dragMouse(point, button);
|
dragMouse(point, button);
|
||||||
microsleep(mouseDelay);
|
microsleep(mouseDelay);
|
||||||
|
|
||||||
|
@ -65,13 +65,13 @@ typedef int MMMouseWheelDirection;
|
|||||||
/* Immediately moves the mouse to the given point on-screen.
|
/* Immediately moves the mouse to the given point on-screen.
|
||||||
* It is up to the caller to ensure that this point is within the
|
* It is up to the caller to ensure that this point is within the
|
||||||
* screen boundaries. */
|
* screen boundaries. */
|
||||||
void moveMouse(MMSignedPoint point);
|
void moveMouse(MMPointInt32 point);
|
||||||
|
|
||||||
/* Like moveMouse, moves the mouse to the given point on-screen, but marks
|
/* 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.
|
* 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
|
* It is up to the caller to ensure that this point is within the screen
|
||||||
* boundaries. */
|
* boundaries. */
|
||||||
void dragMouse(MMSignedPoint point, const MMMouseButton button);
|
void dragMouse(MMPointInt32 point, const MMMouseButton button);
|
||||||
|
|
||||||
/* Smoothly moves the mouse from the current position to the given point.
|
/* Smoothly moves the mouse from the current position to the given point.
|
||||||
* deadbeef_srand() should be called before using this function.
|
* deadbeef_srand() should be called before using this function.
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
* @param event The mouse move event (by ref).
|
* @param event The mouse move event (by ref).
|
||||||
* @param point The new mouse x and y.
|
* @param point The new mouse x and y.
|
||||||
*/
|
*/
|
||||||
void calculateDeltas(CGEventRef *event, MMSignedPoint point){
|
void calculateDeltas(CGEventRef *event, MMPointInt32 point){
|
||||||
/**
|
/**
|
||||||
* The next few lines are a workaround for games not detecting mouse moves.
|
* The next few lines are a workaround for games not detecting mouse moves.
|
||||||
* See this issue for more information:
|
* See this issue for more information:
|
||||||
@ -91,10 +91,10 @@ void calculateDeltas(CGEventRef *event, MMSignedPoint point){
|
|||||||
* Move the mouse to a specific point.
|
* Move the mouse to a specific point.
|
||||||
* @param point The coordinates to move the mouse to (x, y).
|
* @param point The coordinates to move the mouse to (x, y).
|
||||||
*/
|
*/
|
||||||
void moveMouse(MMSignedPoint point){
|
void moveMouse(MMPointInt32 point){
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved,
|
CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved,
|
||||||
CGPointFromMMSignedPoint(point),
|
CGPointFromMMPointInt32(point),
|
||||||
kCGMouseButtonLeft);
|
kCGMouseButtonLeft);
|
||||||
|
|
||||||
calculateDeltas(&move, point);
|
calculateDeltas(&move, point);
|
||||||
@ -129,7 +129,7 @@ void moveMouse(MMSignedPoint point){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dragMouse(MMSignedPoint point, const MMMouseButton button){
|
void dragMouse(MMPointInt32 point, const MMMouseButton button){
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
const CGEventType dragType = MMMouseDragToCGEventType(button);
|
const CGEventType dragType = MMMouseDragToCGEventType(button);
|
||||||
CGEventRef drag = CGEventCreateMouseEvent(NULL, dragType,
|
CGEventRef drag = CGEventCreateMouseEvent(NULL, dragType,
|
||||||
@ -432,7 +432,7 @@ bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveMouse(MMSignedPointMake((int32_t)pos.x, (int32_t)pos.y));
|
moveMouse(MMPointInt32Make((int32_t)pos.x, (int32_t)pos.y));
|
||||||
|
|
||||||
/* Wait 1 - 3 milliseconds. */
|
/* Wait 1 - 3 milliseconds. */
|
||||||
microsleep(DEADBEEF_UNIFORM(lowSpeed, highSpeed));
|
microsleep(DEADBEEF_UNIFORM(lowSpeed, highSpeed));
|
||||||
|
Loading…
Reference in New Issue
Block a user