Bladeren bron

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
Mitchell Stokes 5 jaren geleden
bovenliggende
commit
2893d8cef8
2 gewijzigde bestanden met toevoegingen van 8 en 0 verwijderingen
  1. 4 0
      panda/src/device/evdevInputDevice.cxx
  2. 4 0
      panda/src/device/linuxJoystickDevice.cxx

+ 4 - 0
panda/src/device/evdevInputDevice.cxx

@@ -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:

+ 4 - 0
panda/src/device/linuxJoystickDevice.cxx

@@ -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;