SDL Wiki

SDL_PowerState

An enumeration of the basic state of the system's power supply.

Values

SDL_POWERSTATE_UNKNOWN

cannot determine power status

SDL_POWERSTATE_ON_BATTERY

not plugged in, running on the battery

SDL_POWERSTATE_NO_BATTERY

plugged in, no battery available

SDL_POWERSTATE_CHARGING

plugged in, charging battery

SDL_POWERSTATE_CHARGED

plugged in, battery charged

Code Examples

if (SDL_GetPowerInfo(NULL, NULL) == SDL_POWERSTATE_ON_BATTERY) {
    printf("You should plug in your laptop before running this update.\n");
}

Remarks

Not all machines can have batteries at all, and not all platforms can report battery status. Those that do can still having minor moments of confusion about the state of the battery. As such, you should always be prepared to get an otherwise-unexpected SDL_POWERSTATE_UNKNOWN from SDL_GetPowerInfo(). Also, batteries are fickle hardware: reported status can flicker between two states for no obvious reason on occasion.

SDL_GetPowerInfo

CategoryEnum, CategoryPower


[ 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.