Added SDL_GetGamepadPowerLevel() to get the power level directly from a gamepad

This commit is contained in:
Sam Lantinga
2023-07-11 07:09:24 -07:00
parent 9885f4d245
commit 2e3404db01
6 changed files with 26 additions and 1 deletions

View File

@@ -2778,6 +2778,16 @@ const char * SDL_GetGamepadSerial(SDL_Gamepad *gamepad)
return SDL_GetJoystickSerial(joystick);
}
SDL_JoystickPowerLevel SDL_GetGamepadPowerLevel(SDL_Gamepad *gamepad)
{
SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad);
if (joystick == NULL) {
return SDL_JOYSTICK_POWER_UNKNOWN;
}
return SDL_GetJoystickPowerLevel(joystick);
}
/*
* Return if the gamepad in question is currently attached to the system,
* \return 0 if not plugged in, 1 if still present.