Skip to content

Commit

Permalink
SDL: sometimes the PS5 controller doesn't report having to power even…
Browse files Browse the repository at this point in the history
… when connected over USB. Possibly related to being completely charged? Either way we already know that it's USB or BT so let's use the driver's knowledge instead.
  • Loading branch information
slouken authored and icculus committed Apr 27, 2022
1 parent e571d9e commit eae8aaa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/joystick/hidapi/SDL_hidapi_ps5.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,10 @@ HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev,
axis = ((int)packet->ucRightJoystickY * 257) - 32768;
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);

if (packet->ucBatteryLevel & 0x10) {
/* A check of packet->ucBatteryLevel & 0x10 should work as a check for BT vs USB but doesn't
* seem to always work. Possibly related to being 100% charged?
*/
if (!ctx->is_bluetooth) {
/* 0x20 set means fully charged */
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
} else {
Expand Down

0 comments on commit eae8aaa

Please sign in to comment.