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
This commit is contained in:
Rafael Kitover 2018-12-28 04:36:41 -08:00
parent 979ef8ebbd
commit e57beed890
1 changed files with 5 additions and 0 deletions

View File

@ -134,6 +134,11 @@ void wxSDLJoy::Notify()
for (int j = 0; j < nax; j++) { for (int j = 0; j < nax; j++) {
val = SDL_JoystickGetAxis(dev, 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 (digital) {
if (val > 0x3fff) if (val > 0x3fff)
val = 0x7fff; val = 0x7fff;