Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
DeniedAccessLife authored Aug 12, 2024
1 parent 16a071d commit a801747
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 54 deletions.
21 changes: 10 additions & 11 deletions ArduinoStrike/ArduinoStrike/ArduinoStrike.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

Weapon weapon = OFF;

static void HandleWeaponFire(Arduino& arduino, const vector<double>& x, const vector<double>& y, const vector<int>& delay)
static void HandleWeaponFire(const Arduino& arduino, const vector<double>& x, const vector<double>& y, const vector<int>& delay, const Config& config)
{
for (size_t i = 0; i < x.size(); i++)
{
if (IsKeyHolded(VK_LBUTTON))
bool isRecoilControlActive = IsKeyHolded(VK_LBUTTON) && (config.confirmationKey == 0 || IsKeyHolded(config.confirmationKey));

if (isRecoilControlActive)
{
arduino.WriteMessage("MOUSE_LEFT_HOLDED:" + to_string(x[i]) + "," + to_string(y[i]) + "," + to_string(delay[i]));
sleep_for(milliseconds(delay[i]));

if (IsKeyHolded(VK_LBUTTON))
{
arduino.WriteMessage("MOUSE_LEFT_HOLDED:" + to_string(x[i]) + "," + to_string(y[i]) + "," + to_string(delay[i]));
}
}
}
}

static void ProcessKeyEvents(Arduino& arduino, Config& config)
static void ProcessKeyEvents(const Arduino& arduino, const Config& config)
{
if (IsKeyHolded(VK_SPACE) && config.bhop != 0)
{
Expand Down Expand Up @@ -56,14 +54,15 @@ int main()
if (message.rfind("ARDUINO_INITIATED", 0) != 0)
{
double modifier = 2.52 / config.sensitivity;
bool isRecoilControlActive = IsKeyHolded(VK_LBUTTON) && (config.confirmationKey == 0 || IsKeyHolded(config.confirmationKey));

if (IsKeyHolded(VK_LBUTTON))
if (isRecoilControlActive)
{
WeaponData data = GetWeaponData(weapon, modifier);
HandleWeaponFire(arduino, data.x, data.y, data.delay);
HandleWeaponFire(arduino, data.x, data.y, data.delay, config);
}

ProcessKeyEvents(arduino, config);
}
}
}
}
4 changes: 3 additions & 1 deletion ArduinoStrike/ArduinoStrike/ArduinoStrike.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
103 changes: 62 additions & 41 deletions ArduinoStrike/ArduinoStrike/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,52 +51,17 @@ void Utils::Install()

void Utils::LoadConfig(Config& config)
{
string input;
ifstream file("Settings.cfg");

if (!file.is_open())
{
do
{
cout << "Enter bhop boolean value (1/0) -> ";
getline(cin, input);
istringstream iss(input);
if (!(iss >> config.bhop) || (config.bhop != 0 && config.bhop != 1))
{
config.bhop = -1;
cout << "Invalid input! Please enter 1 or 0." << endl << endl;
}
}
while (config.bhop != 0 && config.bhop != 1);

do
{
cout << "Enter rapid-fire boolean value (1/0) -> ";
getline(cin, input);
istringstream iss(input);
if (!(iss >> config.rapidFire) || (config.rapidFire != 0 && config.rapidFire != 1))
{
config.rapidFire = -1;
cout << "Invalid input! Please enter 1 or 0." << endl << endl;
}
}
while (config.rapidFire != 0 && config.rapidFire != 1);

do
{
cout << "Enter sensitivity integer value (1-8) -> ";
getline(cin, input);
istringstream iss(input);
if (!(iss >> config.sensitivity) || config.sensitivity < 1 || config.sensitivity > 8)
{
config.sensitivity = -1;
cout << "Invalid input! Please enter an integer between 1 and 8." << endl << endl;
}
}
while (config.sensitivity < 1 || config.sensitivity > 8);
config.bhop = GetValidatedIntInput("Enter bhop boolean value (1/0) -> ", 0, 1);
config.rapidFire = GetValidatedIntInput("Enter rapid-fire boolean value (1/0) -> ", 0, 1);
config.sensitivity = GetValidatedIntInput("Enter sensitivity integer value (1-8) -> ", 1, 8);
config.confirmationKey = GetValidatedKeyInput("Enter recoil control confirmation key (0/VK_CODE) -> ");

ofstream out("Settings.cfg");
out << config.bhop << endl << config.rapidFire << endl << config.sensitivity;
out << config.bhop << endl << config.rapidFire << endl << config.sensitivity << endl << hex << config.confirmationKey;
out.close();

cout << "Configuration successfully saved!" << endl;
Expand All @@ -106,6 +71,7 @@ void Utils::LoadConfig(Config& config)
file >> config.bhop;
file >> config.rapidFire;
file >> config.sensitivity;
file >> hex >> config.confirmationKey;
file.close();

if (!ValidateConfig(config))
Expand All @@ -119,9 +85,64 @@ void Utils::LoadConfig(Config& config)
}
}

int Utils::GetValidatedIntInput(const string& prompt, int min, int max)
{
string input;
int value = -1;

do
{
cout << prompt;
getline(cin, input);
istringstream iss(input);

if (!(iss >> value) || value < min || value > max)
{
value = -1;

if (min == 0 && max == 1)
{
cout << "Invalid input! Please enter 0 or 1." << endl << endl;
}
else
{
cout << "Invalid input! Please enter an integer between " << min << " and " << max << "." << endl << endl;
}
}
} while (value == -1);

return value;
}

int Utils::GetValidatedKeyInput(const string& prompt)
{
string input;
int value = -1;

do
{
cout << prompt;
getline(cin, input);
istringstream iss(input);

if (!(iss >> hex >> value) || (value != 0 && (value < 0x01 || value > 0xFE)))
{
value = -1;
cout << "Invalid input! Please enter 0 or VK_CODE." << endl << endl;
}
} while (value == -1);

return value;
}

bool Utils::ValidateConfig(Config& config)
{
return ((config.bhop == 0 || config.bhop == 1) && (config.rapidFire == 0 || config.rapidFire == 1) && (config.sensitivity >= 1 && config.sensitivity <= 8)) ? true : false;
bool validBhop = (config.bhop == 0 || config.bhop == 1);
bool validRapidFire = (config.rapidFire == 0 || config.rapidFire == 1);
bool validSensitivity = (config.sensitivity >= 1 && config.sensitivity <= 8);
bool validConfirmationKey = (config.confirmationKey == 0 || (config.confirmationKey >= 0x01 && config.confirmationKey <= 0xFE));

return validBhop && validRapidFire && validSensitivity && validConfirmationKey;
}

void Utils::PrintAscii(const string& asciiArt)
Expand Down
6 changes: 5 additions & 1 deletion ArduinoStrike/ArduinoStrike/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <iostream>
#include <windows.h>
#include <filesystem>
#include <iomanip>

using namespace std;
using namespace filesystem;
Expand All @@ -14,20 +15,23 @@ struct Config
int bhop;
int rapidFire;
int sensitivity;
int confirmationKey;
};

class Utils
{
public:
static void Install();
static void LoadConfig(Config& config);
static bool ValidateConfig(Config& config);

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

private:
static void ConsoleClear();
static bool ValidateConfig(Config& config);
static string GenerateRandomData(int length);
static void SetConsoleMode(const string& title);
static int GetValidatedIntInput(const string& prompt, int min, int max);
static int GetValidatedKeyInput(const string& prompt);
};

0 comments on commit a801747

Please sign in to comment.