Skip to content

Commit

Permalink
Remove deadzone setting
Browse files Browse the repository at this point in the history
  • Loading branch information
garbear committed Aug 21, 2016
1 parent 2a69ba4 commit caa6722
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 44 deletions.
6 changes: 0 additions & 6 deletions peripheral.joystick/resources/settings.xml

This file was deleted.

17 changes: 1 addition & 16 deletions src/api/Joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void CJoystick::SetAxisValue(unsigned int axisIndex, JOYSTICK_STATE_AXIS axisVal
axisValue = CONSTRAIN(-1.0f, axisValue, 1.0f);

if (axisIndex < m_stateBuffer.axes.size())
m_stateBuffer.axes[axisIndex] = ScaleDeadzone(m_axisFilters[axisIndex]->Filter(axisValue));
m_stateBuffer.axes[axisIndex] = m_axisFilters[axisIndex]->Filter(axisValue);
}

void CJoystick::SetAxisValue(unsigned int axisIndex, long value, long maxAxisAmount)
Expand All @@ -242,18 +242,3 @@ float CJoystick::NormalizeAxis(long value, long maxAxisAmount)
{
return 1.0f * CONSTRAIN(-maxAxisAmount, value, maxAxisAmount) / maxAxisAmount;
}

float CJoystick::ScaleDeadzone(float value)
{
const float deadzone = CSettings::Get().Deadzone();

if (deadzone >= 1.0f)
return 0.0f;

if (value > deadzone)
return (float)(value - deadzone) / (float)(1.0f - deadzone);
else if (value < -deadzone)
return (float)(value + deadzone) / (float)(1.0f - deadzone);

return 0.0f;
}
7 changes: 0 additions & 7 deletions src/settings/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@

using namespace JOYSTICK;

#define SETTING_DEADZONE "deadzone"
#define SETTING_RETROARCH_CONFIG "retroarchconfig"

CSettings::CSettings(void)
: m_bInitialized(false),
m_deadzone(0.0f),
m_bGenerateRetroArchConfigs(false)
{
}
Expand All @@ -41,11 +39,6 @@ CSettings& CSettings::Get(void)

void CSettings::SetSetting(const std::string& strName, const void* value)
{
if (strName == SETTING_DEADZONE)
{
m_deadzone = *static_cast<const float*>(value);
dsyslog("Setting \"%s\" set to %f", SETTING_DEADZONE, m_deadzone);
}
if (strName == SETTING_RETROARCH_CONFIG)
{
m_bGenerateRetroArchConfigs = *static_cast<const bool*>(value);
Expand Down
15 changes: 0 additions & 15 deletions src/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,6 @@ namespace JOYSTICK

bool IsInitialized(void) const { return m_bInitialized; }

/*!
* \brief The analog stick deadzone
*
* This is applied to each axis. Axis is scaled appropriately, so position
* is continuous from -1.0 to 1.0:
*
* | / 1.0
* | /
* __|__/
* / |
* / |--| Deadzone
* -1.0 / |
*/
float Deadzone(void) const { return m_deadzone; }

/*!
* \brief Generate .cfg files compatible with RetroArch's joypad autoconfig
*/
Expand Down

0 comments on commit caa6722

Please sign in to comment.