From 18ac612647dfc0d8538d4ed0c7117c2a15550759 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sun, 1 Sep 2019 10:44:48 +0200 Subject: [PATCH] Revert "prevent menu navigation with analog input" This reverts commit cce980a4d461ef6aefb4c73e6d0bb240e92064c7. (breaks editing mappings for analog devices) --- src/common/PJoystickHandler.cxx | 36 +++++++++++++++------------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index b06dd7dc0..eea35dfa8 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -610,13 +610,12 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value) if(j) { int button = j->buttonLast[stick]; - bool isAnalog = abs(j->axisLastValue[axis] - value) < 30000; if(myHandler.state() == EventHandlerState::EMULATION) { // Check for analog events, which are handled differently // A value change lower than ~90% indicates analog input - if(isAnalog) + if(abs(j->axisLastValue[axis] - value) < 30000) { Event::Type eventAxisAnalog = j->joyMap.get(EventMode::kEmulationMode, button, JoyAxis(axis), JoyDir::ANALOG); @@ -649,32 +648,29 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value) } } } + j->axisLastValue[axis] = value; } else if(myHandler.hasOverlay()) { - // prevent menu navigation by analog input - if(!isAnalog) - { - // First, clamp the values to simulate digital input - // (the only thing that the underlying code understands) - if(value > Joystick::deadzone()) - value = 32000; - else if(value < -Joystick::deadzone()) - value = -32000; - else - value = 0; + // First, clamp the values to simulate digital input + // (the only thing that the underlying code understands) + if(value > Joystick::deadzone()) + value = 32000; + else if(value < -Joystick::deadzone()) + value = -32000; + else + value = 0; - // Now filter out consecutive, similar values - // (only pass on the event if the state has changed) - if(value != j->axisLastValue[axis]) - { + // Now filter out consecutive, similar values + // (only pass on the event if the state has changed) + if(value != j->axisLastValue[axis]) + { #ifdef GUI_SUPPORT - myHandler.overlay().handleJoyAxisEvent(stick, JoyAxis(axis), convertAxisValue(value), button); + myHandler.overlay().handleJoyAxisEvent(stick, JoyAxis(axis), convertAxisValue(value), button); #endif - } + j->axisLastValue[axis] = value; } } - j->axisLastValue[axis] = value; } }