diff options
Diffstat (limited to 'uisimulator/sdl/screenhack.c')
-rw-r--r-- | uisimulator/sdl/screenhack.c | 232 |
1 files changed, 0 insertions, 232 deletions
diff --git a/uisimulator/sdl/screenhack.c b/uisimulator/sdl/screenhack.c deleted file mode 100644 index ad138c282e..0000000000 --- a/uisimulator/sdl/screenhack.c +++ /dev/null | |||
@@ -1,232 +0,0 @@ | |||
1 | /* xscreensaver, Copyright (c) 1992, 1995, 1997, 1998 | ||
2 | * Jamie Zawinski <jwz@jwz.org> | ||
3 | * | ||
4 | * Permission to use, copy, modify, distribute, and sell this software and its | ||
5 | * documentation for any purpose is hereby granted without fee, provided that | ||
6 | * the above copyright notice appear in all copies and that both that | ||
7 | * copyright notice and this permission notice appear in supporting | ||
8 | * documentation. No representations are made about the suitability of this | ||
9 | * software for any purpose. It is provided "as is" without express or | ||
10 | * implied warranty. | ||
11 | * | ||
12 | * And remember: X Windows is to graphics hacking as roman numerals are to | ||
13 | * the square root of pi. | ||
14 | */ | ||
15 | |||
16 | /* This file contains simple code to open a window or draw on the root. | ||
17 | The idea being that, when writing a graphics hack, you can just link | ||
18 | with this .o to get all of the uninteresting junk out of the way. | ||
19 | |||
20 | - create a procedure `screenhack(dpy, window)' | ||
21 | |||
22 | - create a variable `char *progclass' which names this program's | ||
23 | resource class. | ||
24 | |||
25 | - create a variable `char defaults []' for the default resources, and | ||
26 | null-terminate it. | ||
27 | |||
28 | - create a variable `XrmOptionDescRec options[]' for the command-line, | ||
29 | and null-terminate it. | ||
30 | |||
31 | And that's it... | ||
32 | */ | ||
33 | |||
34 | #include <stdio.h> | ||
35 | #include <string.h> | ||
36 | #include <SDL.h> | ||
37 | #include "lcd-x11.h" | ||
38 | #include "screenhack.h" | ||
39 | #include "version.h" | ||
40 | |||
41 | #include "debug.h" | ||
42 | #include "config.h" | ||
43 | |||
44 | #ifndef isupper | ||
45 | # define isupper(c) ((c) >= 'A' && (c) <= 'Z') | ||
46 | #endif | ||
47 | #ifndef _tolower | ||
48 | # define _tolower(c) ((c) - 'A' + 'a') | ||
49 | #endif | ||
50 | |||
51 | #define KEYBOARD_GENERIC \ | ||
52 | "Keyboard Rockbox\n" \ | ||
53 | "-------- ------------\n" \ | ||
54 | "4, Left LEFT\n" \ | ||
55 | "6, Right RIGHT\n" | ||
56 | |||
57 | #if CONFIG_KEYPAD == PLAYER_PAD | ||
58 | #define KEYBOARD_SPECIFIC \ | ||
59 | "8, Up PLAY\n" \ | ||
60 | "2, Down STOP\n" \ | ||
61 | "+, Q ON\n" \ | ||
62 | "., INS MENU\n" | ||
63 | |||
64 | #elif CONFIG_KEYPAD == RECORDER_PAD | ||
65 | #define KEYBOARD_SPECIFIC \ | ||
66 | "8, Up UP\n" \ | ||
67 | "2, Down DOWN\n" \ | ||
68 | "5, Space PLAY\n" \ | ||
69 | "+, Q ON\n" \ | ||
70 | "Enter, A OFF\n" \ | ||
71 | "/, (F1) F1\n" \ | ||
72 | "*, (F2) F2\n" \ | ||
73 | "-, (F3) F3\n" | ||
74 | |||
75 | #elif CONFIG_KEYPAD == ONDIO_PAD | ||
76 | #define KEYBOARD_SPECIFIC \ | ||
77 | "8, Up UP\n" \ | ||
78 | "2, Down DOWN\n" \ | ||
79 | "., INS MENU\n" \ | ||
80 | "Enter, A OFF\n" | ||
81 | |||
82 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD | ||
83 | #define KEYBOARD_SPECIFIC \ | ||
84 | "8, Up UP\n" \ | ||
85 | "2, Down DOWN\n" \ | ||
86 | "5, Space SELECT\n" \ | ||
87 | "+, Q ON\n" \ | ||
88 | "Enter, A OFF\n" \ | ||
89 | "., INS MODE\n" \ | ||
90 | "/, (F1) RECORD\n" | ||
91 | |||
92 | #elif CONFIG_KEYPAD == IRIVER_H300_PAD | ||
93 | #define KEYBOARD_SPECIFIC \ | ||
94 | "8, Up UP\n" \ | ||
95 | "2, Down DOWN\n" \ | ||
96 | "4, Left LEFT\n" \ | ||
97 | "6, Right RIGHT\n" \ | ||
98 | "5, Space SELECT\n" \ | ||
99 | "+, Q ON\n" \ | ||
100 | "Enter, A OFF\n" \ | ||
101 | "., INS MODE\n" \ | ||
102 | "/, (F1) RECORD\n" | ||
103 | |||
104 | #elif CONFIG_KEYPAD == GMINI100_PAD | ||
105 | #define KEYBOARD_SPECIFIC \ | ||
106 | "8, Up UP\n" \ | ||
107 | "2, Down DOWN\n" \ | ||
108 | "5, Space PLAY\n" \ | ||
109 | "+, Q ON\n" \ | ||
110 | "Enter, A OFF\n" \ | ||
111 | "., INS MENU\n" | ||
112 | |||
113 | #elif (CONFIG_KEYPAD == IPOD_4G_PAD) | ||
114 | #define KEYBOARD_SPECIFIC \ | ||
115 | "[not written yet]" | ||
116 | |||
117 | #elif (CONFIG_KEYPAD == IAUDIO_X5_PAD) | ||
118 | #define KEYBOARD_SPECIFIC \ | ||
119 | "[not written yet]" | ||
120 | |||
121 | #endif | ||
122 | |||
123 | |||
124 | SDL_Surface *surface; | ||
125 | |||
126 | char having_new_lcd = true; | ||
127 | |||
128 | extern int display_zoom; | ||
129 | |||
130 | /* Dead-trivial event handling. | ||
131 | */ | ||
132 | int screenhack_handle_event(SDL_Event *event, bool *release) | ||
133 | { | ||
134 | int key = 0; | ||
135 | |||
136 | *release = false; | ||
137 | |||
138 | switch (event->type) { | ||
139 | case SDL_KEYDOWN: | ||
140 | { | ||
141 | key = event->key.keysym.sym; | ||
142 | *release = false; | ||
143 | } | ||
144 | break; | ||
145 | case SDL_KEYUP: | ||
146 | { | ||
147 | key = event->key.keysym.sym; | ||
148 | *release = true; | ||
149 | } | ||
150 | break; | ||
151 | case SDL_QUIT: | ||
152 | { | ||
153 | SDL_Quit(); | ||
154 | exit(0); | ||
155 | } | ||
156 | break; | ||
157 | default: | ||
158 | break; | ||
159 | } | ||
160 | |||
161 | return key; | ||
162 | } | ||
163 | |||
164 | int screenhack_handle_events(bool *release) | ||
165 | { | ||
166 | int key = 0; | ||
167 | SDL_Event event; | ||
168 | |||
169 | if (SDL_PollEvent(&event)) { | ||
170 | key = screenhack_handle_event(&event, release); | ||
171 | } | ||
172 | |||
173 | return key; | ||
174 | } | ||
175 | |||
176 | |||
177 | int main (int argc, char **argv) | ||
178 | { | ||
179 | int window_width; | ||
180 | int window_height; | ||
181 | |||
182 | if (argc > 1) | ||
183 | { | ||
184 | int x; | ||
185 | for (x=1; x<argc; x++) { | ||
186 | if (!strcmp("--old_lcd", argv[x])) { | ||
187 | having_new_lcd=false; | ||
188 | printf("Using old LCD layout.\n"); | ||
189 | } else if (!strcmp("--zoom", argv[x])) { | ||
190 | if (++x < argc) { | ||
191 | display_zoom=atoi(argv[x]); | ||
192 | printf("Window zoom is %d\n", display_zoom); | ||
193 | if (display_zoom < 1 || display_zoom > 5) { | ||
194 | printf("fatal: --zoom argument must be between 1 and 5\n"); | ||
195 | exit(0); | ||
196 | } | ||
197 | } else { | ||
198 | printf("fatal: --zoom requires an integer argument\n"); | ||
199 | exit(0); | ||
200 | } | ||
201 | } else { | ||
202 | printf("rockboxui\n"); | ||
203 | printf("Arguments:\n"); | ||
204 | printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n"); | ||
205 | printf(" --zoom [1-5]\t window zoom\n"); | ||
206 | printf(KEYBOARD_GENERIC KEYBOARD_SPECIFIC); | ||
207 | exit(0); | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
212 | window_width = (LCD_WIDTH + 2*MARGIN_X) * display_zoom; | ||
213 | window_height = (LCD_HEIGHT + 2*MARGIN_Y) * display_zoom; | ||
214 | #ifdef LCD_REMOTE_HEIGHT | ||
215 | window_height += (LCD_REMOTE_HEIGHT + 2*MARGIN_Y) * display_zoom; | ||
216 | #endif | ||
217 | |||
218 | if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)) { | ||
219 | fprintf(stderr, "fatal: %s", SDL_GetError()); | ||
220 | exit(-1); | ||
221 | } | ||
222 | |||
223 | atexit(SDL_Quit); | ||
224 | |||
225 | if ((surface = SDL_SetVideoMode(window_width, window_height, 24, 0)) == NULL) { | ||
226 | fprintf(stderr, "fatal: %s", SDL_GetError()); | ||
227 | exit(-1); | ||
228 | } | ||
229 | |||
230 | screenhack(); /* doesn't return */ | ||
231 | return 0; | ||
232 | } | ||