08d2c4c71cb97dd0ccc3a7219cb83a352f925274
[xscreensaver] / android / XScreenSaverView.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <zlib.h>
4 #include "screenhackI.h"
5 #include "xlockmoreI.h"
6
7 extern struct xscreensaver_function_table *xscreensaver_function_table;
8
9 extern const char *progname;
10 extern const char *progclass;
11 int mono_p = 0;
12
13 static int sproingies_count = 8;
14 static double superquadrics_speed = 5.0;
15 static int stonerview_delay = 20000;
16 static char *hilbert_mode;
17 static Bool stonerview_transparent = False;
18
19 // TODO: fill in what is not here
20 Bool get_boolean_resource(Display * dpy, char *name, char *class)
21 {
22     Bool b;
23
24     if (strcmp(progname, "hilbert") == 0) {
25
26         if (strcmp(name, "spin") == 0 && strcmp(class, "Spin") == 0) {
27             b = True;
28         } else if (strcmp(name, "wireframe") == 0
29                    && strcmp(class, "Boolean") == 0) {
30             b = False;
31         } else if (strcmp(name, "wander") == 0
32                    && strcmp(class, "Wander") == 0) {
33             b = False;
34         }
35     } else if (strcmp(progname, "stonerview") == 0) {
36         if (strcmp(name, "use3d") == 0 && strcmp(class, "Boolean") == 0) {
37             b = True;
38         } else if (strcmp(name, "transparent") == 0
39                    && strcmp(class, "Transparent") == 0) {
40             b = stonerview_transparent;
41         } else if (strcmp(name, "wireframe") == 0
42                    && strcmp(class, "Boolean") == 0) {
43             b = False;
44         } else if (strcmp(name, "doFPS") == 0
45                    && strcmp(class, "DoFPS") == 0) {
46             b = False;
47         }
48     } else if (strcmp(progname, "superquadrics") == 0) {
49         if (strcmp(name, "wireframe") == 0
50             && strcmp(class, "Boolean") == 0) {
51             b = False;
52         }
53     } else if (strcmp(progname, "sproingies") == 0) {
54         if (strcmp(name, "wireframe") == 0
55             && strcmp(class, "Boolean") == 0) {
56             b = False;
57         }
58     }
59
60     return b;
61 }
62
63 // TODO: fill in what is not here
64 char *get_string_resource(Display * dpy, char *name, char *class)
65 {
66     char *implement;
67
68     if (strcmp(progname, "hilbert") == 0) {
69         if (strcmp(name, "mode") == 0 && strcmp(class, "Mode") == 0) {
70             implement = malloc(8 * sizeof(char));
71             strcpy(implement, hilbert_mode);
72         } else if (strcmp(name, "ends") == 0 && strcmp(class, "Ends") == 0) {
73             implement = malloc(5 * sizeof(char));
74             strcpy(implement, "open");
75         } else {
76             implement = 0;
77         }
78
79     } else {
80         implement = 0;
81     }
82
83     return implement;
84 }
85
86
87 // TODO: fill in what is not here
88 int get_integer_resource(Display * dpy, char *name, char *class)
89 {
90
91     if (strcmp(progname, "sproingies") == 0) {
92         if (strcmp(name, "count") == 0 && strcmp(class, "Int") == 0) {
93             return sproingies_count;
94         }
95     } else if (strcmp(progname, "superquadrics") == 0) {
96
97         if (strcmp(name, "count") == 0 && strcmp(class, "Int") == 0) {
98             return 25;
99         } else if (strcmp(name, "cycles") == 0
100                    && strcmp(class, "Int") == 0) {
101             return 40;
102         } else if (strcmp(name, "delay") == 0
103                    && strcmp(class, "Usecs") == 0) {
104             return 40000;
105         }
106
107     } else if (strcmp(progname, "hilbert") == 0) {
108         if (strcmp(name, "delay") == 0 && strcmp(class, "Usecs") == 0) {
109             return 30000;
110         }
111         if (strcmp(name, "maxDepth") == 0
112             && strcmp(class, "MaxDepth") == 0) {
113             // too deep is too much for less powerful Android phones
114             return 3;
115             //return 5;
116         }
117     }
118
119 }
120
121
122 // TODO: fill in what is not here
123 double get_float_resource(Display * dpy, char *name, char *class)
124 {
125
126     if (strcmp(progname, "superquadrics") == 0) {
127         if (strcmp(name, "spinspeed") == 0
128             && strcmp(class, "Spinspeed") == 0) {
129             return superquadrics_speed;
130         }
131     } else if (strcmp(progname, "hilbert") == 0) {
132         if (strcmp(name, "speed") == 0 && strcmp(class, "Speed") == 0) {
133             return 1.0;
134         } else if (strcmp(name, "thickness") == 0
135                    && strcmp(class, "Thickness") == 0) {
136             return 0.25;
137         }
138     }
139 }
140
141
142 void setSproingiesCount(int c)
143 {
144     sproingies_count = c;
145 }
146
147 void setStonerviewTransparency(int c)
148 {
149     if (c == 1) {
150         stonerview_transparent = True;
151     } else {
152         stonerview_transparent = False;
153     }
154 }
155
156 void setHilbertMode(char *mode)
157 {
158     if (!hilbert_mode) {
159         hilbert_mode = malloc(8 * sizeof(char));
160     }
161     if (strcmp(mode, "3d") == 0) {
162         strcpy(hilbert_mode, "3d");
163     }
164     if (strcmp(mode, "2d") == 0) {
165         strcpy(hilbert_mode, "2d");
166     } else {
167         strcpy(hilbert_mode, "random");
168     }
169 }
170
171
172 void setSuperquadricsSpeed(double sq_speed)
173 {
174     superquadrics_speed = sq_speed;
175 }