mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-01 23:07:45 +08:00
Fixed Steam Controller battery state
This commit is contained in:
@@ -228,14 +228,20 @@ static void HIDAPI_DriverSteamTriton_HandleBatteryStatus(SDL_HIDAPI_Device *devi
|
|||||||
{
|
{
|
||||||
SDL_PowerState state;
|
SDL_PowerState state;
|
||||||
|
|
||||||
if (device->is_bluetooth) {
|
switch (pTritonBatteryStatus->ucChargeState) {
|
||||||
|
case k_EChargeStateDischarging:
|
||||||
state = SDL_POWERSTATE_ON_BATTERY;
|
state = SDL_POWERSTATE_ON_BATTERY;
|
||||||
} else if (IsProteusDongle(device->product_id)) {
|
break;
|
||||||
state = SDL_POWERSTATE_ON_BATTERY;
|
case k_EChargeStateCharging:
|
||||||
} else if (pTritonBatteryStatus->ucBatteryLevel == 100) {
|
|
||||||
state = SDL_POWERSTATE_CHARGED;
|
|
||||||
} else {
|
|
||||||
state = SDL_POWERSTATE_CHARGING;
|
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);
|
SDL_SendJoystickPowerInfo(joystick, state, pTritonBatteryStatus->ucBatteryLevel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -603,15 +603,25 @@ typedef struct
|
|||||||
TritonMTUIMU_t imu;
|
TritonMTUIMU_t imu;
|
||||||
} TritonMTUFull_t;
|
} TritonMTUFull_t;
|
||||||
|
|
||||||
|
enum EChargeState
|
||||||
|
{
|
||||||
|
k_EChargeStateReset,
|
||||||
|
k_EChargeStateDischarging,
|
||||||
|
k_EChargeStateCharging,
|
||||||
|
k_EChargeStateSrcValidate,
|
||||||
|
k_EChargeStateChargingDone,
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
unsigned char ucChargeState; // EChargeState
|
||||||
unsigned char ucBatteryLevel;
|
unsigned char ucBatteryLevel;
|
||||||
unsigned short sBatteryVoltage;
|
unsigned short sBatteryVoltage;
|
||||||
unsigned short sSystemVoltage;
|
unsigned short sSystemVoltage;
|
||||||
unsigned short sInputVoltage;
|
unsigned short sInputVoltage;
|
||||||
unsigned short sCurrent;
|
unsigned short sCurrent;
|
||||||
unsigned short sInputCurrent;
|
unsigned short sInputCurrent;
|
||||||
char cTemperature;
|
unsigned short sTemperature;
|
||||||
} TritonBatteryStatus_t;
|
} TritonBatteryStatus_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
Reference in New Issue
Block a user