rename type names make clearer

This commit is contained in:
vcaesar 2019-12-01 08:46:04 -04:00
parent 4df22c5baa
commit 772a43de44
4 changed files with 29 additions and 29 deletions

View File

@ -16,12 +16,12 @@ struct _MMPoint {
typedef struct _MMPoint MMPoint;
struct _MMSignedPoint {
struct _MMPointInt32 {
int32_t x;
int32_t y;
};
typedef struct _MMSignedPoint MMSignedPoint;
typedef struct _MMPointInt32 MMPointInt32;
struct _MMSize {
size_t width;
@ -30,12 +30,12 @@ struct _MMSize {
typedef struct _MMSize MMSize;
struct _MMSignedSize {
struct _MMSizeInt32 {
int32_t w;
int32_t h;
};
typedef struct _MMSignedSize MMSignedSize;
typedef struct _MMSizeInt32 MMSizeInt32;
struct _MMRect {
@ -45,12 +45,12 @@ struct _MMRect {
typedef struct _MMRect MMRect;
struct _MMSignedRect {
MMSignedPoint origin;
MMSignedSize size;
struct _MMRectInt32 {
MMPointInt32 origin;
MMSizeInt32 size;
};
typedef struct _MMSignedRect MMSignedRect;
typedef struct _MMRectInt32 MMRectInt32;
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;
}
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.y = y;
return point;
@ -76,9 +76,9 @@ H_INLINE MMSize MMSizeMake(size_t width, size_t height)
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.h = h;
return size;
@ -92,11 +92,11 @@ H_INLINE MMRect MMRectMake(size_t x, size_t y, size_t width, size_t height)
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;
rect.origin = MMSignedPointMake(x, y);
rect.size = MMSignedSizeMake(w, h);
MMRectInt32 rect;
rect.origin = MMPointInt32Make(x, y);
rect.size = MMSizeInt32Make(w, h);
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 MMPointFromCGPoint(p) MMPointMake((size_t)(p).x, (size_t)(p).y)
#define CGPointFromMMSignedPoint(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
#define MMSignedPointFromCGPoint(p) MMPointMake((int32_t)(p).x, (int32_t)(p).y)
#define CGPointFromMMPointInt32(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
#define MMPointInt32FromCGPoint(p) MMPointMake((int32_t)(p).x, (int32_t)(p).y)
#elif defined(IS_WINDOWS)

View File

@ -36,10 +36,10 @@ int mouseDelay = 10;
// }
int move_mouse(int32_t x, int32_t y){
MMSignedPoint point;
MMPointInt32 point;
// int x = 103;
// int y = 104;
point = MMSignedPointMake(x, y);
point = MMPointInt32Make(x, y);
moveMouse(point);
return 0;
@ -51,8 +51,8 @@ int drag_mouse(int32_t x, int32_t y, MMMouseButton button){
// const size_t y = 20;
// MMMouseButton button = LEFT_BUTTON;
MMSignedPoint point;
point = MMSignedPointMake(x, y);
MMPointInt32 point;
point = MMPointInt32Make(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(MMSignedPoint point);
void moveMouse(MMPointInt32 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(MMSignedPoint point, const MMMouseButton button);
void dragMouse(MMPointInt32 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, MMSignedPoint point){
void calculateDeltas(CGEventRef *event, MMPointInt32 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, MMSignedPoint point){
* Move the mouse to a specific point.
* @param point The coordinates to move the mouse to (x, y).
*/
void moveMouse(MMSignedPoint point){
void moveMouse(MMPointInt32 point){
#if defined(IS_MACOSX)
CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved,
CGPointFromMMSignedPoint(point),
CGPointFromMMPointInt32(point),
kCGMouseButtonLeft);
calculateDeltas(&move, point);
@ -129,7 +129,7 @@ void moveMouse(MMSignedPoint point){
#endif
}
void dragMouse(MMSignedPoint point, const MMMouseButton button){
void dragMouse(MMPointInt32 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(MMSignedPointMake((int32_t)pos.x, (int32_t)pos.y));
moveMouse(MMPointInt32Make((int32_t)pos.x, (int32_t)pos.y));
/* Wait 1 - 3 milliseconds. */
microsleep(DEADBEEF_UNIFORM(lowSpeed, highSpeed));