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

SDL_GameControllerHasRumbleTriggers reports false for a PS5 controller #5372

Closed
uramer opened this issue Feb 28, 2022 · 10 comments
Closed

SDL_GameControllerHasRumbleTriggers reports false for a PS5 controller #5372

uramer opened this issue Feb 28, 2022 · 10 comments

Comments

@uramer
Copy link

uramer commented Feb 28, 2022

I'm using SDL 2.0.18, Windows 10, PS5 controller connected through USB, and this code to test the rumble triggers:

Log(Debug::Info) << "Detected controller:"
    << SDL_GameControllerName(controller)
    << "\nRumble support: "
    << SDL_GameControllerHasRumble(controller)
    << "\nRumble triggers support: "
    << SDL_GameControllerHasRumbleTriggers(controller);
SDL_GameControllerRumbleTriggers(controller, 0x1111, 0xFFFF, 2000);

Which prints:

[01:56:29.928 I] Detected controller:PS5 Controller
[01:56:29.928 I] Rumble support: 1
[01:56:29.928 I] Rumble triggers support: 0

The rumble triggers work fine in games, e. g. Deathloop, so it's unlikely it's an issue with my controller or setup.

@AntTheAlchemist
Copy link
Contributor

Have you tried the following hint?

	SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");

I've found because HIDAPI is enabled by default, but extended inputs are disabled by default, means PS rumble won't work without this hint.

@uramer
Copy link
Author

uramer commented Mar 3, 2022

Yes, I'm using these hints:

SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
SDL_SetHint(SDL_HINT_LINUX_JOYSTICK_DEADZONES, "1");

I've also tried it with just

SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");

in case any conflicts between the hints are possible.

@AntTheAlchemist
Copy link
Contributor

Could also play around with

		SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "0"); // or "1"
		SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI, "0"); // or "1"

Are you able to test the PS5 touchpad, sensors, and LED? Might give some hint to what's going on.
Have you tried seeing if there's a difference between wired and bluetooth?

All else I can tell you is that I have a Chinese pretend PS4 and it kind of works (apart from LED), but only if wired.

@slouken
Copy link
Collaborator

slouken commented Mar 3, 2022

PS5 controllers don't actually have trigger rumble the way it's defined in SDL. They instead have advanced haptic actuators that don't (at least at the original firmware release) provide indefinite trigger vibration.

@slouken slouken closed this as completed Mar 3, 2022
@slouken
Copy link
Collaborator

slouken commented Mar 3, 2022

Games like Deathloop use an SDK provided by Sony that allows setting pressure thresholds and trigger effects. You can do this yourself by using the code in testgamecontroller.c (look for CyclePS5TriggerEffect), but calling SDL_GameControllerRumbleTriggers() won't have any effect.

@uramer
Copy link
Author

uramer commented Mar 4, 2022

Thanks for the clarification. The SDL documentation on these methods is extremely confusing https://wiki.libsdl.org/SDL_GameControllerRumbleTriggers

It says: "Note that this is rumbling of the triggers and not the game controller as a whole. The first controller to offer this feature was the PlayStation 5's DualShock 5."

This implies it only works with DualShock 5. While if I understand your response correctly, it works only with Xbox One style controllers.

@slouken
Copy link
Collaborator

slouken commented Mar 4, 2022

Yes, the documentation was incorrect. I've fixed it, thanks!

@Etaash-mathamsetty
Copy link
Contributor

Etaash-mathamsetty commented Mar 26, 2022

I am having this issue with an xbox one S controller :/
my code:
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_XBOX,"1"); SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); printf("num joys %d\n", SDL_NumJoysticks()); SDL_Joystick* joystick = SDL_JoystickOpen(0); SDL_JoystickSetLED(joystick, 50, 10, 10); printf("name %s\n",SDL_JoystickName(joystick)); printf("supports? %d\n",SDL_JoystickHasRumbleTriggers(joystick) == SDL_TRUE); SDL_JoystickRumbleTriggers(joystick, UINT16_MAX/2, UINT16_MAX/2, 10000); printf("error: %s\n", SDL_GetError()); sleep(10);

@uramer
Copy link
Author

uramer commented Mar 27, 2022

I've had an Xbox style controller report true from SDL_JoystickHasRumbleTriggers, despite not even having them.

Are you using it wired or wireless? A lot of these advanced haptic features are disabled in wireless mode, I assume due to power consumption.

@Etaash-mathamsetty
Copy link
Contributor

Etaash-mathamsetty commented Mar 28, 2022

I've had an Xbox style controller report true from SDL_JoystickHasRumbleTriggers, despite not even having them.

Are you using it wired or wireless? A lot of these advanced haptic features are disabled in wireless mode, I assume due to power consumption.

wired and wireless, and it worked on my windows pc (in forza horizon 5)
(am using linux btw)
and it should work with wireless too since the trigger rumble works wirelessly on my xbox...
sample code behaves the same on my dualsense and my xbox one S controller (no trigger rumble)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants