SDL  2.0
SDL_power.c File Reference
#include "../SDL_internal.h"
#include "SDL_power.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_bool SDL_GetPowerInfo_Linux_sys_class_power_supply (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_Linux_proc_acpi (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_Linux_proc_apm (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_Windows (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_MacOSX (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_Haiku (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_UIKit (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_Android (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_PSP (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_WinRT (SDL_PowerState *, int *, int *)
 
SDL_bool SDL_GetPowerInfo_Emscripten (SDL_PowerState *, int *, int *)
 
SDL_PowerState SDL_GetPowerInfo (int *seconds, int *percent)
 Get the current power supply details. More...
 

Variables

static SDL_GetPowerInfo_Impl implementations []
 

Typedef Documentation

§ SDL_GetPowerInfo_Impl

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

Definition at line 29 of file SDL_power.c.

Function Documentation

§ SDL_GetPowerInfo()

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 98 of file SDL_power.c.

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

99 {
100  const int total = sizeof(implementations) / sizeof(implementations[0]);
101  int _seconds, _percent;
103  int i;
104 
105  /* Make these never NULL for platform-specific implementations. */
106  if (seconds == NULL) {
107  seconds = &_seconds;
108  }
109 
110  if (percent == NULL) {
111  percent = &_percent;
112  }
113 
114  for (i = 0; i < total; i++) {
115  if (implementations[i](&retval, seconds, percent)) {
116  return retval;
117  }
118  }
119 
120  /* nothing was definitive. */
121  *seconds = -1;
122  *percent = -1;
123  return SDL_POWERSTATE_UNKNOWN;
124 }
SDL_bool retval
static SDL_GetPowerInfo_Impl implementations[]
Definition: SDL_power.c:59
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:143
SDL_PowerState
The basic state for the system&#39;s power supply.
Definition: SDL_power.h:42

§ SDL_GetPowerInfo_Android()

SDL_bool SDL_GetPowerInfo_Android ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_Emscripten()

SDL_bool SDL_GetPowerInfo_Emscripten ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_Haiku()

SDL_bool SDL_GetPowerInfo_Haiku ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_Linux_proc_acpi()

SDL_bool SDL_GetPowerInfo_Linux_proc_acpi ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_Linux_proc_apm()

SDL_bool SDL_GetPowerInfo_Linux_proc_apm ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_Linux_sys_class_power_supply()

SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_MacOSX()

SDL_bool SDL_GetPowerInfo_MacOSX ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_PSP()

SDL_bool SDL_GetPowerInfo_PSP ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_UIKit()

SDL_bool SDL_GetPowerInfo_UIKit ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_Windows()

SDL_bool SDL_GetPowerInfo_Windows ( SDL_PowerState ,
int *  ,
int *   
)

§ SDL_GetPowerInfo_WinRT()

SDL_bool SDL_GetPowerInfo_WinRT ( SDL_PowerState ,
int *  ,
int *   
)

Variable Documentation

§ implementations

SDL_GetPowerInfo_Impl implementations[]
static

Definition at line 59 of file SDL_power.c.

Referenced by SDL_GetPowerInfo().