# SDL: SDL: sometimes the PS5 controller doesn't report having to power even when connected over USB. Possibly related to being...

**URL:** <https://discourse.libsdl.org/t/sdl-sdl-sometimes-the-ps5-controller-doesnt-report-having-to-power-even-when-connected-over-usb-possibly-related-to-being/35418>\
**Category:** SDL Commits\
**Created:** [April 22, 2022, 9:24pm UTC](https://discourse.libsdl.org/t/sdl-sdl-sometimes-the-ps5-controller-doesnt-report-having-to-power-even-when-connected-over-usb-possibly-related-to-being/35418 "2022-04-22T21:24:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [April 22, 2022, 9:24pm UTC](https://discourse.libsdl.org/t/sdl-sdl-sometimes-the-ps5-controller-doesnt-report-having-to-power-even-when-connected-over-usb-possibly-related-to-being/35418/1 "2022-04-22T21:24:02Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/2ca083788876129a20b2b2d0fa9724c39aba1128>

```diff
From 2ca083788876129a20b2b2d0fa9724c39aba1128 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 22 Apr 2022 14:21:41 -0700
Subject: [PATCH] SDL: sometimes the PS5 controller doesn't report having to
 power even 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.

---
 src/joystick/hidapi/SDL_hidapi_ps5.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 5989eb930cf..2549c2afd5d 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -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 {

```
