-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouseManager.hpp
More file actions
65 lines (47 loc) · 1.46 KB
/
mouseManager.hpp
File metadata and controls
65 lines (47 loc) · 1.46 KB
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
#pragma once
#include <windows.h>
#include <atomic>
#include <thread>
#include <mutex>
#include <condition_variable>
#include "lockfreequeue.hpp"
#include "settings/config.hpp"
#include "overlayController.hpp"
namespace mm {
class MouseManager {
public:
MouseManager(HINSTANCE hi, Config* cfg);
~MouseManager();
void InstallHook();
void UninstallHook();
private:
static LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam);
void InputLoop(std::stop_token st);
void HookLoop(std::stop_token st);
void ProcessMouse(WPARAM wp);
static inline MouseManager* instance = nullptr;
Config* config = nullptr;
HHOOK hookHandle = nullptr;
DWORD hookThreadId = 0;
std::jthread inputThread;
std::jthread hookThread;
std::condition_variable cv;
std::mutex cvMutex;
std::condition_variable hookCv;
std::mutex hookCvMutex;
std::atomic<POINT> latestMousePos = {POINT{0, 0}};
std::atomic<POINT> lastDownPt{POINT{0, 0}};
POINT dragOffset = {};
POINT resizeStartCursor = {};
RECT resizeStartRect = {};
HWND targetWindow = nullptr;
OverlayController overlayController;
bool installHookRequested = false;
bool uninstallHookRequested = false;
bool allowLUpPassthrough = false;
bool allowRUpPassthrough = false;
LockFreeQueue<WPARAM, 16> mouseQueue;
ResizeCorner resizeCorner = ResizeCorner::BottomRight; // default
HINSTANCE hInstance;
};
} // namespace mm