mirror of https://github.com/encounter/SDL.git
Don't report battery level for disconnected batteries
Fixes https://github.com/libsdl-org/SDL/issues/6536
This commit is contained in:
parent
8ae46a49ea
commit
8b20b568b0
|
@ -133,10 +133,13 @@ using namespace XInputOnGameInput;
|
||||||
#ifndef BATTERY_DEVTYPE_GAMEPAD
|
#ifndef BATTERY_DEVTYPE_GAMEPAD
|
||||||
#define BATTERY_DEVTYPE_GAMEPAD 0x00
|
#define BATTERY_DEVTYPE_GAMEPAD 0x00
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BATTERY_TYPE_DISCONNECTED
|
||||||
|
#define BATTERY_TYPE_DISCONNECTED 0x00
|
||||||
|
#endif
|
||||||
#ifndef BATTERY_TYPE_WIRED
|
#ifndef BATTERY_TYPE_WIRED
|
||||||
#define BATTERY_TYPE_WIRED 0x01
|
#define BATTERY_TYPE_WIRED 0x01
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BATTERY_TYPE_UNKNOWN
|
#ifndef BATTERY_TYPE_UNKNOWN
|
||||||
#define BATTERY_TYPE_UNKNOWN 0xFF
|
#define BATTERY_TYPE_UNKNOWN 0xFF
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2901,7 +2901,7 @@ void SDL_PrivateJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLe
|
||||||
{
|
{
|
||||||
CHECK_JOYSTICK_MAGIC(joystick, );
|
CHECK_JOYSTICK_MAGIC(joystick, );
|
||||||
|
|
||||||
SDL_assert(joystick->ref_count); /* make sure we are calling this only for update, not for initialisation */
|
SDL_assert(joystick->ref_count); /* make sure we are calling this only for update, not for initialization */
|
||||||
if (ePowerLevel != joystick->epowerlevel) {
|
if (ePowerLevel != joystick->epowerlevel) {
|
||||||
#if !SDL_EVENTS_DISABLED
|
#if !SDL_EVENTS_DISABLED
|
||||||
if (SDL_GetEventState(SDL_JOYBATTERYUPDATED) == SDL_ENABLE) {
|
if (SDL_GetEventState(SDL_JOYBATTERYUPDATED) == SDL_ENABLE) {
|
||||||
|
|
|
@ -1775,7 +1775,8 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
|
||||||
}
|
}
|
||||||
has_trigger_data = SDL_TRUE;
|
has_trigger_data = SDL_TRUE;
|
||||||
|
|
||||||
if (battery_info->BatteryType != BATTERY_TYPE_UNKNOWN) {
|
if (battery_info->BatteryType != BATTERY_TYPE_UNKNOWN &&
|
||||||
|
battery_info->BatteryType != BATTERY_TYPE_DISCONNECTED) {
|
||||||
SDL_JoystickPowerLevel ePowerLevel = SDL_JOYSTICK_POWER_UNKNOWN;
|
SDL_JoystickPowerLevel ePowerLevel = SDL_JOYSTICK_POWER_UNKNOWN;
|
||||||
if (battery_info->BatteryType == BATTERY_TYPE_WIRED) {
|
if (battery_info->BatteryType == BATTERY_TYPE_WIRED) {
|
||||||
ePowerLevel = SDL_JOYSTICK_POWER_WIRED;
|
ePowerLevel = SDL_JOYSTICK_POWER_WIRED;
|
||||||
|
|
Loading…
Reference in New Issue