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
106
107
|
#include "includes.h"
int mouseController::vx=0;
int mouseController::vy=0;
byte mouseController::mouseKeys[9]={0};
bool mouseController::mouseButtonStates[3]={0};
wchar mouseController::mouseSymbols[9]={0x15CF,0x15CB,0x15CC,0x15CA,0x15E1,0x15DE,0x15DD,0x15E3,0x15E2};
// generate mouse event for the specified button
void mouseController::mouseEvent(DWORD vkCode, bool isReleased){
INPUT in;
memset(&in,0,sizeof(INPUT));
in.type=INPUT_MOUSE;
if(vkCode==mouseKeys[MOUSE_MOVE_L]){
if(isReleased){
vx=0;
return;
}
if(vx>0){vx=0;}
if(vx>-20){vx--;}
in.mi.dx=vx;
in.mi.dwFlags=MOUSEEVENTF_MOVE;
}
else if(vkCode==mouseKeys[MOUSE_MOVE_R]){
if(isReleased){
vx=0;
return;
}
if(vx<0){vx=0;}
if(vx<20){vx++;}
in.mi.dx=vx;
in.mi.dwFlags=MOUSEEVENTF_MOVE;
}
else if(vkCode==mouseKeys[MOUSE_MOVE_U]){
if(isReleased){
vy=0;
return;
}
if(vy>0){vy=0;}
if(vy>-20){vy--;}
in.mi.dy=vy;
in.mi.dwFlags=MOUSEEVENTF_MOVE;
}
else if(vkCode==mouseKeys[MOUSE_MOVE_D]){
if(isReleased){
vy=0;
return;
}
if(vy<0){vy=0;}
if(vy<20){vy++;}
in.mi.dy=vy;
in.mi.dwFlags=MOUSEEVENTF_MOVE;
}
else if(vkCode==mouseKeys[MOUSE_BUTTON_L]){
if(!isReleased && mouseButtonStates[0]){return;} // dont resend clicks
if(!isReleased){
in.mi.dwFlags=MOUSEEVENTF_LEFTDOWN;
mouseButtonStates[0]=true;
}
else{
in.mi.dwFlags=MOUSEEVENTF_LEFTUP;
mouseButtonStates[0]=false;
}
}
else if(vkCode==mouseKeys[MOUSE_BUTTON_R]){
if(!isReleased && mouseButtonStates[1]){return;} // dont resend clicks
if(!isReleased){
in.mi.dwFlags=MOUSEEVENTF_RIGHTDOWN;
mouseButtonStates[1]=true;
}
else{
in.mi.dwFlags=MOUSEEVENTF_RIGHTUP;
mouseButtonStates[1]=false;
}
}
else if(vkCode==mouseKeys[MOUSE_BUTTON_M]){
if(!isReleased && mouseButtonStates[2]){return;} // dont resend clicks
if(!isReleased){
in.mi.dwFlags=MOUSEEVENTF_MIDDLEDOWN;
mouseButtonStates[2]=true;
}
else{
in.mi.dwFlags=MOUSEEVENTF_MIDDLEUP;
mouseButtonStates[2]=false;
}
}
else if(vkCode==mouseKeys[MOUSE_SCROLL_U]){
if(isReleased){return;}
in.mi.dwFlags=MOUSEEVENTF_WHEEL;
in.mi.mouseData=WHEEL_DELTA;
}
else if(vkCode==mouseKeys[MOUSE_SCROLL_D]){
if(isReleased){return;}
in.mi.dwFlags=MOUSEEVENTF_WHEEL;
in.mi.mouseData=-WHEEL_DELTA;
}
else{
return; // do not call sendinput
}
// send mouse event
SendInput(1,&in,sizeof(INPUT));
}
|