forked from JDoe212/DS-FPS-Mouse-Fixer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUniversal_Functions.cpp
76 lines (62 loc) · 1.91 KB
/
Universal_Functions.cpp
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
/*
目的: このファイルには、他の「XXX_Functions.c」ファイルで使用される関数が含まれている。これらの関数は、すべてのゲームを実行するために必要.
*/
#include <windows.h>
#include <thread>
extern int mouseUp, mouseDown, activeMouse;
extern int mouseResetWait, buttonWait, swapWait, keyWait;
extern int autoMouseDrag;
extern RECT playSpace;
extern POINT center;
__forceinline void GetActiveMouseDown(const int *waitTime)
{
while (GetAsyncKeyState(activeMouse) >= 0) { }
Sleep(*waitTime);
}
__forceinline void GetActiveMouseUp(const int *waitTime)
{
while (GetAsyncKeyState(activeMouse) < 0) { }
Sleep(*waitTime);
}
__forceinline void LockPlaySpace()
{
ClipCursor(&playSpace);
}
__forceinline void CursorUp()
{
mouse_event(mouseUp, 0, 0, 0, 0);
GetActiveMouseUp(&mouseResetWait);
}
__forceinline void lockPlaySpaceAfterResetPos() {
RECT tempRect;
GetClipCursor(&tempRect);
if (tempRect.left != playSpace.left || tempRect.right != playSpace.right ||
tempRect.top != playSpace.top || tempRect.bottom != playSpace.bottom)
{
LockPlaySpace();
}
}
__forceinline void ResetPos()
{
mouse_event(mouseUp, 0, 0, 0, 0);
GetActiveMouseUp(&mouseResetWait);
SetCursorPos(center.x, center.y);
if (autoMouseDrag)
{
mouse_event(mouseDown, 0, 0, 0, 0);
}
std::thread lockPlaySpaceAfterResetPos_thread(lockPlaySpaceAfterResetPos);
lockPlaySpaceAfterResetPos_thread.detach(); // スレッドをデタッチして、バックグラウンドで実行
}
__forceinline int ResetPosAfterButton()
{
GetActiveMouseDown(&buttonWait);
mouse_event(mouseUp, 0, 0, 0, 0);
GetActiveMouseUp(&buttonWait);
SetCursorPos(center.x, center.y);
if (autoMouseDrag)
{
mouse_event(mouseDown, 0, 0, 0, 0);
}
return 0;
}