diff options
Diffstat (limited to 'uisimulator')
-rw-r--r-- | uisimulator/FILES | 3 | ||||
-rw-r--r-- | uisimulator/sdl/Makefile | 60 | ||||
-rw-r--r-- | uisimulator/sdl/README | 6 | ||||
-rw-r--r-- | uisimulator/sdl/SOURCES | 7 | ||||
-rw-r--r-- | uisimulator/sdl/button-x11.c | 307 | ||||
-rw-r--r-- | uisimulator/sdl/kernel.c | 160 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-x11.c | 210 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-x11.h | 26 | ||||
-rw-r--r-- | uisimulator/sdl/screenhack.c | 228 | ||||
-rw-r--r-- | uisimulator/sdl/screenhack.h | 33 | ||||
-rw-r--r-- | uisimulator/sdl/sound.c | 119 | ||||
-rw-r--r-- | uisimulator/sdl/sound.h | 22 | ||||
-rw-r--r-- | uisimulator/sdl/sprintf.h | 12 | ||||
-rw-r--r-- | uisimulator/sdl/thread.c | 148 | ||||
-rw-r--r-- | uisimulator/sdl/timefuncs.h | 7 | ||||
-rw-r--r-- | uisimulator/sdl/uisdl.c | 226 | ||||
-rw-r--r-- | uisimulator/sdl/uisw32.c | 344 | ||||
-rw-r--r-- | uisimulator/sdl/uisw32.h | 156 | ||||
-rw-r--r-- | uisimulator/sdl/version.h | 1 |
19 files changed, 2075 insertions, 0 deletions
diff --git a/uisimulator/FILES b/uisimulator/FILES index 85b1dbe850..95318c010a 100644 --- a/uisimulator/FILES +++ b/uisimulator/FILES | |||
@@ -18,3 +18,6 @@ x11/archos/rockbox112.bmp | |||
18 | common/SOURCES | 18 | common/SOURCES |
19 | win32/SOURCES | 19 | win32/SOURCES |
20 | x11/SOURCES | 20 | x11/SOURCES |
21 | sdl/*.[ch] | ||
22 | sdl/Makefile | ||
23 | sdl/SOURCES | ||
diff --git a/uisimulator/sdl/Makefile b/uisimulator/sdl/Makefile new file mode 100644 index 0000000000..989ac65223 --- /dev/null +++ b/uisimulator/sdl/Makefile | |||
@@ -0,0 +1,60 @@ | |||
1 | ############################################################################ | ||
2 | # __________ __ ___. | ||
3 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | # \/ \/ \/ \/ \/ | ||
8 | # $Id$ | ||
9 | # | ||
10 | # Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
11 | # | ||
12 | # All files in this archive are subject to the GNU General Public License. | ||
13 | # See the file COPYING in the source tree root for full license agreement. | ||
14 | # | ||
15 | # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | # KIND, either express or implied. | ||
17 | # | ||
18 | ############################################################################ | ||
19 | |||
20 | SIMCOMMON = ../common | ||
21 | |||
22 | DEPFILE = $(OBJDIR)/dep-sim | ||
23 | |||
24 | RM = rm -f | ||
25 | DEBUG = -g | ||
26 | |||
27 | # Use this for simulator-only files | ||
28 | INCLUDES = -I. -I$(SIMCOMMON) -I$(OBJDIR) -I$(FIRMDIR)/export -I$(APPSDIR) \ | ||
29 | -I$(BUILDDIR) | ||
30 | |||
31 | # This sets up 'SRC' based on the files mentioned in SOURCES | ||
32 | include $(TOOLSDIR)/makesrc.inc | ||
33 | |||
34 | OBJS := $(SRC:%.c=$(OBJDIR)/%.o) | ||
35 | |||
36 | DEFINES := -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \ | ||
37 | $(TARGET) -DAPPSVERSION=\"$(VERSION)\" -DMEM=${MEMORYSIZE} $(EXTRA_DEFINES) | ||
38 | |||
39 | SOURCES = $(SRC) | ||
40 | |||
41 | DIRS = . | ||
42 | |||
43 | CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS) | ||
44 | |||
45 | OUTFILE = $(BUILDDIR)/libsim.a | ||
46 | |||
47 | all: $(OUTFILE) | ||
48 | |||
49 | include $(TOOLSDIR)/make.inc | ||
50 | |||
51 | clean: | ||
52 | @echo "cleaning sim" | ||
53 | @$(RM) $(OBJS) *~ core $(OUTFILE) $(DEPFILE) | ||
54 | @$(MAKE) -C $(SIMCOMMON) clean | ||
55 | |||
56 | $(OUTFILE): $(OBJS) | ||
57 | @echo "AR $@" | ||
58 | @$(AR) ruv $@ $(OBJS) >/dev/null 2>&1 | ||
59 | |||
60 | -include $(DEPFILE) | ||
diff --git a/uisimulator/sdl/README b/uisimulator/sdl/README new file mode 100644 index 0000000000..0a293f6ad2 --- /dev/null +++ b/uisimulator/sdl/README | |||
@@ -0,0 +1,6 @@ | |||
1 | To build: | ||
2 | |||
3 | $ ../tools/configure | ||
4 | [answer questions] | ||
5 | $ make | ||
6 | $ ./rockboxui | ||
diff --git a/uisimulator/sdl/SOURCES b/uisimulator/sdl/SOURCES new file mode 100644 index 0000000000..32d70b50bf --- /dev/null +++ b/uisimulator/sdl/SOURCES | |||
@@ -0,0 +1,7 @@ | |||
1 | button-x11.c | ||
2 | kernel.c | ||
3 | lcd-x11.c | ||
4 | screenhack.c | ||
5 | thread.c | ||
6 | uisdl.c | ||
7 | sound.c | ||
diff --git a/uisimulator/sdl/button-x11.c b/uisimulator/sdl/button-x11.c new file mode 100644 index 0000000000..5fda7cf45a --- /dev/null +++ b/uisimulator/sdl/button-x11.c | |||
@@ -0,0 +1,307 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Björn Stenberg | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include <stdlib.h> | ||
20 | #include "config.h" | ||
21 | #include "button.h" | ||
22 | #include "kernel.h" | ||
23 | #include "debug.h" | ||
24 | #include "backlight.h" | ||
25 | #include "misc.h" | ||
26 | #include <SDL.h> | ||
27 | |||
28 | extern int screenhack_handle_events(bool *release); | ||
29 | |||
30 | struct event_queue button_queue; | ||
31 | |||
32 | static int button_state = 0; /* keeps track of pressed keys */ | ||
33 | static long lastbtn; /* Last valid button status */ | ||
34 | |||
35 | /* how often we check to see if a button is pressed */ | ||
36 | #define POLL_FREQUENCY HZ/25 | ||
37 | |||
38 | /* how long until repeat kicks in */ | ||
39 | #define REPEAT_START 8 | ||
40 | |||
41 | /* the speed repeat starts at */ | ||
42 | #define REPEAT_INTERVAL_START 4 | ||
43 | |||
44 | /* speed repeat finishes at */ | ||
45 | #define REPEAT_INTERVAL_FINISH 2 | ||
46 | |||
47 | /* mostly copied from real button.c */ | ||
48 | void button_read (void); | ||
49 | |||
50 | static void button_tick(void) | ||
51 | { | ||
52 | static int tick = 0; | ||
53 | static int count = 0; | ||
54 | static int repeat_speed = REPEAT_INTERVAL_START; | ||
55 | static int repeat_count = 0; | ||
56 | static bool repeat = false; | ||
57 | int diff; | ||
58 | int btn; | ||
59 | |||
60 | /* only poll every X ticks */ | ||
61 | if ( ++tick >= POLL_FREQUENCY ) | ||
62 | { | ||
63 | bool post = false; | ||
64 | button_read(); | ||
65 | btn = button_state; | ||
66 | |||
67 | /* Find out if a key has been released */ | ||
68 | diff = btn ^ lastbtn; | ||
69 | if(diff && (btn & diff) == 0) | ||
70 | { | ||
71 | queue_post(&button_queue, BUTTON_REL | diff, NULL); | ||
72 | } | ||
73 | else | ||
74 | { | ||
75 | if ( btn ) | ||
76 | { | ||
77 | /* normal keypress */ | ||
78 | if ( btn != lastbtn ) | ||
79 | { | ||
80 | post = true; | ||
81 | repeat = false; | ||
82 | repeat_speed = REPEAT_INTERVAL_START; | ||
83 | |||
84 | } | ||
85 | else /* repeat? */ | ||
86 | { | ||
87 | if ( repeat ) | ||
88 | { | ||
89 | count--; | ||
90 | if (count == 0) { | ||
91 | post = true; | ||
92 | /* yes we have repeat */ | ||
93 | repeat_speed--; | ||
94 | if (repeat_speed < REPEAT_INTERVAL_FINISH) | ||
95 | repeat_speed = REPEAT_INTERVAL_FINISH; | ||
96 | count = repeat_speed; | ||
97 | |||
98 | repeat_count++; | ||
99 | |||
100 | } | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | if (count++ > REPEAT_START) | ||
105 | { | ||
106 | post = true; | ||
107 | repeat = true; | ||
108 | repeat_count = 0; | ||
109 | /* initial repeat */ | ||
110 | count = REPEAT_INTERVAL_START; | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | if ( post ) | ||
115 | { | ||
116 | if (repeat) | ||
117 | queue_post(&button_queue, BUTTON_REPEAT | btn, NULL); | ||
118 | else | ||
119 | queue_post(&button_queue, btn, NULL); | ||
120 | #ifdef HAVE_REMOTE_LCD | ||
121 | if(btn & BUTTON_REMOTE) | ||
122 | remote_backlight_on(); | ||
123 | else | ||
124 | #endif | ||
125 | backlight_on(); | ||
126 | |||
127 | } | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | repeat = false; | ||
132 | count = 0; | ||
133 | } | ||
134 | } | ||
135 | lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT); | ||
136 | tick = 0; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | /* | ||
141 | * Read SDL keys and translate to rockbox buttons | ||
142 | */ | ||
143 | |||
144 | void button_read (void) | ||
145 | { | ||
146 | int k; | ||
147 | bool release = false; /* is this a release event */ | ||
148 | int ev = screenhack_handle_events(&release); | ||
149 | |||
150 | switch (ev) | ||
151 | { | ||
152 | case SDLK_KP4: | ||
153 | case SDLK_LEFT: | ||
154 | case SDLK_4: | ||
155 | k = BUTTON_LEFT; | ||
156 | break; | ||
157 | |||
158 | case SDLK_KP6: | ||
159 | case SDLK_RIGHT: | ||
160 | case SDLK_6: | ||
161 | k = BUTTON_RIGHT; | ||
162 | break; | ||
163 | |||
164 | case SDLK_KP8: | ||
165 | case SDLK_UP: | ||
166 | case SDLK_8: | ||
167 | #ifdef BUTTON_UP | ||
168 | k = BUTTON_UP; | ||
169 | #elif defined BUTTON_PLAY | ||
170 | k = BUTTON_PLAY; | ||
171 | #endif | ||
172 | break; | ||
173 | |||
174 | case SDLK_KP2: | ||
175 | case SDLK_DOWN: | ||
176 | case SDLK_2: | ||
177 | #ifdef BUTTON_DOWN | ||
178 | k = BUTTON_DOWN; | ||
179 | #elif defined BUTTON_STOP | ||
180 | k = BUTTON_STOP; | ||
181 | #endif | ||
182 | break; | ||
183 | |||
184 | #ifdef BUTTON_ON | ||
185 | case SDLK_KP_PLUS: | ||
186 | case SDLK_q: | ||
187 | k = BUTTON_ON; | ||
188 | break; | ||
189 | #endif | ||
190 | |||
191 | #ifdef BUTTON_OFF | ||
192 | case SDLK_KP_ENTER: | ||
193 | case SDLK_a: | ||
194 | k = BUTTON_OFF; | ||
195 | break; | ||
196 | #endif | ||
197 | |||
198 | #ifdef BUTTON_F1 | ||
199 | case SDLK_KP_DIVIDE: | ||
200 | case SDLK_F1: | ||
201 | k = BUTTON_F1; | ||
202 | break; | ||
203 | |||
204 | case SDLK_KP_MULTIPLY: | ||
205 | case SDLK_F2: | ||
206 | k = BUTTON_F2; | ||
207 | break; | ||
208 | |||
209 | case SDLK_KP_MINUS: | ||
210 | case SDLK_F3: | ||
211 | k = BUTTON_F3; | ||
212 | break; | ||
213 | #elif defined(BUTTON_REC) | ||
214 | case SDLK_KP_DIVIDE: | ||
215 | case SDLK_F1: | ||
216 | k = BUTTON_REC; | ||
217 | break; | ||
218 | #endif | ||
219 | |||
220 | case SDLK_KP5: | ||
221 | case SDLK_5: | ||
222 | case SDLK_SPACE: | ||
223 | #ifdef BUTTON_PLAY | ||
224 | k = BUTTON_PLAY; | ||
225 | #elif defined(BUTTON_SELECT) | ||
226 | k = BUTTON_SELECT; | ||
227 | #endif | ||
228 | break; | ||
229 | |||
230 | #ifdef HAVE_LCD_BITMAP | ||
231 | case SDLK_7: | ||
232 | if(!release) | ||
233 | screen_dump(); | ||
234 | break; | ||
235 | #endif | ||
236 | |||
237 | case SDLK_KP_PERIOD: | ||
238 | case SDLK_INSERT: | ||
239 | #ifdef BUTTON_MENU | ||
240 | k = BUTTON_MENU; | ||
241 | #elif defined(BUTTON_MODE) | ||
242 | k = BUTTON_MODE; | ||
243 | #endif | ||
244 | break; | ||
245 | |||
246 | default: | ||
247 | k = 0; | ||
248 | if(ev) | ||
249 | DEBUGF("received ev %d\n", ev); | ||
250 | break; | ||
251 | } | ||
252 | |||
253 | if (release) | ||
254 | button_state &= ~k; | ||
255 | else | ||
256 | button_state |= k; | ||
257 | } | ||
258 | |||
259 | /* Again copied from real button.c... */ | ||
260 | |||
261 | long button_get(bool block) | ||
262 | { | ||
263 | struct event ev; | ||
264 | |||
265 | if ( block || !queue_empty(&button_queue) ) | ||
266 | { | ||
267 | queue_wait(&button_queue, &ev); | ||
268 | return ev.id; | ||
269 | } | ||
270 | return BUTTON_NONE; | ||
271 | } | ||
272 | |||
273 | long button_get_w_tmo(int ticks) | ||
274 | { | ||
275 | struct event ev; | ||
276 | queue_wait_w_tmo(&button_queue, &ev, ticks); | ||
277 | return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE; | ||
278 | } | ||
279 | |||
280 | void button_init(void) | ||
281 | { | ||
282 | tick_add_task(button_tick); | ||
283 | } | ||
284 | |||
285 | int button_status(void) | ||
286 | { | ||
287 | return lastbtn; | ||
288 | } | ||
289 | |||
290 | void button_clear_queue(void) | ||
291 | { | ||
292 | queue_clear(&button_queue); | ||
293 | } | ||
294 | |||
295 | #ifdef HAS_BUTTON_HOLD | ||
296 | bool button_hold(void) { | ||
297 | /* temp fix for hold button on irivers */ | ||
298 | return false; | ||
299 | } | ||
300 | #endif | ||
301 | |||
302 | #ifdef HAS_REMOTE_BUTTON_HOLD | ||
303 | bool remote_button_hold(void) { | ||
304 | /* temp fix for hold button on irivers */ | ||
305 | return false; | ||
306 | } | ||
307 | #endif | ||
diff --git a/uisimulator/sdl/kernel.c b/uisimulator/sdl/kernel.c new file mode 100644 index 0000000000..25f2df220c --- /dev/null +++ b/uisimulator/sdl/kernel.c | |||
@@ -0,0 +1,160 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Jens Arnold | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include <stddef.h> | ||
21 | #include "kernel.h" | ||
22 | #include "thread.h" | ||
23 | #include "debug.h" | ||
24 | |||
25 | static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); | ||
26 | |||
27 | int set_irq_level (int level) | ||
28 | { | ||
29 | static int _lv = 0; | ||
30 | return (_lv = level); | ||
31 | } | ||
32 | |||
33 | void queue_init(struct event_queue *q) | ||
34 | { | ||
35 | q->read = 0; | ||
36 | q->write = 0; | ||
37 | } | ||
38 | |||
39 | void queue_wait(struct event_queue *q, struct event *ev) | ||
40 | { | ||
41 | while(q->read == q->write) | ||
42 | { | ||
43 | switch_thread(); | ||
44 | } | ||
45 | |||
46 | *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK]; | ||
47 | } | ||
48 | |||
49 | void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks) | ||
50 | { | ||
51 | unsigned int timeout = current_tick + ticks; | ||
52 | |||
53 | while(q->read == q->write && TIME_BEFORE( current_tick, timeout )) | ||
54 | { | ||
55 | sleep(1); | ||
56 | } | ||
57 | |||
58 | if(q->read != q->write) | ||
59 | { | ||
60 | *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK]; | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | ev->id = SYS_TIMEOUT; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | void queue_post(struct event_queue *q, long id, void *data) | ||
69 | { | ||
70 | int wr; | ||
71 | int oldlevel; | ||
72 | |||
73 | oldlevel = set_irq_level(15<<4); | ||
74 | wr = (q->write++) & QUEUE_LENGTH_MASK; | ||
75 | |||
76 | q->events[wr].id = id; | ||
77 | q->events[wr].data = data; | ||
78 | set_irq_level(oldlevel); | ||
79 | } | ||
80 | |||
81 | bool queue_empty(const struct event_queue* q) | ||
82 | { | ||
83 | return ( q->read == q->write ); | ||
84 | } | ||
85 | |||
86 | void queue_clear(struct event_queue* q) | ||
87 | { | ||
88 | /* fixme: This is potentially unsafe in case we do interrupt-like processing */ | ||
89 | q->read = 0; | ||
90 | q->write = 0; | ||
91 | } | ||
92 | |||
93 | void switch_thread (void) | ||
94 | { | ||
95 | yield (); | ||
96 | } | ||
97 | |||
98 | void sim_tick_tasks(void) | ||
99 | { | ||
100 | int i; | ||
101 | |||
102 | /* Run through the list of tick tasks */ | ||
103 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
104 | { | ||
105 | if(tick_funcs[i]) | ||
106 | { | ||
107 | tick_funcs[i](); | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | int tick_add_task(void (*f)(void)) | ||
113 | { | ||
114 | int i; | ||
115 | |||
116 | /* Add a task if there is room */ | ||
117 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
118 | { | ||
119 | if(tick_funcs[i] == NULL) | ||
120 | { | ||
121 | tick_funcs[i] = f; | ||
122 | return 0; | ||
123 | } | ||
124 | } | ||
125 | DEBUGF("Error! tick_add_task(): out of tasks"); | ||
126 | return -1; | ||
127 | } | ||
128 | |||
129 | int tick_remove_task(void (*f)(void)) | ||
130 | { | ||
131 | int i; | ||
132 | |||
133 | /* Remove a task if it is there */ | ||
134 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
135 | { | ||
136 | if(tick_funcs[i] == f) | ||
137 | { | ||
138 | tick_funcs[i] = NULL; | ||
139 | return 0; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | return -1; | ||
144 | } | ||
145 | |||
146 | void mutex_init(struct mutex *m) | ||
147 | { | ||
148 | (void)m; | ||
149 | } | ||
150 | |||
151 | void mutex_lock(struct mutex *m) | ||
152 | { | ||
153 | (void)m; | ||
154 | } | ||
155 | |||
156 | void mutex_unlock(struct mutex *m) | ||
157 | { | ||
158 | (void)m; | ||
159 | } | ||
160 | |||
diff --git a/uisimulator/sdl/lcd-x11.c b/uisimulator/sdl/lcd-x11.c new file mode 100644 index 0000000000..3ab5bc0e16 --- /dev/null +++ b/uisimulator/sdl/lcd-x11.c | |||
@@ -0,0 +1,210 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include <stdio.h> | ||
21 | #include <string.h> | ||
22 | #include <stdarg.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <ctype.h> | ||
25 | #include <sys/types.h> | ||
26 | #include <sys/stat.h> | ||
27 | #include <fcntl.h> | ||
28 | |||
29 | #include <errno.h> | ||
30 | #include <ctype.h> | ||
31 | #include <time.h> | ||
32 | |||
33 | #include "screenhack.h" | ||
34 | #include "config.h" | ||
35 | |||
36 | /* | ||
37 | * Specific implementations for X11, using the generic LCD API and data. | ||
38 | */ | ||
39 | |||
40 | #include "lcd-x11.h" | ||
41 | #include "lcd-playersim.h" | ||
42 | |||
43 | #include <SDL.h> | ||
44 | |||
45 | extern SDL_Surface *surface; | ||
46 | |||
47 | extern void screen_resized(int width, int height); | ||
48 | extern bool lcd_display_redraw; | ||
49 | |||
50 | #ifdef HAVE_LCD_BITMAP | ||
51 | #if LCD_DEPTH==16 | ||
52 | fb_data lcd_framebuffer_copy[LCD_HEIGHT][LCD_WIDTH*2]; | ||
53 | #else | ||
54 | fb_data lcd_framebuffer_copy[LCD_HEIGHT][LCD_WIDTH]; | ||
55 | #endif | ||
56 | |||
57 | void lcd_update (void) | ||
58 | { | ||
59 | /* update a full screen rect */ | ||
60 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
61 | } | ||
62 | |||
63 | void lcd_update_rect(int x_start, int y_start, | ||
64 | int width, int height) | ||
65 | { | ||
66 | int x; | ||
67 | int y; | ||
68 | int p=0; | ||
69 | int xmax; | ||
70 | int ymax; | ||
71 | int colors[LCD_WIDTH * LCD_HEIGHT]; | ||
72 | struct coordinate points[LCD_WIDTH * LCD_HEIGHT]; | ||
73 | |||
74 | #if 0 | ||
75 | fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n", | ||
76 | counter++, x_start, y_start, width, height); | ||
77 | #endif | ||
78 | ymax = y_start + height; | ||
79 | xmax = x_start + width; | ||
80 | |||
81 | if(xmax > LCD_WIDTH) | ||
82 | xmax = LCD_WIDTH; | ||
83 | if(ymax >= LCD_HEIGHT) | ||
84 | ymax = LCD_HEIGHT; | ||
85 | |||
86 | for (x = x_start; x < xmax; x++) | ||
87 | for (y = y_start; y < ymax; y++) | ||
88 | { | ||
89 | #if LCD_DEPTH == 1 | ||
90 | Uint32 sdl_white = SDL_MapRGB(surface->format, 255, 255, 255); | ||
91 | Uint32 sdl_black = SDL_MapRGB(surface->format, 0, 0, 0); | ||
92 | points[p].x = x + MARGIN_X; | ||
93 | points[p].y = y + MARGIN_Y; | ||
94 | colors[p] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1) ? sdl_black : sdl_white; | ||
95 | #elif LCD_DEPTH == 2 | ||
96 | unsigned gray = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3) << 6; | ||
97 | points[p].x = x + MARGIN_X; | ||
98 | points[p].y = y + MARGIN_Y; | ||
99 | colors[p] = SDL_MapRGB(surface->format, 255-gray, 255-gray, 255-gray); | ||
100 | #elif LCD_DEPTH == 16 | ||
101 | #if LCD_PIXELFORMAT == RGB565SWAPPED | ||
102 | unsigned b = ((lcd_framebuffer[y][x] >> 11) & 0x1f) << 3; | ||
103 | unsigned g = ((lcd_framebuffer[y][x] >> 5) & 0x3f) << 2; | ||
104 | unsigned r = ((lcd_framebuffer[y][x]) & 0x1f) << 3; | ||
105 | points[p].x = x + MARGIN_X; | ||
106 | points[p].y = y + MARGIN_Y; | ||
107 | colors[p] = SDL_MapRGB(surface->format, r, g, b); | ||
108 | #else | ||
109 | unsigned r = ((lcd_framebuffer[y][x] >> 11) & 0x1f) << 3; | ||
110 | unsigned g = ((lcd_framebuffer[y][x] >> 5) & 0x3f) << 2; | ||
111 | unsigned b = ((lcd_framebuffer[y][x]) & 0x1f) << 3; | ||
112 | points[p].x = x + MARGIN_X; | ||
113 | points[p].y = y + MARGIN_Y; | ||
114 | colors[p] = SDL_MapRGB(surface->format, r, g, b); | ||
115 | #endif | ||
116 | #endif | ||
117 | p++; | ||
118 | } | ||
119 | |||
120 | dots(colors, &points[0], p); | ||
121 | /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/ | ||
122 | SDL_UpdateRect(surface, 0, 0, 0, 0); | ||
123 | lcd_display_redraw=false; | ||
124 | } | ||
125 | |||
126 | #ifdef LCD_REMOTE_HEIGHT | ||
127 | extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH]; | ||
128 | unsigned char lcd_remote_framebuffer_copy[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH]; | ||
129 | |||
130 | #define REMOTE_START_Y (LCD_HEIGHT + 2*MARGIN_Y) | ||
131 | |||
132 | void lcd_remote_update (void) | ||
133 | { | ||
134 | lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT); | ||
135 | } | ||
136 | |||
137 | void lcd_remote_update_rect(int x_start, int y_start, | ||
138 | int width, int height) | ||
139 | { | ||
140 | int x; | ||
141 | int y; | ||
142 | int p=0; | ||
143 | int xmax; | ||
144 | int ymax; | ||
145 | struct coordinate points[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT]; | ||
146 | int colors[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT]; | ||
147 | Uint32 sdl_white = SDL_MapRGB(surface->format, 255, 255, 255); | ||
148 | Uint32 sdl_black = SDL_MapRGB(surface->format, 0, 0, 0); | ||
149 | |||
150 | #if 0 | ||
151 | fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n", | ||
152 | counter++, x_start, y_start, width, height); | ||
153 | #endif | ||
154 | ymax = y_start + height; | ||
155 | xmax = x_start + width; | ||
156 | |||
157 | if(xmax > LCD_REMOTE_WIDTH) | ||
158 | xmax = LCD_REMOTE_WIDTH; | ||
159 | if(ymax >= LCD_REMOTE_HEIGHT) | ||
160 | ymax = LCD_REMOTE_HEIGHT; | ||
161 | |||
162 | for (x = x_start; x < xmax; x++) | ||
163 | for (y = y_start; y < ymax; y++) { | ||
164 | colors[p] = ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1) ? sdl_black : sdl_white; | ||
165 | points[p].x = x + MARGIN_X; | ||
166 | points[p].y = y + MARGIN_Y + REMOTE_START_Y; | ||
167 | p++; | ||
168 | } | ||
169 | |||
170 | dots(colors, &points[0], p); | ||
171 | /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/ | ||
172 | SDL_UpdateRect(surface, 0, 0, 0, 0); | ||
173 | lcd_display_redraw=false; | ||
174 | } | ||
175 | |||
176 | |||
177 | #endif | ||
178 | |||
179 | #endif | ||
180 | #ifdef HAVE_LCD_CHARCELLS | ||
181 | |||
182 | /* Defined in lcd-playersim.c */ | ||
183 | extern void lcd_print_char(int x, int y); | ||
184 | extern unsigned char lcd_buffer[2][11]; | ||
185 | |||
186 | extern unsigned char hardware_buffer_lcd[11][2]; | ||
187 | static unsigned char lcd_buffer_copy[11][2]; | ||
188 | |||
189 | void lcd_update (void) | ||
190 | { | ||
191 | bool changed=false; | ||
192 | int x, y; | ||
193 | for (y=0; y<2; y++) { | ||
194 | for (x=0; x<11; x++) { | ||
195 | if (lcd_display_redraw || | ||
196 | lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y]) { | ||
197 | lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y]; | ||
198 | lcd_print_char(x, y); | ||
199 | changed=true; | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | if (changed) | ||
204 | { | ||
205 | SDL_UpdateRect(surface, 0, 0, 0, 0); | ||
206 | } | ||
207 | lcd_display_redraw=false; | ||
208 | } | ||
209 | |||
210 | #endif | ||
diff --git a/uisimulator/sdl/lcd-x11.h b/uisimulator/sdl/lcd-x11.h new file mode 100644 index 0000000000..07911b2530 --- /dev/null +++ b/uisimulator/sdl/lcd-x11.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #define MARGIN_X 3 | ||
21 | #define MARGIN_Y 3 | ||
22 | |||
23 | /* include the "real" lcd.h file here */ | ||
24 | #include <lcd.h> | ||
25 | |||
26 | |||
diff --git a/uisimulator/sdl/screenhack.c b/uisimulator/sdl/screenhack.c new file mode 100644 index 0000000000..c77cb575e4 --- /dev/null +++ b/uisimulator/sdl/screenhack.c | |||
@@ -0,0 +1,228 @@ | |||
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 | #endif | ||
118 | |||
119 | |||
120 | SDL_Surface *surface; | ||
121 | |||
122 | char having_new_lcd = true; | ||
123 | |||
124 | extern int display_zoom; | ||
125 | |||
126 | /* Dead-trivial event handling. | ||
127 | */ | ||
128 | int screenhack_handle_event(SDL_Event *event, bool *release) | ||
129 | { | ||
130 | int key = 0; | ||
131 | |||
132 | *release = false; | ||
133 | |||
134 | switch (event->type) { | ||
135 | case SDL_KEYDOWN: | ||
136 | { | ||
137 | key = event->key.keysym.sym; | ||
138 | *release = false; | ||
139 | } | ||
140 | break; | ||
141 | case SDL_KEYUP: | ||
142 | { | ||
143 | key = event->key.keysym.sym; | ||
144 | *release = true; | ||
145 | } | ||
146 | break; | ||
147 | case SDL_QUIT: | ||
148 | { | ||
149 | SDL_Quit(); | ||
150 | exit(0); | ||
151 | } | ||
152 | break; | ||
153 | default: | ||
154 | break; | ||
155 | } | ||
156 | |||
157 | return key; | ||
158 | } | ||
159 | |||
160 | int screenhack_handle_events(bool *release) | ||
161 | { | ||
162 | int key = 0; | ||
163 | SDL_Event event; | ||
164 | |||
165 | if (SDL_PollEvent(&event)) { | ||
166 | key = screenhack_handle_event(&event, release); | ||
167 | } | ||
168 | |||
169 | return key; | ||
170 | } | ||
171 | |||
172 | |||
173 | int main (int argc, char **argv) | ||
174 | { | ||
175 | int window_width; | ||
176 | int window_height; | ||
177 | |||
178 | if (argc > 1) | ||
179 | { | ||
180 | int x; | ||
181 | for (x=1; x<argc; x++) { | ||
182 | if (!strcmp("--old_lcd", argv[x])) { | ||
183 | having_new_lcd=false; | ||
184 | printf("Using old LCD layout.\n"); | ||
185 | } else if (!strcmp("--zoom", argv[x])) { | ||
186 | if (++x < argc) { | ||
187 | display_zoom=atoi(argv[x]); | ||
188 | printf("Window zoom is %d\n", display_zoom); | ||
189 | if (display_zoom < 1 || display_zoom > 5) { | ||
190 | printf("fatal: --zoom argument must be between 1 and 5\n"); | ||
191 | exit(0); | ||
192 | } | ||
193 | } else { | ||
194 | printf("fatal: --zoom requires an integer argument\n"); | ||
195 | exit(0); | ||
196 | } | ||
197 | } else { | ||
198 | printf("rockboxui\n"); | ||
199 | printf("Arguments:\n"); | ||
200 | printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n"); | ||
201 | printf(" --zoom [1-5]\t window zoom\n"); | ||
202 | printf(KEYBOARD_GENERIC KEYBOARD_SPECIFIC); | ||
203 | exit(0); | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
208 | window_width = (LCD_WIDTH + 2*MARGIN_X) * display_zoom; | ||
209 | window_height = (LCD_HEIGHT + 2*MARGIN_Y) * display_zoom; | ||
210 | #ifdef LCD_REMOTE_HEIGHT | ||
211 | window_height += (LCD_REMOTE_HEIGHT + 2*MARGIN_Y) * display_zoom; | ||
212 | #endif | ||
213 | |||
214 | if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)) { | ||
215 | fprintf(stderr, "fatal: %s", SDL_GetError()); | ||
216 | exit(-1); | ||
217 | } | ||
218 | |||
219 | atexit(SDL_Quit); | ||
220 | |||
221 | if ((surface = SDL_SetVideoMode(window_width, window_height, 24, 0)) == NULL) { | ||
222 | fprintf(stderr, "fatal: %s", SDL_GetError()); | ||
223 | exit(-1); | ||
224 | } | ||
225 | |||
226 | screenhack(); /* doesn't return */ | ||
227 | return 0; | ||
228 | } | ||
diff --git a/uisimulator/sdl/screenhack.h b/uisimulator/sdl/screenhack.h new file mode 100644 index 0000000000..4c7a8307a4 --- /dev/null +++ b/uisimulator/sdl/screenhack.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* xscreensaver, Copyright (c) 1992-1997 Jamie Zawinski <jwz@jwz.org> | ||
2 | * | ||
3 | * Permission to use, copy, modify, distribute, and sell this software and its | ||
4 | * documentation for any purpose is hereby granted without fee, provided that | ||
5 | * the above copyright notice appear in all copies and that both that | ||
6 | * copyright notice and this permission notice appear in supporting | ||
7 | * documentation. No representations are made about the suitability of this | ||
8 | * software for any purpose. It is provided "as is" without express or | ||
9 | * implied warranty. | ||
10 | */ | ||
11 | |||
12 | #ifndef __SCREENHACK_H__ | ||
13 | #define __SCREENHACK_H__ | ||
14 | |||
15 | #include <stdlib.h> | ||
16 | #include <stdbool.h> | ||
17 | |||
18 | #ifdef __hpux | ||
19 | /* Which of the ten billion standards does values.h belong to? | ||
20 | What systems always have it? */ | ||
21 | # include <values.h> | ||
22 | #endif | ||
23 | |||
24 | #include <stdio.h> | ||
25 | #include <SDL.h> | ||
26 | |||
27 | extern void screenhack(); | ||
28 | extern int screenhack_handle_event(SDL_Event*, bool *); | ||
29 | extern int screenhack_handle_events(bool *); | ||
30 | extern void screen_redraw(); | ||
31 | extern void screen_resized(); | ||
32 | |||
33 | #endif /* __SCREENHACK_H__ */ | ||
diff --git a/uisimulator/sdl/sound.c b/uisimulator/sdl/sound.c new file mode 100644 index 0000000000..6068fb3863 --- /dev/null +++ b/uisimulator/sdl/sound.c | |||
@@ -0,0 +1,119 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Nick Lanham | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "autoconf.h" | ||
21 | |||
22 | #ifdef ROCKBOX_HAS_SIMSOUND /* play sound in sim enabled */ | ||
23 | |||
24 | #include <stdio.h> | ||
25 | #include <stdlib.h> | ||
26 | #include <unistd.h> | ||
27 | #include <fcntl.h> | ||
28 | #include <string.h> | ||
29 | #include <SDL.h> | ||
30 | |||
31 | #include "sound.h" | ||
32 | |||
33 | //static Uint8 *audio_chunk; | ||
34 | static int audio_len; | ||
35 | static char *audio_pos; | ||
36 | SDL_sem* sem; | ||
37 | |||
38 | /* The audio function callback takes the following parameters: | ||
39 | stream: A pointer to the audio buffer to be filled | ||
40 | len: The length (in bytes) of the audio buffer | ||
41 | */ | ||
42 | void mixaudio(void *udata, Uint8 *stream, int len) | ||
43 | { | ||
44 | (void)udata; | ||
45 | |||
46 | /* Only play if we have data left */ | ||
47 | if ( audio_len == 0 ) | ||
48 | return; | ||
49 | |||
50 | len = (len > audio_len) ? audio_len : len; | ||
51 | memcpy(stream, audio_pos, len); | ||
52 | audio_pos += len; | ||
53 | audio_len -= len; | ||
54 | |||
55 | if(audio_len == 0) { | ||
56 | if(SDL_SemPost(sem)) | ||
57 | fprintf(stderr,"Couldn't post: %s",SDL_GetError()); | ||
58 | |||
59 | } | ||
60 | } | ||
61 | |||
62 | |||
63 | |||
64 | int sim_sound_init(void) | ||
65 | { | ||
66 | SDL_AudioSpec fmt; | ||
67 | |||
68 | /* Set 16-bit stereo audio at 44Khz */ | ||
69 | fmt.freq = 44100; | ||
70 | fmt.format = AUDIO_S16SYS; | ||
71 | fmt.channels = 2; | ||
72 | fmt.samples = 512; /* A good value for games */ | ||
73 | fmt.callback = mixaudio; | ||
74 | fmt.userdata = NULL; | ||
75 | |||
76 | sem = SDL_CreateSemaphore(0); | ||
77 | |||
78 | /* Open the audio device and start playing sound! */ | ||
79 | if(SDL_OpenAudio(&fmt, NULL) < 0) { | ||
80 | fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError()); | ||
81 | return -1; | ||
82 | } | ||
83 | SDL_PauseAudio(0); | ||
84 | return 0; | ||
85 | |||
86 | //... | ||
87 | |||
88 | //SDL_CloseAudio(); | ||
89 | } | ||
90 | |||
91 | void sound_playback_thread(void) | ||
92 | { | ||
93 | int sndret = sim_sound_init(); | ||
94 | unsigned char *buf; | ||
95 | long size; | ||
96 | |||
97 | while(sndret) | ||
98 | sleep(100000); /* wait forever, can't play sound! */ | ||
99 | |||
100 | do { | ||
101 | while(!sound_get_pcm) | ||
102 | /* TODO: fix a fine thread-synch mechanism here */ | ||
103 | usleep(10000); | ||
104 | do { | ||
105 | sound_get_pcm(&buf, &size); | ||
106 | if(!size) { | ||
107 | sound_get_pcm = NULL; | ||
108 | break; | ||
109 | } | ||
110 | audio_pos = buf; // TODO: is this safe? | ||
111 | audio_len = size; | ||
112 | //printf("len: %i\n",audio_len); | ||
113 | if(SDL_SemWait(sem)) | ||
114 | fprintf(stderr,"Couldn't wait: %s",SDL_GetError()); | ||
115 | } while(size); | ||
116 | } while(1); | ||
117 | } | ||
118 | |||
119 | #endif /* ROCKBOX_HAS_SIMSOUND */ | ||
diff --git a/uisimulator/sdl/sound.h b/uisimulator/sdl/sound.h new file mode 100644 index 0000000000..87499cac8e --- /dev/null +++ b/uisimulator/sdl/sound.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Daniel Stenberg <daniel@haxx.se> | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | void sound_playback_thread(void); | ||
21 | |||
22 | extern void (*sound_get_pcm)(unsigned char** start, long* size); | ||
diff --git a/uisimulator/sdl/sprintf.h b/uisimulator/sdl/sprintf.h new file mode 100644 index 0000000000..64a22f3c6e --- /dev/null +++ b/uisimulator/sdl/sprintf.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #include <stdarg.h> | ||
2 | #include <stdio.h> | ||
3 | |||
4 | int rockbox_snprintf (char *buf, size_t size, const char *fmt, ...); | ||
5 | int rockbox_vsnprintf (char *buf, int size, const char *fmt, va_list ap); | ||
6 | int rockbox_fprintf (int fd, const char *fmt, ...); | ||
7 | |||
8 | #ifndef NO_REDEFINES_PLEASE | ||
9 | #define snprintf rockbox_snprintf | ||
10 | #define vsnprintf rockbox_vsnprintf | ||
11 | #define fprintf rockbox_fprintf | ||
12 | #endif | ||
diff --git a/uisimulator/sdl/thread.c b/uisimulator/sdl/thread.c new file mode 100644 index 0000000000..6d9139c35d --- /dev/null +++ b/uisimulator/sdl/thread.c | |||
@@ -0,0 +1,148 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Daniel Stenberg | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "autoconf.h" | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <pthread.h> | ||
24 | |||
25 | #include "kernel.h" | ||
26 | #include <sys/time.h> | ||
27 | |||
28 | #ifdef ROCKBOX_HAS_SIMSOUND | ||
29 | #include "sound.h" | ||
30 | #endif | ||
31 | |||
32 | long current_tick = 0; | ||
33 | extern void sim_tick_tasks(void); | ||
34 | |||
35 | static void msleep(int msec) | ||
36 | { | ||
37 | struct timeval delay; | ||
38 | |||
39 | delay.tv_sec = msec / 1000; | ||
40 | delay.tv_usec = (msec % 1000) * 1000; | ||
41 | select(0, NULL, NULL, NULL, &delay); /* portable sub-second sleep */ | ||
42 | } | ||
43 | |||
44 | /* | ||
45 | * This is not a target thread, so it does not fall under the 1 thread at a | ||
46 | * time thing. | ||
47 | */ | ||
48 | static void update_tick_thread() | ||
49 | { | ||
50 | struct timeval start, now; | ||
51 | long new_tick; | ||
52 | |||
53 | gettimeofday(&start, NULL); | ||
54 | while (1) | ||
55 | { | ||
56 | msleep(5); /* check twice per simulated target tick */ | ||
57 | gettimeofday(&now, NULL); | ||
58 | new_tick = (now.tv_sec - start.tv_sec) * HZ | ||
59 | + (now.tv_usec - start.tv_usec) / (1000000/HZ); | ||
60 | if (new_tick > current_tick) | ||
61 | { | ||
62 | sim_tick_tasks(); | ||
63 | current_tick = new_tick; | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * We emulate the target threads by using pthreads. We have a mutex that only | ||
70 | * allows one thread at a time to execute. It forces each thread to yield() | ||
71 | * for the other(s) to run. | ||
72 | */ | ||
73 | |||
74 | pthread_mutex_t mp; | ||
75 | |||
76 | void init_threads(void) | ||
77 | { | ||
78 | pthread_t tick_tid; | ||
79 | |||
80 | pthread_mutex_init(&mp, NULL); | ||
81 | /* get mutex to only allow one thread running at a time */ | ||
82 | pthread_mutex_lock(&mp); | ||
83 | |||
84 | /* start a tick thread */ | ||
85 | pthread_create(&tick_tid, NULL, (void *(*)(void *)) update_tick_thread, | ||
86 | NULL); | ||
87 | |||
88 | #ifdef ROCKBOX_HAS_SIMSOUND /* start thread that plays PCM data */ | ||
89 | { | ||
90 | pthread_t sound_tid; | ||
91 | pthread_create(&sound_tid, NULL, | ||
92 | (void *(*)(void *)) sound_playback_thread, | ||
93 | NULL); | ||
94 | } | ||
95 | #endif | ||
96 | |||
97 | } | ||
98 | /* | ||
99 | int pthread_create(pthread_t *new_thread_ID, | ||
100 | const pthread_attr_t *attr, | ||
101 | void * (*start_func)(void *), void *arg); | ||
102 | */ | ||
103 | |||
104 | void yield(void) | ||
105 | { | ||
106 | pthread_mutex_unlock(&mp); /* return */ | ||
107 | msleep(1); /* prevent busy loop */ | ||
108 | pthread_mutex_lock(&mp); /* get it again */ | ||
109 | } | ||
110 | |||
111 | void newfunc(void (*func)(void)) | ||
112 | { | ||
113 | pthread_mutex_lock(&mp); | ||
114 | func(); | ||
115 | pthread_mutex_unlock(&mp); | ||
116 | } | ||
117 | |||
118 | |||
119 | int create_thread(void (*fp)(void), void* sp, int stk_size) | ||
120 | { | ||
121 | pthread_t tid; | ||
122 | int i; | ||
123 | int error; | ||
124 | |||
125 | /* we really don't care about these arguments */ | ||
126 | (void)sp; | ||
127 | (void)stk_size; | ||
128 | error = pthread_create(&tid, | ||
129 | NULL, /* default attributes please */ | ||
130 | (void *(*)(void *)) newfunc, /* function to start */ | ||
131 | fp /* start argument */); | ||
132 | if(0 != error) | ||
133 | fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); | ||
134 | else | ||
135 | fprintf(stderr, "Thread %ld is running\n", (long)tid); | ||
136 | |||
137 | yield(); | ||
138 | |||
139 | return error; | ||
140 | } | ||
141 | |||
142 | void sim_sleep(int ticks) | ||
143 | { | ||
144 | pthread_mutex_unlock(&mp); /* return */ | ||
145 | msleep((1000/HZ) * ticks); | ||
146 | pthread_mutex_lock(&mp); /* get it again */ | ||
147 | } | ||
148 | |||
diff --git a/uisimulator/sdl/timefuncs.h b/uisimulator/sdl/timefuncs.h new file mode 100644 index 0000000000..de17fcdc73 --- /dev/null +++ b/uisimulator/sdl/timefuncs.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #include <time.h> | ||
2 | #include <stdbool.h> | ||
3 | |||
4 | /* struct tm defined */ | ||
5 | struct tm *get_time(void); | ||
6 | int set_time(const struct tm *tm); | ||
7 | bool valid_time(const struct tm *tm); | ||
diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c new file mode 100644 index 0000000000..e17a925313 --- /dev/null +++ b/uisimulator/sdl/uisdl.c | |||
@@ -0,0 +1,226 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include <stdio.h> | ||
20 | #include <string.h> | ||
21 | #include <stdarg.h> | ||
22 | #include <stdlib.h> | ||
23 | #include <ctype.h> | ||
24 | #include <sys/types.h> | ||
25 | #include <sys/stat.h> | ||
26 | #include <fcntl.h> | ||
27 | |||
28 | #include <errno.h> | ||
29 | #include <ctype.h> | ||
30 | #include <time.h> | ||
31 | |||
32 | #include <SDL.h> | ||
33 | |||
34 | #include "config.h" | ||
35 | #include "screenhack.h" | ||
36 | |||
37 | #include "version.h" | ||
38 | |||
39 | #include "lcd-x11.h" | ||
40 | #include "lcd-playersim.h" | ||
41 | |||
42 | #define MAX(x,y) ((x)>(y)?(x):(y)) | ||
43 | #define MIN(x,y) ((x)<(y)?(x):(y)) | ||
44 | |||
45 | #define PROGNAME "rockboxui" | ||
46 | |||
47 | /* -- -- */ | ||
48 | |||
49 | extern SDL_Surface *surface; | ||
50 | |||
51 | int display_zoom=2; | ||
52 | |||
53 | bool lcd_display_redraw=true; | ||
54 | |||
55 | char *progclass = "rockboxui"; | ||
56 | |||
57 | void init_window () | ||
58 | { | ||
59 | /* stub */ | ||
60 | } | ||
61 | |||
62 | /* used for the player sim */ | ||
63 | void drawdots(int color, struct coordinate *points, int count) | ||
64 | { | ||
65 | SDL_Rect rect; | ||
66 | |||
67 | while (count--) { | ||
68 | rect.x = points[count].x * display_zoom; | ||
69 | rect.y = points[count].y * display_zoom; | ||
70 | rect.w = display_zoom; | ||
71 | rect.h = display_zoom; | ||
72 | |||
73 | SDL_FillRect(surface, &rect, color); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | void drawrect(int color, int x1, int y1, int x2, int y2) | ||
78 | { | ||
79 | SDL_Rect rect; | ||
80 | |||
81 | rect.x = x1 * display_zoom; | ||
82 | rect.y = y1 * display_zoom; | ||
83 | rect.w = (x2-x1) * display_zoom; | ||
84 | rect.h = (y2-y1) * display_zoom; | ||
85 | |||
86 | SDL_FillRect(surface, &rect, color); | ||
87 | } | ||
88 | |||
89 | #if 0 | ||
90 | static void help(void) | ||
91 | { | ||
92 | printf(PROGNAME " " ROCKBOXUI_VERSION " " __DATE__ "\n" | ||
93 | "usage: " PROGNAME "\n"); | ||
94 | } | ||
95 | #endif | ||
96 | |||
97 | void dots(int *colors, struct coordinate *points, int count) | ||
98 | { | ||
99 | int bpp = surface->format->BytesPerPixel; | ||
100 | |||
101 | if (SDL_MUSTLOCK(surface)) { | ||
102 | if (SDL_LockSurface(surface)) { | ||
103 | fprintf(stderr, "cannot lock surface: %s", SDL_GetError()); | ||
104 | exit(-1); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | while (count--) { | ||
109 | int x_off, y_off; | ||
110 | |||
111 | for (x_off = 0; x_off < display_zoom; x_off++) { | ||
112 | for (y_off = 0; y_off < display_zoom; y_off++) { | ||
113 | int x = points[count].x*display_zoom + x_off; | ||
114 | int y = points[count].y*display_zoom + y_off; | ||
115 | |||
116 | Uint8 *p = (Uint8 *) surface->pixels + y * surface->pitch + x * bpp; | ||
117 | |||
118 | switch (bpp) { | ||
119 | case 1: | ||
120 | *p = colors[count]; | ||
121 | break; | ||
122 | |||
123 | case 2: | ||
124 | *(Uint16 *)p = colors[count]; | ||
125 | break; | ||
126 | |||
127 | case 3: | ||
128 | if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { | ||
129 | p[0] = (colors[count] >> 16) & 0xff; | ||
130 | p[1] = (colors[count] >> 8) & 0xff; | ||
131 | p[2] = (colors[count]) & 0xff; | ||
132 | } else { | ||
133 | p[2] = (colors[count] >> 16) & 0xff; | ||
134 | p[1] = (colors[count] >> 8) & 0xff; | ||
135 | p[0] = (colors[count]) & 0xff; | ||
136 | } | ||
137 | break; | ||
138 | |||
139 | case 4: | ||
140 | *(Uint32 *)p = colors[count]; | ||
141 | break; | ||
142 | } | ||
143 | } | ||
144 | } | ||
145 | } | ||
146 | |||
147 | if (SDL_MUSTLOCK(surface)) { | ||
148 | SDL_UnlockSurface(surface); | ||
149 | } | ||
150 | |||
151 | SDL_UpdateRect(surface, 0, 0, 0, 0); | ||
152 | } | ||
153 | |||
154 | /* this is where the applicaton starts */ | ||
155 | extern void app_main(void); | ||
156 | |||
157 | void screenhack() | ||
158 | { | ||
159 | #if 0 | ||
160 | Bool helpme; | ||
161 | |||
162 | /* This doesn't work, but I don't know why (Daniel 1999-12-01) */ | ||
163 | helpme = get_boolean_resource ("help", "Boolean"); | ||
164 | if(helpme) | ||
165 | help(); | ||
166 | #endif | ||
167 | |||
168 | printf(PROGNAME " " ROCKBOXUI_VERSION " (" __DATE__ ")\n"); | ||
169 | |||
170 | init_window(); | ||
171 | |||
172 | screen_redraw(); | ||
173 | |||
174 | app_main(); | ||
175 | } | ||
176 | |||
177 | /* used for the player sim */ | ||
178 | void drawrectangles(int color, struct rectangle *points, int count) | ||
179 | { | ||
180 | SDL_Rect rect; | ||
181 | Uint32 sdl_white = SDL_MapRGB(surface->format, 255, 255, 255); | ||
182 | Uint32 sdl_black = SDL_MapRGB(surface->format, 0, 0, 0); | ||
183 | |||
184 | while (count--) { | ||
185 | rect.x = points[count].x * display_zoom; | ||
186 | rect.y = points[count].y * display_zoom; | ||
187 | rect.w = points[count].width * display_zoom; | ||
188 | rect.h = points[count].height * display_zoom; | ||
189 | |||
190 | SDL_FillRect(surface, &rect, color ? sdl_white : sdl_black); | ||
191 | } | ||
192 | } | ||
193 | |||
194 | |||
195 | void screen_redraw() | ||
196 | { | ||
197 | /* draw a border around the screen */ | ||
198 | int X1 = 0; | ||
199 | int Y1 = 0; | ||
200 | int X2 = LCD_WIDTH + 2*MARGIN_X - 1; | ||
201 | int Y2 = LCD_HEIGHT + 2*MARGIN_Y - 1; | ||
202 | |||
203 | drawrect(SDL_MapRGB(surface->format, 255, 255, 255), X1, Y1, X2, Y1+1); | ||
204 | drawrect(SDL_MapRGB(surface->format, 255, 255, 255), X2, Y1, X2+1, Y2); | ||
205 | drawrect(SDL_MapRGB(surface->format, 255, 255, 255), X1, Y2, X2, Y2+1); | ||
206 | drawrect(SDL_MapRGB(surface->format, 255, 255, 255), X1, Y1, X1+1, Y2); | ||
207 | |||
208 | lcd_display_redraw = true; | ||
209 | lcd_update(); | ||
210 | |||
211 | #ifdef LCD_REMOTE_HEIGHT | ||
212 | /* draw a border around the remote LCD screen */ | ||
213 | int RX1 = 0; | ||
214 | int RY1 = Y2 + 1; | ||
215 | int RX2 = LCD_REMOTE_WIDTH + 2*MARGIN_X - 1; | ||
216 | int RY2 = RY1 + LCD_REMOTE_HEIGHT + 2*MARGIN_Y - 1; | ||
217 | |||
218 | drawrect(SDL_MapRGB(surface->format, 255, 255, 255), RX1, RY1, RX2, RY1+1); | ||
219 | drawrect(SDL_MapRGB(surface->format, 255, 255, 255), RX2, RY1, RX2+1, RY2); | ||
220 | drawrect(SDL_MapRGB(surface->format, 255, 255, 255), RX1, RY2, RX2, RY2+1); | ||
221 | drawrect(SDL_MapRGB(surface->format, 255, 255, 255), RX1, RY1, RX1+1, RY2); | ||
222 | |||
223 | lcd_display_redraw = true; | ||
224 | lcd_remote_update(); | ||
225 | #endif | ||
226 | } | ||
diff --git a/uisimulator/sdl/uisw32.c b/uisimulator/sdl/uisw32.c new file mode 100644 index 0000000000..1b4dbbd410 --- /dev/null +++ b/uisimulator/sdl/uisw32.c | |||
@@ -0,0 +1,344 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Felix Arends | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include <windows.h> | ||
21 | #include <process.h> | ||
22 | #include <stdlib.h> | ||
23 | #include <fcntl.h> | ||
24 | #include "autoconf.h" | ||
25 | #include "uisw32.h" | ||
26 | #include "resource.h" | ||
27 | #include "button.h" | ||
28 | #include "thread.h" | ||
29 | #include "thread-win32.h" | ||
30 | #include "kernel.h" | ||
31 | #include "sound.h" | ||
32 | |||
33 | #ifndef LR_VGACOLOR /* Should be under MINGW32 builds? */ | ||
34 | #define LR_VGACOLOR LR_COLOR | ||
35 | #endif | ||
36 | |||
37 | // extern functions | ||
38 | extern void app_main (void *); // mod entry point | ||
39 | extern void new_key(int key); | ||
40 | extern void sim_tick_tasks(void); | ||
41 | |||
42 | void button_event(int key, bool pressed); | ||
43 | |||
44 | // variables | ||
45 | HWND hGUIWnd; // the GUI window handle | ||
46 | unsigned int uThreadID; // id of mod thread | ||
47 | PBYTE lpKeys; | ||
48 | bool bActive; // window active? | ||
49 | HANDLE hGUIThread; // thread for GUI | ||
50 | #ifdef ROCKBOX_HAS_SIMSOUND | ||
51 | HANDLE hSoundThread; // thread for sound | ||
52 | #endif | ||
53 | bool bIsWinNT; // Windows NT derivate? | ||
54 | |||
55 | bool lcd_display_redraw=true; // Used for player simulator | ||
56 | char having_new_lcd=true; // Used for player simulator | ||
57 | |||
58 | // GUIWndProc | ||
59 | // window proc for GUI simulator | ||
60 | LRESULT CALLBACK GUIWndProc ( | ||
61 | HWND hWnd, | ||
62 | UINT uMsg, | ||
63 | WPARAM wParam, | ||
64 | LPARAM lParam | ||
65 | ) | ||
66 | { | ||
67 | static HBITMAP hBkgnd; | ||
68 | static HDC hMemDc; | ||
69 | |||
70 | static LARGE_INTEGER persec, tick1, ticknow; | ||
71 | long new_tick; | ||
72 | |||
73 | switch (uMsg) | ||
74 | { | ||
75 | case WM_TIMER: | ||
76 | QueryPerformanceCounter(&ticknow); | ||
77 | new_tick = ((ticknow.QuadPart-tick1.QuadPart)*HZ)/persec.QuadPart; | ||
78 | if (new_tick != current_tick) | ||
79 | { | ||
80 | long i; | ||
81 | for (i = new_tick - current_tick; i > 0; i--) | ||
82 | sim_tick_tasks(); | ||
83 | current_tick = new_tick; | ||
84 | } | ||
85 | return TRUE; | ||
86 | case WM_ACTIVATE: | ||
87 | if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) | ||
88 | bActive = true; | ||
89 | else | ||
90 | bActive = false; | ||
91 | return TRUE; | ||
92 | case WM_CREATE: | ||
93 | QueryPerformanceFrequency(&persec); | ||
94 | QueryPerformanceCounter(&tick1); | ||
95 | SetTimer (hWnd, TIMER_EVENT, 1, NULL); | ||
96 | |||
97 | // load background image | ||
98 | hBkgnd = (HBITMAP)LoadImage (GetModuleHandle (NULL), | ||
99 | MAKEINTRESOURCE(IDB_UI), IMAGE_BITMAP, 0, 0, LR_VGACOLOR); | ||
100 | hMemDc = CreateCompatibleDC (GetDC (hWnd)); | ||
101 | SelectObject (hMemDc, hBkgnd); | ||
102 | return TRUE; | ||
103 | case WM_SIZING: | ||
104 | { | ||
105 | LPRECT r = (LPRECT)lParam; | ||
106 | char s[256]; | ||
107 | int v; | ||
108 | int h_add = GetSystemMetrics (SM_CXSIZEFRAME) * 2 + 4; | ||
109 | int v_add = GetSystemMetrics (SM_CYSIZEFRAME) * 2 | ||
110 | + GetSystemMetrics (SM_CYCAPTION) + 4; | ||
111 | |||
112 | switch (wParam) | ||
113 | { | ||
114 | case WMSZ_BOTTOM: | ||
115 | v = (r->bottom - r->top) / (UI_HEIGHT / 5); | ||
116 | r->bottom = r->top + v * UI_HEIGHT / 5 + v_add; | ||
117 | r->right = r->left + v * UI_WIDTH / 5 + h_add; | ||
118 | break; | ||
119 | case WMSZ_RIGHT: | ||
120 | v = (r->right - r->left) / (UI_WIDTH / 5); | ||
121 | r->bottom = r->top + v * UI_HEIGHT / 5 + v_add; | ||
122 | r->right = r->left + v * UI_WIDTH / 5 + h_add; | ||
123 | break; | ||
124 | case WMSZ_TOP: | ||
125 | v = (r->bottom - r->top) / (UI_HEIGHT / 5); | ||
126 | r->top = r->bottom - v * UI_HEIGHT / 5 - v_add; | ||
127 | r->right = r->left + v * UI_WIDTH / 5 + h_add; | ||
128 | break; | ||
129 | case WMSZ_LEFT: | ||
130 | v = (r->right - r->left) / (UI_WIDTH / 5); | ||
131 | r->bottom = r->top + v * UI_HEIGHT / 5 + v_add; | ||
132 | r->left = r->right - v * UI_WIDTH / 5 - h_add; | ||
133 | break; | ||
134 | case WMSZ_BOTTOMRIGHT: | ||
135 | v = ((r->right - r->left) * UI_HEIGHT | ||
136 | +(r->bottom - r->top) * UI_WIDTH) | ||
137 | / (2 * UI_WIDTH * UI_HEIGHT / 5); | ||
138 | r->bottom = r->top + v * UI_HEIGHT / 5 + v_add; | ||
139 | r->right = r->left + v * UI_WIDTH / 5 + h_add; | ||
140 | break; | ||
141 | case WMSZ_BOTTOMLEFT: | ||
142 | v = ((r->right - r->left) * UI_HEIGHT | ||
143 | +(r->bottom - r->top) * UI_WIDTH) | ||
144 | / (2 * UI_WIDTH * UI_HEIGHT / 5); | ||
145 | r->bottom = r->top + v * UI_HEIGHT / 5 + v_add; | ||
146 | r->left = r->right - v * UI_WIDTH / 5 - h_add; | ||
147 | break; | ||
148 | case WMSZ_TOPRIGHT: | ||
149 | v = ((r->right - r->left) * UI_HEIGHT | ||
150 | +(r->bottom - r->top) * UI_WIDTH) | ||
151 | / (2 * UI_WIDTH * UI_HEIGHT / 5); | ||
152 | r->top = r->bottom - v * UI_HEIGHT / 5 - v_add; | ||
153 | r->right = r->left + v * UI_WIDTH / 5 + h_add; | ||
154 | break; | ||
155 | case WMSZ_TOPLEFT: | ||
156 | v = ((r->right - r->left) * UI_HEIGHT | ||
157 | +(r->bottom - r->top) * UI_WIDTH) | ||
158 | / (2 * UI_WIDTH * UI_HEIGHT / 5); | ||
159 | r->top = r->bottom - v * UI_HEIGHT / 5 - v_add; | ||
160 | r->left = r->right - v * UI_WIDTH / 5 - h_add; | ||
161 | break; | ||
162 | } | ||
163 | |||
164 | wsprintf (s, UI_TITLE " @%d%%", | ||
165 | (r->right - r->left - h_add + 1) * 100 / UI_WIDTH); | ||
166 | SetWindowText (hWnd, s); | ||
167 | |||
168 | return TRUE; | ||
169 | } | ||
170 | case WM_ERASEBKGND: | ||
171 | { | ||
172 | HDC hDc = (HDC) wParam; | ||
173 | RECT r; | ||
174 | |||
175 | GetClientRect (hWnd, &r); | ||
176 | // blit background image to screen | ||
177 | SetStretchBltMode(hDc, bIsWinNT ? HALFTONE : COLORONCOLOR); | ||
178 | StretchBlt (hDc, 0, 0, r.right, r.bottom, | ||
179 | hMemDc, 0, 0, UI_WIDTH, UI_HEIGHT, SRCCOPY); | ||
180 | return TRUE; | ||
181 | } | ||
182 | case WM_PAINT: | ||
183 | { | ||
184 | PAINTSTRUCT ps; | ||
185 | RECT r; | ||
186 | HDC hDc = BeginPaint (hWnd, &ps); | ||
187 | |||
188 | GetClientRect (hWnd, &r); | ||
189 | // draw lcd screen | ||
190 | SetStretchBltMode(hDc, bIsWinNT ? HALFTONE : COLORONCOLOR); | ||
191 | StretchDIBits (hDc, | ||
192 | UI_LCD_POSX * r.right / UI_WIDTH, | ||
193 | UI_LCD_POSY * r.bottom / UI_HEIGHT, | ||
194 | UI_LCD_WIDTH * r.right / UI_WIDTH, | ||
195 | UI_LCD_HEIGHT * r.bottom / UI_HEIGHT, | ||
196 | 0, 0, LCD_WIDTH, LCD_HEIGHT, | ||
197 | bitmap, (BITMAPINFO *) &bmi, DIB_RGB_COLORS, | ||
198 | SRCCOPY); | ||
199 | #ifdef HAVE_REMOTE_LCD | ||
200 | StretchDIBits (hDc, | ||
201 | UI_REMOTE_POSX * r.right / UI_WIDTH, | ||
202 | UI_REMOTE_POSY * r.bottom / UI_HEIGHT, | ||
203 | UI_REMOTE_WIDTH * r.right / UI_WIDTH, | ||
204 | UI_REMOTE_HEIGHT * r.bottom / UI_HEIGHT, | ||
205 | 0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, | ||
206 | remote_bitmap, (BITMAPINFO *) &remote_bmi, | ||
207 | DIB_RGB_COLORS, SRCCOPY); | ||
208 | #endif | ||
209 | EndPaint (hWnd, &ps); | ||
210 | return TRUE; | ||
211 | } | ||
212 | case WM_CLOSE: | ||
213 | // close simulator | ||
214 | KillTimer (hWnd, TIMER_EVENT); | ||
215 | hGUIWnd = NULL; | ||
216 | PostQuitMessage (0); | ||
217 | break; | ||
218 | case WM_DESTROY: | ||
219 | // close simulator | ||
220 | hGUIWnd = NULL; | ||
221 | PostQuitMessage (0); | ||
222 | break; | ||
223 | case WM_KEYDOWN: | ||
224 | button_event(wParam, true); | ||
225 | break; | ||
226 | case WM_KEYUP: | ||
227 | button_event(wParam, false); | ||
228 | break; | ||
229 | } | ||
230 | |||
231 | return DefWindowProc (hWnd, uMsg, wParam, lParam); | ||
232 | } | ||
233 | |||
234 | // GUIStartup | ||
235 | // register window class, show window, init GUI | ||
236 | BOOL GUIStartup () | ||
237 | { | ||
238 | WNDCLASS wc; | ||
239 | |||
240 | // create window class | ||
241 | ZeroMemory (&wc, sizeof(wc)); | ||
242 | wc.hbrBackground = GetSysColorBrush (COLOR_WINDOW); | ||
243 | wc.hCursor = LoadCursor (NULL, IDC_ARROW); | ||
244 | wc.hInstance = GetModuleHandle (NULL); | ||
245 | wc.lpfnWndProc = GUIWndProc; | ||
246 | wc.lpszClassName = "RockBoxUISimulator"; | ||
247 | wc.style = CS_HREDRAW | CS_VREDRAW; | ||
248 | |||
249 | if (RegisterClass (&wc) == 0) | ||
250 | return FALSE; | ||
251 | |||
252 | // create window | ||
253 | hGUIWnd = CreateWindowEx ( | ||
254 | WS_EX_OVERLAPPEDWINDOW, | ||
255 | "RockBoxUISimulator", UI_TITLE, | ||
256 | WS_VISIBLE | WS_SYSMENU | WS_OVERLAPPEDWINDOW, | ||
257 | CW_USEDEFAULT, CW_USEDEFAULT, | ||
258 | UI_WIDTH + GetSystemMetrics (SM_CXSIZEFRAME) * 2 +4, | ||
259 | UI_HEIGHT + GetSystemMetrics (SM_CYSIZEFRAME) * 2 + | ||
260 | GetSystemMetrics (SM_CYCAPTION) +4, | ||
261 | NULL, NULL, GetModuleHandle (NULL), NULL); | ||
262 | |||
263 | if (hGUIWnd == NULL) | ||
264 | return FALSE; | ||
265 | |||
266 | simlcdinit(); | ||
267 | |||
268 | return TRUE; | ||
269 | } | ||
270 | |||
271 | // GUIDown | ||
272 | // destroy window, unregister window class | ||
273 | int GUIDown () | ||
274 | { | ||
275 | int i; | ||
276 | |||
277 | DestroyWindow (hGUIWnd); | ||
278 | CloseHandle (hGUIThread); | ||
279 | #ifdef ROCKBOX_HAS_SIMSOUND | ||
280 | CloseHandle (hSoundThread); | ||
281 | #endif | ||
282 | |||
283 | for (i = 0; i < nThreads; i++) | ||
284 | { | ||
285 | CloseHandle (lpThreads[i]); | ||
286 | } | ||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | // GUIMessageLoop | ||
291 | // standard message loop for GUI window | ||
292 | void GUIMessageLoop () | ||
293 | { | ||
294 | MSG msg; | ||
295 | while (GetMessage (&msg, NULL, 0, 0)) | ||
296 | { | ||
297 | TranslateMessage (&msg); | ||
298 | DispatchMessage (&msg); | ||
299 | } | ||
300 | } | ||
301 | |||
302 | |||
303 | // WinMain | ||
304 | // program entry point | ||
305 | int WINAPI WinMain ( | ||
306 | HINSTANCE hInstance, // current instance | ||
307 | HINSTANCE hPrevInstance, // previous instance | ||
308 | LPSTR lpCmd, // command line | ||
309 | int nShowCmd // show command | ||
310 | ) | ||
311 | { | ||
312 | DWORD dwThreadID; | ||
313 | |||
314 | (void)hInstance; | ||
315 | (void)hPrevInstance; | ||
316 | (void)lpCmd; | ||
317 | (void)nShowCmd; | ||
318 | |||
319 | /* default file mode should be O_BINARY to be consistent with rockbox */ | ||
320 | _fmode = _O_BINARY; | ||
321 | |||
322 | bIsWinNT = ((GetVersion() & 0x80000000) == 0); | ||
323 | |||
324 | if (!GUIStartup ()) | ||
325 | return 0; | ||
326 | |||
327 | hGUIThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)app_main, | ||
328 | NULL, 0, &dwThreadID); | ||
329 | |||
330 | if (hGUIThread == NULL) | ||
331 | return MessageBox (NULL, "Error creating gui thread!", "Error", MB_OK); | ||
332 | |||
333 | #ifdef ROCKBOX_HAS_SIMSOUND | ||
334 | hSoundThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) | ||
335 | sound_playback_thread, NULL, 0, &dwThreadID); | ||
336 | |||
337 | if (hSoundThread == NULL) | ||
338 | MessageBox (NULL, "Error creating sound thread!", "Warning", MB_OK); | ||
339 | #endif | ||
340 | |||
341 | GUIMessageLoop (); | ||
342 | |||
343 | return GUIDown (); | ||
344 | } | ||
diff --git a/uisimulator/sdl/uisw32.h b/uisimulator/sdl/uisw32.h new file mode 100644 index 0000000000..7b393a761b --- /dev/null +++ b/uisimulator/sdl/uisw32.h | |||
@@ -0,0 +1,156 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Felix Arends | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef __UISW32_H__ | ||
21 | #define __UISW32_H__ | ||
22 | |||
23 | #ifdef _MSC_VER | ||
24 | typedef unsigned short wchar_t; | ||
25 | #define _WCHAR_T_DEFINED | ||
26 | #endif | ||
27 | #include <windows.h> | ||
28 | #include "lcd-win32.h" | ||
29 | |||
30 | #if defined(ARCHOS_RECORDER) | ||
31 | #define UI_TITLE "Jukebox Recorder" | ||
32 | #define UI_WIDTH 270 // width of GUI window | ||
33 | #define UI_HEIGHT 406 // height of GUI window | ||
34 | #define UI_LCD_BGCOLOR 90, 145, 90 // bkgnd color of LCD (no backlight) | ||
35 | #define UI_LCD_BGCOLORLIGHT 126, 229, 126 // bkgnd color of LCD (backlight) | ||
36 | #define UI_LCD_BLACK 0, 0, 0 // black | ||
37 | #define UI_LCD_POSX 80 // x position of lcd | ||
38 | #define UI_LCD_POSY 104 // y position of lcd (96 for real aspect) | ||
39 | #define UI_LCD_WIDTH 112 | ||
40 | #define UI_LCD_HEIGHT 64 // (80 for real aspect) | ||
41 | |||
42 | #elif defined(ARCHOS_PLAYER) | ||
43 | #define UI_TITLE "Jukebox Player" | ||
44 | #define UI_WIDTH 284 // width of GUI window | ||
45 | #define UI_HEIGHT 420 // height of GUI window | ||
46 | #define UI_LCD_BGCOLOR 90, 145, 90 // bkgnd color of LCD (no backlight) | ||
47 | #define UI_LCD_BGCOLORLIGHT 126, 229, 126 // bkgnd color of LCD (backlight) | ||
48 | #define UI_LCD_BLACK 0, 0, 0 // black | ||
49 | #define UI_LCD_POSX 75 // x position of lcd | ||
50 | #define UI_LCD_POSY 111 // y position of lcd | ||
51 | #define UI_LCD_WIDTH 132 | ||
52 | #define UI_LCD_HEIGHT 75 | ||
53 | |||
54 | #elif defined(ARCHOS_FMRECORDER) || defined(ARCHOS_RECORDERV2) | ||
55 | #define UI_TITLE "Jukebox FM Recorder" | ||
56 | #define UI_WIDTH 285 // width of GUI window | ||
57 | #define UI_HEIGHT 414 // height of GUI window | ||
58 | #define UI_LCD_BGCOLOR 90, 145, 90 // bkgnd color of LCD (no backlight) | ||
59 | #define UI_LCD_BGCOLORLIGHT 126, 229, 126 // bkgnd color of LCD (backlight) | ||
60 | #define UI_LCD_BLACK 0, 0, 0 // black | ||
61 | #define UI_LCD_POSX 87 // x position of lcd | ||
62 | #define UI_LCD_POSY 77 // y position of lcd (69 for real aspect) | ||
63 | #define UI_LCD_WIDTH 112 | ||
64 | #define UI_LCD_HEIGHT 64 // (80 for real aspect) | ||
65 | |||
66 | #elif defined(ARCHOS_ONDIOSP) || defined(ARCHOS_ONDIOFM) | ||
67 | #define UI_TITLE "Ondio" | ||
68 | #define UI_WIDTH 155 // width of GUI window | ||
69 | #define UI_HEIGHT 334 // height of GUI window | ||
70 | #define UI_LCD_BGCOLOR 90, 145, 90 // bkgnd color of LCD (no backlight) | ||
71 | #define UI_LCD_BGCOLORLIGHT 90, 145, 90 // bkgnd color of LCD (backlight) | ||
72 | #define UI_LCD_BLACK 0, 0, 0 // black | ||
73 | #define UI_LCD_POSX 21 // x position of lcd | ||
74 | #define UI_LCD_POSY 82 // y position of lcd (74 for real aspect) | ||
75 | #define UI_LCD_WIDTH 112 | ||
76 | #define UI_LCD_HEIGHT 64 // (80 for real aspect) | ||
77 | |||
78 | #elif defined(IRIVER_H100_SERIES) | ||
79 | #define UI_TITLE "iriver H1x0" | ||
80 | #define UI_WIDTH 379 // width of GUI window | ||
81 | #define UI_HEIGHT 508 // height of GUI window | ||
82 | #define UI_LCD_BGCOLOR 90, 145, 90 // bkgnd color of LCD (no backlight) | ||
83 | #define UI_LCD_BGCOLORLIGHT 230, 216, 173 // bkgnd color of LCD (backlight) | ||
84 | #define UI_LCD_BLACK 0, 0, 0 // black | ||
85 | #define UI_LCD_POSX 109 // x position of lcd | ||
86 | #define UI_LCD_POSY 23 // y position of lcd | ||
87 | #define UI_LCD_WIDTH 160 | ||
88 | #define UI_LCD_HEIGHT 128 | ||
89 | #define UI_REMOTE_BGCOLOR 90, 145, 90 // bkgnd of remote lcd (no bklight) | ||
90 | #define UI_REMOTE_BGCOLORLIGHT 250, 180, 130 // bkgnd of remote lcd (bklight) | ||
91 | #define UI_REMOTE_POSX 50 // x position of remote lcd | ||
92 | #define UI_REMOTE_POSY 403 // y position of remote lcd | ||
93 | #define UI_REMOTE_WIDTH 128 | ||
94 | #define UI_REMOTE_HEIGHT 64 | ||
95 | |||
96 | #elif defined(IRIVER_H300_SERIES) | ||
97 | #define UI_TITLE "iriver H300" | ||
98 | #define UI_WIDTH 288 // width of GUI window | ||
99 | #define UI_HEIGHT 581 // height of GUI window | ||
100 | /* high-colour */ | ||
101 | #define UI_LCD_POSX 26 // x position of lcd | ||
102 | #define UI_LCD_POSY 36 // y position of lcd | ||
103 | #define UI_LCD_WIDTH 220 | ||
104 | #define UI_LCD_HEIGHT 176 | ||
105 | #define UI_REMOTE_BGCOLOR 90, 145, 90 // bkgnd of remote lcd (no bklight) | ||
106 | #define UI_REMOTE_BGCOLORLIGHT 250, 180, 130 // bkgnd of remote lcd (bklight) | ||
107 | #define UI_REMOTE_POSX 12 // x position of remote lcd | ||
108 | #define UI_REMOTE_POSY 478 // y position of remote lcd | ||
109 | #define UI_REMOTE_WIDTH 128 | ||
110 | #define UI_REMOTE_HEIGHT 64 | ||
111 | |||
112 | #elif defined(IPOD_COLOR) | ||
113 | #define UI_TITLE "iPod Color" | ||
114 | #define UI_WIDTH 261 // width of GUI window | ||
115 | #define UI_HEIGHT 493 // height of GUI window | ||
116 | /* high-colour */ | ||
117 | #define UI_LCD_POSX 21 // x position of lcd | ||
118 | #define UI_LCD_POSY 16 // y position of lcd | ||
119 | #define UI_LCD_WIDTH 220 | ||
120 | #define UI_LCD_HEIGHT 176 | ||
121 | |||
122 | #elif defined(IPOD_NANO) | ||
123 | #define UI_TITLE "iPod Nano" | ||
124 | #define UI_WIDTH 199 // width of GUI window | ||
125 | #define UI_HEIGHT 421 // height of GUI window | ||
126 | /* high-colour */ | ||
127 | #define UI_LCD_POSX 13 // x position of lcd | ||
128 | #define UI_LCD_POSY 14 // y position of lcd | ||
129 | #define UI_LCD_WIDTH 176 | ||
130 | #define UI_LCD_HEIGHT 132 | ||
131 | |||
132 | #elif defined(ARCHOS_GMINI120) | ||
133 | #define UI_TITLE "Gmini 120" | ||
134 | #define UI_WIDTH 370 // width of GUI window | ||
135 | #define UI_HEIGHT 264 // height of GUI window | ||
136 | #define UI_LCD_BGCOLOR 90, 145, 90 // bkgnd color of LCD (no backlight) | ||
137 | #define UI_LCD_BGCOLORLIGHT 230, 160, 60 // bkgnd color of LCD (backlight) | ||
138 | #define UI_LCD_BLACK 0, 0, 0 // black | ||
139 | #define UI_LCD_POSX 85 // x position of lcd | ||
140 | #define UI_LCD_POSY 61 // y position of lcd (74 for real aspect) | ||
141 | #define UI_LCD_WIDTH 192 // * 1.5 | ||
142 | #define UI_LCD_HEIGHT 96 // * 1.5 | ||
143 | |||
144 | #endif | ||
145 | |||
146 | #define TIMER_EVENT 0x34928340 | ||
147 | |||
148 | extern HWND hGUIWnd; // the GUI window handle | ||
149 | extern unsigned int uThreadID; // id of mod thread | ||
150 | extern bool bActive; | ||
151 | |||
152 | // typedefs | ||
153 | typedef unsigned char uchar; | ||
154 | typedef unsigned int uint32; | ||
155 | |||
156 | #endif // #ifndef __UISW32_H__ | ||
diff --git a/uisimulator/sdl/version.h b/uisimulator/sdl/version.h new file mode 100644 index 0000000000..1d40c08781 --- /dev/null +++ b/uisimulator/sdl/version.h | |||
@@ -0,0 +1 @@ | |||
#define ROCKBOXUI_VERSION "0.2" | |||