logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

SDL_GetJoystickPowerInfo - Get the battery state of a joystick.

Availability

       This function is available since SDL 3.2.0.

Simple Directmedia Layer                           SDL 3.2.20                        SDL_GetJoystickPowerInfo(3)

Description

       You  should  never  take a battery status as absolute truth. Batteries (especially failing batteries) are
       delicate hardware, and the values reported here are best estimates based on what that  hardware  reports.
       It's  not  uncommon  for  older batteries to lose stored power much faster than it reports, or completely
       drain when reporting it has 20 percent left, etc.

Function Parameters

joystick
              the joystick to query.

       percent
              a pointer filled in with the percentage of battery life left,  between  0  and  100,  or  NULL  to
              ignore. This will be filled in with -1 we can't determine a value or there is no battery.

Name

       SDL_GetJoystickPowerInfo - Get the battery state of a joystick.

Return Value

       Returns  the  current  battery  state  or  SDL_POWERSTATE_ERROR  on failure; call SDL_GetError() for more
       information.

Synopsis

#include<SDL3/SDL_joystick.h>SDL_PowerStateSDL_GetJoystickPowerInfo(SDL_Joystick*joystick,int*percent);

See Also