device: Fix erroneous dpad_*-up events when emulating a dpad on Linux

The first time axis are processed while a dpad axis is engaged will
result in the opposite dpad "button" getting set to a state of S_up from
S_unknown, which results in an '-up' event getting fired. Instead,
assume the emulated dpad buttons start in a state of S_up.

This fix is for the Joystick API and for the evdev API, but only the
evdev changes were tested.

Closes #973
This commit is contained in:
Mitchell Stokes 2020-07-14 19:53:08 -07:00 committed by rdb
parent 3fe1d286d0
commit 2893d8cef8
2 changed files with 8 additions and 0 deletions

View File

@ -595,6 +595,8 @@ init_device() {
_buttons.push_back(ButtonState(GamepadButton::hat_left()));
_buttons.push_back(ButtonState(GamepadButton::hat_right()));
}
_buttons[_dpad_left_button]._state = S_up;
_buttons[_dpad_left_button+1]._state = S_up;
}
break;
case ABS_HAT0Y:
@ -608,6 +610,8 @@ init_device() {
_buttons.push_back(ButtonState(GamepadButton::hat_up()));
_buttons.push_back(ButtonState(GamepadButton::hat_down()));
}
_buttons[_dpad_up_button]._state = S_up;
_buttons[_dpad_up_button+1]._state = S_up;
}
break;
case ABS_HAT2X:

View File

@ -234,6 +234,8 @@ open_device() {
add_button(GamepadButton::hat_left());
add_button(GamepadButton::hat_right());
}
_buttons[_dpad_left_button]._state = S_up;
_buttons[_dpad_left_button+1]._state = S_up;
axis = Axis::none;
}
break;
@ -250,6 +252,8 @@ open_device() {
add_button(GamepadButton::hat_up());
add_button(GamepadButton::hat_down());
}
_buttons[_dpad_up_button]._state = S_up;
_buttons[_dpad_up_button+1]._state = S_up;
axis = Axis::none;
}
break;