Skip to content

Commit

Permalink
Skip deadzone option on tilt
Browse files Browse the repository at this point in the history
  • Loading branch information
iota97 committed Mar 23, 2020
1 parent c694856 commit 4d6fc42
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ static ConfigSetting controlSettings[] = {
ConfigSetting("TiltSensitivityX", &g_Config.iTiltSensitivityX, 100, true, true),
ConfigSetting("TiltSensitivityY", &g_Config.iTiltSensitivityY, 100, true, true),
ConfigSetting("DeadzoneRadius", &g_Config.fDeadzoneRadius, 0.2f, true, true),
ConfigSetting("TiltDeadzoneSkip", &g_Config.fTiltDeadzoneSkip, 0.0f, true, true),
ConfigSetting("TiltInputType", &g_Config.iTiltInputType, 0, true, true),
#endif

Expand Down
2 changes: 2 additions & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ struct Config {
int iTiltSensitivityY;
//the deadzone radius of the tilt
float fDeadzoneRadius;
// deadzone skip
float fTiltDeadzoneSkip;
//type of tilt input currently selected: Defined in TiltEventProcessor.h
//0 - no tilt, 1 - analog stick, 2 - D-Pad, 3 - Action Buttons (Tri, Cross, Square, Circle)
int iTiltInputType;
Expand Down
1 change: 1 addition & 0 deletions UI/TiltAnalogSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void TiltAnalogSettingsScreen::CreateViews() {
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityX, 0, 100, co->T("Tilt Sensitivity along X axis"), screenManager(),"%"));
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityY, 0, 100, co->T("Tilt Sensitivity along Y axis"), screenManager(),"%"));
settings->Add(new PopupSliderChoiceFloat(&g_Config.fDeadzoneRadius, 0.0, 1.0, co->T("Deadzone Radius"), 0.01f, screenManager(),"/ 1.0"));
settings->Add(new PopupSliderChoiceFloat(&g_Config.fTiltDeadzoneSkip, 0.0, 1.0, co->T("Tilt Base Radius"), 0.01f, screenManager(),"/ 1.0"));

settings->Add(new ItemHeader(co->T("Calibration")));
InfoItem *calibrationInfo = new InfoItem(co->T("To Calibrate", "To calibrate, keep device on a flat surface and press calibrate."), "");
Expand Down
4 changes: 2 additions & 2 deletions UI/TiltEventProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ inline float tiltInputCurve (float x, float deadzone, float sensitivity) {
const float factor = sensitivity * 1.0f / (1.0f - deadzone);

if (x > deadzone) {
return (x - deadzone) * factor * factor;
return (x + g_Config.fTiltDeadzoneSkip - deadzone) * factor * factor;
} else if (x < -deadzone) {
return (x + deadzone) * factor * factor;
return (x - g_Config.fTiltDeadzoneSkip + deadzone) * factor * factor;
} else {
return 0.0f;
}
Expand Down

0 comments on commit 4d6fc42

Please sign in to comment.