libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.82k stars 1.82k forks source link

[SDL2] Gamepad Motion Sensors via Bluetooth don't work until you launch another SDL App with working Motion Sensors or swap older SDL2.dll files #10524

Closed AL2009man closed 2 weeks ago

AL2009man commented 2 months ago

since the release of DOOM + DOOM II (SDL 2.28.5), I've spotted a weird bug where Motion Sensors do not work on Bluetooth vs. USB, one of the Nightdive Studios developers told me that it's a bug with their implementation of SDL2 where a specific flag that causes other controllers to break-- but they don't really know the full details...

until recently; I found a workaround, and this will sound silly. I'm starting to believe it's an SDL2-related regression more than anything. It turns out; connecting via Bluetooth will not have a Game detect Motion Sensors in one Application (DOOM + DOOM II), but in another application, it works instantly under the same SDL2...but if you went back to the same application that initially doesn't work; now works all the sudden-- and it stays there until you disconnect the controller.

(to make sure; I'm on Windows 11, i dunno which version)

There are at least two workarounds:

  1. Fnding a game that happens to use SDL2 and see if the game can read gyro input data, (my case: Yagami Quake 2, the latest test build). Then I exit the game, and then I launch DOOM 1 + 2 Kex, and now the Gyro Aiming toggle has appeared.
  2. swap SDL2.dll file with an older build (ideally; around 2.14.0, taken from Quake 2 Remastered) and now the game will see Motion Sensors.

I tested it with both DualShock 4 and DualSense Controller, both have the same exact workaround.

this isn't exclusively a DOOM Kex-only issue, it appears to also affect another doom sourceport whose been implementing Gyro Aiming as well, the sourceport dev confirmed the same behavior as well. This helps determine that it's indeed a regression.

AntTheAlchemist commented 2 months ago

This sounds like one app is set up to enable extended features with the hints SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE & SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE. Once this has been enabled on the gamepad, it will change the gamepad's behaviour until it's switched off and on again. Does that sound right?

ceski-1 commented 2 months ago

This is resolved by using these hints:

SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");

It's not obvious that those lines allow bluetooth gyro to function correctly. Maybe the descriptions can be updated?

slouken commented 2 weeks ago

Duplicate of https://github.com/libsdl-org/SDL/issues/10086