Skip to content

Commit

Permalink
Fix stepping of tilt low end radius setting. Add some asserts.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Nov 7, 2023
1 parent 7393260 commit 25ab120
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Common/UI/PopupScreens.cpp
Expand Up @@ -167,12 +167,15 @@ PopupSliderChoice::PopupSliderChoice(int *value, int minValue, int maxValue, int

PopupSliderChoiceFloat::PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, const std::string &text, ScreenManager *screenManager, const std::string &units, LayoutParams *layoutParams)
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), minValue_(minValue), maxValue_(maxValue), defaultValue_(defaultValue), step_(1.0f), units_(units), screenManager_(screenManager) {
_dbg_assert_(maxValue > minValue);
fmt_ = "%2.2f";
OnClick.Handle(this, &PopupSliderChoiceFloat::HandleClick);
}

PopupSliderChoiceFloat::PopupSliderChoiceFloat(float *value, float minValue, float maxValue, float defaultValue, const std::string &text, float step, ScreenManager *screenManager, const std::string &units, LayoutParams *layoutParams)
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), minValue_(minValue), maxValue_(maxValue), defaultValue_(defaultValue), step_(step), units_(units), screenManager_(screenManager) {
_dbg_assert_(step > 0.0f);
_dbg_assert_(maxValue > minValue);
fmt_ = "%2.2f";
OnClick.Handle(this, &PopupSliderChoiceFloat::HandleClick);
}
Expand Down
4 changes: 4 additions & 0 deletions Common/UI/View.cpp
Expand Up @@ -1557,6 +1557,9 @@ bool SliderFloat::ApplyKey(InputKeyCode keyCode) {
default:
return false;
}

_dbg_assert_(!my_isnanorinf(*value_));

EventParams params{};
params.v = this;
params.a = (uint32_t)(*value_);
Expand Down Expand Up @@ -1584,6 +1587,7 @@ bool SliderFloat::Touch(const TouchInput &input) {
}

void SliderFloat::Clamp() {
_dbg_assert_(!my_isnanorinf(*value_));
if (*value_ < minValue_)
*value_ = minValue_;
else if (*value_ > maxValue_)
Expand Down
4 changes: 2 additions & 2 deletions UI/TiltAnalogSettingsScreen.cpp
Expand Up @@ -122,8 +122,8 @@ void TiltAnalogSettingsScreen::CreateViews() {

settings->Add(new ItemHeader(co->T("Sensitivity")));
if (g_Config.iTiltInputType == 1) {
settings->Add(new PopupSliderChoiceFloat(&g_Config.fTiltAnalogDeadzoneRadius, 0.0f, 0.8f, 0.0f, co->T("Deadzone radius"), 0.01f, screenManager(), "/ 1.0"))->SetEnabledFunc(enabledFunc);
settings->Add(new PopupSliderChoiceFloat(&g_Config.fTiltInverseDeadzone, 0.0f, 0.8f, 0.0f, co->T("Low end radius"), 0.0f, screenManager(), "/ 1.0"))->SetEnabledFunc(enabledFunc);
settings->Add(new PopupSliderChoiceFloat(&g_Config.fTiltAnalogDeadzoneRadius, 0.0f, 0.8f, 0.0f, co->T("Deadzone radius"), 0.02f, screenManager(), "/ 1.0"))->SetEnabledFunc(enabledFunc);
settings->Add(new PopupSliderChoiceFloat(&g_Config.fTiltInverseDeadzone, 0.0f, 0.8f, 0.0f, co->T("Low end radius"), 0.02f, screenManager(), "/ 1.0"))->SetEnabledFunc(enabledFunc);
settings->Add(new CheckBox(&g_Config.bTiltCircularInverseDeadzone, co->T("Circular low end radius")))->SetEnabledFunc(enabledFunc);
}
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityX, 0, 100, 60, co->T("Tilt Sensitivity along X axis"), screenManager(), "%"))->SetEnabledFunc(enabledFunc);
Expand Down

0 comments on commit 25ab120

Please sign in to comment.