-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInput.cpp
More file actions
78 lines (60 loc) · 1.23 KB
/
Input.cpp
File metadata and controls
78 lines (60 loc) · 1.23 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
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Overlord Project
* Copyright (C) 2016-2017 RangeMachine
*/
#pragma once
#include "Input.h"
#include "Settings.h"
#include "ImGui/imgui.h"
Input* Input::m_pInstance;
Input::Input()
{
}
Input::~Input()
{
}
void Input::StartThread()
{
m_hThread = CreateThread(NULL, NULL, reinterpret_cast<LPTHREAD_START_ROUTINE>(MenuKeyMonitor), NULL, NULL, NULL);
}
void Input::StopThread()
{
TerminateThread(m_hThread, 0);
}
void Input::MenuKeyMonitor()
{
HWND gameWindow = FindWindowA(NULL, "Rainbow Six");
while (true)
{
if (Settings::GetInstance()->Menu)
{
POINT mousePosition;
GetCursorPos(&mousePosition);
ScreenToClient(gameWindow, &mousePosition);
ImGuiIO& io = ImGui::GetIO();
io.MousePos.x = mousePosition.x;
io.MousePos.y = mousePosition.y;
if (GetAsyncKeyState(VK_LBUTTON))
io.MouseDown[0] = true;
else
io.MouseDown[0] = false;
}
else
{
std::this_thread::sleep_for(
std::chrono::milliseconds(250));
}
if (GetAsyncKeyState(VK_INSERT))
{
Settings::GetInstance()->Menu = !Settings::GetInstance()->Menu;
std::this_thread::sleep_for(
std::chrono::milliseconds(250));
}
}
}
Input* Input::GetInstance()
{
if (!m_pInstance)
m_pInstance = new Input();
return m_pInstance;
}