diasurgical / devilutionX

Diablo build for modern operating systems
Other
8.06k stars 793 forks source link

Select + D-Pad mouse simulation broken #5449

Closed glebm closed 2 years ago

glebm commented 2 years ago
  1. Mouse moves in wrong directions and doesn't stop when d-pad button is released (while holding select).
  2. The SELECT menu reappers when d-pad button is released (while holding select).
StephenCWills commented 2 years ago

I figured out why this was working so differently on Windows with my PS3 controller. I'm constantly getting interference from spurious axis motion events. They fall well within the deadzone, but GameController::ProcessAxisMotion() still fiddles with the global variables used by SimulateRightStickWithDpad() regardless.

I was able to work around it by simply disabling the axes that produce the spurious events.

diff --git a/Source/controls/controller_motion.cpp b/Source/controls/controller_motion.cpp
index c35b7c6e9..441d36a86 100644
--- a/Source/controls/controller_motion.cpp
+++ b/Source/controls/controller_motion.cpp
@@ -143,6 +143,8 @@ void ScaleJoysticks()
 bool ProcessControllerMotion(const SDL_Event &event, ControllerButtonEvent ctrlEvent)
 {
 #ifndef USE_SDL1
+   if (event.type == SDL_CONTROLLERAXISMOTION && IsAnyOf(event.caxis.axis, SDL_CONTROLLER_AXIS_LEFTX, SDL_CONTROLLER_AXIS_LEFTY, SDL_CONTROLLER_AXIS_RIGHTX, SDL_CONTROLLER_AXIS_RIGHTY))
+       return true;
    GameController *const controller = GameController::Get(event);
    if (controller != nullptr && devilution::GameController::ProcessAxisMotion(event)) {
        ScaleJoysticks();