Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add option for Keyboard Steering Sensitivity #3120

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ tools/l10n/languages/
tools/l10n/ror\.pot
CMakeUserPresets.json
tools/l10n/TMP.pot
.cache
1 change: 1 addition & 0 deletions source/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ CVar* io_ffb_stress_gain;
CVar* io_input_grab_mode;
CVar* io_arcade_controls;
CVar* io_hydro_coupling;
CVar* io_hydro_sensivity;
CVar* io_outgauge_mode;
CVar* io_outgauge_ip;
CVar* io_outgauge_port;
Expand Down
1 change: 1 addition & 0 deletions source/main/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ extern CVar* io_ffb_stress_gain;
extern CVar* io_input_grab_mode;
extern CVar* io_arcade_controls;
extern CVar* io_hydro_coupling;
extern CVar* io_hydro_sensivity;
extern CVar* io_outgauge_mode;
extern CVar* io_outgauge_ip;
extern CVar* io_outgauge_port;
Expand Down
6 changes: 6 additions & 0 deletions source/main/gui/panels/GUI_TopMenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,12 @@ void TopMenubar::Draw(float dt)
ImGui::Separator();
ImGui::TextColored(GRAY_HINT_TEXT, "%s", _LC("TopMenubar", "Vehicle control options:"));
DrawGCheckbox(App::io_hydro_coupling, _LC("TopMenubar", "Keyboard steering speed coupling"));
DrawGFloatSlider(App::io_hydro_sensivity, _LC("TopMenubar", "Sensitivity"), 0.3, 5);
ImGui::SameLine();
if (ImGui::SmallButton("Reset"))
{
App::io_hydro_sensivity->setVal(1.f);
}
}
if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
{
Expand Down
8 changes: 5 additions & 3 deletions source/main/physics/ActorForcesEuler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void Actor::CalcHydros()
{
if (!App::io_hydro_coupling->getBool())
{
float rate = std::max(1.2f, 30.0f / (10.0f));
float rate = App::io_hydro_sensivity->getFloat() * std::max(1.2f, 30.0f / (10.0f));
if (ar_hydro_dir_state > ar_hydro_dir_command)
ar_hydro_dir_state -= PHYSICS_DT * rate;
else
Expand All @@ -572,14 +572,16 @@ void Actor::CalcHydros()
else
{
// minimum rate: 20% --> enables to steer high velocity vehicles
float rate = std::max(1.2f, 30.0f / (10.0f + std::abs(ar_wheel_speed / 2.0f)));
float rate = App::io_hydro_sensivity->getFloat() *
std::max(1.2f, 30.0f / (10.0f + std::abs(ar_wheel_speed / 2.0f)));
if (ar_hydro_dir_state > ar_hydro_dir_command)
ar_hydro_dir_state -= PHYSICS_DT * rate;
else
ar_hydro_dir_state += PHYSICS_DT * rate;
}
}
float dirdelta = PHYSICS_DT;
// return rate
float dirdelta = App::io_hydro_sensivity->getFloat() * PHYSICS_DT;
if (ar_hydro_dir_state > dirdelta)
ar_hydro_dir_state -= dirdelta;
else if (ar_hydro_dir_state < -dirdelta)
Expand Down
2 changes: 2 additions & 0 deletions source/main/system/CVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "Application.h"
#include "Console.h"
#include "CVar.h"

#include <Ogre.h>

Expand Down Expand Up @@ -140,6 +141,7 @@ void Console::cVarSetupBuiltins()
App::io_input_grab_mode = this->cVarCreate("io_input_grab_mode", "Input Grab", CVAR_ARCHIVE | CVAR_TYPE_INT, "1"/*(int)IoInputGrabMode::ALL*/);
App::io_arcade_controls = this->cVarCreate("io_arcade_controls", "ArcadeControls", CVAR_ARCHIVE | CVAR_TYPE_BOOL, "false");
App::io_hydro_coupling = this->cVarCreate("io_hydro_coupling", "Keyboard Steering Speed Coupling",CVAR_ARCHIVE | CVAR_TYPE_BOOL, "true");
App::io_hydro_sensivity = this->cVarCreate("io_hydro_sensivity", "Keyboard Steering Sensitivity", CVAR_ARCHIVE | CVAR_TYPE_FLOAT, "1.0");
App::io_outgauge_mode = this->cVarCreate("io_outgauge_mode", "OutGauge Mode", CVAR_ARCHIVE | CVAR_TYPE_INT); // 0 = disabled, 1 = enabled
App::io_outgauge_ip = this->cVarCreate("io_outgauge_ip", "OutGauge IP", CVAR_ARCHIVE, "192.168.1.100");
App::io_outgauge_port = this->cVarCreate("io_outgauge_port", "OutGauge Port", CVAR_ARCHIVE | CVAR_TYPE_INT, "1337");
Expand Down