Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rumble on Xbox 360 controller only works after a button press #802

Closed
ckeisc opened this issue Nov 15, 2022 · 9 comments
Closed

Rumble on Xbox 360 controller only works after a button press #802

ckeisc opened this issue Nov 15, 2022 · 9 comments
Labels
input Related to input controllers and devices

Comments

@ckeisc
Copy link

ckeisc commented Nov 15, 2022

Seeing this on Windows Standalone. Here is my setup - I have a driving cabinet powered by a Windows PC, the wheels and pedals are connected through an USB interface that present them as an USB HID gamepad, no rumble. There is a separate Xbox 360 controller connected via USB that drives the rumble motor.

In Flycast, I can see both controllers but the rumble (via Xbox 360 controller) would only work if I press some other buttons on it first. In my actual setup, the Xbox 360 controller is not accessible, so that would not be possible. The same setup works in other emulators using SDL (PCSX2, Duckstation, etc.) without having to press a button first for rumble to start working, so I don't think it's an inherently an SDL issue.

Does Flycast has any additional logic to "filter" controllers until a button is pressed? Is there a way to modify or suppress this behavior?

For reference, how the 2 controllers show up in Settings UI:
image

@flyinghead flyinghead added the input Related to input controllers and devices label Nov 15, 2022
@vkedwardli
Copy link
Collaborator

vkedwardli commented Nov 15, 2022

Does Flycast has any additional logic to "filter" controllers until a button is pressed?

I don't think so

May be you could test by

  • Create a savestate before the car is going to crash (not sure what causes the vibration, just an example)
  • Only plug in the Xbox controller
  • Load the state

And see if your controller can vibrate during the crash

if yes, then plug in the steering wheels also and try loading the state again
if yes also, right after you load the state, add some input from the steering wheel and see if the Xbox controller won't vibrate now

@flyinghead
Copy link
Owner

Flycast doesn't need a button press to recognize a gamepad or to make it rumble. I just double checked by playing a game with the keyboard and the PS3 gamepad on my desk started rumbling.

@ckeisc
Copy link
Author

ckeisc commented Nov 17, 2022

Could this be related to XInput controllers? I tested several times with Crazy Tax and Crazy Taxi 2:

  1. keyboard + a single wired Xbox 360 controller - rumble would not start working until the first key is pressed on the game pad
  2. keyboard + a single Xbox One controller connected using USB - rumble would not start working until the first key is pressed on the game pad
  3. keyboard + both Xbox 360 controller and Xbox One controller are connected via USB - rumble would only start working when the first key is pressed from EITHER game pad. Once a key is pressed, rumble from both controllers would start working.

I wonder if this is some SDL behavior when used with XInput controllers. That said, I tested PCSX2 that also uses SDL, and it could vibrate a motor from XInput controller without needing any buttons to be pressed. Not sure if the SDL versions are the same between the 2 emulators though. This behaviors happens very consistently for me in Flycast. Do you have an XInput controller to try?

@vkedwardli
Copy link
Collaborator

Both PCSX2 & Duckstation are using the higher level SDL_GameControllerRumble, while Flycast is using SDL_JoystickRumble.

There could be some extra handling / initialisation when using SDL_GameController?

@flyinghead
Copy link
Owner

SDL_GameControllerRumble simply calls SDL_JoystickRumble so I doubt this would be an issue.

I just tried on Windows and yes, I have to press a button for the rumble to start working. I tried with a Xbox Series X controller and a PS3 gamepad with the same result. The same PS3 controller doesn't need a button press for the rumble to start working on linux so I assume this is a Windows / XInput thing.

@ckeisc
Copy link
Author

ckeisc commented Nov 17, 2022

Thank you both for looking into this. Searching in SDL github and found some threads with some suggestion / hint. It seems there is a “correlation” process that is known. Having to press a button to correlate is a blocker for my setup though, so hope there is a viable workaround.

Not familiar with the code base. Is there something applicable there?

libsdl-org/SDL#6432

libsdl-org/SDL#5351

@flyinghead
Copy link
Owner

The latter issue seems related. Apparently SDL is now using the raw input API on windows, and it needs to correlate rumble devices with input devices. This explains why rumble isn't active until after a button is pressed on the corresponding gamepad.

I was able to make a gamepad rumble without interaction by disabling the raw input api in SDL with this environment variable:

set SDL_JOYSTICK_RAWINPUT=0

@ckeisc
Copy link
Author

ckeisc commented Nov 18, 2022

The SDL_JOYSTICK_RAWINPUT environment variable gave me a viable workaround, thank you. Something to consider opt-out the default behavior since it seems unlikely Flycast would need more than 4 controllers. But I am happy to find a resolution for my issue. Thanks again.

@ckeisc ckeisc closed this as completed Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
input Related to input controllers and devices
Projects
None yet
Development

No branches or pull requests

3 participants