Skip to content

Commit a801747

Browse files
Add files via upload
1 parent 16a071d commit a801747

File tree

4 files changed

+80
-54
lines changed

4 files changed

+80
-54
lines changed

ArduinoStrike/ArduinoStrike/ArduinoStrike.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@
55

66
Weapon weapon = OFF;
77

8-
static void HandleWeaponFire(Arduino& arduino, const vector<double>& x, const vector<double>& y, const vector<int>& delay)
8+
static void HandleWeaponFire(const Arduino& arduino, const vector<double>& x, const vector<double>& y, const vector<int>& delay, const Config& config)
99
{
1010
for (size_t i = 0; i < x.size(); i++)
1111
{
12-
if (IsKeyHolded(VK_LBUTTON))
12+
bool isRecoilControlActive = IsKeyHolded(VK_LBUTTON) && (config.confirmationKey == 0 || IsKeyHolded(config.confirmationKey));
13+
14+
if (isRecoilControlActive)
1315
{
16+
arduino.WriteMessage("MOUSE_LEFT_HOLDED:" + to_string(x[i]) + "," + to_string(y[i]) + "," + to_string(delay[i]));
1417
sleep_for(milliseconds(delay[i]));
15-
16-
if (IsKeyHolded(VK_LBUTTON))
17-
{
18-
arduino.WriteMessage("MOUSE_LEFT_HOLDED:" + to_string(x[i]) + "," + to_string(y[i]) + "," + to_string(delay[i]));
19-
}
2018
}
2119
}
2220
}
2321

24-
static void ProcessKeyEvents(Arduino& arduino, Config& config)
22+
static void ProcessKeyEvents(const Arduino& arduino, const Config& config)
2523
{
2624
if (IsKeyHolded(VK_SPACE) && config.bhop != 0)
2725
{
@@ -56,14 +54,15 @@ int main()
5654
if (message.rfind("ARDUINO_INITIATED", 0) != 0)
5755
{
5856
double modifier = 2.52 / config.sensitivity;
57+
bool isRecoilControlActive = IsKeyHolded(VK_LBUTTON) && (config.confirmationKey == 0 || IsKeyHolded(config.confirmationKey));
5958

60-
if (IsKeyHolded(VK_LBUTTON))
59+
if (isRecoilControlActive)
6160
{
6261
WeaponData data = GetWeaponData(weapon, modifier);
63-
HandleWeaponFire(arduino, data.x, data.y, data.delay);
62+
HandleWeaponFire(arduino, data.x, data.y, data.delay, config);
6463
}
6564

6665
ProcessKeyEvents(arduino, config);
6766
}
6867
}
69-
}
68+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup />
3+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
4+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
5+
</PropertyGroup>
46
</Project>

ArduinoStrike/ArduinoStrike/Utils.cpp

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -51,52 +51,17 @@ void Utils::Install()
5151

5252
void Utils::LoadConfig(Config& config)
5353
{
54-
string input;
5554
ifstream file("Settings.cfg");
5655

5756
if (!file.is_open())
5857
{
59-
do
60-
{
61-
cout << "Enter bhop boolean value (1/0) -> ";
62-
getline(cin, input);
63-
istringstream iss(input);
64-
if (!(iss >> config.bhop) || (config.bhop != 0 && config.bhop != 1))
65-
{
66-
config.bhop = -1;
67-
cout << "Invalid input! Please enter 1 or 0." << endl << endl;
68-
}
69-
}
70-
while (config.bhop != 0 && config.bhop != 1);
71-
72-
do
73-
{
74-
cout << "Enter rapid-fire boolean value (1/0) -> ";
75-
getline(cin, input);
76-
istringstream iss(input);
77-
if (!(iss >> config.rapidFire) || (config.rapidFire != 0 && config.rapidFire != 1))
78-
{
79-
config.rapidFire = -1;
80-
cout << "Invalid input! Please enter 1 or 0." << endl << endl;
81-
}
82-
}
83-
while (config.rapidFire != 0 && config.rapidFire != 1);
84-
85-
do
86-
{
87-
cout << "Enter sensitivity integer value (1-8) -> ";
88-
getline(cin, input);
89-
istringstream iss(input);
90-
if (!(iss >> config.sensitivity) || config.sensitivity < 1 || config.sensitivity > 8)
91-
{
92-
config.sensitivity = -1;
93-
cout << "Invalid input! Please enter an integer between 1 and 8." << endl << endl;
94-
}
95-
}
96-
while (config.sensitivity < 1 || config.sensitivity > 8);
58+
config.bhop = GetValidatedIntInput("Enter bhop boolean value (1/0) -> ", 0, 1);
59+
config.rapidFire = GetValidatedIntInput("Enter rapid-fire boolean value (1/0) -> ", 0, 1);
60+
config.sensitivity = GetValidatedIntInput("Enter sensitivity integer value (1-8) -> ", 1, 8);
61+
config.confirmationKey = GetValidatedKeyInput("Enter recoil control confirmation key (0/VK_CODE) -> ");
9762

9863
ofstream out("Settings.cfg");
99-
out << config.bhop << endl << config.rapidFire << endl << config.sensitivity;
64+
out << config.bhop << endl << config.rapidFire << endl << config.sensitivity << endl << hex << config.confirmationKey;
10065
out.close();
10166

10267
cout << "Configuration successfully saved!" << endl;
@@ -106,6 +71,7 @@ void Utils::LoadConfig(Config& config)
10671
file >> config.bhop;
10772
file >> config.rapidFire;
10873
file >> config.sensitivity;
74+
file >> hex >> config.confirmationKey;
10975
file.close();
11076

11177
if (!ValidateConfig(config))
@@ -119,9 +85,64 @@ void Utils::LoadConfig(Config& config)
11985
}
12086
}
12187

