diff --git a/src/joystick/hidapi/SDL_hidapi_steam_triton.c b/src/joystick/hidapi/SDL_hidapi_steam_triton.c index e5c0f1a5c8..0a140eda03 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 0496f8308e..dc67093c67 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