4 //#include <android/log.h>
5 #include "screenhackI.h"
6 #include "xlockmoreI.h"
9 # define isupper(c) ((c) >= 'A' && (c) <= 'Z')
12 # define _tolower(c) ((c) - 'A' + 'a')
15 extern struct xscreensaver_function_table *xscreensaver_function_table;
17 extern const char *progname;
18 extern const char *progclass;
21 static char *hilbert_mode;
22 static char *sproingies_count;
23 static char *sproingies_wireframe;
24 static char *bouncingcow_count;
25 static char *bouncingcow_speed;
26 static char *superquadrics_spinspeed;
27 static char *stonerview_delay;
28 static char *stonerview_transparent;
29 static char *unknownpleasures_wireframe;
30 static char *unknownpleasures_speed;
31 static char *hypertorus_displayMode;
32 static char *hypertorus_appearance;
33 static char *hypertorus_colors;
34 static char *hypertorus_projection3d;
35 static char *hypertorus_projection4d;
36 static char *hypertorus_speedwx;
37 static char *hypertorus_speedwy;
38 static char *hypertorus_speedwz;
39 static char *hypertorus_speedxy;
40 static char *hypertorus_speedxz;
41 static char *hypertorus_speedyz;
42 static char *glhanoi_light;
43 static char *glhanoi_fog;
44 static char *glhanoi_trails;
45 static char *glhanoi_poles;
46 static char *glhanoi_speed;
50 get_boolean_resource (Display *dpy, char *res_name, char *res_class)
53 char *s = get_string_resource (dpy, res_name, res_class);
56 for (tmp = buf; *s; s++)
57 *tmp++ = isupper (*s) ? _tolower (*s) : *s;
62 (buf[strlen(buf)-1] == ' ' ||
63 buf[strlen(buf)-1] == '\t'))
64 buf[strlen(buf)-1] = 0;
66 if (!strcmp (buf, "on") || !strcmp (buf, "true") || !strcmp (buf, "yes"))
68 if (!strcmp (buf,"off") || !strcmp (buf, "false") || !strcmp (buf,"no"))
70 fprintf (stderr, "%s: %s must be boolean, not %s.\n",
71 progname, res_name, buf);
76 get_integer_resource (Display *dpy, char *res_name, char *res_class)
79 char c, *s = get_string_resource (dpy, res_name, res_class);
83 while (*ss && *ss <= ' ') ss++; /* skip whitespace */
85 if (ss[0] == '0' && (ss[1] == 'x' || ss[1] == 'X')) /* 0x: parse as hex */
87 if (1 == sscanf (ss+2, "%x %c", (unsigned int *) &val, &c))
93 else /* else parse as dec */
95 if (1 == sscanf (ss, "%d %c", &val, &c))
102 fprintf (stderr, "%s: %s must be an integer, not %s.\n",
103 progname, res_name, s);
109 get_float_resource (Display *dpy, char *res_name, char *res_class)
112 char c, *s = get_string_resource (dpy, res_name, res_class);
114 if (1 == sscanf (s, " %lf %c", &val, &c))
119 fprintf (stderr, "%s: %s must be a float, not %s.\n",
120 progname, res_name, s);
126 // TODO: fill in what is not here
127 char *get_string_resource(Display * dpy, char *name, char *class)
130 //__android_log_print (ANDROID_LOG_INFO, "xscreensaver", "s %s %s %s", progname, name, class);
132 if (strcmp(progname, "hilbert") == 0) {
133 if (strcmp(name, "mode") == 0 && strcmp(class, "Mode") == 0) {
134 implement = malloc(8 * sizeof(char));
135 strcpy(implement, hilbert_mode);
136 } else if (strcmp(name, "ends") == 0 && strcmp(class, "Ends") == 0) {
137 implement = malloc(5 * sizeof(char));
138 strcpy(implement, "open");
139 } else if (strcmp(name, "speed") == 0 && strcmp(class, "Speed") == 0) {
141 } else if (strcmp(name, "thickness") == 0
142 && strcmp(class, "Thickness") == 0) {
144 } else if (strcmp(name, "delay") == 0 && strcmp(class, "Usecs") == 0) {
146 } else if (strcmp(name, "maxDepth") == 0
147 && strcmp(class, "MaxDepth") == 0) {
148 // too deep is too much for less powerful Android phones
151 } else if (strcmp(name, "spin") == 0 && strcmp(class, "Spin") == 0) {
153 } else if (strcmp(name, "wireframe") == 0
154 && strcmp(class, "Boolean") == 0) {
156 } else if (strcmp(name, "wander") == 0
157 && strcmp(class, "Wander") == 0) {
163 else if (strcmp(progname, "sproingies") == 0) {
164 if (strcmp(name, "count") == 0 && strcmp(class, "Int") == 0) {
165 return sproingies_count;
166 } else if (strcmp(name, "wireframe") == 0
167 && strcmp(class, "Boolean") == 0) {
168 return sproingies_wireframe;
173 else if (strcmp(progname, "superquadrics") == 0) {
174 if (strcmp(name, "spinspeed") == 0
175 && strcmp(class, "Spinspeed") == 0) {
176 return superquadrics_spinspeed;
177 } else if (strcmp(name, "count") == 0 && strcmp(class, "Int") == 0) {
179 } else if (strcmp(name, "cycles") == 0
180 && strcmp(class, "Int") == 0) {
182 } else if (strcmp(name, "delay") == 0
183 && strcmp(class, "Usecs") == 0) {
185 } else if (strcmp(name, "wireframe") == 0
186 && strcmp(class, "Boolean") == 0) {
192 else if (strcmp(progname, "stonerview") == 0) {
193 if (strcmp(name, "use3d") == 0 && strcmp(class, "Boolean") == 0) {
195 } else if (strcmp(name, "transparent") == 0
196 && strcmp(class, "Transparent") == 0) {
197 return stonerview_transparent;
198 } else if (strcmp(name, "wireframe") == 0
199 && strcmp(class, "Boolean") == 0) {
201 } else if (strcmp(name, "doFPS") == 0
202 && strcmp(class, "DoFPS") == 0) {
208 else if (strcmp(progname, "bouncingcow") == 0) {
209 if (strcmp(name, "count") == 0
210 && strcmp(class, "Int") == 0) {
211 return bouncingcow_count;
212 } else if (strcmp(name, "speed") == 0
213 && strcmp(class, "Speed") == 0) {
214 return bouncingcow_speed;
219 else if (strcmp(progname, "unknownpleasures") == 0) {
221 if (strcmp(name, "wireframe") == 0) {
222 return unknownpleasures_wireframe;
223 } else if (strcmp(name, "speed") == 0) {
224 return unknownpleasures_speed;
225 } else if (strcmp(name, "count") == 0) {
227 } else if (strcmp(name, "resolution") == 0) {
230 } else if (strcmp(name, "ortho") == 0) {
238 else if (strcmp(progname, "hypertorus") == 0) {
239 if (strcmp(name, "displayMode") == 0) {
240 return hypertorus_displayMode;
241 } else if (strcmp(name, "appearance") == 0) {
242 return hypertorus_appearance;
243 } else if (strcmp(name, "colors") == 0) {
244 return hypertorus_colors;
245 } else if (strcmp(name, "projection3d") == 0) {
246 return hypertorus_projection3d;
247 } else if (strcmp(name, "projection4d") == 0) {
248 return hypertorus_projection4d;
249 } else if (strcmp(name, "speedwx") == 0) {
250 return hypertorus_speedwz;
251 } else if (strcmp(name, "speedwy") == 0) {
252 return hypertorus_speedwy;
253 } else if (strcmp(name, "speedwz") == 0) {
254 return hypertorus_speedwz;
255 } else if (strcmp(name, "speedxy") == 0) {
256 return hypertorus_speedxy;
257 } else if (strcmp(name, "speedxz") == 0) {
258 return hypertorus_speedxz;
259 } else if (strcmp(name, "speedyz") == 0) {
260 return hypertorus_speedyz;
265 else if (strcmp(progname, "glhanoi") == 0) {
266 if (strcmp(name, "light") == 0) {
267 return glhanoi_light;
268 } else if (strcmp(name, "fog") == 0) {
270 } else if (strcmp(name, "trails") == 0) {
271 return glhanoi_trails;
272 } else if (strcmp(name, "poles") == 0) {
273 return glhanoi_poles;
274 } else if (strcmp(name, "speed") == 0) {
275 return glhanoi_speed;
288 void setSuperquadricsSettings(char *hck, char *khck)
290 if (strcmp(khck, "superquadrics_spinspeed") == 0) {
291 superquadrics_spinspeed = malloc(4 * sizeof(char));
292 strcpy(superquadrics_spinspeed, hck);
296 void setHilbertSettings(char *hck, char *khck)
298 if (strcmp(khck, "hilbert_mode") == 0) {
300 hilbert_mode = malloc(8 * sizeof(char));
302 if (strcmp(hck, "3D") == 0) {
303 strcpy(hilbert_mode, "3D");
305 else if (strcmp(hck, "2D") == 0) {
306 strcpy(hilbert_mode, "2D");
311 void setSproingiesSettings(char *hck, char *khck)
313 if (strcmp(khck, "sproingies_count") == 0) {
314 sproingies_count = malloc(3 * sizeof(char));
315 strcpy(sproingies_count, hck);
317 else if (strcmp(khck, "sproingies_wireframe") == 0) {
318 sproingies_wireframe = malloc(6 * sizeof(char));
319 strcpy(sproingies_wireframe, hck);
323 void setStonerviewSettings(char *hck, char *khck)
325 if (strcmp(khck, "stonerview_transparent") == 0) {
326 stonerview_transparent = malloc(6 * sizeof(char));
327 strcpy(stonerview_transparent, hck);
331 void setBouncingcowSettings(char *hck, char *khck)
333 if (strcmp(khck, "bouncingcow_count") == 0) {
334 bouncingcow_count = malloc(3 * sizeof(char));
335 strcpy(bouncingcow_count, hck);
337 else if (strcmp(khck, "bouncingcow_speed") == 0) {
338 bouncingcow_speed = malloc(4 * sizeof(char));
339 strcpy(bouncingcow_speed, hck);
343 void setUnknownpleasuresSettings(char *hck, char *khck)
345 if (strcmp(khck, "unknownpleasures_speed") == 0) {
346 unknownpleasures_speed = malloc(3 * sizeof(char));
347 strcpy(unknownpleasures_speed, hck);
349 else if (strcmp(khck, "unknownpleasures_wireframe") == 0) {
350 unknownpleasures_wireframe = malloc(6 * sizeof(char));
351 strcpy(unknownpleasures_wireframe, hck);
355 void setHypertorusSettings(char *hck, char *khck)
357 if (strcmp(khck, "hypertorus_displayMode") == 0) {
358 hypertorus_displayMode = malloc(13 * sizeof(char));
359 strcpy(hypertorus_displayMode, hck);
361 else if (strcmp(khck, "hypertorus_appearance") == 0) {
362 hypertorus_appearance = malloc(12 * sizeof(char));
363 strcpy(hypertorus_appearance, hck);
365 else if (strcmp(khck, "hypertorus_colors") == 0) {
366 hypertorus_colors = malloc(5 * sizeof(char));
367 strcpy(hypertorus_colors, hck);
369 else if (strcmp(khck, "hypertorus_projection3d") == 0) {
370 hypertorus_projection3d = malloc(17 * sizeof(char));
371 strcpy(hypertorus_projection3d, hck);
373 else if (strcmp(khck, "hypertorus_projection4d") == 0) {
374 hypertorus_projection4d = malloc(17 * sizeof(char));
375 strcpy(hypertorus_projection4d, hck);
377 else if (strcmp(khck, "hypertorus_speedwx") == 0) {
378 hypertorus_speedwx = malloc(5 * sizeof(char));
379 strcpy(hypertorus_speedwx, hck);
381 else if (strcmp(khck, "hypertorus_speedwy") == 0) {
382 hypertorus_speedwy = malloc(5 * sizeof(char));
383 strcpy(hypertorus_speedwy, hck);
385 else if (strcmp(khck, "hypertorus_speedwz") == 0) {
386 hypertorus_speedwz = malloc(5 * sizeof(char));
387 strcpy(hypertorus_speedwz, hck);
389 else if (strcmp(khck, "hypertorus_speedxy") == 0) {
390 hypertorus_speedxy = malloc(5 * sizeof(char));
391 strcpy(hypertorus_speedxy, hck);
393 else if (strcmp(khck, "hypertorus_speedxz") == 0) {
394 hypertorus_speedxz = malloc(5 * sizeof(char));
395 strcpy(hypertorus_speedxz, hck);
397 else if (strcmp(khck, "hypertorus_speedyz") == 0) {
398 hypertorus_speedyz = malloc(5 * sizeof(char));
399 strcpy(hypertorus_speedyz, hck);
403 void setGlhanoiSettings(char *hck, char *khck) {
405 if (strcmp(khck, "glhanoi_light") == 0) {
406 glhanoi_light = malloc(6 * sizeof(char));
407 strcpy(glhanoi_light , hck);
409 else if (strcmp(khck, "glhanoi_fog") == 0) {
410 glhanoi_fog = malloc(6 * sizeof(char));
411 strcpy(glhanoi_fog , hck);
413 else if (strcmp(khck, "glhanoi_trails") == 0) {
414 glhanoi_trails = malloc(3 * sizeof(char));
415 strcpy(glhanoi_trails , hck);
417 else if (strcmp(khck, "glhanoi_poles") == 0) {
418 glhanoi_poles = malloc(3 * sizeof(char));
419 strcpy(glhanoi_poles , hck);
421 else if (strcmp(khck, "glhanoi_speed") == 0) {
422 glhanoi_speed = malloc(3 * sizeof(char));
423 strcpy(glhanoi_speed , hck);