Skip to content

Commit aa7c513

Browse files
Changed sensitivity variable type
1 parent b48de08 commit aa7c513

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

ArduinoStrike/ArduinoStrike/Config.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const json Config::DEFAULT_CONFIG =
1616
{ "rapidFire", true },
1717
{ "fastReload", false },
1818

19-
{ "sensitivity", 8 },
19+
{ "sensitivity", 8.0 },
2020
{ "zoomSensitivity", 1.0 },
2121
{ "colorThreshold", 20 },
2222

@@ -168,7 +168,7 @@ bool Config::Validate(const json& j) const
168168
{ "augKey", 0, 0xFE },
169169
{ "sgKey", 0, 0xFE },
170170
{ "offKey", 0, 0xFE },
171-
{ "sensitivity", 1, 8 },
171+
{ "sensitivity", 1.0, 8.0 },
172172
{ "zoomSensitivity", 0.01, 3.0 },
173173
{ "colorThreshold", 0, 20 },
174174
{ "confirmationKey", 0, 0xFE },
@@ -351,8 +351,8 @@ void Config::ConfigureSettings()
351351
sensitivity = GetValidatedInput(
352352
"Enter your mouse sensitivity for general gameplay.\n"
353353
"This controls how fast your cursor moves in the game.\n"
354-
"Range: 1 (slow) to 8 (fast).\n"
355-
"Example: 8\n> ", 1, 8);
354+
"Range: 1.0 (slow) to 8.0 (fast).\n"
355+
"Example: 8.0\n> ", 1.0, 8.0);
356356

357357
zoomSensitivity = GetValidatedInput(
358358
"Enter your mouse sensitivity when zoomed in (e.g., aiming down sights).\n"
@@ -590,11 +590,8 @@ void Config::PrintSuccess() const
590590
printLine("Rapid Fire", (rapidFire ? "ENABLED" : "DISABLED"));
591591
printLine("Fast Reload", (fastReload ? "ENABLED" : "DISABLED"));
592592

593-
printLine("Sensitivity", to_string(sensitivity));
594-
595-
ostringstream oss;
596-
oss << fixed << setprecision(2) << zoomSensitivity;
597-
printLine("Zoom Sensitivity", oss.str());
593+
printLine("Sensitivity", FormatFloat(sensitivity));
594+
printLine("Zoom Sensitivity", FormatFloat(zoomSensitivity));
598595

599596
printLine("Color Bot Threshold", to_string(colorThreshold));
600597

@@ -674,6 +671,13 @@ void Config::FromJson(const json& j)
674671
readKey("offKey", offKey);
675672
}
676673

674+
string Config::FormatFloat(double value, int precision)
675+
{
676+
ostringstream oss;
677+
oss << fixed << setprecision(precision) << value;
678+
return oss.str();
679+
}
680+
677681
void Config::Save() const
678682
{
679683
ofstream file("Config.json");

ArduinoStrike/ArduinoStrike/Config.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Config {
2525

2626
bool GetBhop() const { return bhop; }
2727
bool GetRapidFire() const { return rapidFire; }
28-
int GetSensitivity() const { return sensitivity; }
28+
double GetSensitivity() const { return sensitivity; }
2929
double GetZoomSensitivity() const { return zoomSensitivity; }
3030
int GetConfirmationKey() const { return confirmationKey; }
3131
int GetColorBotKey() const { return colorBotKey; }
@@ -48,7 +48,7 @@ class Config {
4848
bool rapidFire;
4949
bool fastReload;
5050

51-
int sensitivity;
51+
double sensitivity;
5252
double zoomSensitivity;
5353
int colorThreshold;
5454

@@ -67,6 +67,8 @@ class Config {
6767

6868
json ToJson() const;
6969
void FromJson(const json& j);
70+
71+
static string FormatFloat(double value, int precision = 2);
7072

7173
static const json DEFAULT_CONFIG;
7274
};

0 commit comments

Comments
 (0)