SDL Wiki
(This is the documentation for SDL3, which is the current stable version. SDL2 was the previous version!)

SDL_GetJoystickPowerInfo

Get the battery state of a joystick.

Header File

Defined in <SDL3/SDL_joystick.h>

Syntax

SDL_PowerState SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent);

Function Parameters

SDL_Joystick * joystick the joystick to query.
int * 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.

Return Value

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

Remarks

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.

Version

This function is available since SDL 3.1.3.


CategoryAPI, CategoryAPIFunction, CategoryJoystick


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.