annotate src/power/linux/SDL_syspower.c @ 3203:790cbbda6429

Power: First shot at Linux /proc/acpi/battery support. Untested, not even tried to compile yet.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 30 Jun 2009 03:50:30 +0000
parents 51750b7a966f
children f77f50add24f
rev   line source
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /*
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 Lesser General Public License for more details.
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 Sam Lantinga
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 slouken@libsdl.org
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 */
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22 #include "SDL_config.h"
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 #ifndef SDL_POWER_DISABLED
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 #ifdef SDL_POWER_LINUX
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27 #include <stdio.h>
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 #include <unistd.h>
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29
3174
c8b9c6d27476 Fixed some typos and added a couple of includes. All were need to get SDL_power to compile on Linux.
Bob Pendleton <bob@pendleton.com>
parents: 3170
diff changeset
30 #include <sys/types.h>
c8b9c6d27476 Fixed some typos and added a couple of includes. All were need to get SDL_power to compile on Linux.
Bob Pendleton <bob@pendleton.com>
parents: 3170
diff changeset
31 #include <sys/stat.h>
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
32 #include <dirent.h>
3174
c8b9c6d27476 Fixed some typos and added a couple of includes. All were need to get SDL_power to compile on Linux.
Bob Pendleton <bob@pendleton.com>
parents: 3170
diff changeset
33 #include <fcntl.h>
c8b9c6d27476 Fixed some typos and added a couple of includes. All were need to get SDL_power to compile on Linux.
Bob Pendleton <bob@pendleton.com>
parents: 3170
diff changeset
34
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 #include "SDL_power.h"
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 SDL_bool
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
38 SDL_GetPowerInfo_Linux_sys_power(SDL_PowerState * state,
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 int *seconds, int *percent)
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 {
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
41 return SDL_FALSE; /* !!! FIXME: write me. */
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
42 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
43
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
44
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
45 static const char *proc_acpi_path = "/proc/acpi/battery";
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
46
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
47 static int open_acpi_file(const char *node, const char *key)
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
48 {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
49 const size_t pathlen = strlen(proc_acpi_path)+strlen(node)+strlen(key)+3;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
50 char *path = (char *) alloca(pathlen);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
51 if (path == NULL) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
52 return -1; /* oh well. */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
53 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
54
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
55 snprintf(path, pathlen, "%s/%s/%s", proc_acpi_path, node, key);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
56 return open(path, O_RDONLY);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
57 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
58
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
59
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
60 static SDL_bool
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
61 load_acpi_file(const char *node, const char *key, char *buf, size_t buflen)
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
62 {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
63 ssize_t br = 0;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
64 const int fd = open_acpi_file(node, key);
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65 if (fd == -1) {
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
66 return SDL_FALSE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
67 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
68 br = read(fd, buf, buflen-1);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
69 close(fd);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
70 if (br < 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
71 return SDL_FALSE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
72 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
73 buf[br] = '\0'; // null-terminate the string.
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
74 return SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
75 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
76
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
77 static SDL_bool
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
78 make_acpi_key_val(char **_ptr, char **_key, char **_val)
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
79 {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
80 char *ptr = *_ptr;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
81
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
82 while (*ptr == ' ') {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
83 ptr++; /* skip whitespace. */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
84 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
85
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
86 if (*ptr == '\0') {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
87 return SDL_FALSE; /* EOF. */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
88 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
89
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
90 *_key = ptr;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
91
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
92 while ((*ptr != ':') && (*ptr != '\0')) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
93 ptr++;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
94 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
95
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
96 if (*ptr == '\0') {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
97 return SDL_FALSE; /* (unexpected) EOF. */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
98 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
99
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
100 *(ptr++) = '\0'; /* terminate the key. */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
101
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
102 while ((*ptr == ' ') && (*ptr != '\0')) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
103 ptr++; /* skip whitespace. */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
104 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
105
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
106 if (*ptr == '\0') {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
107 return SDL_FALSE; /* (unexpected) EOF. */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
108 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
109
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
110 *_val = ptr;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
111
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
112 while ((*ptr != '\n') && (*ptr != '\0')) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
113 ptr++;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
114 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
115
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
116 if (*ptr != '\0') {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
117 *(ptr++) = '\0'; /* terminate the value. */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118 }
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
119
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
120 *_ptr = ptr; /* store for next time. */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121 return SDL_TRUE;
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
122 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
123
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
124 static void
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
125 check_acpi(const char * fname, SDL_bool * have_ac, SDL_bool * have_battery,
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
126 SDL_bool * charging, int *seconds, int *percent)
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
127 {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
128 int fd = -1;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
129 char info[1024];
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
130 char state[1024];
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
131 ssize_t br = 0;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
132 char *ptr = NULL;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
133 char *key = NULL;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
134 char *val = NULL;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
135 SDL_bool charge = SDL_FALSE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
136 SDL_bool choose = SDL_FALSE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
137 SDL_bool is_ac = SDL_FALSE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
138 int maximum = -1;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
139 int remaining = -1;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
140 int secs = -1;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
141 int pct = -1;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
142
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
143 if (!load_acpi_file(fname, "state", state, sizeof (state))) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
144 return;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
145 } else if (!load_acpi_file(fname, "info", info, sizeof (info))) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
146 return;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
147 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
148
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
149 ptr = &state[0];
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
150 while (make_acpi_key_val(&ptr, &key, &val)) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
151 if (strcmp(key, "present") == 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
152 if (strcmp(val, "yes") == 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
153 *have_battery = SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
154 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
155 } else if (strcmp(key, "charging state") == 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
156 /* !!! FIXME: what exactly _does_ charging/discharging mean? */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
157 if (strcmp(val, "charging/discharging") == 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
158 *have_ac = is_ac = SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
159 charge = SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
160 } else if (strcmp(val, "charging") == 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
161 *have_ac = is_ac = SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
162 charge = SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
163 } else if (strcmp(val, "charged") == 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
164 /* !!! FIXME: maybe another battery is discharging,
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
165 !!! FIXME: instead of AC connection. */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
166 *have_ac = is_ac = SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
167 charge = SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
168 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
169 } else if (strcmp(key, "remaining capacity") == 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
170 char *endptr = NULL;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
171 const int cvt = (int) strtol(val, &endptr, 10);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
172 if (*endptr == ' ') {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
173 remaining = cvt;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
174 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
175 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
176 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
177
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
178 ptr = &info[0];
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
179 while (make_acpi_key_val(&ptr, &key, &val)) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
180 if (strcmp(key, "design capacity") == 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
181 char *endptr = NULL;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
182 const int cvt = (int) strtol(val, &endptr, 10);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
183 if (*endptr == ' ') {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
184 maximum = cvt;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
185 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
186 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
187 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
188
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
189 if ((maximum >= 0) && (remaining >= 0)) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
190 pct = (int) ((((float) remaining) / ((float) maximum)) * 100.0f);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
191 if (pct < 0) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
192 pct = 0;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
193 } else if (pct > 100) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
194 pct = 100;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
195 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
196 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
197
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
198 /* !!! FIXME: calculate (secs). */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
199
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
200 /*
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
201 * We pick the battery that claims to have the most minutes left.
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
202 * (failing a report of minutes, we'll take the highest percent.)
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
203 */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
204 if ((secs < 0) && (*seconds < 0)) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
205 if ((pct < 0) && (*percent < 0)) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
206 choose = SDL_TRUE; /* at least we know there's a battery. */
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
207 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
208 if (pct > *percent) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
209 choose = SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
210 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
211 } else if (secs > *seconds) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
212 choose = SDL_TRUE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
213 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
214
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
215 if (choose) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
216 *seconds = secs;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
217 *percent = pct;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
218 *charging = charge;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
219 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
220
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
221 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
222
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
223 SDL_bool
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
224 SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState * state,
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
225 int *seconds, int *percent)
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
226 {
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
227 struct dirent *dent = NULL;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
228 DIR *dirp = NULL;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
229 SDL_bool have_ac = SDL_FALSE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
230 SDL_bool have_battery = SDL_FALSE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
231 SDL_bool charging = SDL_FALSE;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
232
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
233 *seconds = -1;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
234 *percent = -1;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
235 *state = SDL_POWERSTATE_UNKNOWN;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
236
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
237 dirp = opendir(proc_acpi_path);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
238 if (dirp == NULL) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
239 return SDL_FALSE; /* can't use this interface. */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
240 }
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
241
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
242 while ((dent = readdir(dirp)) != NULL) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
243 const char *name = dent->d_name;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
244 check_acpi(name, &have_ac, &have_battery, &charging, seconds, percent);
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
245 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
246
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
247 if (!have_battery) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
248 *state = SDL_POWERSTATE_NO_BATTERY;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
249 } else if (charging) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
250 *state = SDL_POWERSTATE_CHARGING;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
251 } else if (have_ac) {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
252 *state = SDL_POWERSTATE_CHARGED;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
253 } else {
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
254 *state = SDL_POWERSTATE_ON_BATTERY;
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
255 }
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
256
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
257 return SDL_TRUE; /* definitive answer. */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
258 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
259
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
260
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
261 static SDL_bool
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262 next_string(char **_ptr, char **_str)
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263 {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264 char *ptr = *_ptr;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
265 char *str = *_str;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
266
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
267 while (*ptr == ' ') { /* skip any spaces... */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
268 ptr++;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
269 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
270
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
271 if (*ptr == '\0') {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
272 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
273 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
274
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
275 str = ptr;
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
276 while ((*ptr != ' ') && (*ptr != '\n') && (*ptr != '\0'))
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
277 ptr++;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
278
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279 if (*ptr != '\0')
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
280 *(ptr++) = '\0';
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282 *_str = str;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283 *_ptr = ptr;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
284 return SDL_TRUE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
285 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
286
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
287 static SDL_bool
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288 int_string(char *str, int *val)
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289 {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
290 char *endptr = NULL;
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
291 *val = (int) strtol(str + 2, &endptr, 16);
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
292 return ((*str != '\0') && (*endptr == '\0'));
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
293 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295 /* http://lxr.linux.no/linux+v2.6.29/drivers/char/apm-emulation.c */
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296 SDL_bool
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
297 SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state,
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
298 int *seconds, int *percent)
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299 {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
300 SDL_bool need_details = SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
301 int ac_status = 0;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
302 int battery_status = 0;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
303 int battery_flag = 0;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
304 int battery_percent = 0;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
305 int battery_time = 0;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
306 const int fd = open("/proc/apm", O_RDONLY);
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
307 char buf[128];
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308 char *ptr = &buf[0];
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
309 char *str = NULL;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310 ssize_t br;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
311
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
312 if (fd == -1) {
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
313 return SDL_FALSE; /* can't use this interface. */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
314 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
315
3203
790cbbda6429 Power: First shot at Linux /proc/acpi/battery support.
Ryan C. Gordon <icculus@icculus.org>
parents: 3186
diff changeset
316 br = read(fd, buf, sizeof (buf) - 1);
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
317 close(fd);
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
318
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
319 if (br < 0) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
320 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
321 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
322
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
323 buf[br] = '\0'; // null-terminate the string.
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
324 if (!next_string(&ptr, &str)) { /* driver version */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
325 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
326 }
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
327 if (!next_string(&ptr, &str)) { /* BIOS version */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
328 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
329 }
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
330 if (!next_string(&ptr, &str)) { /* APM flags */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
331 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
332 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
333
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
334 if (!next_string(&ptr, &str)) { /* AC line status */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
335 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
336 } else if (!int_string(str, &ac_status)) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
337 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
338 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
339
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
340 if (!next_string(&ptr, &str)) { /* battery status */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
341 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
342 } else if (!int_string(str, &battery_status)) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
343 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
344 }
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
345 if (!next_string(&ptr, &str)) { /* battery flag */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
346 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
347 } else if (!int_string(str, &battery_flag)) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
349 }
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
350 if (!next_string(&ptr, &str)) { /* remaining battery life percent */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
352 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
353 if (str[strlen(str) - 1] == '%') {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354 str[strlen(str) - 1] = '\0';
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
355 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
356 if (!int_string(str, &battery_percent)) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
360 if (!next_string(&ptr, &str)) { /* remaining battery life time */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
361 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
362 } else if (!int_string(str, &battery_time)) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
364 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
365
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
366 if (!next_string(&ptr, &str)) { /* remaining battery life time units */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367 return SDL_FALSE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368 } else if (strcmp(str, "min") == 0) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369 battery_time *= 60;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
370 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
372 if (battery_flag == 0xFF) { /* unknown state */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 *state = SDL_POWERSTATE_UNKNOWN;
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
374 } else if (battery_flag & (1 << 7)) { /* no battery */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375 *state = SDL_POWERSTATE_NO_BATTERY;
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
376 } else if (battery_flag & (1 << 3)) { /* charging */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
377 *state = SDL_POWERSTATE_CHARGING;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
378 need_details = SDL_TRUE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
379 } else if (ac_status == 1) {
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
380 *state = SDL_POWERSTATE_CHARGED; /* on AC, not charging. */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381 need_details = SDL_TRUE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
382 } else {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
383 *state = SDL_POWERSTATE_ON_BATTERY;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
384 need_details = SDL_TRUE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
386
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
387 *percent = -1;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
388 *seconds = -1;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
389 if (need_details) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 const int pct = battery_percent;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
391 const int secs = battery_time;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
392
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
393 if (pct >= 0) { /* -1 == unknown */
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
394 *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
395 }
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3174
diff changeset
396 if (secs >= 0) { /* -1 == unknown */
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
397 *seconds = secs;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
398 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
399 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
400
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401 return SDL_TRUE;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
403
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404 #endif /* SDL_POWER_LINUX */
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405 #endif /* SDL_POWER_DISABLED */
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
406
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
407 /* vi: set ts=4 sw=4 expandtab: */