Revert "prevent menu navigation with analog input"

This reverts commit c30cd906a6.
(breaks editing mappings for analog devices)
This commit is contained in:
Thomas Jentzsch 2019-09-01 10:44:48 +02:00
parent c30cd906a6
commit 1d9a2366dc
1 changed files with 16 additions and 20 deletions

View File

@ -610,13 +610,12 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
if(j) if(j)
{ {
int button = j->buttonLast[stick]; int button = j->buttonLast[stick];
bool isAnalog = abs(j->axisLastValue[axis] - value) < 30000;
if(myHandler.state() == EventHandlerState::EMULATION) if(myHandler.state() == EventHandlerState::EMULATION)
{ {
// Check for analog events, which are handled differently // Check for analog events, which are handled differently
// A value change lower than ~90% indicates analog input // 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); 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()) else if(myHandler.hasOverlay())
{ {
// prevent menu navigation by analog input // First, clamp the values to simulate digital input
if(!isAnalog) // (the only thing that the underlying code understands)
{ if(value > Joystick::deadzone())
// First, clamp the values to simulate digital input value = 32000;
// (the only thing that the underlying code understands) else if(value < -Joystick::deadzone())
if(value > Joystick::deadzone()) value = -32000;
value = 32000; else
else if(value < -Joystick::deadzone()) value = 0;
value = -32000;
else
value = 0;
// Now filter out consecutive, similar values // Now filter out consecutive, similar values
// (only pass on the event if the state has changed) // (only pass on the event if the state has changed)
if(value != j->axisLastValue[axis]) if(value != j->axisLastValue[axis])
{ {
#ifdef GUI_SUPPORT #ifdef GUI_SUPPORT
myHandler.overlay().handleJoyAxisEvent(stick, JoyAxis(axis), convertAxisValue(value), button); myHandler.overlay().handleJoyAxisEvent(stick, JoyAxis(axis), convertAxisValue(value), button);
#endif #endif
} j->axisLastValue[axis] = value;
} }
} }
j->axisLastValue[axis] = value;
} }
} }