-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrawinput.h
54 lines (40 loc) · 1.36 KB
/
rawinput.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
#ifndef RAWINPUT_H_
#define RAWINPUT_H_
#include <windows.h>
#include <detours.h> // Required for function hooking
#define RAWINPUTHDRSIZE sizeof(RAWINPUTHEADER)
#define RAWPTRSIZE 40
#define INPUTWINDOW "RInput"
// Prevent warning level 4 warnings for detouring
#pragma warning(disable: 4100)
/**
* Sadly everything has been made static, as Win32 API does not support object oriented callbacks, as it has been written in C.
* To keep the performance as high as possible, I decided not to work with storing the class instance through Win32 API.
* Feel free to rewrite this to something more clean in coding terms :).
*/
class CRawInput {
public:
// Initialize raw input
static bool initialize(WCHAR* pwszError);
// Enable/Disable the hooking
static bool hookLibrary(bool bInstall);
// Hooked functions handling
static int __stdcall hGetCursorPos(LPPOINT lpPoint);
static int __stdcall hSetCursorPos(int x, int y);
// Poll Input
static unsigned int pollInput();
// Input Window Proc
static LRESULT __stdcall wpInput(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
// Initialization
static bool initWindow(WCHAR* pwszError);
static bool initInput(WCHAR* pwszError);
// Unload Raw Input
static void unload();
private:
static long x;
static long y;
static HWND hwndInput;
static bool bRegistered;
};
extern void displayError(WCHAR* pwszError);
#endif