From e57beed8906638a1309076be8f453f299cefddca Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Fri, 28 Dec 2018 04:36:41 -0800 Subject: [PATCH] ignore depressed gamepad triggers #88 On joystick event notification, filter out axis values that are equal to their initial state. The reason for doing this is explained in 539027ca. Triggers on e.g. the 360 controller are an axis that are the max negative value in the depressed state, and for some reason a constant stream of events are generated for them, that's another issue that needs to be addressed. For the time being, this fixes the other half of the main issue in #88: users with an old config with the default special key bindings will now be able to use keyboard hotkeys as these spurious joystick events will be filtered out and will not block keyboard events. TODO: - stop generating events for depressed triggers in the first place - fix joystick events completely blocking keyboard events --- src/wx/widgets/sdljoy.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wx/widgets/sdljoy.cpp b/src/wx/widgets/sdljoy.cpp index aa0c8449..897a2103 100644 --- a/src/wx/widgets/sdljoy.cpp +++ b/src/wx/widgets/sdljoy.cpp @@ -134,6 +134,11 @@ void wxSDLJoy::Notify() for (int j = 0; j < nax; j++) { val = SDL_JoystickGetAxis(dev, j); + // trigger axes always return max negative value, we ignore these + int16_t initial_state; + if (SDL_JoystickGetAxisInitialState(dev, j, &initial_state) && val == initial_state) + continue; + if (digital) { if (val > 0x3fff) val = 0x7fff;