Use the correct internal API for updating the battery level for PS5 controllers

This commit is contained in:
Sam Lantinga 2020-11-30 13:04:30 -08:00
parent f4ed07de06
commit e3966e25ca
1 changed files with 5 additions and 5 deletions

View File

@ -798,18 +798,18 @@ HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, SDL_
if (packet->ucBatteryLevel & 0x10) { if (packet->ucBatteryLevel & 0x10) {
/* 0x20 set means fully charged */ /* 0x20 set means fully charged */
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED; SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
} else { } else {
/* Battery level ranges from 0 to 10 */ /* Battery level ranges from 0 to 10 */
int level = (packet->ucBatteryLevel & 0xF); int level = (packet->ucBatteryLevel & 0xF);
if (level == 0) { if (level == 0) {
joystick->epowerlevel = SDL_JOYSTICK_POWER_EMPTY; SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
} else if (level <= 2) { } else if (level <= 2) {
joystick->epowerlevel = SDL_JOYSTICK_POWER_LOW; SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
} else if (level <= 7) { } else if (level <= 7) {
joystick->epowerlevel = SDL_JOYSTICK_POWER_MEDIUM; SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
} else { } else {
joystick->epowerlevel = SDL_JOYSTICK_POWER_FULL; SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
} }
} }