/[pcsx2_0.9.7]/trunk/3rdparty/SDL-1.3.0-5387/test/testpower.c
ViewVC logotype

Contents of /trunk/3rdparty/SDL-1.3.0-5387/test/testpower.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 401 - (show annotations) (download)
Fri Feb 25 17:31:09 2011 UTC (9 years, 9 months ago) by william
File MIME type: text/plain
File size: 1404 byte(s)
Auto Commited Import of: pcsx2-0.9.7-DEBUG (upstream: v0.9.7.4358 local: v0.9.7.313-latest) in ./trunk
1 /* Simple test of power subsystem. */
2
3 #include <stdio.h>
4 #include "SDL.h"
5
6 static void
7 report_power(void)
8 {
9 int seconds, percent;
10 const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
11 char *statestr = NULL;
12
13 printf("SDL-reported power info...\n");
14 switch (state) {
15 case SDL_POWERSTATE_UNKNOWN:
16 statestr = "Unknown";
17 break;
18 case SDL_POWERSTATE_ON_BATTERY:
19 statestr = "On battery";
20 break;
21 case SDL_POWERSTATE_NO_BATTERY:
22 statestr = "No battery";
23 break;
24 case SDL_POWERSTATE_CHARGING:
25 statestr = "Charging";
26 break;
27 case SDL_POWERSTATE_CHARGED:
28 statestr = "Charged";
29 break;
30 default:
31 statestr = "!!API ERROR!!";
32 break;
33 }
34
35 printf("State: %s\n", statestr);
36
37 if (percent == -1) {
38 printf("Percent left: unknown\n");
39 } else {
40 printf("Percent left: %d%%\n", percent);
41 }
42
43 if (seconds == -1) {
44 printf("Time left: unknown\n");
45 } else {
46 printf("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
47 (int) (seconds % 60));
48 }
49 }
50
51
52 int
53 main(int argc, char *argv[])
54 {
55 if (SDL_Init(SDL_INIT_VIDEO) == -1) {
56 fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
57 return 1;
58 }
59
60 report_power();
61
62 SDL_Quit();
63 return 0;
64 }
65
66 /* end of testpower.c ... */

  ViewVC Help
Powered by ViewVC 1.1.22