From 5daaaa3aad536fdb54445ac932b052536aa4e6d8 Mon Sep 17 00:00:00 2001 From: Siddharth Date: Mon, 28 Oct 2013 16:43:42 +0530 Subject: [PATCH] made deadzones configurable --- Core/Config.cpp | 2 ++ Core/Config.h | 2 ++ UI/EmuScreen.cpp | 2 +- UI/TiltAnalogSettingsScreen.cpp | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 3cf1d2f3ca..246f9ed3ab 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -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); diff --git a/Core/Config.h b/Core/Config.h index 13ddde2e05..94398131fd 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -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; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 65f57e4a0c..c0449d24cd 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -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; diff --git a/UI/TiltAnalogSettingsScreen.cpp b/UI/TiltAnalogSettingsScreen.cpp index fd0ce0762e..b21004bb66 100644 --- a/UI/TiltAnalogSettingsScreen.cpp +++ b/UI/TiltAnalogSettingsScreen.cpp @@ -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.", "");