SDL  2.0
SDL_power.h File Reference
#include "SDL_stdinc.h"
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL_power.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  SDL_PowerState {
  SDL_POWERSTATE_UNKNOWN,
  SDL_POWERSTATE_ON_BATTERY,
  SDL_POWERSTATE_NO_BATTERY,
  SDL_POWERSTATE_CHARGING,
  SDL_POWERSTATE_CHARGED
}
 The basic state for the system's power supply. More...

Functions

SDL_PowerState SDL_GetPowerInfo (int *secs, int *pct)
 Get the current power supply details.

Detailed Description

Header for the SDL power management routines.

Definition in file SDL_power.h.

Enumeration Type Documentation

The basic state for the system's power supply.

Enumerator:
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

Definition at line 42 of file SDL_power.h.

{
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 */

Function Documentation

SDL_PowerState SDL_GetPowerInfo ( int *  secs,
int *  pct 
)

Get the current power supply details.

Parameters
secsSeconds of battery life left. You can pass a NULL here if you don't care. Will return -1 if we can't determine a value, or we're not running on a battery.
pctPercentage of battery life left, between 0 and 100. You can pass a NULL here if you don't care. Will return -1 if we can't determine a value, or we're not running on a battery.
Returns
The state of the battery (if any).

Definition at line 85 of file SDL_power.c.

References i, implementations, NULL, retval, and SDL_POWERSTATE_UNKNOWN.

{
#ifndef SDL_POWER_DISABLED
const int total = sizeof(implementations) / sizeof(implementations[0]);
int i;
#endif
int _seconds, _percent;
/* Make these never NULL for platform-specific implementations. */
if (seconds == NULL) {
seconds = &_seconds;
}
if (percent == NULL) {
percent = &_percent;
}
#ifndef SDL_POWER_DISABLED
for (i = 0; i < total; i++) {
if (implementations[i](&retval, seconds, percent)) {
return retval;
}
}
#endif
/* nothing was definitive. */
*seconds = -1;
*percent = -1;
}