88+
int Utils::GetValidatedIntInput(const string& prompt, int min, int max)
89+
{
90+
string input;
91+
int value = -1;
92+
93+
do
94+
{
95+
cout << prompt;
96+
getline(cin, input);
97+
istringstream iss(input);
98+
99+
if (!(iss >> value) || value < min || value > max)
100+
{
101+
value = -1;
102+
103+
if (min == 0 && max == 1)
104+
{
105+
cout << "Invalid input! Please enter 0 or 1." << endl << endl;
106+
}
107+
else
108+
{
109+
cout << "Invalid input! Please enter an integer between " << min << " and " << max << "." << endl << endl;
110+
}
111+
}
112+
} while (value == -1);
113+
114+
return value;
115+
}
116+
117+
int Utils::GetValidatedKeyInput(const string& prompt)
118+
{
119+
string input;
120+
int value = -1;
121+
122+
do
123+
{
124+
cout << prompt;
125+
getline(cin, input);
126+
istringstream iss(input);
127+
128+
if (!(iss >> hex >> value) || (value != 0 && (value < 0x01 || value > 0xFE)))
129+
{
130+
value = -1;
131+
cout << "Invalid input! Please enter 0 or VK_CODE." << endl << endl;
132+
}
133+
} while (value == -1);
134+
135+
return value;
136+
}
137+
122138
bool Utils::ValidateConfig(Config& config)
123139
{
124-
return ((config.bhop == 0 || config.bhop == 1) && (config.rapidFire == 0 || config.rapidFire == 1) && (config.sensitivity >= 1 && config.sensitivity <= 8)) ? true : false;
140+
bool validBhop = (config.bhop == 0 || config.bhop == 1);
141+
bool validRapidFire = (config.rapidFire == 0 || config.rapidFire == 1);
142+
bool validSensitivity = (config.sensitivity >= 1 && config.sensitivity <= 8);
143+
bool validConfirmationKey = (config.confirmationKey == 0 || (config.confirmationKey >= 0x01 && config.confirmationKey <= 0xFE));
144+
145+
return validBhop && validRapidFire && validSensitivity && validConfirmationKey;
125146
}
126147

127148
void Utils::PrintAscii(const string& asciiArt)

ArduinoStrike/ArduinoStrike/Utils.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <iostream>
66
#include <windows.h>
77
#include <filesystem>
8+
#include <iomanip>
89

910
using namespace std;
1011
using namespace filesystem;
@@ -14,20 +15,23 @@ struct Config
1415
int bhop;
1516
int rapidFire;
1617
int sensitivity;
18+
int confirmationKey;
1719
};
1820

1921
class Utils
2022
{
2123
public:
2224
static void Install();
2325
static void LoadConfig(Config& config);
24-
static bool ValidateConfig(Config& config);
2526

2627
static void PrintAscii(const string& asciiArt);
2728
static void PrintHotkeys(const string& hotkeys);
2829

2930
private:
3031
static void ConsoleClear();
32+
static bool ValidateConfig(Config& config);
3133
static string GenerateRandomData(int length);
3234
static void SetConsoleMode(const string& title);
35+
static int GetValidatedIntInput(const string& prompt, int min, int max);
36+
static int GetValidatedKeyInput(const string& prompt);
3337
};

0 commit comments

Comments
 (0)