mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
remove deadzone handling from Joystick class
This commit is contained in:
parent
17b9f4a37d
commit
8e2d41f37f
1 changed files with 5 additions and 7 deletions
|
@ -42,14 +42,12 @@ void Joystick::update() {
|
|||
#ifdef HAVE_SDL
|
||||
// update our current values, emit a signal when there is a change
|
||||
for (int j = 0; j < getNumAxes(); j++) {
|
||||
float value = 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] != cleanValue) {
|
||||
float newValue = glm::round(SDL_JoystickGetAxis(_sdlJoystick, j) + 0.5f) / std::numeric_limits<short>::max();
|
||||
|
||||
if (_axes[j] != newValue) {
|
||||
float oldValue = _axes[j];
|
||||
_axes[j] = cleanValue;
|
||||
emit axisValueChanged(j, cleanValue, oldValue);
|
||||
_axes[j] = newValue;
|
||||
emit axisValueChanged(j, newValue, oldValue);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < getNumButtons(); j++) {
|
||||
|
|
Loading…
Reference in a new issue