made deadzones configurable

This commit is contained in:
Siddharth 2013-10-28 16:43:42 +05:30
parent ec0e0d7047
commit 5daaaa3aad
4 changed files with 7 additions and 1 deletions

View File

@ -226,6 +226,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
control->Get("InvertTiltY", &bInvertTiltY, true);
control->Get("TiltSensitivityX", &iTiltSensitivityX, 100);
control->Get("TiltSensitivityY", &iTiltSensitivityY, 100);
control->Get("DeadzoneRadius", &fDeadzoneRadius, 0.35);
#endif
control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65);
@ -424,6 +425,7 @@ void Config::Save() {
control->Set("InvertTiltY", bInvertTiltY);
control->Set("TiltSensitivityX", iTiltSensitivityX);
control->Set("TiltSensitivityY", iTiltSensitivityY);
control->Set("DeadzoneRadius", fDeadzoneRadius);
#endif
control->Set("TouchButtonOpacity", iTouchButtonOpacity);
control->Set("ButtonScale", fButtonScale);

View File

@ -119,6 +119,8 @@ public:
int iTiltSensitivityX;
//the sensitivity of the tilt in the Y direction
int iTiltSensitivityY;
//the deadzone radius of the tilt
float fDeadzoneRadius;
// The three tabs.
bool bGridView1;

View File

@ -192,7 +192,7 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
//curve1 implements a smooth deadzone as described here:
//http://www.gamasutra.com/blogs/JoshSutphin/20130416/190541/Doing_Thumbstick_Dead_Zones_Right.php
inline float curve1(float x) {
const float deadzone = 0.03f;
const float deadzone = g_Config.fDeadzoneRadius;
const float factor = 1.0f / (1.0f - deadzone);
if (x > deadzone) {
return (x - deadzone) * (x - deadzone) * factor;

View File

@ -24,6 +24,8 @@ void TiltAnalogSettingsScreen::CreateViews(){
//TODO: allow values greater than 100? I'm not sure if that's needed.
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityX, 0, 100, c->T("Tilt Sensitivity along X axis"), screenManager()));
settings->Add(new PopupSliderChoice(&g_Config.iTiltSensitivityY, 0, 100, c->T("Tilt Sensitivity along Y axis"), screenManager()));
settings->Add(new PopupSliderChoiceFloat(&g_Config.fDeadzoneRadius, 0.0, 1.0, c->T("Deadzone Radius"), screenManager()));
settings->Add(new ItemHeader(c->T("Calibration")));
InfoItem *calibrationInfo = new InfoItem("To calibrate, keep device on a flat surface and press calibrate.", "");