| Summary: | [PATCH] PS4 Controller Lightbar always reset to default blue | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Vitor <vitor-kiguchi> |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | trivial | ||
| Priority: | P2 | CC: | cameron.gutman |
| Version: | 2.0.10 | ||
| Hardware: | x86 | ||
| OS: | Windows 10 | ||
| Attachments: |
Added support for indicating player index on DS4 controllers
Clear the old player index slot when moving to a new one |
||
|
Description
Vitor
2020-03-05 22:20:30 UTC
Created attachment 4238 [details]
Added support for indicating player index on DS4 controllers
This patch sets the DS4 LED to indicate the player index like the PS4 does. It also matches the colors that the hid-sony driver uses in the Linux kernel when the player count exceeds 4 (max supported on PS4).
Thanks, your patch is in: https://hg.libsdl.org/SDL/rev/ea9492fc2eae Can you adapt it so it adjusts the color when someone sets the player index? Created attachment 4242 [details] Clear the old player index slot when moving to a new one HIDAPI_DriverPS4_SetDevicePlayerIndex() should properly handle changing player index on the fly. After some additional testing, I think I may have found the issue you are seeing. SDL_SetJoystickIDForPlayerIndex() isn't clearing the old location in SDL_joystick_players[], so you wouldn't be able to go from 0 -> 1 -> 0, since the check added in https://hg.libsdl.org/SDL/rev/36aabb2051e9 would see it as a no-op. With the attached patch, I can SDL_SetJoystickIDForPlayerIndex() to whatever index I want and the LED color is set correctly both over BT (with SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE=1) and USB. Great, I applied your second patch, but the first one doesn't apply cleanly to Mercurial. Can you rebase and test it? Thanks! The first patch was already applied as https://hg.libsdl.org/SDL/rev/ea9492fc2eae This bug can be resolved now unless you see something else broken. Thanks Cameron. Vitor, how did the user originally change their PS4 light bar color? It doesn't look like it's possible to read back the existing color, and I don't think anyone will go to the trouble of using an SDL API to set it to match a specific color, so if nobody wants more specific control, I'll go ahead and close this bug. Hello, first of all thank you Cameron for the quick patch. Sam, from what I understand, the user set the color via Steam's big picture mode. With that in mind, it is possible the observed behavior has a different underlying cause (maybe the user set the color but has since exited big picture mode/Steam? Or maybe it's a different bug in Steam or SDL?), and so some investigation is needed. Nevertheless I see this as a good solution for the presented problem. Having an API for setting the lightbar color would be a little overkill. While I don't think it would go totally unused, it's probably more trouble than it's worth. I'll keep investigating the issue, but I believe the bug as presented here is fixed. The solution of using the same colors as the PS4 is quite nice. It looks like this is resolved. Feel free to reopen it if that's not the case. |