Fixed Steam Controller battery state

(cherry picked from commit dd53ecbce8)
This commit is contained in:
Sam Lantinga
2026-01-27 09:53:04 -08:00
parent 13f8201dbe
commit 6fef8fd0dc
2 changed files with 23 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -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