Skip to content

Commit

Permalink
Merge pull request #17489 from hrydgard/tilt-restore-setting
Browse files Browse the repository at this point in the history
Restore "low end radius" (inverse deadzone) for tilt input
  • Loading branch information
hrydgard authored May 22, 2023
2 parents d5dfef8 + 15ff2cf commit d121b25
Show file tree
Hide file tree
Showing 48 changed files with 79 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@ static const ConfigSetting controlSettings[] = {
ConfigSetting("TiltSensitivityX", &g_Config.iTiltSensitivityX, 60, CfgFlag::PER_GAME),
ConfigSetting("TiltSensitivityY", &g_Config.iTiltSensitivityY, 60, CfgFlag::PER_GAME),
ConfigSetting("TiltAnalogDeadzoneRadius", &g_Config.fTiltAnalogDeadzoneRadius, 0.0f, CfgFlag::PER_GAME),
ConfigSetting("TiltInverseDeadzone", &g_Config.fTiltInverseDeadzone, 0.0f, CfgFlag::PER_GAME),
ConfigSetting("TiltCircularInverseDeadzone", &g_Config.bTiltCircularInverseDeadzone, true, CfgFlag::PER_GAME),
ConfigSetting("TiltInputType", &g_Config.iTiltInputType, 0, CfgFlag::PER_GAME),
#endif

Expand Down
2 changes: 2 additions & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ struct Config {
int iTiltSensitivityY;
// The deadzone radius of the tilt. Only used in the analog mapping.
float fTiltAnalogDeadzoneRadius;
float fTiltInverseDeadzone; // An inverse deadzone for the output, counteracting excessive deadzones applied by games. See #17483.
bool bTiltCircularInverseDeadzone;
// 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
25 changes: 24 additions & 1 deletion Core/TiltEventProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ inline float ApplyDeadzone(float x, float deadzone) {
}
}

// Also clamps to -1.0..1.0.
// This applies a (circular if desired) inverse deadzone.
inline void ApplyInverseDeadzone(float x, float y, float *outX, float *outY, float inverseDeadzone, bool circular) {
if (inverseDeadzone == 0.0f) {
*outX = Clamp(x, -1.0f, 1.0f);
*outY = Clamp(y, -1.0f, 1.0f);
}
if (circular) {
float magnitude = sqrtf(x * x + y * y);
magnitude = (magnitude + inverseDeadzone) / magnitude;
*outX = Clamp(x * magnitude, -1.0f, 1.0f);
*outY = Clamp(y * magnitude, -1.0f, 1.0f);
} else {
*outX = Clamp(x + copysignf(inverseDeadzone, x), -1.0f, 1.0f);
*outY = Clamp(y + copysignf(inverseDeadzone, y), -1.0f, 1.0f);
}
}

void ProcessTilt(bool landscape, float calibrationAngle, float x, float y, float z, bool invertX, bool invertY, float xSensitivity, float ySensitivity) {
if (g_Config.iTiltInputType == TILT_NULL) {
// Turned off - nothing to do.
Expand Down Expand Up @@ -79,9 +97,14 @@ void ProcessTilt(bool landscape, float calibrationAngle, float x, float y, float

if (g_Config.iTiltInputType == TILT_ANALOG) {
// Only analog mappings use the deadzone.

float adjustedTiltX = ApplyDeadzone(tiltX, g_Config.fTiltAnalogDeadzoneRadius);
float adjustedTiltY = ApplyDeadzone(tiltY, g_Config.fTiltAnalogDeadzoneRadius);

// Unlike regular deadzone, where per-axis is okay, inverse deadzone (to compensate for game deadzones) really needs to be
// applied on the two axes together.
// TODO: Share this code with the joystick code. For now though, we keep it separate.
ApplyInverseDeadzone(adjustedTiltX, adjustedTiltY, &adjustedTiltX, &adjustedTiltY, g_Config.fTiltInverseDeadzone, g_Config.bTiltCircularInverseDeadzone);

rawTiltAnalogX = adjustedTiltX;
rawTiltAnalogY = adjustedTiltY;
GenerateAnalogStickEvent(adjustedTiltX, adjustedTiltY);
Expand Down
12 changes: 6 additions & 6 deletions Tools/langtool/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions UI/TiltAnalogSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,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 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);
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityY, 0, 100, 60, co->T("Tilt Sensitivity along Y axis"), screenManager(), "%"))->SetEnabledFunc(enabledFunc);
Expand Down
1 change: 1 addition & 0 deletions assets/lang/ar_AE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = ‎معايرة
Calibrated = Calibrated
Calibration = ‎المعايرة
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = ‎كلاسيكي
Confine Mouse = ‎حجز مؤشر الماوس في حدود نافذة البرنامج
Expand Down
1 change: 1 addition & 0 deletions assets/lang/az_AZ.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrate
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Classic
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/bg_BG.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrate
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Класик
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/ca_ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrar
Calibrated = Calibrat
Calibration = Calibració
Circular low end radius = Ràdio inferior circular
Circular stick input = Entrada de stick circular
Classic = Clàssic
Confine Mouse = Fixar el ratolí a l'àrea de la finestra/pantalla
Expand Down
1 change: 1 addition & 0 deletions assets/lang/cz_CZ.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Kalibrovat
Calibrated = Calibrated
Calibration = Kalibrace
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klasický
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/da_DK.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Kalibrer
Calibrated = Calibrated
Calibration = Kalibrering
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klassisk
Confine Mouse = Begræns mus indenfor vindue/skærmområde
Expand Down
1 change: 1 addition & 0 deletions assets/lang/de_DE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Kalibriere Analog Stick
Calibrate = Kalibriere Steuerkreuz
Calibrated = Kalibriert
Calibration = Kalibrierung
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klassisch
Confine Mouse = Maus in Fenster/sichtbaren Bereich einsperren
Expand Down
1 change: 1 addition & 0 deletions assets/lang/dr_ID.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrate
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Classic
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/en_US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrate
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Classic
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/es_ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrar stick
Calibrate = Calibrar
Calibrated = Calibrado
Calibration = Calibración
Circular low end radius = Circular low end radius
Circular stick input = Entrada de stick circular
Classic = Clásico
Confine Mouse = Fijar el ratón al área de la ventana/pantalla
Expand Down
1 change: 1 addition & 0 deletions assets/lang/es_LA.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrar análogo
Calibrate = Calibrar
Calibrated = Calibrado
Calibration = Calibración
Circular low end radius = Circular low end radius
Circular stick input = Entrada del stick circular
Classic = Clásico
Confine Mouse = Fijar el ratón al área de la ventana/pantalla
Expand Down
1 change: 1 addition & 0 deletions assets/lang/fa_IR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = دسته آنالوگ را کالیبراسیون کن
Calibrate = ‎کالیبره کردن
Calibrated = کالیبراسیون شد
Calibration = ‎کالیبره کردن
Circular low end radius = Circular شعاع کم پایان
Circular stick input = ورودی دایره ای
Classic = ‎کلاسیک
Confine Mouse = ‎محدود کردن موس به ناحیه درون پنجره
Expand Down
1 change: 1 addition & 0 deletions assets/lang/fi_FI.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrate
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klassinen
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/fr_FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Étalonner
Calibrated = Calibrated
Calibration = Étalonnage
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Classique
Confine Mouse = Capturer la souris dans la fenêtre/zone d'affichage
Expand Down
1 change: 1 addition & 0 deletions assets/lang/gl_ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrar
Calibrated = Calibrated
Calibration = Calibración
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Clásico
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/gr_EL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Βαθμονόμηση
Calibrated = Calibrated
Calibration = Βαθμονόμηση ψηφιακού πληκρολογίου
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Κλασικό
Confine Mouse = Εγκλωβισμός ποντικιού μέσα στην περιοχή παραθύρου/οθόνης
Expand Down
1 change: 1 addition & 0 deletions assets/lang/he_IL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrate
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Classic
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/he_IL_invert.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrate
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Classic
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/hr_HR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Kalibriraj
Calibrated = Calibrated
Calibration = Kalibracija
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klasično
Confine Mouse = Zaključaj miš u window/display području
Expand Down
1 change: 1 addition & 0 deletions assets/lang/hu_HU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Kalibrálása
Calibrated = Calibrated
Calibration = Kalibrálás
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klasszikus
Confine Mouse = Egérkurzor rögzítése az ablakhoz
Expand Down
1 change: 1 addition & 0 deletions assets/lang/id_ID.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Kalibrasi stik analog
Calibrate = Kalibrasi
Calibrated = Dikalibrasi
Calibration = Kalibrasi
Circular low end radius = Circular low end radius
Circular stick input = Masukan stik melingkar
Classic = Klasik
Confine Mouse = Kunci mouse di area layar
Expand Down
1 change: 1 addition & 0 deletions assets/lang/it_IT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibra Stick Analogico
Calibrate = Calibra
Calibrated = Calibrato
Calibration = Calibratura
Circular low end radius = Circular low end radius
Circular stick input = Input stick circolare
Classic = Classico
Confine Mouse = Confina il mouse all'interno dell'area della finestra
Expand Down
1 change: 1 addition & 0 deletions assets/lang/ja_JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = アナログスティックをキャリブレートす
Calibrate = キャリブレート
Calibrated = キャリブレーション\n(調整)された動作
Calibration = キャリブレーション
Circular low end radius = Circular low end radius
Circular stick input = 環状スティック入力
Classic = クラシック
Confine Mouse = ウィンドウ/表示領域内でマウスをトラップする
Expand Down
1 change: 1 addition & 0 deletions assets/lang/jv_ID.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Kalibrasi
Calibrated = Calibrated
Calibration = Kalibrasi
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klasik
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/ko_KR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = 아날로그 스틱 보정
Calibrate = 보정
Calibrated = 보정됨
Calibration = 교정
Circular low end radius = Circular low end radius
Circular stick input = 원형 스틱 입력
Classic = 클래식
Confine Mouse = 창/표시 영역 내에서 마우스 트랩
Expand Down
1 change: 1 addition & 0 deletions assets/lang/lo_LA.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = ປັບຄ່າຄວາມຄາດເຄື່ອນຂອງ
Calibrated = Calibrated
Calibration = ປັບຄ່າຄວາມຄາດເຄື່ອນ
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = ແບບດັ້ງເດີມ
Confine Mouse = ຈຳກັດເມົ້າໃນໜ້າຕ່າງ/ພື້ນທີ່ສະແດງຜົນ
Expand Down
1 change: 1 addition & 0 deletions assets/lang/lt-LT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Kalibruoti
Calibrated = Calibrated
Calibration = Kalibravimas
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klasikinis
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/ms_MY.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrate
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klasik
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/nl_NL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Kalibreren
Calibrated = Calibrated
Calibration = Kalibreren
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klassiek
Confine Mouse = Muis binnen venster/weergavegebied vastzetten
Expand Down
1 change: 1 addition & 0 deletions assets/lang/no_NO.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Kalibrer
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Classic
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/pl_PL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Kalibracja Analoga
Calibrate = Kalibracja
Calibrated = Skalibrowany
Calibration = Kalibracja
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klasyczny
Confine Mouse = Zablokuj myszkę w oknie
Expand Down
1 change: 1 addition & 0 deletions assets/lang/pt_BR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Calibrate Analog Stick = Calibrar Direcional Analógico
Calibrate = Calibrar
Calibrated = Calibrado
Calibration = Calibração
Circular low end radius = Circular low end radius
Circular stick input = Entrada circular do direcional
Classic = Clássico
Confine Mouse = Travar o mouse dentro da janela/área de exibição
Expand Down
1 change: 1 addition & 0 deletions assets/lang/pt_PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Calibrate Analog Stick = Calibrar Analógico
Calibrate = Calibrar
Calibrated = Calibrado
Calibration = Calibração
Circular low end radius = Circular low end radius
Circular stick input = Entrada circular do direcional
Classic = Clássico
Confine Mouse = Travar o mouse dentro da janela/área de exibição
Expand Down
1 change: 1 addition & 0 deletions assets/lang/ro_RO.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrare
Calibrated = Calibrated
Calibration = Calibrare
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Clasic
Confine Mouse = Trap mouse within window/display area
Expand Down
1 change: 1 addition & 0 deletions assets/lang/ru_RU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Калибровка аналогового стика
Calibrate = Калибровка
Calibrated = Откалиблированный
Calibration = Калибровка
Circular low end radius = Circular low end radius
Circular stick input = Круговой ввод стика
Classic = Классический
Confine Mouse = Не давать мыши выходить за пределы окна
Expand Down
1 change: 1 addition & 0 deletions assets/lang/sv_SE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Kalibrera analog styrspak
Calibrate = Kalibrera
Calibrated = Kalibrerad
Calibration = Kalibrering
Circular low end radius = Circulär inner-radie
Circular stick input = Cirkulär analog input
Classic = Klassisk
Confine Mouse = Stäng in muspekaren i fönstret
Expand Down
1 change: 1 addition & 0 deletions assets/lang/tg_PH.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Calibrate Analog Stick = Calibrate Analog Stick
Calibrate = Calibrate
Calibrated = Calibrated
Calibration = Calibration
Circular low end radius = Circular low end radius
Circular stick input = Circular stick input
Classic = Klasiko
Confine Mouse = Trap mouse within window/display area
Expand Down
Loading

0 comments on commit d121b25

Please sign in to comment.