Wiki Page Content

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.


CategoryEnum, CategoryPower

None: SDL_PowerState (last edited 2013-08-07 20:39:31 by RyanGordon)

Feedback
Please include your contact information if you'd like to receive a reply.
Submit