mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-13 15:23:34 +00:00
Fixed Steam Controller battery state
(cherry picked from commit dd53ecbce8)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user