remove deadzone handling from Joystick class

This commit is contained in:
Stephen Birarda 2014-10-08 11:41:07 -07:00
parent 17b9f4a37d
commit 8e2d41f37f

View file

@ -42,14 +42,12 @@ void Joystick::update() {
#ifdef HAVE_SDL #ifdef HAVE_SDL
// update our current values, emit a signal when there is a change // update our current values, emit a signal when there is a change
for (int j = 0; j < getNumAxes(); j++) { for (int j = 0; j < getNumAxes(); j++) {
float value = glm::round(SDL_JoystickGetAxis(_sdlJoystick, j) + 0.5f) / std::numeric_limits<short>::max(); float newValue = glm::round(SDL_JoystickGetAxis(_sdlJoystick, j) + 0.5f) / std::numeric_limits<short>::max();
const float DEAD_ZONE = 0.1f;
float cleanValue = glm::abs(value) < DEAD_ZONE ? 0.0f : value; if (_axes[j] != newValue) {
if (_axes[j] != cleanValue) {
float oldValue = _axes[j]; float oldValue = _axes[j];
_axes[j] = cleanValue; _axes[j] = newValue;
emit axisValueChanged(j, cleanValue, oldValue); emit axisValueChanged(j, newValue, oldValue);
} }
} }
for (int j = 0; j < getNumButtons(); j++) { for (int j = 0; j < getNumButtons(); j++) {