From dd53ecbce85067fd3be7e743e94a548053faa43d Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 27 Jan 2026 09:53:04 -0800
Subject: [PATCH] Fixed Steam Controller battery state
---
src/joystick/hidapi/SDL_hidapi_steam_triton.c | 18 ++++++++++++------
src/joystick/hidapi/steam/controller_structs.h | 12 +++++++++++-
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/src/joystick/hidapi/SDL_hidapi_steam_triton.c b/src/joystick/hidapi/SDL_hidapi_steam_triton.c
index e5c0f1a5c8386..0a140eda03b90 100644
--- a/src/joystick/hidapi/SDL_hidapi_steam_triton.c
+++ b/src/joystick/hidapi/SDL_hidapi_steam_triton.c
@@ -228,14 +228,20 @@ static void HIDAPI_DriverSteamTriton_HandleBatteryStatus(SDL_HIDAPI_Device *devi
{
SDL_PowerState state;
- if (device->is_bluetooth) {
+ switch (pTritonBatteryStatus->ucChargeState) {
+ case k_EChargeStateDischarging:
state = SDL_POWERSTATE_ON_BATTERY;
- } else if (IsProteusDongle(device->product_id)) {
- state = SDL_POWERSTATE_ON_BATTERY;
- } else if (pTritonBatteryStatus->ucBatteryLevel == 100) {
- state = SDL_POWERSTATE_CHARGED;
- } else {
+ break;
+ case k_EChargeStateCharging:
state = SDL_POWERSTATE_CHARGING;
+ break;
+ case k_EChargeStateChargingDone:
+ state = SDL_POWERSTATE_CHARGED;
+ break;
+ default:
+ // Error state?
+ state = SDL_POWERSTATE_UNKNOWN;
+ break;
}
SDL_SendJoystickPowerInfo(joystick, state, pTritonBatteryStatus->ucBatteryLevel);
}
diff --git a/src/joystick/hidapi/steam/controller_structs.h b/src/joystick/hidapi/steam/controller_structs.h
index 0496f8308e8cd..dc67093c67996 100644
--- a/src/joystick/hidapi/steam/controller_structs.h
+++ b/src/joystick/hidapi/steam/controller_structs.h
@@ -603,15 +603,25 @@ typedef struct
TritonMTUIMU_t imu;
} TritonMTUFull_t;
+enum EChargeState
+{
+ k_EChargeStateReset,
+ k_EChargeStateDischarging,
+ k_EChargeStateCharging,
+ k_EChargeStateSrcValidate,
+ k_EChargeStateChargingDone,
+};
+
typedef struct
{
+ unsigned char ucChargeState; // EChargeState
unsigned char ucBatteryLevel;
unsigned short sBatteryVoltage;
unsigned short sSystemVoltage;
unsigned short sInputVoltage;
unsigned short sCurrent;
unsigned short sInputCurrent;
- char cTemperature;
+ unsigned short sTemperature;
} TritonBatteryStatus_t;
typedef struct