forked from octalmage/robotjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse.h
105 lines (83 loc) · 2.59 KB
/
mouse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#pragma once
#ifndef MOUSE_H
#define MOUSE_H
#include "os.h"
#include "types.h"
#if defined(_MSC_VER)
#include "ms_stdbool.h"
#else
#include <stdbool.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#if defined(IS_MACOSX)
#include <ApplicationServices/ApplicationServices.h>
typedef enum {
LEFT_BUTTON = kCGMouseButtonLeft,
RIGHT_BUTTON = kCGMouseButtonRight,
CENTER_BUTTON = kCGMouseButtonCenter
} MMMouseButton;
#elif defined(USE_X11)
enum _MMMouseButton {
LEFT_BUTTON = 1,
CENTER_BUTTON = 2,
RIGHT_BUTTON = 3
};
typedef unsigned int MMMouseButton;
#elif defined(IS_WINDOWS)
enum _MMMouseButton {
LEFT_BUTTON = 1,
CENTER_BUTTON = 2,
RIGHT_BUTTON = 3
};
typedef unsigned int MMMouseButton;
#else
#error "No mouse button constants set for platform"
#endif
#define MMMouseButtonIsValid(button) \
(button == LEFT_BUTTON || button == RIGHT_BUTTON || \
button == CENTER_BUTTON)
enum __MMMouseWheelDirection
{
DIRECTION_DOWN = -1,
DIRECTION_UP = 1
};
typedef int MMMouseWheelDirection;
/* Updates information about current virtual screen size and coordinates
* in Windows
* It is up to the caller to ensure that this called before mouse moving
*/
void updateScreenMetrics();
/* 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);
/* 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);
/* Smoothly moves the mouse from the current position to the given point.
* deadbeef_srand() should be called before using this function.
*
* Returns false if unsuccessful (i.e. a point was hit that is outside of the
* screen boundaries), or true if successful. */
bool smoothlyMoveMouse(MMPoint point,double speed);
/* Returns the coordinates of the mouse on the current screen. */
MMPoint getMousePos(void);
/* Holds down or releases the mouse with the given button in the current
* position. */
void toggleMouse(bool down, MMMouseButton button);
/* Clicks the mouse with the given button in the current position. */
void clickMouse(MMMouseButton button);
/* Double clicks the mouse with the given button. */
void doubleClick(MMMouseButton button);
/* Scrolls the mouse in the stated direction.
* TODO: Add a smoothly scroll mouse next. */
void scrollMouse(int x, int y);
#endif /* MOUSE_H */
#ifdef __cplusplus
}
#endif