-
Notifications
You must be signed in to change notification settings - Fork 0
/
WndProc.h
112 lines (100 loc) · 2.37 KB
/
WndProc.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
106
107
108
109
110
111
112
#include "imgui\imgui_impl_dx9.h"
#include "imgui\imgui_impl_win32.h"
#include "interfaces.h"
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT __stdcall Hooked_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static int wheelDelta = 0;
const auto getButtonToggle = [uMsg, wParam](bool& bButton, int vKey)
{
if (wParam != vKey) return;
if (uMsg == WM_KEYUP)
bButton = !bButton;
};
if (uMsg == WM_MOUSEWHEEL) {
wheelDelta += GET_WHEEL_DELTA_WPARAM(wParam);
for (; wheelDelta > WHEEL_DELTA; wheelDelta -= WHEEL_DELTA)
csgo->scroll_amount += 1;
for (; wheelDelta < 0; wheelDelta += WHEEL_DELTA)
csgo->scroll_amount -= 1;
}
switch (uMsg) {
case WM_LBUTTONDOWN:
csgo->key_pressed[VK_LBUTTON] = true;
break;
case WM_LBUTTONUP:
csgo->key_pressed[VK_LBUTTON] = false;
break;
case WM_RBUTTONDOWN:
csgo->key_pressed[VK_RBUTTON] = true;
break;
case WM_RBUTTONUP:
csgo->key_pressed[VK_RBUTTON] = false;
break;
case WM_MBUTTONDOWN:
csgo->key_pressed[VK_MBUTTON] = true;
break;
case WM_MBUTTONUP:
csgo->key_pressed[VK_MBUTTON] = false;
break;
case WM_MOUSEMOVE:
break;
case WM_XBUTTONDOWN:
{
UINT button = GET_XBUTTON_WPARAM(wParam);
if (button == XBUTTON1)
{
csgo->key_pressed[VK_XBUTTON1] = true;
}
else if (button == XBUTTON2)
{
csgo->key_pressed[VK_XBUTTON2] = true;
}
break;
}
case WM_XBUTTONUP:
{
UINT button = GET_XBUTTON_WPARAM(wParam);
if (button == XBUTTON1)
{
csgo->key_pressed[VK_XBUTTON1] = false;
}
else if (button == XBUTTON2)
{
csgo->key_pressed[VK_XBUTTON2] = false;
}
break;
}
case WM_MOUSEWHEEL:
{
break;
}
case WM_SYSKEYDOWN:
csgo->key_pressed[18] = true;
break;
case WM_SYSKEYUP:
csgo->key_pressed[18] = false;
break;
case WM_KEYDOWN:
csgo->key_pressed[wParam] = true;
break;
case WM_KEYUP:
csgo->key_pressed[wParam] = false;
break;
default: break;
}
//window->update_keystates();
for (int i = 0; i < 256; i++) {
if (csgo->key_pressed[i])
csgo->key_down[i] = csgo->key_pressedticks[i]++ == 0;
else
csgo->key_pressedticks[i] = 0;
}
getButtonToggle(vars.menu.open, VK_INSERT);
if (vars.menu.open) {
ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam);
if (ImGui::GetIO().WantTextInput)
return true;
}
return CallWindowProc(csgo->Init.OldWindow, hWnd, uMsg, wParam, lParam);
}