SDL  2.0
SDL_power.c File Reference
#include "../SDL_internal.h"
#include "SDL_power.h"
#include "SDL_syspower.h"
+ Include dependency graph for SDL_power.c:

Go to the source code of this file.

Typedefs

typedef SDL_bool(* SDL_GetPowerInfo_Impl )(SDL_PowerState *state, int *seconds, int *percent)

Functions

SDL_PowerState SDL_GetPowerInfo (int *seconds, int *percent)
 Get the current power supply details.

Variables

static SDL_GetPowerInfo_Impl implementations []

Typedef Documentation

typedef SDL_bool(* SDL_GetPowerInfo_Impl)(SDL_PowerState *state, int *seconds, int *percent)

Definition at line 30 of file SDL_power.c.

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;
}

Variable Documentation

SDL_GetPowerInfo_Impl implementations[]
static

Definition at line 46 of file SDL_power.c.

Referenced by SDL_GetPowerInfo().