summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-09-24 17:22:12 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-09-24 17:22:12 +0000
commitb1b8bd4dd159e90f9e197c8870953da079162639 (patch)
tree27238f1b5a1535de0604e423ca91236bb3e2f833
parentc909b4b42e88a8e797e58a5e3e5ecf3716ae4783 (diff)
downloadrockbox-b1b8bd4dd159e90f9e197c8870953da079162639.tar.gz
rockbox-b1b8bd4dd159e90f9e197c8870953da079162639.zip
Moved on_screen, f2_screen, f3_screen and handle_usb (renamed usb_screen) to a new file: screens.c.
typedef Menu replaced with a bool. All code now calls usb_screen() for usb handling. Nearly all code now deals with USB connect/disconnect properly. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2401 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c62
-rw-r--r--apps/debug_menu.h6
-rw-r--r--apps/demo_menu.c10
-rw-r--r--apps/demo_menu.h2
-rw-r--r--apps/games_menu.c8
-rw-r--r--apps/games_menu.h2
-rw-r--r--apps/main_menu.c16
-rw-r--r--apps/main_menu.h2
-rw-r--r--apps/menu.c46
-rw-r--r--apps/menu.h11
-rw-r--r--apps/recorder/snake.c4
-rw-r--r--apps/recorder/sokoban.c31
-rw-r--r--apps/recorder/sokoban.h5
-rw-r--r--apps/recorder/tetris.c79
-rw-r--r--apps/recorder/wormlet.c9
-rw-r--r--apps/recorder/wormlet.h2
-rw-r--r--apps/screens.c292
-rw-r--r--apps/screens.h30
-rw-r--r--apps/settings.c180
-rw-r--r--apps/settings.h11
-rw-r--r--apps/settings_menu.c129
-rw-r--r--apps/settings_menu.h2
-rw-r--r--apps/sound_menu.c74
-rw-r--r--apps/sound_menu.h2
-rw-r--r--apps/tree.c24
-rw-r--r--apps/wps.c288
-rw-r--r--apps/wps.h1
-rw-r--r--uisimulator/win32/Makefile6
-rw-r--r--uisimulator/x11/Makefile6
29 files changed, 695 insertions, 645 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 9be6667808..2a9b898975 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -46,7 +46,7 @@ extern char *thread_name[];
46 46
47#ifdef HAVE_LCD_BITMAP 47#ifdef HAVE_LCD_BITMAP
48/* Test code!!! */ 48/* Test code!!! */
49Menu dbg_os(void) 49bool dbg_os(void)
50{ 50{
51 char buf[32]; 51 char buf[32];
52 int button; 52 int button;
@@ -77,13 +77,13 @@ Menu dbg_os(void)
77 { 77 {
78 case BUTTON_OFF: 78 case BUTTON_OFF:
79 case BUTTON_LEFT: 79 case BUTTON_LEFT:
80 return MENU_OK; 80 return false;
81 } 81 }
82 } 82 }
83 return MENU_OK; 83 return false;
84} 84}
85#else 85#else
86Menu dbg_os(void) 86bool dbg_os(void)
87{ 87{
88 char buf[32]; 88 char buf[32];
89 int button; 89 int button;
@@ -110,7 +110,7 @@ Menu dbg_os(void)
110 switch(button) 110 switch(button)
111 { 111 {
112 case BUTTON_STOP: 112 case BUTTON_STOP:
113 return MENU_OK; 113 return false;
114 114
115 case BUTTON_LEFT: 115 case BUTTON_LEFT:
116 currval--; 116 currval--;
@@ -125,13 +125,13 @@ Menu dbg_os(void)
125 break; 125 break;
126 } 126 }
127 } 127 }
128 return MENU_OK; 128 return false;
129} 129}
130#endif 130#endif
131 131
132#ifdef HAVE_LCD_BITMAP 132#ifdef HAVE_LCD_BITMAP
133/* Test code!!! */ 133/* Test code!!! */
134Menu dbg_ports(void) 134bool dbg_ports(void)
135{ 135{
136 unsigned short porta; 136 unsigned short porta;
137 unsigned short portb; 137 unsigned short portb;
@@ -186,13 +186,13 @@ Menu dbg_ports(void)
186 switch(button) 186 switch(button)
187 { 187 {
188 case BUTTON_OFF: 188 case BUTTON_OFF:
189 return MENU_OK; 189 return false;
190 } 190 }
191 } 191 }
192 return MENU_OK; 192 return false;
193} 193}
194#else 194#else
195Menu dbg_ports(void) 195bool dbg_ports(void)
196{ 196{
197 unsigned short porta; 197 unsigned short porta;
198 unsigned short portb; 198 unsigned short portb;
@@ -268,7 +268,7 @@ Menu dbg_ports(void)
268 switch(button) 268 switch(button)
269 { 269 {
270 case BUTTON_STOP: 270 case BUTTON_STOP:
271 return MENU_OK; 271 return false;
272 272
273 case BUTTON_LEFT: 273 case BUTTON_LEFT:
274 currval--; 274 currval--;
@@ -283,13 +283,13 @@ Menu dbg_ports(void)
283 break; 283 break;
284 } 284 }
285 } 285 }
286 return MENU_OK; 286 return false;
287} 287}
288#endif 288#endif
289 289
290#ifdef HAVE_RTC 290#ifdef HAVE_RTC
291/* Read RTC RAM contents and display them */ 291/* Read RTC RAM contents and display them */
292Menu dbg_rtc(void) 292bool dbg_rtc(void)
293{ 293{
294 char buf[32]; 294 char buf[32];
295 unsigned char addr = 0, r, c; 295 unsigned char addr = 0, r, c;
@@ -333,15 +333,15 @@ Menu dbg_rtc(void)
333 break; 333 break;
334 case BUTTON_OFF: 334 case BUTTON_OFF:
335 case BUTTON_LEFT: 335 case BUTTON_LEFT:
336 return MENU_OK; 336 return false;
337 } 337 }
338 } 338 }
339 return MENU_OK; 339 return false;
340} 340}
341#else 341#else
342Menu dbg_rtc(void) 342bool dbg_rtc(void)
343{ 343{
344 return MENU_OK; 344 return false;
345} 345}
346#endif 346#endif
347 347
@@ -351,7 +351,7 @@ Menu dbg_rtc(void)
351#define NUMROWS 4 351#define NUMROWS 4
352#endif 352#endif
353/* Read MAS registers and display them */ 353/* Read MAS registers and display them */
354Menu dbg_mas(void) 354bool dbg_mas(void)
355{ 355{
356 char buf[32]; 356 char buf[32];
357 unsigned int addr = 0, r, i; 357 unsigned int addr = 0, r, i;
@@ -395,14 +395,14 @@ Menu dbg_mas(void)
395#else 395#else
396 case BUTTON_DOWN: 396 case BUTTON_DOWN:
397#endif 397#endif
398 return MENU_OK; 398 return false;
399 } 399 }
400 } 400 }
401 return MENU_OK; 401 return false;
402} 402}
403 403
404#ifdef HAVE_MAS3587F 404#ifdef HAVE_MAS3587F
405Menu dbg_mas_codec(void) 405bool dbg_mas_codec(void)
406{ 406{
407 char buf[32]; 407 char buf[32];
408 unsigned int addr = 0, r, i; 408 unsigned int addr = 0, r, i;
@@ -433,10 +433,10 @@ Menu dbg_mas_codec(void)
433 if (addr) { addr -= 4; } 433 if (addr) { addr -= 4; }
434 break; 434 break;
435 case BUTTON_LEFT: 435 case BUTTON_LEFT:
436 return MENU_OK; 436 return false;
437 } 437 }
438 } 438 }
439 return MENU_OK; 439 return false;
440} 440}
441#endif 441#endif
442 442
@@ -450,7 +450,7 @@ Menu dbg_mas_codec(void)
450#define BAT_FIRST_VAL MAX(POWER_HISTORY_LEN - LCD_WIDTH - 1, 0) 450#define BAT_FIRST_VAL MAX(POWER_HISTORY_LEN - LCD_WIDTH - 1, 0)
451#define BAT_YSPACE (LCD_HEIGHT - 20) 451#define BAT_YSPACE (LCD_HEIGHT - 20)
452 452
453Menu view_battery(void) 453bool view_battery(void)
454{ 454{
455 int view = 0; 455 int view = 0;
456 int i, x, y; 456 int i, x, y;
@@ -571,16 +571,16 @@ Menu view_battery(void)
571 571
572 case BUTTON_LEFT: 572 case BUTTON_LEFT:
573 case BUTTON_OFF: 573 case BUTTON_OFF:
574 return MENU_OK; 574 return false;
575 } 575 }
576 } 576 }
577 return MENU_OK; 577 return false;
578} 578}
579 579
580#endif 580#endif
581 581
582#ifdef HAVE_MAS3507D 582#ifdef HAVE_MAS3507D
583Menu dbg_mas_info(void) 583bool dbg_mas_info(void)
584{ 584{
585 int button; 585 int button;
586 char buf[32]; 586 char buf[32];
@@ -714,7 +714,7 @@ Menu dbg_mas_info(void)
714 switch(button) 714 switch(button)
715 { 715 {
716 case BUTTON_STOP: 716 case BUTTON_STOP:
717 return MENU_OK; 717 return false;
718 718
719 case BUTTON_LEFT: 719 case BUTTON_LEFT:
720 currval--; 720 currval--;
@@ -750,14 +750,14 @@ Menu dbg_mas_info(void)
750 break; 750 break;
751 } 751 }
752 } 752 }
753 return MENU_OK; 753 return false;
754} 754}
755#endif 755#endif
756 756
757Menu debug_menu(void) 757bool debug_menu(void)
758{ 758{
759 int m; 759 int m;
760 Menu result; 760 bool result;
761 761
762 struct menu_items items[] = { 762 struct menu_items items[] = {
763 { "View I/O ports", dbg_ports }, 763 { "View I/O ports", dbg_ports },
diff --git a/apps/debug_menu.h b/apps/debug_menu.h
index 5dcc3ac183..9b4841f653 100644
--- a/apps/debug_menu.h
+++ b/apps/debug_menu.h
@@ -19,12 +19,12 @@
19#ifndef _DEBUG_MENU_H 19#ifndef _DEBUG_MENU_H
20#define _DEBUG_MENU_H 20#define _DEBUG_MENU_H
21 21
22Menu debug_menu(void); 22bool debug_menu(void);
23 23
24#ifndef SIMULATOR 24#ifndef SIMULATOR
25extern Menu dbg_ports(void); 25extern bool dbg_ports(void);
26#ifdef HAVE_RTC 26#ifdef HAVE_RTC
27extern Menu dbg_rtc(void); 27extern bool dbg_rtc(void);
28#endif 28#endif
29#endif 29#endif
30 30
diff --git a/apps/demo_menu.c b/apps/demo_menu.c
index 23cd7d1cb5..fa918dc476 100644
--- a/apps/demo_menu.c
+++ b/apps/demo_menu.c
@@ -33,14 +33,14 @@
33 33
34#include "lang.h" 34#include "lang.h"
35 35
36extern Menu bounce(void); 36extern bool bounce(void);
37extern Menu snow(void); 37extern bool snow(void);
38extern Menu oscillograph(void); 38extern bool oscillograph(void);
39 39
40Menu demo_menu(void) 40bool demo_menu(void)
41{ 41{
42 int m; 42 int m;
43 Menu result; 43 bool result;
44 44
45 struct menu_items items[] = { 45 struct menu_items items[] = {
46 { str(LANG_BOUNCE), bounce }, 46 { str(LANG_BOUNCE), bounce },
diff --git a/apps/demo_menu.h b/apps/demo_menu.h
index 13c315dd82..dba057f4eb 100644
--- a/apps/demo_menu.h
+++ b/apps/demo_menu.h
@@ -19,7 +19,7 @@
19#ifndef _DEMOS_MENU_H 19#ifndef _DEMOS_MENU_H
20#define _DEMOS_MENU_H 20#define _DEMOS_MENU_H
21 21
22Menu demo_menu(void); 22bool demo_menu(void);
23 23
24#endif 24#endif
25 25
diff --git a/apps/games_menu.c b/apps/games_menu.c
index 6ab1faf7e6..5b4198e05a 100644
--- a/apps/games_menu.c
+++ b/apps/games_menu.c
@@ -36,13 +36,13 @@
36#include "wormlet.h" 36#include "wormlet.h"
37#include "lang.h" 37#include "lang.h"
38 38
39extern Menu tetris(void); 39extern bool tetris(void);
40extern Menu snake(void); 40extern bool snake(void);
41 41
42Menu games_menu(void) 42bool games_menu(void)
43{ 43{
44 int m; 44 int m;
45 Menu result; 45 bool result;
46 46
47 struct menu_items items[] = { 47 struct menu_items items[] = {
48 { str(LANG_TETRIS), tetris }, 48 { str(LANG_TETRIS), tetris },
diff --git a/apps/games_menu.h b/apps/games_menu.h
index a179a2a8ea..5c6d81b5a5 100644
--- a/apps/games_menu.h
+++ b/apps/games_menu.h
@@ -21,6 +21,6 @@
21 21
22#include "menu.h" 22#include "menu.h"
23 23
24Menu games_menu(void); 24bool games_menu(void);
25 25
26#endif 26#endif
diff --git a/apps/main_menu.c b/apps/main_menu.c
index ad5388ec6f..199dca66e7 100644
--- a/apps/main_menu.c
+++ b/apps/main_menu.c
@@ -117,7 +117,7 @@ int show_logo( void )
117 return 0; 117 return 0;
118} 118}
119 119
120Menu show_credits(void) 120bool show_credits(void)
121{ 121{
122 int j = 0; 122 int j = 0;
123 int btn; 123 int btn;
@@ -132,23 +132,23 @@ Menu show_credits(void)
132 132
133 btn = button_get(false); 133 btn = button_get(false);
134 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 134 if (btn != BUTTON_NONE && !(btn & BUTTON_REL))
135 return MENU_OK; 135 return false;
136 } 136 }
137 roll_credits(); 137 roll_credits();
138 return MENU_OK; 138 return false;
139} 139}
140 140
141#ifdef SIMULATOR 141#ifdef SIMULATOR
142#define mp3buf 0 142#define mp3buf 0
143#define mp3end 0 143#define mp3end 0
144 144
145extern Menu simulate_usb(void); 145extern bool simulate_usb(void);
146#else 146#else
147/* defined in linker script */ 147/* defined in linker script */
148extern unsigned char mp3buf[]; 148extern unsigned char mp3buf[];
149extern unsigned char mp3end[]; 149extern unsigned char mp3end[];
150#endif 150#endif
151Menu show_info(void) 151bool show_info(void)
152{ 152{
153 char s[32]; 153 char s[32];
154 int buflen = ((mp3end - mp3buf) * 100) / 0x100000; 154 int buflen = ((mp3end - mp3buf) * 100) / 0x100000;
@@ -199,13 +199,13 @@ Menu show_info(void)
199 done = true; 199 done = true;
200 } 200 }
201 201
202 return MENU_OK; 202 return false;
203} 203}
204 204
205Menu main_menu(void) 205bool main_menu(void)
206{ 206{
207 int m; 207 int m;
208 Menu result; 208 bool result;
209 209
210 /* main menu */ 210 /* main menu */
211 struct menu_items items[] = { 211 struct menu_items items[] = {
diff --git a/apps/main_menu.h b/apps/main_menu.h
index 8efcd6f380..b79528e610 100644
--- a/apps/main_menu.h
+++ b/apps/main_menu.h
@@ -22,6 +22,6 @@
22#include "menu.h" 22#include "menu.h"
23 23
24extern int show_logo(void); 24extern int show_logo(void);
25extern Menu main_menu(void); 25extern bool main_menu(void);
26 26
27#endif 27#endif
diff --git a/apps/menu.c b/apps/menu.c
index 3539f161fa..ac5c857a70 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -33,7 +33,7 @@
33#ifdef HAVE_LCD_BITMAP 33#ifdef HAVE_LCD_BITMAP
34#include "icons.h" 34#include "icons.h"
35#include "widgets.h" 35#include "widgets.h"
36#include "wps.h" 36#include "screens.h"
37#endif 37#endif
38 38
39struct menu { 39struct menu {
@@ -242,13 +242,13 @@ void menu_exit(int m)
242 inuse[m] = false; 242 inuse[m] = false;
243} 243}
244 244
245Menu menu_run(int m) 245bool menu_run(int m)
246{ 246{
247 Menu result = MENU_OK; 247 bool exit = false;
248 248
249 menu_draw(m); 249 menu_draw(m);
250 250
251 while(1) { 251 while (!exit) {
252 switch( button_get_w_tmo(HZ/2) ) { 252 switch( button_get_w_tmo(HZ/2) ) {
253#ifdef HAVE_RECORDER_KEYPAD 253#ifdef HAVE_RECORDER_KEYPAD
254 case BUTTON_UP: 254 case BUTTON_UP:
@@ -303,12 +303,12 @@ Menu menu_run(int m)
303 are gonna clear the screen anyway */ 303 are gonna clear the screen anyway */
304 lcd_clear_display(); 304 lcd_clear_display();
305 305
306 /* if a child returns that the contents is changed, we 306 /* if a child returns that USB was used,
307 must remember this, even if we perhaps invoke other 307 we return immediately */
308 children too before returning back */ 308 if (menus[m].items[menus[m].cursor].function()) {
309 if(MENU_DISK_CHANGED == 309 lcd_scroll_pause(); /* just in case */
310 menus[m].items[menus[m].cursor].function()) 310 return true;
311 result = MENU_DISK_CHANGED; 311 }
312 312
313 /* Return to previous display state */ 313 /* Return to previous display state */
314 menu_draw(m); 314 menu_draw(m);
@@ -321,39 +321,29 @@ Menu menu_run(int m)
321 case BUTTON_STOP: 321 case BUTTON_STOP:
322 case BUTTON_MENU: 322 case BUTTON_MENU:
323#endif 323#endif
324 lcd_stop_scroll(); 324 lcd_scroll_pause();
325 while (button_get(false)); /* clear button queue */ 325 exit = true;
326 return result; 326 break;
327 327
328#ifdef HAVE_RECORDER_KEYPAD 328#ifdef HAVE_RECORDER_KEYPAD
329 case BUTTON_F3: 329 case BUTTON_F3:
330 if (f3_screen()) 330 if (f3_screen())
331 return SYS_USB_CONNECTED; 331 return true;
332 menu_draw(m); 332 menu_draw(m);
333 break; 333 break;
334#endif 334#endif
335 335
336#ifndef SIMULATOR
337 case SYS_USB_CONNECTED: 336 case SYS_USB_CONNECTED:
338 backlight_time(4); 337 usb_screen();
339 usb_acknowledge(SYS_USB_CONNECTED_ACK);
340 usb_wait_for_disconnect(&button_queue);
341 backlight_time(global_settings.backlight);
342#ifdef HAVE_LCD_CHARCELLS 338#ifdef HAVE_LCD_CHARCELLS
343 lcd_icon(ICON_PARAM, true); 339 lcd_icon(ICON_PARAM, false);
344#endif 340#endif
345 menu_draw(m); 341 return true;
346 result = MENU_DISK_CHANGED;
347 break;
348#endif
349
350 default:
351 break;
352 } 342 }
353 343
354 status_draw(); 344 status_draw();
355 lcd_update(); 345 lcd_update();
356 } 346 }
357 347
358 return result; 348 return false;
359} 349}
diff --git a/apps/menu.h b/apps/menu.h
index 49c0beb23d..a21d07a7ee 100644
--- a/apps/menu.h
+++ b/apps/menu.h
@@ -22,16 +22,9 @@
22 22
23#include <stdbool.h> 23#include <stdbool.h>
24 24
25typedef enum {
26 MENU_OK,
27 MENU_DISK_CHANGED, /* any file/directory contents need to be re-read */
28 MENU_LAST /* don't use as return code, only for number of return codes
29 available */
30} Menu;
31
32struct menu_items { 25struct menu_items {
33 unsigned char *desc; 26 unsigned char *desc;
34 Menu (*function) (void); 27 bool (*function) (void); /* return true if USB was connected */
35}; 28};
36 29
37int menu_init(struct menu_items* items, int count); 30int menu_init(struct menu_items* items, int count);
@@ -39,6 +32,6 @@ void menu_exit(int menu);
39 32
40void put_cursorxy(int x, int y, bool on); 33void put_cursorxy(int x, int y, bool on);
41 34
42Menu menu_run(int menu); 35bool menu_run(int menu);
43 36
44#endif /* End __MENU_H__ */ 37#endif /* End __MENU_H__ */
diff --git a/apps/recorder/snake.c b/apps/recorder/snake.c
index 8c14527bd5..736d08dbd7 100644
--- a/apps/recorder/snake.c
+++ b/apps/recorder/snake.c
@@ -257,10 +257,10 @@ void game_init(void) {
257 257
258} 258}
259 259
260Menu snake(void) { 260bool snake(void) {
261 game_init(); 261 game_init();
262 lcd_clear_display(); 262 lcd_clear_display();
263 game(); 263 game();
264 return MENU_OK; 264 return false;
265} 265}
266 266
diff --git a/apps/recorder/sokoban.c b/apps/recorder/sokoban.c
index bec556054a..3e5d447ae9 100644
--- a/apps/recorder/sokoban.c
+++ b/apps/recorder/sokoban.c
@@ -27,6 +27,7 @@
27#include "button.h" 27#include "button.h"
28#include "kernel.h" 28#include "kernel.h"
29#include "menu.h" 29#include "menu.h"
30#include "screens.h"
30 31
31#ifdef SIMULATOR 32#ifdef SIMULATOR
32#include <stdio.h> 33#include <stdio.h>
@@ -37,6 +38,10 @@
37#define SOKOBAN_TITLE_FONT 2 38#define SOKOBAN_TITLE_FONT 2
38#define NUM_LEVELS sizeof(levels)/320 39#define NUM_LEVELS sizeof(levels)/320
39 40
41static void load_level(int);
42static void update_screen(void);
43static bool sokoban_loop(void);
44
40static char board[16][20]; 45static char board[16][20];
41static int current_level=0; 46static int current_level=0;
42static int moves=0; 47static int moves=0;
@@ -1766,7 +1771,7 @@ static const char levels[][320] = {
1766}; 1771};
1767 1772
1768 1773
1769void load_level (int level_to_load) { 1774static void load_level (int level_to_load) {
1770 int a = 0; 1775 int a = 0;
1771 int b = 0; 1776 int b = 0;
1772 int c = 0; 1777 int c = 0;
@@ -1790,7 +1795,7 @@ void load_level (int level_to_load) {
1790 return; 1795 return;
1791} 1796}
1792 1797
1793void update_screen(void) { 1798static void update_screen(void) {
1794 int b = 0; 1799 int b = 0;
1795 int c = 0; 1800 int c = 0;
1796 char s[25]; 1801 char s[25];
@@ -1855,7 +1860,8 @@ void update_screen(void) {
1855 1860
1856 1861
1857 1862
1858void sokoban_loop(void) { 1863static bool sokoban_loop(void)
1864{
1859 int ii = 0; 1865 int ii = 0;
1860 moves = 0; 1866 moves = 0;
1861 current_level = 0; 1867 current_level = 0;
@@ -1868,7 +1874,7 @@ void sokoban_loop(void) {
1868 1874
1869 case BUTTON_OFF: 1875 case BUTTON_OFF:
1870 /* get out of here */ 1876 /* get out of here */
1871 return; 1877 return false;
1872 1878
1873 case BUTTON_F3: 1879 case BUTTON_F3:
1874 /* increase level */ 1880 /* increase level */
@@ -2170,6 +2176,10 @@ void sokoban_loop(void) {
2170 row++; 2176 row++;
2171 break; 2177 break;
2172 2178
2179 case SYS_USB_CONNECTED:
2180 usb_screen();
2181 return true;
2182
2173 default: 2183 default:
2174 idle = true; 2184 idle = true;
2175 break; 2185 break;
@@ -2192,20 +2202,23 @@ void sokoban_loop(void) {
2192 lcd_invertrect(0,0,111,63); 2202 lcd_invertrect(0,0,111,63);
2193 lcd_update(); 2203 lcd_update();
2194 if ( button_get(false) ) 2204 if ( button_get(false) )
2195 return; 2205 return false;
2196 } 2206 }
2197 return; 2207 return false;
2198 } 2208 }
2199 load_level(current_level); 2209 load_level(current_level);
2200 lcd_clear_display(); 2210 lcd_clear_display();
2201 update_screen(); 2211 update_screen();
2202 } 2212 }
2203 } 2213 }
2214
2215 return false;
2204} 2216}
2205 2217
2206 2218
2207Menu sokoban(void) 2219bool sokoban(void)
2208{ 2220{
2221 bool result;
2209 int w, h; 2222 int w, h;
2210 int len = strlen(SOKOBAN_TITLE); 2223 int len = strlen(SOKOBAN_TITLE);
2211 2224
@@ -2240,9 +2253,9 @@ Menu sokoban(void)
2240 lcd_update(); 2253 lcd_update();
2241 sleep(HZ*2); 2254 sleep(HZ*2);
2242 lcd_clear_display(); 2255 lcd_clear_display();
2243 sokoban_loop(); 2256 result = sokoban_loop();
2244 2257
2245 return MENU_OK; 2258 return result;
2246} 2259}
2247 2260
2248#endif 2261#endif
diff --git a/apps/recorder/sokoban.h b/apps/recorder/sokoban.h
index ee1398c011..f4f8fdd24f 100644
--- a/apps/recorder/sokoban.h
+++ b/apps/recorder/sokoban.h
@@ -22,10 +22,7 @@
22 22
23#include "menu.h" 23#include "menu.h"
24 24
25void load_level(int); 25bool sokoban(void);
26void update_screen(void);
27void sokoban_loop(void);
28Menu sokoban(void);
29 26
30#endif /*__SOKOBAN__ */ 27#endif /*__SOKOBAN__ */
31 28
diff --git a/apps/recorder/tetris.c b/apps/recorder/tetris.c
index 2455f269b3..5264b8e789 100644
--- a/apps/recorder/tetris.c
+++ b/apps/recorder/tetris.c
@@ -30,6 +30,7 @@
30#include "kernel.h" 30#include "kernel.h"
31#include <string.h> 31#include <string.h>
32#include "menu.h" 32#include "menu.h"
33#include "screens.h"
33 34
34#ifdef SIMULATOR 35#ifdef SIMULATOR
35#include <stdio.h> 36#include <stdio.h>
@@ -106,12 +107,12 @@ static const char block_data[7][4][2][4] =
106 } 107 }
107}; 108};
108 109
109int t_rand(int range) 110static int t_rand(int range)
110{ 111{
111 return current_tick % range; 112 return current_tick % range;
112} 113}
113 114
114void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y) 115static void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y)
115{ 116{
116 lcd_drawline(fstart_x, fstart_y, fstop_x, fstart_y); 117 lcd_drawline(fstart_x, fstart_y, fstop_x, fstart_y);
117 lcd_drawline(fstart_x, fstop_y, fstop_x, fstop_y); 118 lcd_drawline(fstart_x, fstop_y, fstop_x, fstop_y);
@@ -123,7 +124,7 @@ void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y)
123 lcd_drawline(fstart_x - 1, fstop_y + 1, fstop_x - 1, fstop_y + 1); 124 lcd_drawline(fstart_x - 1, fstop_y + 1, fstop_x - 1, fstop_y + 1);
124} 125}
125 126
126void draw_block(int x, int y, int block, int frame, bool clear) 127static void draw_block(int x, int y, int block, int frame, bool clear)
127{ 128{
128 int i, a, b; 129 int i, a, b;
129 for(i=0;i < 4;i++) { 130 for(i=0;i < 4;i++) {
@@ -144,7 +145,7 @@ void draw_block(int x, int y, int block, int frame, bool clear)
144 } 145 }
145} 146}
146 147
147void to_virtual(void) 148static void to_virtual(void)
148{ 149{
149 int i,a,b; 150 int i,a,b;
150 151
@@ -156,7 +157,7 @@ void to_virtual(void)
156 current_x + block_data[current_b][current_f][1][i] * 4 - b) = current_b + 1; 157 current_x + block_data[current_b][current_f][1][i] * 4 - b) = current_b + 1;
157} 158}
158 159
159bool block_touch (int x, int y) 160static bool block_touch (int x, int y)
160{ 161{
161 int a,b; 162 int a,b;
162 for (a = 0; a < 4; a++) 163 for (a = 0; a < 4; a++)
@@ -166,7 +167,7 @@ bool block_touch (int x, int y)
166 return false; 167 return false;
167} 168}
168 169
169bool gameover(void) 170static bool gameover(void)
170{ 171{
171 int i; 172 int i;
172 int frame, block, y, x; 173 int frame, block, y, x;
@@ -191,7 +192,7 @@ bool gameover(void)
191 return false; 192 return false;
192} 193}
193 194
194bool valid_position(int x, int y, int block, int frame) 195static bool valid_position(int x, int y, int block, int frame)
195{ 196{
196 int i; 197 int i;
197 for(i=0;i < 4;i++) 198 for(i=0;i < 4;i++)
@@ -204,7 +205,7 @@ bool valid_position(int x, int y, int block, int frame)
204 return true; 205 return true;
205} 206}
206 207
207void from_virtual(void) 208static void from_virtual(void)
208{ 209{
209 int x,y; 210 int x,y;
210 for(y = 0; y < max_y; y++) 211 for(y = 0; y < max_y; y++)
@@ -215,7 +216,7 @@ void from_virtual(void)
215 lcd_clearpixel(start_x + x, start_y + y); 216 lcd_clearpixel(start_x + x, start_y + y);
216} 217}
217 218
218void move_block(int x,int y,int f) 219static void move_block(int x,int y,int f)
219{ 220{
220 int last_frame = current_f; 221 int last_frame = current_f;
221 if(f != 0) 222 if(f != 0)
@@ -239,7 +240,7 @@ void move_block(int x,int y,int f)
239 current_f = last_frame; 240 current_f = last_frame;
240} 241}
241 242
242void new_block(void) 243static void new_block(void)
243{ 244{
244 current_b = next_b; 245 current_b = next_b;
245 current_f = next_f; 246 current_f = next_f;
@@ -266,7 +267,7 @@ void new_block(void)
266 draw_block(current_x, current_y, current_b, current_f, false); 267 draw_block(current_x, current_y, current_b, current_f, false);
267} 268}
268 269
269int check_lines(void) 270static int check_lines(void)
270{ 271{
271 int x,y,i,j; 272 int x,y,i,j;
272 bool line; 273 bool line;
@@ -298,7 +299,7 @@ int check_lines(void)
298 return lines / 4; 299 return lines / 4;
299} 300}
300 301
301void move_down(void) 302static void move_down(void)
302{ 303{
303 int l; 304 int l;
304 char s[25]; 305 char s[25];
@@ -327,7 +328,7 @@ void move_down(void)
327 move_block(-4,0,0); 328 move_block(-4,0,0);
328} 329}
329 330
330void game_loop(void) 331static bool game_loop(void)
331{ 332{
332 while(1) 333 while(1)
333 { 334 {
@@ -336,28 +337,32 @@ void game_loop(void)
336 { 337 {
337 switch(button_get_w_tmo(HZ/10)) 338 switch(button_get_w_tmo(HZ/10))
338 { 339 {
339 case BUTTON_OFF: 340 case BUTTON_OFF:
340 return; 341 return false;
341 342
342 case BUTTON_UP: 343 case BUTTON_UP:
343 case BUTTON_UP | BUTTON_REPEAT: 344 case BUTTON_UP | BUTTON_REPEAT:
344 move_block(0,-3,0); 345 move_block(0,-3,0);
345 break; 346 break;
346 347
347 case BUTTON_DOWN: 348 case BUTTON_DOWN:
348 case BUTTON_DOWN | BUTTON_REPEAT: 349 case BUTTON_DOWN | BUTTON_REPEAT:
349 move_block(0,3,0); 350 move_block(0,3,0);
350 break; 351 break;
351 352
352 case BUTTON_RIGHT: 353 case BUTTON_RIGHT:
353 case BUTTON_RIGHT | BUTTON_REPEAT: 354 case BUTTON_RIGHT | BUTTON_REPEAT:
354 move_block(0,0,1); 355 move_block(0,0,1);
355 break; 356 break;
356 357
357 case BUTTON_LEFT: 358 case BUTTON_LEFT:
358 case BUTTON_LEFT | BUTTON_REPEAT: 359 case BUTTON_LEFT | BUTTON_REPEAT:
359 move_down(); 360 move_down();
360 break; 361 break;
362
363 case SYS_USB_CONNECTED:
364 usb_screen();
365 return true;
361 } 366 }
362 367
363 count++; 368 count++;
@@ -369,14 +374,16 @@ void game_loop(void)
369 lcd_putsxy (2, 52, str(LANG_TETRIS_LOSE), 0); 374 lcd_putsxy (2, 52, str(LANG_TETRIS_LOSE), 0);
370 lcd_update(); 375 lcd_update();
371 sleep(HZ * 3); 376 sleep(HZ * 3);
372 return; 377 return false;
373 } 378 }
374 379
375 move_down(); 380 move_down();
376 } 381 }
382
383 return false;
377} 384}
378 385
379void init_tetris(void) 386static void init_tetris(void)
380{ 387{
381 memset(&virtual, 0, sizeof(virtual)); 388 memset(&virtual, 0, sizeof(virtual));
382 389
@@ -391,7 +398,7 @@ void init_tetris(void)
391 next_f = 0; 398 next_f = 0;
392} 399}
393 400
394Menu tetris(void) 401bool tetris(void)
395{ 402{
396 init_tetris(); 403 init_tetris();
397 404
@@ -402,9 +409,7 @@ Menu tetris(void)
402 next_b = t_rand(blocks); 409 next_b = t_rand(blocks);
403 next_f = t_rand(block_frames[next_b]); 410 next_f = t_rand(block_frames[next_b]);
404 new_block(); 411 new_block();
405 game_loop(); 412 return game_loop();
406
407 return MENU_OK;
408} 413}
409 414
410#endif 415#endif
diff --git a/apps/recorder/wormlet.c b/apps/recorder/wormlet.c
index acebbad8bf..0edd550966 100644
--- a/apps/recorder/wormlet.c
+++ b/apps/recorder/wormlet.c
@@ -34,6 +34,7 @@
34#include "menu.h" 34#include "menu.h"
35#include "rtc.h" 35#include "rtc.h"
36#include "lang.h" 36#include "lang.h"
37#include "screens.h"
37 38
38/* size of the field the worm lives in */ 39/* size of the field the worm lives in */
39#define FIELD_RECT_X 1 40#define FIELD_RECT_X 1
@@ -1888,7 +1889,7 @@ extern bool use_old_rect;
1888/** 1889/**
1889 * Main entry point from the menu to start the game control. 1890 * Main entry point from the menu to start the game control.
1890 */ 1891 */
1891Menu wormlet(void) 1892bool wormlet(void)
1892{ 1893{
1893 bool wormDead = false; 1894 bool wormDead = false;
1894 int button; 1895 int button;
@@ -1974,6 +1975,10 @@ Menu wormlet(void)
1974 use_remote = true; 1975 use_remote = true;
1975 } 1976 }
1976 break; 1977 break;
1978
1979 case SYS_USB_CONNECTED:
1980 usb_screen();
1981 return true;
1977 } 1982 }
1978 } while (button != BUTTON_PLAY && 1983 } while (button != BUTTON_PLAY &&
1979 button != BUTTON_OFF && button != BUTTON_ON); 1984 button != BUTTON_OFF && button != BUTTON_ON);
@@ -2007,7 +2012,7 @@ Menu wormlet(void)
2007 } 2012 }
2008 while (button != BUTTON_OFF); 2013 while (button != BUTTON_OFF);
2009 2014
2010 return MENU_OK; 2015 return false;
2011} 2016}
2012 2017
2013 2018
diff --git a/apps/recorder/wormlet.h b/apps/recorder/wormlet.h
index 347c6be737..0aeea3cc77 100644
--- a/apps/recorder/wormlet.h
+++ b/apps/recorder/wormlet.h
@@ -22,7 +22,7 @@
22 22
23#include "menu.h" 23#include "menu.h"
24 24
25Menu wormlet(void); 25bool wormlet(void);
26 26
27#endif /*__WORMLET__ */ 27#endif /*__WORMLET__ */
28 28
diff --git a/apps/screens.c b/apps/screens.c
new file mode 100644
index 0000000000..04870d1f1a
--- /dev/null
+++ b/apps/screens.c
@@ -0,0 +1,292 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 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 <stdbool.h>
20#include <string.h>
21#include <stdio.h>
22#include "backlight.h"
23#include "button.h"
24#include "lcd.h"
25#include "lang.h"
26#include "icons.h"
27#include "font.h"
28#include "mpeg.h"
29#include "usb.h"
30#include "settings.h"
31#include "playlist.h"
32
33void usb_screen(void)
34{
35#ifndef SIMULATOR
36 backlight_on();
37 usb_acknowledge(SYS_USB_CONNECTED_ACK);
38 usb_wait_for_disconnect(&button_queue);
39 backlight_on();
40#endif
41}
42
43#ifdef HAVE_RECORDER_KEYPAD
44/* returns:
45 0 if no key was pressed
46 1 if a key was pressed (or if ON was held down long enough to repeat)
47 2 if USB was connected */
48int on_screen(void)
49{
50 static int pitch = 100;
51 bool exit = false;
52 bool used = false;
53
54 while (!exit) {
55
56 if ( used ) {
57 char* ptr;
58 char buf[32];
59 int w, h;
60
61 lcd_scroll_pause();
62 lcd_clear_display();
63
64 ptr = str(LANG_PITCH_UP);
65 lcd_getstringsize(ptr,FONT_UI,&w,&h);
66 lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr, FONT_UI);
67 lcd_bitmap(bitmap_icons_7x8[Icon_UpArrow],
68 LCD_WIDTH/2 - 3, h*2, 7, 8, true);
69
70 snprintf(buf, sizeof buf, "%d%%", pitch);
71 lcd_getstringsize(buf,FONT_UI,&w,&h);
72 lcd_putsxy((LCD_WIDTH-w)/2, h, buf, FONT_UI);
73
74 ptr = str(LANG_PITCH_DOWN);
75 lcd_getstringsize(ptr,FONT_UI,&w,&h);
76 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr, FONT_UI);
77 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
78 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
79
80 ptr = str(LANG_PAUSE);
81 lcd_getstringsize(ptr,FONT_UI,&w,&h);
82 lcd_putsxy((LCD_WIDTH-(w/2))/2, LCD_HEIGHT/2 - h/2, ptr, FONT_UI);
83 lcd_bitmap(bitmap_icons_7x8[Icon_Pause],
84 (LCD_WIDTH-(w/2))/2-10, LCD_HEIGHT/2 - h/2, 7, 8, true);
85
86 lcd_update();
87 }
88
89 /* use lastbutton, so the main loop can decide whether to
90 exit to browser or not */
91 switch (button_get(true)) {
92 case BUTTON_UP:
93 case BUTTON_ON | BUTTON_UP:
94 case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT:
95 used = true;
96 pitch++;
97 if ( pitch > 200 )
98 pitch = 200;
99#ifdef HAVE_MAS3587F
100 mpeg_set_pitch(pitch);
101#endif
102 break;
103
104 case BUTTON_DOWN:
105 case BUTTON_ON | BUTTON_DOWN:
106 case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT:
107 used = true;
108 pitch--;
109 if ( pitch < 50 )
110 pitch = 50;
111#ifdef HAVE_MAS3587F
112 mpeg_set_pitch(pitch);
113#endif
114 break;
115
116 case BUTTON_ON | BUTTON_PLAY:
117 mpeg_pause();
118 used = true;
119 break;
120
121 case BUTTON_PLAY | BUTTON_REL:
122 mpeg_resume();
123 used = true;
124 break;
125
126 case BUTTON_ON | BUTTON_PLAY | BUTTON_REL:
127 mpeg_resume();
128 exit = true;
129 break;
130
131#ifdef SIMULATOR
132 case BUTTON_ON:
133#else
134 case BUTTON_ON | BUTTON_REL:
135 case BUTTON_ON | BUTTON_UP | BUTTON_REL:
136 case BUTTON_ON | BUTTON_DOWN | BUTTON_REL:
137#endif
138 exit = true;
139 break;
140
141 case BUTTON_ON | BUTTON_REPEAT:
142 used = true;
143 break;
144
145 case SYS_USB_CONNECTED:
146 usb_screen();
147 return 2;
148 }
149 }
150
151 if ( used )
152 return 1;
153 else
154 return 0;
155}
156
157bool f2_screen(void)
158{
159 bool exit = false;
160 bool used = false;
161 int w, h;
162 char buf[32];
163
164 /* Get the font height */
165 lcd_getstringsize("A",FONT_UI,&w,&h);
166
167 lcd_stop_scroll();
168
169 while (!exit) {
170 lcd_clear_display();
171
172 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE), FONT_UI);
173 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE), FONT_UI);
174 lcd_putsxy(0, LCD_HEIGHT/2,
175 global_settings.playlist_shuffle ?
176 str(LANG_ON) : str(LANG_OFF), FONT_UI);
177 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
178 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
179
180 snprintf(buf, sizeof buf, str(LANG_DIR_FILTER),
181 global_settings.mp3filter ? str(LANG_ON) : str(LANG_OFF));
182
183 /* Get the string width and height */
184 lcd_getstringsize(buf,FONT_UI,&w,&h);
185 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf, FONT_UI);
186 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
187 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
188
189 lcd_update();
190
191 switch (button_get(true)) {
192 case BUTTON_LEFT:
193 case BUTTON_F2 | BUTTON_LEFT:
194 global_settings.playlist_shuffle =
195 !global_settings.playlist_shuffle;
196
197 if (global_settings.playlist_shuffle)
198 randomise_playlist(current_tick);
199 else
200 sort_playlist(true);
201 used = true;
202 break;
203
204 case BUTTON_DOWN:
205 case BUTTON_F2 | BUTTON_DOWN:
206 global_settings.mp3filter = !global_settings.mp3filter;
207 used = true;
208 break;
209
210 case BUTTON_F2 | BUTTON_REL:
211 if ( used )
212 exit = true;
213 used = true;
214 break;
215
216 case SYS_USB_CONNECTED:
217 usb_screen();
218 return true;
219 }
220 }
221
222 settings_save();
223
224 return false;
225}
226
227bool f3_screen(void)
228{
229 bool exit = false;
230 bool used = false;
231
232 lcd_stop_scroll();
233
234 while (!exit) {
235 int w,h;
236 char* ptr;
237
238 ptr = str(LANG_F3_STATUS);
239 lcd_getstringsize(ptr,FONT_UI,&w,&h);
240 lcd_clear_display();
241
242 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_F3_SCROLL), FONT_UI);
243 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
244 lcd_putsxy(0, LCD_HEIGHT/2,
245 global_settings.scrollbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
246 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
247 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
248
249 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr, FONT_UI);
250 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
251 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2,
252 global_settings.statusbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
253 lcd_bitmap(bitmap_icons_7x8[Icon_FastForward],
254 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true);
255 lcd_update();
256
257 switch (button_get(true)) {
258 case BUTTON_LEFT:
259 case BUTTON_F3 | BUTTON_LEFT:
260 global_settings.scrollbar = !global_settings.scrollbar;
261 used = true;
262 break;
263
264 case BUTTON_RIGHT:
265 case BUTTON_F3 | BUTTON_RIGHT:
266 global_settings.statusbar = !global_settings.statusbar;
267 used = true;
268 break;
269
270 case BUTTON_F3 | BUTTON_REL:
271 if ( used )
272 exit = true;
273 used = true;
274 break;
275
276 case SYS_USB_CONNECTED:
277 usb_screen();
278 return true;
279 }
280 }
281
282 settings_save();
283 if (global_settings.statusbar)
284 lcd_setmargins(0, STATUSBAR_HEIGHT);
285 else
286 lcd_setmargins(0, 0);
287
288 return false;
289}
290#endif
291
292
diff --git a/apps/screens.h b/apps/screens.h
new file mode 100644
index 0000000000..22eebb8053
--- /dev/null
+++ b/apps/screens.h
@@ -0,0 +1,30 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 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#ifndef _SCREENS_H_
20#define _SCREENS_H_
21
22void usb_screen(void);
23
24#ifdef HAVE_RECORDER_KEYPAD
25int on_screen(void);
26bool f2_screen(void);
27bool f3_screen(void);
28#endif
29
30#endif
diff --git a/apps/settings.c b/apps/settings.c
index 61076836be..025a911557 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -38,6 +38,7 @@
38#include "powermgmt.h" 38#include "powermgmt.h"
39#include "status.h" 39#include "status.h"
40#include "atoi.h" 40#include "atoi.h"
41#include "screens.h"
41#ifdef HAVE_LCD_BITMAP 42#ifdef HAVE_LCD_BITMAP
42#include "icons.h" 43#include "icons.h"
43#include "font.h" 44#include "font.h"
@@ -476,84 +477,84 @@ bool settings_load_eq(char* file)
476 if (!strcasecmp(buf_set,"volume")) { 477 if (!strcasecmp(buf_set,"volume")) {
477 global_settings.volume = (atoi(buf_val)/2); 478 global_settings.volume = (atoi(buf_val)/2);
478 if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME) || 479 if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME) ||
479 global_settings.volume < mpeg_sound_min(SOUND_VOLUME)) { 480 global_settings.volume < mpeg_sound_min(SOUND_VOLUME)) {
480 global_settings.volume = mpeg_sound_default(SOUND_VOLUME); 481 global_settings.volume = mpeg_sound_default(SOUND_VOLUME);
481 syntax_error = true; 482 syntax_error = true;
482 } 483 }
483 mpeg_sound_set(SOUND_VOLUME, global_settings.volume); 484 mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
484 485
485 } else 486 } else
486 if (!strcasecmp(buf_set,"bass")) { 487 if (!strcasecmp(buf_set,"bass")) {
487 if (buf_val[0] == '-') 488 if (buf_val[0] == '-')
488 global_settings.bass = ((mpeg_sound_max(SOUND_BASS)/2)-atoi(buf_val+1)); 489 global_settings.bass = ((mpeg_sound_max(SOUND_BASS)/2)-atoi(buf_val+1));
489 else 490 else
490 global_settings.bass = (atoi(buf_val)+(mpeg_sound_max(SOUND_BASS)/2)); 491 global_settings.bass = (atoi(buf_val)+(mpeg_sound_max(SOUND_BASS)/2));
491 if (global_settings.bass > mpeg_sound_max(SOUND_BASS) || 492 if (global_settings.bass > mpeg_sound_max(SOUND_BASS) ||
492 global_settings.bass < mpeg_sound_min(SOUND_BASS)) { 493 global_settings.bass < mpeg_sound_min(SOUND_BASS)) {
493 global_settings.bass = mpeg_sound_default(SOUND_BASS); 494 global_settings.bass = mpeg_sound_default(SOUND_BASS);
494 syntax_error = true; 495 syntax_error = true;
495 } 496 }
496 mpeg_sound_set(SOUND_BASS, global_settings.bass); 497 mpeg_sound_set(SOUND_BASS, global_settings.bass);
497 } else 498 } else
498 if (!strcasecmp(buf_set,"treble")) { 499 if (!strcasecmp(buf_set,"treble")) {
499 if (buf_val[0] == '-') 500 if (buf_val[0] == '-')
500 global_settings.treble = ((mpeg_sound_max(SOUND_TREBLE)/2)-atoi(buf_val+1)); 501 global_settings.treble = ((mpeg_sound_max(SOUND_TREBLE)/2)-atoi(buf_val+1));
501 else 502 else
502 global_settings.treble = (atoi(buf_val)+(mpeg_sound_max(SOUND_TREBLE)/2)); 503 global_settings.treble = (atoi(buf_val)+(mpeg_sound_max(SOUND_TREBLE)/2));
503 if (global_settings.treble > mpeg_sound_max(SOUND_TREBLE) || 504 if (global_settings.treble > mpeg_sound_max(SOUND_TREBLE) ||
504 global_settings.treble < mpeg_sound_min(SOUND_TREBLE)) { 505 global_settings.treble < mpeg_sound_min(SOUND_TREBLE)) {
505 global_settings.treble = mpeg_sound_default(SOUND_TREBLE); 506 global_settings.treble = mpeg_sound_default(SOUND_TREBLE);
506 syntax_error = true; 507 syntax_error = true;
507 } 508 }
508 mpeg_sound_set(SOUND_TREBLE, global_settings.treble); 509 mpeg_sound_set(SOUND_TREBLE, global_settings.treble);
509 } else 510 } else
510 if (!strcasecmp(buf_set,"balance")) { 511 if (!strcasecmp(buf_set,"balance")) {
511 if (buf_val[0] == '-') 512 if (buf_val[0] == '-')
512 global_settings.balance = -(atoi(buf_val+1)/2); 513 global_settings.balance = -(atoi(buf_val+1)/2);
513 else 514 else
514 global_settings.balance = ((atoi(buf_val)/2)); 515 global_settings.balance = ((atoi(buf_val)/2));
515 if (global_settings.balance > mpeg_sound_max(SOUND_BALANCE) || 516 if (global_settings.balance > mpeg_sound_max(SOUND_BALANCE) ||
516 global_settings.balance < mpeg_sound_min(SOUND_BALANCE)) { 517 global_settings.balance < mpeg_sound_min(SOUND_BALANCE)) {
517 global_settings.balance = mpeg_sound_default(SOUND_BALANCE); 518 global_settings.balance = mpeg_sound_default(SOUND_BALANCE);
518 syntax_error = true; 519 syntax_error = true;
519 } 520 }
520 mpeg_sound_set(SOUND_BALANCE, global_settings.balance); 521 mpeg_sound_set(SOUND_BALANCE, global_settings.balance);
521 } else 522 } else
522 if (!strcasecmp(buf_set,"channels")) { 523 if (!strcasecmp(buf_set,"channels")) {
523 global_settings.channel_config = atoi(buf_val); 524 global_settings.channel_config = atoi(buf_val);
524 if (global_settings.channel_config > mpeg_sound_max(SOUND_CHANNELS) || 525 if (global_settings.channel_config > mpeg_sound_max(SOUND_CHANNELS) ||
525 global_settings.channel_config < mpeg_sound_min(SOUND_CHANNELS)) { 526 global_settings.channel_config < mpeg_sound_min(SOUND_CHANNELS)) {
526 global_settings.channel_config = mpeg_sound_default(SOUND_CHANNELS); 527 global_settings.channel_config = mpeg_sound_default(SOUND_CHANNELS);
527 syntax_error = true; 528 syntax_error = true;
528 } 529 }
529 mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config); 530 mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config);
530 } else 531 } else
531 if (!strcasecmp(buf_set,"loudness")) { 532 if (!strcasecmp(buf_set,"loudness")) {
532 global_settings.loudness = atoi(buf_val); 533 global_settings.loudness = atoi(buf_val);
533 if(global_settings.loudness > mpeg_sound_max(SOUND_LOUDNESS) || 534 if(global_settings.loudness > mpeg_sound_max(SOUND_LOUDNESS) ||
534 global_settings.loudness < mpeg_sound_min(SOUND_LOUDNESS)) { 535 global_settings.loudness < mpeg_sound_min(SOUND_LOUDNESS)) {
535 global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS); 536 global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS);
536 syntax_error = true; 537 syntax_error = true;
537 } 538 }
538 mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness); 539 mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness);
539 } else 540 } else
540 if (!strcasecmp(buf_set,"bass boost")) { 541 if (!strcasecmp(buf_set,"bass boost")) {
541 global_settings.bass_boost = (atoi(buf_val)/10); 542 global_settings.bass_boost = (atoi(buf_val)/10);
542 if(global_settings.bass_boost > mpeg_sound_max(SOUND_SUPERBASS) || 543 if(global_settings.bass_boost > mpeg_sound_max(SOUND_SUPERBASS) ||
543 global_settings.bass_boost < mpeg_sound_min(SOUND_SUPERBASS)) { 544 global_settings.bass_boost < mpeg_sound_min(SOUND_SUPERBASS)) {
544 global_settings.bass_boost = mpeg_sound_default(SOUND_SUPERBASS); 545 global_settings.bass_boost = mpeg_sound_default(SOUND_SUPERBASS);
545 syntax_error = true; 546 syntax_error = true;
546 } 547 }
547 mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost); 548 mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost);
548 } else if (!strcasecmp(buf_set,"auto volume")) { 549 } else if (!strcasecmp(buf_set,"auto volume")) {
549 global_settings.avc = atoi(buf_val); 550 global_settings.avc = atoi(buf_val);
550 if (global_settings.avc > mpeg_sound_max(SOUND_AVC) || 551 if (global_settings.avc > mpeg_sound_max(SOUND_AVC) ||
551 global_settings.avc < mpeg_sound_min(SOUND_AVC)) { 552 global_settings.avc < mpeg_sound_min(SOUND_AVC)) {
552 global_settings.avc = mpeg_sound_default(SOUND_AVC); 553 global_settings.avc = mpeg_sound_default(SOUND_AVC);
553 syntax_error = true; 554 syntax_error = true;
554 } 555 }
555 mpeg_sound_set(SOUND_AVC, global_settings.avc); 556 mpeg_sound_set(SOUND_AVC, global_settings.avc);
556 } 557 }
557 if (syntax_error) { 558 if (syntax_error) {
558 lcd_clear_display(); 559 lcd_clear_display();
559 lcd_puts(0,1,"SyntaxError"); 560 lcd_puts(0,1,"SyntaxError");
@@ -636,20 +637,24 @@ void settings_display(void)
636#endif 637#endif
637} 638}
638 639
639void set_bool(char* string, bool* variable ) 640bool set_bool(char* string, bool* variable )
640{ 641{
641 set_bool_options(string, variable, "yes", "no "); 642 return set_bool_options(string, variable, "yes", "no ");
642} 643}
643 644
644void set_bool_options(char* string, bool* variable, char* yes_str, char* no_str ) 645bool set_bool_options(char* string, bool* variable,
646 char* yes_str, char* no_str )
645{ 647{
646 char* names[] = { yes_str, no_str }; 648 char* names[] = { yes_str, no_str };
647 int value = !*variable; 649 int value = !*variable;
648 set_option(string, &value, names, 2, NULL); 650 bool result;
651
652 result = set_option(string, &value, names, 2, NULL);
649 *variable = !value; 653 *variable = !value;
654 return result;
650} 655}
651 656
652void set_int(char* string, 657bool set_int(char* string,
653 char* unit, 658 char* unit,
654 int* variable, 659 int* variable,
655 void (*function)(int), 660 void (*function)(int),
@@ -713,14 +718,20 @@ void set_int(char* string,
713#endif 718#endif
714 done = true; 719 done = true;
715 break; 720 break;
721
722 case SYS_USB_CONNECTED:
723 usb_screen();
724 return true;
716 } 725 }
717 if ( function && button != BUTTON_NONE) 726 if ( function && button != BUTTON_NONE)
718 function(*variable); 727 function(*variable);
719 } 728 }
720 lcd_stop_scroll(); 729 lcd_stop_scroll();
730
731 return false;
721} 732}
722 733
723void set_option(char* string, int* variable, char* options[], 734bool set_option(char* string, int* variable, char* options[],
724 int numoptions, void (*function)(int)) 735 int numoptions, void (*function)(int))
725{ 736{
726 bool done = false; 737 bool done = false;
@@ -778,12 +789,17 @@ void set_option(char* string, int* variable, char* options[],
778#endif 789#endif
779 done = true; 790 done = true;
780 break; 791 break;
792
793 case SYS_USB_CONNECTED:
794 usb_screen();
795 return true;
781 } 796 }
782 797
783 if ( function && button != BUTTON_NONE) 798 if ( function && button != BUTTON_NONE)
784 function(*variable); 799 function(*variable);
785 } 800 }
786 lcd_stop_scroll(); 801 lcd_stop_scroll();
802 return false;
787} 803}
788 804
789#ifdef HAVE_LCD_BITMAP 805#ifdef HAVE_LCD_BITMAP
@@ -797,7 +813,7 @@ char cursor[][3] = {{ 0, 8, 12}, {18, 8, 12}, {36, 8, 12},
797 {24, 16, 24}, {54, 16, 18}, {78, 16, 12}}; 813 {24, 16, 24}, {54, 16, 18}, {78, 16, 12}};
798char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 814char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
799 815
800void set_time(char* string, int timedate[]) 816bool set_time(char* string, int timedate[])
801{ 817{
802 bool done = false; 818 bool done = false;
803 int button; 819 int button;
@@ -999,9 +1015,13 @@ void set_time(char* string, int timedate[])
999#endif 1015#endif
1000 break; 1016 break;
1001#endif 1017#endif
1002 default: 1018
1003 break; 1019 case SYS_USB_CONNECTED:
1020 usb_screen();
1021 return true;
1004 } 1022 }
1005 } 1023 }
1024
1025 return false;
1006} 1026}
1007#endif 1027#endif
diff --git a/apps/settings.h b/apps/settings.h
index 374b6e476c..1539d6d2e3 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -112,19 +112,20 @@ void settings_reset(void);
112void settings_display(void); 112void settings_display(void);
113 113
114bool settings_load_eq(char* file); 114bool settings_load_eq(char* file);
115void set_bool_options(char* string, bool* variable, char* yes_str, char* no_str ); 115bool set_bool_options(char* string, bool* variable,
116 char* yes_str, char* no_str );
116 117
117void set_bool(char* string, bool* variable ); 118bool set_bool(char* string, bool* variable );
118void set_option(char* string, int* variable, char* options[], 119bool set_option(char* string, int* variable, char* options[],
119 int numoptions, void (*function)(int)); 120 int numoptions, void (*function)(int));
120void set_int(char* string, 121bool set_int(char* string,
121 char* unit, 122 char* unit,
122 int* variable, 123 int* variable,
123 void (*function)(int), 124 void (*function)(int),
124 int step, 125 int step,
125 int min, 126 int min,
126 int max ); 127 int max );
127void set_time(char* string, int timedate[]); 128bool set_time(char* string, int timedate[]);
128 129
129/* global settings */ 130/* global settings */
130extern struct user_settings global_settings; 131extern struct user_settings global_settings;
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 1e7f2f7808..41afc72468 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -38,99 +38,94 @@
38#include "ata.h" 38#include "ata.h"
39#include "lang.h" 39#include "lang.h"
40 40
41static Menu show_hidden_files(void) 41static bool show_hidden_files(void)
42{ 42{
43 set_bool_options( str(LANG_HIDDEN), &global_settings.show_hidden_files, 43 return set_bool_options( str(LANG_HIDDEN),
44 str(LANG_HIDDEN_SHOW), str(LANG_HIDDEN_HIDE) ); 44 &global_settings.show_hidden_files,
45 return MENU_OK; 45 str(LANG_HIDDEN_SHOW),
46 str(LANG_HIDDEN_HIDE) );
46} 47}
47 48
48static Menu contrast(void) 49static bool contrast(void)
49{ 50{
50 set_int( str(LANG_CONTRAST), "", &global_settings.contrast, 51 return set_int( str(LANG_CONTRAST), "", &global_settings.contrast,
51 lcd_set_contrast, 1, 0, MAX_CONTRAST_SETTING ); 52 lcd_set_contrast, 1, 0, MAX_CONTRAST_SETTING );
52 return MENU_OK;
53} 53}
54 54
55#ifndef HAVE_RECORDER_KEYPAD 55#ifndef HAVE_RECORDER_KEYPAD
56static Menu shuffle(void) 56static bool shuffle(void)
57{ 57{
58 set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle ); 58 return set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle );
59 return MENU_OK;
60} 59}
61#endif 60#endif
62 61
63static Menu play_selected(void) 62static bool play_selected(void)
64{ 63{
65 set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected ); 64 return set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected );
66 return MENU_OK;
67} 65}
68 66
69static Menu mp3_filter(void) 67static bool mp3_filter(void)
70{ 68{
71 set_bool( str(LANG_MP3FILTER), &global_settings.mp3filter ); 69 return set_bool( str(LANG_MP3FILTER), &global_settings.mp3filter );
72 return MENU_OK;
73} 70}
74 71
75static Menu sort_case(void) 72static bool sort_case(void)
76{ 73{
77 set_bool( str(LANG_SORT_CASE), &global_settings.sort_case ); 74 return set_bool( str(LANG_SORT_CASE), &global_settings.sort_case );
78 return MENU_OK;
79} 75}
80 76
81static Menu resume(void) 77static bool resume(void)
82{ 78{
83 char* names[] = { str(LANG_OFF), 79 char* names[] = { str(LANG_OFF),
84 str(LANG_RESUME_SETTING_ASK), 80 str(LANG_RESUME_SETTING_ASK),
85 str(LANG_ON) }; 81 str(LANG_ON) };
86 set_option( str(LANG_RESUME), &global_settings.resume, names, 3, NULL ); 82 return set_option( str(LANG_RESUME), &global_settings.resume,
87 return MENU_OK; 83 names, 3, NULL );
88} 84}
89 85
90static Menu backlight_timer(void) 86static bool backlight_timer(void)
91{ 87{
92 char* names[] = { str(LANG_OFF), str(LANG_ON), 88 char* names[] = { str(LANG_OFF), str(LANG_ON),
93 "1s ", "2s ", "3s ", "4s ", "5s ", 89 "1s ", "2s ", "3s ", "4s ", "5s ",
94 "6s ", "7s ", "8s ", "9s ", "10s", 90 "6s ", "7s ", "8s ", "9s ", "10s",
95 "15s", "20s", "25s", "30s", "45s", 91 "15s", "20s", "25s", "30s", "45s",
96 "60s", "90s"}; 92 "60s", "90s"};
97 set_option(str(LANG_BACKLIGHT), &global_settings.backlight, names, 19, 93 return set_option(str(LANG_BACKLIGHT), &global_settings.backlight,
98 backlight_time ); 94 names, 19, backlight_time );
99 return MENU_OK;
100} 95}
101 96
102static Menu poweroff_idle_timer(void) 97static bool poweroff_idle_timer(void)
103{ 98{
104 char* names[] = { str(LANG_OFF), 99 char* names[] = { str(LANG_OFF),
105 "1m ", "2m ", "3m ", "4m ", "5m ", 100 "1m ", "2m ", "3m ", "4m ", "5m ",
106 "6m ", "7m ", "8m ", "9m ", "10m", 101 "6m ", "7m ", "8m ", "9m ", "10m",
107 "15m", "30m", "45m", "60m"}; 102 "15m", "30m", "45m", "60m"};
108 set_option(str(LANG_POWEROFF_IDLE), &global_settings.poweroff, names, 103 return set_option(str(LANG_POWEROFF_IDLE), &global_settings.poweroff,
109 15, set_poweroff_timeout); 104 names, 15, set_poweroff_timeout);
110 return MENU_OK;
111} 105}
112 106
113static Menu scroll_speed(void) 107static bool scroll_speed(void)
114{ 108{
115 set_int(str(LANG_SCROLL), "", &global_settings.scroll_speed, 109 return set_int(str(LANG_SCROLL), "", &global_settings.scroll_speed,
116 &lcd_scroll_speed, 1, 1, 30 ); 110 &lcd_scroll_speed, 1, 1, 30 );
117 return MENU_OK;
118} 111}
119 112
120#ifdef HAVE_CHARGE_CTRL 113#ifdef HAVE_CHARGE_CTRL
121static Menu deep_discharge(void) 114static bool deep_discharge(void)
122{ 115{
123 set_bool( str(LANG_DISCHARGE), &global_settings.discharge ); 116 bool result;
117 result = set_bool( str(LANG_DISCHARGE), &global_settings.discharge );
124 charge_restart_level = global_settings.discharge ? 118 charge_restart_level = global_settings.discharge ?
125 CHARGE_RESTART_LO : CHARGE_RESTART_HI; 119 CHARGE_RESTART_LO : CHARGE_RESTART_HI;
126 return MENU_OK; 120 return result;
127} 121}
128#endif 122#endif
129 123
130#ifdef HAVE_LCD_BITMAP 124#ifdef HAVE_LCD_BITMAP
131static Menu timedate_set(void) 125static bool timedate_set(void)
132{ 126{
133 int timedate[7]; /* hour,minute,second,year,month,day,dayofweek */ 127 int timedate[7]; /* hour,minute,second,year,month,day,dayofweek */
128 bool result;
134 129
135#ifdef HAVE_RTC 130#ifdef HAVE_RTC
136 timedate[0] = rtc_read(0x03); /* hour */ 131 timedate[0] = rtc_read(0x03); /* hour */
@@ -167,7 +162,7 @@ static Menu timedate_set(void)
167 timedate[5] = 1; 162 timedate[5] = 1;
168#endif 163#endif
169 164
170 set_time(str(LANG_TIME),timedate); 165 result = set_time(str(LANG_TIME),timedate);
171 166
172#ifdef HAVE_RTC 167#ifdef HAVE_RTC
173 if(timedate[0] != -1) { 168 if(timedate[0] != -1) {
@@ -194,49 +189,45 @@ static Menu timedate_set(void)
194 rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */ 189 rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
195 } 190 }
196#endif 191#endif
197 return MENU_OK; 192 return result;
198} 193}
199#endif 194#endif
200 195
201static Menu spindown(void) 196static bool spindown(void)
202{ 197{
203 set_int(str(LANG_SPINDOWN), "s", &global_settings.disk_spindown, 198 return set_int(str(LANG_SPINDOWN), "s", &global_settings.disk_spindown,
204 ata_spindown, 1, 3, 254 ); 199 ata_spindown, 1, 3, 254 );
205 return MENU_OK;
206} 200}
207 201
208static Menu ff_rewind_min_step(void) 202static bool ff_rewind_min_step(void)
209{ 203{
210 char* names[] = { "1s", "2s", "3s", "4s", 204 char* names[] = { "1s", "2s", "3s", "4s",
211 "5s", "6s", "8s", "10s", 205 "5s", "6s", "8s", "10s",
212 "15s", "20s", "25s", "30s", 206 "15s", "20s", "25s", "30s",
213 "45s", "60s" }; 207 "45s", "60s" };
214 set_option(str(LANG_FFRW_STEP), &global_settings.ff_rewind_min_step, 208 return set_option(str(LANG_FFRW_STEP), &global_settings.ff_rewind_min_step,
215 names, 14, NULL ); 209 names, 14, NULL );
216 return MENU_OK;
217} 210}
218 211
219static Menu ff_rewind_accel(void) 212static bool ff_rewind_accel(void)
220{ 213{
221 char* names[] = { str(LANG_OFF), "2x/1s", "2x/2s", "2x/3s", 214 char* names[] = { str(LANG_OFF), "2x/1s", "2x/2s", "2x/3s",
222 "2x/4s", "2x/5s", "2x/6s", "2x/7s", 215 "2x/4s", "2x/5s", "2x/6s", "2x/7s",
223 "2x/8s", "2x/9s", "2x/10s", "2x/11s", 216 "2x/8s", "2x/9s", "2x/10s", "2x/11s",
224 "2x/12s", "2x/13s", "2x/14s", "2x/15s", }; 217 "2x/12s", "2x/13s", "2x/14s", "2x/15s", };
225 set_option(str(LANG_FFRW_ACCEL), &global_settings.ff_rewind_accel, 218 return set_option(str(LANG_FFRW_ACCEL), &global_settings.ff_rewind_accel,
226 names, 16, NULL ); 219 names, 16, NULL );
227 return MENU_OK;
228} 220}
229 221
230static Menu browse_current(void) 222static bool browse_current(void)
231{ 223{
232 set_bool( str(LANG_FOLLOW), &global_settings.browse_current ); 224 return set_bool( str(LANG_FOLLOW), &global_settings.browse_current );
233 return MENU_OK;
234} 225}
235 226
236Menu playback_settings_menu(void) 227static bool playback_settings_menu(void)
237{ 228{
238 int m; 229 int m;
239 Menu result; 230 bool result;
240 231
241 struct menu_items items[] = { 232 struct menu_items items[] = {
242#ifndef HAVE_RECORDER_KEYPAD 233#ifndef HAVE_RECORDER_KEYPAD
@@ -268,7 +259,7 @@ Menu playback_settings_menu(void)
268 return result; 259 return result;
269} 260}
270 261
271static Menu reset_settings(void) 262static bool reset_settings(void)
272{ 263{
273 int button = 0; 264 int button = 0;
274 265
@@ -300,10 +291,10 @@ static Menu reset_settings(void)
300 } 291 }
301} 292}
302 293
303static Menu fileview_settings_menu(void) 294static bool fileview_settings_menu(void)
304{ 295{
305 int m; 296 int m;
306 Menu result; 297 bool result;
307 298
308 struct menu_items items[] = { 299 struct menu_items items[] = {
309 { str(LANG_CASE_MENU), sort_case }, 300 { str(LANG_CASE_MENU), sort_case },
@@ -312,16 +303,16 @@ static Menu fileview_settings_menu(void)
312 { str(LANG_FOLLOW), browse_current }, 303 { str(LANG_FOLLOW), browse_current },
313 }; 304 };
314 305
315 m=menu_init( items, sizeof items / sizeof(struct menu_items) ); 306 m = menu_init( items, sizeof items / sizeof(struct menu_items) );
316 result = menu_run(m); 307 result = menu_run(m);
317 menu_exit(m); 308 menu_exit(m);
318 return result; 309 return result;
319} 310}
320 311
321static Menu display_settings_menu(void) 312static bool display_settings_menu(void)
322{ 313{
323 int m; 314 int m;
324 Menu result; 315 bool result;
325 316
326 struct menu_items items[] = { 317 struct menu_items items[] = {
327 { str(LANG_SCROLL_MENU), scroll_speed }, 318 { str(LANG_SCROLL_MENU), scroll_speed },
@@ -335,10 +326,10 @@ static Menu display_settings_menu(void)
335 return result; 326 return result;
336} 327}
337 328
338static Menu system_settings_menu(void) 329static bool system_settings_menu(void)
339{ 330{
340 int m; 331 int m;
341 Menu result; 332 bool result;
342 333
343 struct menu_items items[] = { 334 struct menu_items items[] = {
344 { str(LANG_SPINDOWN), spindown }, 335 { str(LANG_SPINDOWN), spindown },
@@ -358,10 +349,10 @@ static Menu system_settings_menu(void)
358 return result; 349 return result;
359} 350}
360 351
361Menu settings_menu(void) 352bool settings_menu(void)
362{ 353{
363 int m; 354 int m;
364 Menu result; 355 bool result;
365 356
366 struct menu_items items[] = { 357 struct menu_items items[] = {
367 { str(LANG_PLAYBACK), playback_settings_menu }, 358 { str(LANG_PLAYBACK), playback_settings_menu },
@@ -370,7 +361,7 @@ Menu settings_menu(void)
370 { str(LANG_SYSTEM), system_settings_menu }, 361 { str(LANG_SYSTEM), system_settings_menu },
371 }; 362 };
372 363
373 m=menu_init( items, sizeof items / sizeof(struct menu_items) ); 364 m = menu_init( items, sizeof items / sizeof(struct menu_items) );
374 result = menu_run(m); 365 result = menu_run(m);
375 menu_exit(m); 366 menu_exit(m);
376 return result; 367 return result;
diff --git a/apps/settings_menu.h b/apps/settings_menu.h
index 19cffaccae..8ed8149022 100644
--- a/apps/settings_menu.h
+++ b/apps/settings_menu.h
@@ -21,6 +21,6 @@
21 21
22#include "menu.h" 22#include "menu.h"
23 23
24Menu settings_menu(void); 24bool settings_menu(void);
25 25
26#endif 26#endif
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index c7d72cf553..2938e3a527 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -26,6 +26,7 @@
26#include "mpeg.h" 26#include "mpeg.h"
27#include "settings.h" 27#include "settings.h"
28#include "status.h" 28#include "status.h"
29#include "screens.h"
29#ifdef HAVE_LCD_BITMAP 30#ifdef HAVE_LCD_BITMAP
30#include "icons.h" 31#include "icons.h"
31#endif 32#endif
@@ -38,7 +39,7 @@ static char *fmt[] =
38 "%d.%02d %s " /* 2 decimals */ 39 "%d.%02d %s " /* 2 decimals */
39}; 40};
40 41
41void set_sound(char* string, 42bool set_sound(char* string,
42 int* variable, 43 int* variable,
43 int setting) 44 int setting)
44{ 45{
@@ -120,20 +121,10 @@ void set_sound(char* string,
120#endif 121#endif
121 done = true; 122 done = true;
122 break; 123 break;
123#ifdef HAVE_RECORDER_KEYPAD 124
124 case BUTTON_F3: 125 case SYS_USB_CONNECTED:
125#ifdef HAVE_LCD_BITMAP 126 usb_screen();
126 global_settings.statusbar = !global_settings.statusbar; 127 return true;
127 settings_save();
128 if(global_settings.statusbar)
129 lcd_setmargins(0, STATUSBAR_HEIGHT);
130 else
131 lcd_setmargins(0, 0);
132 lcd_clear_display();
133 lcd_puts_scroll(0, 0, string);
134#endif
135 break;
136#endif
137 } 128 }
138 if (changed) { 129 if (changed) {
139 mpeg_sound_set(setting, *variable); 130 mpeg_sound_set(setting, *variable);
@@ -144,43 +135,41 @@ void set_sound(char* string,
144 } 135 }
145 } 136 }
146 lcd_stop_scroll(); 137 lcd_stop_scroll();
138 return false;
147} 139}
148 140
149static Menu volume(void) 141static bool volume(void)
150{ 142{
151 set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME); 143 return set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME);
152 return MENU_OK;
153} 144}
154 145
155static Menu balance(void) 146static bool balance(void)
156{ 147{
157 set_sound(str(LANG_BALANCE), &global_settings.balance, SOUND_BALANCE); 148 return set_sound(str(LANG_BALANCE), &global_settings.balance,
158 return MENU_OK; 149 SOUND_BALANCE);
159} 150}
160 151
161static Menu bass(void) 152static bool bass(void)
162{ 153{
163 set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS); 154 return set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS);
164 return MENU_OK;
165}; 155};
166 156
167static Menu treble(void) 157static bool treble(void)
168{ 158{
169 set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE); 159 return set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE);
170 return MENU_OK;
171} 160}
172 161
173#ifdef HAVE_MAS3587F 162#ifdef HAVE_MAS3587F
174static Menu loudness(void) 163static bool loudness(void)
175{ 164{
176 set_sound(str(LANG_LOUDNESS), &global_settings.loudness, SOUND_LOUDNESS); 165 return set_sound(str(LANG_LOUDNESS), &global_settings.loudness,
177 return MENU_OK; 166 SOUND_LOUDNESS);
178}; 167};
179 168
180static Menu bass_boost(void) 169static bool bass_boost(void)
181{ 170{
182 set_sound(str(LANG_BBOOST), &global_settings.bass_boost, SOUND_SUPERBASS); 171 return set_sound(str(LANG_BBOOST), &global_settings.bass_boost,
183 return MENU_OK; 172 SOUND_SUPERBASS);
184}; 173};
185 174
186static void set_avc(int val) 175static void set_avc(int val)
@@ -188,11 +177,11 @@ static void set_avc(int val)
188 mpeg_sound_set(SOUND_AVC, val); 177 mpeg_sound_set(SOUND_AVC, val);
189} 178}
190 179
191static Menu avc(void) 180static bool avc(void)
192{ 181{
193 char* names[] = { str(LANG_OFF), "2s", "4s", "8s" }; 182 char* names[] = { str(LANG_OFF), "2s", "4s", "8s" };
194 set_option(str(LANG_DECAY), &global_settings.avc, names, 4, set_avc ); 183 return set_option(str(LANG_DECAY), &global_settings.avc,
195 return MENU_OK; 184 names, 4, set_avc);
196} 185}
197#endif /* ARCHOS_RECORDER */ 186#endif /* ARCHOS_RECORDER */
198 187
@@ -201,19 +190,18 @@ static void set_chanconf(int val)
201 mpeg_sound_set(SOUND_CHANNELS, val); 190 mpeg_sound_set(SOUND_CHANNELS, val);
202} 191}
203 192
204static Menu chanconf(void) 193static bool chanconf(void)
205{ 194{
206 char *names[] = {str(LANG_CHANNEL_STEREO), str(LANG_CHANNEL_MONO), 195 char *names[] = {str(LANG_CHANNEL_STEREO), str(LANG_CHANNEL_MONO),
207 str(LANG_CHANNEL_LEFT),str(LANG_CHANNEL_RIGHT) }; 196 str(LANG_CHANNEL_LEFT), str(LANG_CHANNEL_RIGHT) };
208 set_option(str(LANG_CHANNEL), 197 return set_option(str(LANG_CHANNEL), &global_settings.channel_config,
209 &global_settings.channel_config, names, 4, set_chanconf ); 198 names, 4, set_chanconf );
210 return MENU_OK;
211} 199}
212 200
213Menu sound_menu(void) 201bool sound_menu(void)
214{ 202{
215 int m; 203 int m;
216 Menu result; 204 bool result;
217 struct menu_items items[] = { 205 struct menu_items items[] = {
218 { str(LANG_VOLUME), volume }, 206 { str(LANG_VOLUME), volume },
219 { str(LANG_BASS), bass }, 207 { str(LANG_BASS), bass },
diff --git a/apps/sound_menu.h b/apps/sound_menu.h
index 27e9c5efa3..5063a288d9 100644
--- a/apps/sound_menu.h
+++ b/apps/sound_menu.h
@@ -21,6 +21,6 @@
21 21
22#include "menu.h" 22#include "menu.h"
23 23
24Menu sound_menu(void); 24bool sound_menu(void);
25 25
26#endif 26#endif
diff --git a/apps/tree.c b/apps/tree.c
index 3a6fcfeddc..ce27f7b235 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -47,6 +47,7 @@
47#include "icons.h" 47#include "icons.h"
48#include "lang.h" 48#include "lang.h"
49#include "language.h" 49#include "language.h"
50#include "screens.h"
50 51
51#ifdef HAVE_LCD_BITMAP 52#ifdef HAVE_LCD_BITMAP
52#include "widgets.h" 53#include "widgets.h"
@@ -880,7 +881,8 @@ bool dirbrowse(char *root)
880 881
881 case TREE_MENU: 882 case TREE_MENU:
882 lcd_stop_scroll(); 883 lcd_stop_scroll();
883 main_menu(); 884 if (main_menu())
885 reload_root = true;
884 restore = true; 886 restore = true;
885 break; 887 break;
886 888
@@ -915,24 +917,10 @@ bool dirbrowse(char *root)
915 break; 917 break;
916#endif 918#endif
917 919
918#ifndef SIMULATOR 920 case SYS_USB_CONNECTED:
919 case SYS_USB_CONNECTED: { 921 usb_screen();
920 backlight_time(4);
921
922 /* Tell the USB thread that we are safe */
923 DEBUGF("dirbrowse got SYS_USB_CONNECTED\n");
924 usb_acknowledge(SYS_USB_CONNECTED_ACK);
925
926 /* Wait until the USB cable is extracted again */
927 usb_wait_for_disconnect(&button_queue);
928
929 backlight_time(global_settings.backlight);
930
931 /* Force a re-read of the root directory */
932 reload_root = true; 922 reload_root = true;
933 } 923 break;
934 break;
935#endif
936 } 924 }
937 925
938 if ( button ) 926 if ( button )
diff --git a/apps/wps.c b/apps/wps.c
index be3f21193b..2729b288f3 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -37,6 +37,7 @@
37#include "status.h" 37#include "status.h"
38#include "main_menu.h" 38#include "main_menu.h"
39#include "ata.h" 39#include "ata.h"
40#include "screens.h"
40#ifdef HAVE_LCD_BITMAP 41#ifdef HAVE_LCD_BITMAP
41#include "icons.h" 42#include "icons.h"
42#endif 43#endif
@@ -151,22 +152,6 @@ void display_mute_text(bool muted)
151 sleep(HZ); 152 sleep(HZ);
152} 153}
153 154
154static void handle_usb(void)
155{
156#ifndef SIMULATOR
157 backlight_time(4);
158
159 /* Tell the USB thread that we are safe */
160 DEBUGF("wps got SYS_USB_CONNECTED\n");
161 usb_acknowledge(SYS_USB_CONNECTED_ACK);
162
163 /* Wait until the USB cable is extracted again */
164 usb_wait_for_disconnect(&button_queue);
165
166 backlight_time(global_settings.backlight);
167#endif
168}
169
170static int browse_id3(void) 155static int browse_id3(void)
171{ 156{
172 int button; 157 int button;
@@ -298,12 +283,10 @@ static int browse_id3(void)
298 exit = true; 283 exit = true;
299 break; 284 break;
300 285
301#ifndef SIMULATOR
302 case SYS_USB_CONNECTED: 286 case SYS_USB_CONNECTED:
303 handle_usb(); 287 usb_screen();
304 return SYS_USB_CONNECTED; 288 return SYS_USB_CONNECTED;
305 break; 289 break;
306#endif
307 } 290 }
308 } 291 }
309 return 0; 292 return 0;
@@ -413,7 +396,7 @@ static bool ffwd_rew(int button)
413 break; 396 break;
414 397
415 case SYS_USB_CONNECTED: 398 case SYS_USB_CONNECTED:
416 handle_usb(); 399 usb_screen();
417 usb = true; 400 usb = true;
418 exit = true; 401 exit = true;
419 break; 402 break;
@@ -488,7 +471,7 @@ static bool keylock(void)
488 break; 471 break;
489 472
490 case SYS_USB_CONNECTED: 473 case SYS_USB_CONNECTED:
491 handle_usb(); 474 usb_screen();
492 return true; 475 return true;
493 476
494 case BUTTON_NONE: 477 case BUTTON_NONE:
@@ -541,7 +524,8 @@ static bool menu(void)
541 if ( !last_button ) { 524 if ( !last_button ) {
542 lcd_stop_scroll(); 525 lcd_stop_scroll();
543 button_set_release(old_release_mask); 526 button_set_release(old_release_mask);
544 main_menu(); 527 if (main_menu())
528 return true;
545#ifdef HAVE_LCD_BITMAP 529#ifdef HAVE_LCD_BITMAP
546 if(global_settings.statusbar) 530 if(global_settings.statusbar)
547 lcd_setmargins(0, STATUSBAR_HEIGHT); 531 lcd_setmargins(0, STATUSBAR_HEIGHT);
@@ -608,7 +592,7 @@ static bool menu(void)
608 break; 592 break;
609 593
610 case SYS_USB_CONNECTED: 594 case SYS_USB_CONNECTED:
611 handle_usb(); 595 usb_screen();
612 return true; 596 return true;
613 } 597 }
614 last_button = button; 598 last_button = button;
@@ -623,260 +607,6 @@ static bool menu(void)
623 return false; 607 return false;
624} 608}
625 609
626#ifdef HAVE_LCD_BITMAP
627/* returns:
628 0 if no key was pressed
629 1 if a key was pressed (or if ON was held down long enough to repeat)
630 2 if USB was connected */
631int on_screen(void)
632{
633 static int pitch = 100;
634 bool exit = false;
635 bool used = false;
636
637 while (!exit) {
638
639 if ( used ) {
640 char* ptr;
641 char buf[32];
642 int w, h;
643
644 lcd_scroll_pause();
645 lcd_clear_display();
646
647 ptr = str(LANG_PITCH_UP);
648 lcd_getstringsize(ptr,FONT_UI,&w,&h);
649 lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr, FONT_UI);
650 lcd_bitmap(bitmap_icons_7x8[Icon_UpArrow],
651 LCD_WIDTH/2 - 3, h*2, 7, 8, true);
652
653 snprintf(buf, sizeof buf, "%d%%", pitch);
654 lcd_getstringsize(buf,FONT_UI,&w,&h);
655 lcd_putsxy((LCD_WIDTH-w)/2, h, buf, FONT_UI);
656
657 ptr = str(LANG_PITCH_DOWN);
658 lcd_getstringsize(ptr,FONT_UI,&w,&h);
659 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr, FONT_UI);
660 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
661 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
662
663 ptr = str(LANG_PAUSE);
664 lcd_getstringsize(ptr,FONT_UI,&w,&h);
665 lcd_putsxy((LCD_WIDTH-(w/2))/2, LCD_HEIGHT/2 - h/2, ptr, FONT_UI);
666 lcd_bitmap(bitmap_icons_7x8[Icon_Pause],
667 (LCD_WIDTH-(w/2))/2-10, LCD_HEIGHT/2 - h/2, 7, 8, true);
668
669 lcd_update();
670 }
671
672 /* use lastbutton, so the main loop can decide whether to
673 exit to browser or not */
674 switch (button_get(true)) {
675 case BUTTON_UP:
676 case BUTTON_ON | BUTTON_UP:
677 case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT:
678 used = true;
679 pitch++;
680 if ( pitch > 200 )
681 pitch = 200;
682#ifdef HAVE_MAS3587F
683 mpeg_set_pitch(pitch);
684#endif
685 break;
686
687 case BUTTON_DOWN:
688 case BUTTON_ON | BUTTON_DOWN:
689 case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT:
690 used = true;
691 pitch--;
692 if ( pitch < 50 )
693 pitch = 50;
694#ifdef HAVE_MAS3587F
695 mpeg_set_pitch(pitch);
696#endif
697 break;
698
699 case BUTTON_ON | BUTTON_PLAY:
700 mpeg_pause();
701 used = true;
702 break;
703
704 case BUTTON_PLAY | BUTTON_REL:
705 mpeg_resume();
706 used = true;
707 break;
708
709 case BUTTON_ON | BUTTON_PLAY | BUTTON_REL:
710 mpeg_resume();
711 exit = true;
712 break;
713
714#ifdef SIMULATOR
715 case BUTTON_ON:
716#else
717 case BUTTON_ON | BUTTON_REL:
718 case BUTTON_ON | BUTTON_UP | BUTTON_REL:
719 case BUTTON_ON | BUTTON_DOWN | BUTTON_REL:
720#endif
721 exit = true;
722 break;
723
724 case BUTTON_ON | BUTTON_REPEAT:
725 used = true;
726 break;
727
728#ifndef SIMULATOR
729 case SYS_USB_CONNECTED:
730 handle_usb();
731 return 2;
732#endif
733 }
734 }
735
736 if ( used )
737 return 1;
738 else
739 return 0;
740}
741
742bool f2_screen(void)
743{
744 bool exit = false;
745 bool used = false;
746 int w, h;
747 char buf[32];
748
749 /* Get the font height */
750 lcd_getstringsize("A",FONT_UI,&w,&h);
751
752 lcd_stop_scroll();
753
754 while (!exit) {
755 lcd_clear_display();
756
757 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE), FONT_UI);
758 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE), FONT_UI);
759 lcd_putsxy(0, LCD_HEIGHT/2,
760 global_settings.playlist_shuffle ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
761 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
762 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
763
764 snprintf(buf, sizeof buf, str(LANG_DIR_FILTER),
765 global_settings.mp3filter ? str(LANG_ON) : str(LANG_OFF));
766
767 /* Get the string width and height */
768 lcd_getstringsize(buf,FONT_UI,&w,&h);
769 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf, FONT_UI);
770 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
771 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
772
773 lcd_update();
774
775 switch (button_get(true)) {
776 case BUTTON_LEFT:
777 case BUTTON_F2 | BUTTON_LEFT:
778 global_settings.playlist_shuffle =
779 !global_settings.playlist_shuffle;
780
781 if (global_settings.playlist_shuffle)
782 randomise_playlist(current_tick);
783 else
784 sort_playlist(true);
785 used = true;
786 break;
787
788 case BUTTON_DOWN:
789 case BUTTON_F2 | BUTTON_DOWN:
790 global_settings.mp3filter = !global_settings.mp3filter;
791 used = true;
792 break;
793
794 case BUTTON_F2 | BUTTON_REL:
795 if ( used )
796 exit = true;
797 used = true;
798 break;
799
800#ifndef SIMULATOR
801 case SYS_USB_CONNECTED:
802 handle_usb();
803 return true;
804#endif
805 }
806 }
807
808 settings_save();
809
810 return false;
811}
812
813bool f3_screen(void)
814{
815 bool exit = false;
816 bool used = false;
817
818 lcd_stop_scroll();
819
820 while (!exit) {
821 int w,h;
822 char* ptr;
823
824 ptr = str(LANG_F3_STATUS);
825 lcd_getstringsize(ptr,FONT_UI,&w,&h);
826 lcd_clear_display();
827
828 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_F3_SCROLL), FONT_UI);
829 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
830 lcd_putsxy(0, LCD_HEIGHT/2,
831 global_settings.scrollbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
832 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
833 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
834
835 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr, FONT_UI);
836 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
837 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2,
838 global_settings.statusbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
839 lcd_bitmap(bitmap_icons_7x8[Icon_FastForward],
840 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true);
841 lcd_update();
842
843 switch (button_get(true)) {
844 case BUTTON_LEFT:
845 case BUTTON_F3 | BUTTON_LEFT:
846 global_settings.scrollbar = !global_settings.scrollbar;
847 used = true;
848 break;
849
850 case BUTTON_RIGHT:
851 case BUTTON_F3 | BUTTON_RIGHT:
852 global_settings.statusbar = !global_settings.statusbar;
853 used = true;
854 break;
855
856 case BUTTON_F3 | BUTTON_REL:
857 if ( used )
858 exit = true;
859 used = true;
860 break;
861
862#ifndef SIMULATOR
863 case SYS_USB_CONNECTED:
864 handle_usb();
865 return true;
866#endif
867 }
868 }
869
870 settings_save();
871 if (global_settings.statusbar)
872 lcd_setmargins(0, STATUSBAR_HEIGHT);
873 else
874 lcd_setmargins(0, 0);
875
876 return false;
877}
878#endif
879
880/* demonstrates showing different formats from playtune */ 610/* demonstrates showing different formats from playtune */
881int wps_show(void) 611int wps_show(void)
882{ 612{
@@ -1088,11 +818,9 @@ int wps_show(void)
1088 button_set_release(old_release_mask); 818 button_set_release(old_release_mask);
1089 return 0; 819 return 0;
1090 820
1091#ifndef SIMULATOR
1092 case SYS_USB_CONNECTED: 821 case SYS_USB_CONNECTED:
1093 handle_usb(); 822 usb_screen();
1094 return SYS_USB_CONNECTED; 823 return SYS_USB_CONNECTED;
1095#endif
1096 824
1097 case BUTTON_NONE: /* Timeout */ 825 case BUTTON_NONE: /* Timeout */
1098 update(); 826 update();
diff --git a/apps/wps.h b/apps/wps.h
index 46ec7243d1..0c95796f06 100644
--- a/apps/wps.h
+++ b/apps/wps.h
@@ -29,6 +29,7 @@ int wps_show(void);
29bool load_custom_wps(void); 29bool load_custom_wps(void);
30bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string); 30bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string);
31bool refresh_wps(bool refresh_scroll); 31bool refresh_wps(bool refresh_scroll);
32void handle_usb(void);
32 33
33#ifdef HAVE_RECORDER_KEYPAD 34#ifdef HAVE_RECORDER_KEYPAD
34bool f2_screen(void); 35bool f2_screen(void);
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile
index 226bab10ef..2dc45ebdc5 100644
--- a/uisimulator/win32/Makefile
+++ b/uisimulator/win32/Makefile
@@ -66,7 +66,8 @@ FIRMSRCS = lcd-recorder.c power.c sprintf.c id3.c usb.c \
66 mpeg.c powermgmt.c font.c sysfont.c 66 mpeg.c powermgmt.c font.c sysfont.c
67 67
68APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \ 68APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \
69 playlist.c showtext.c wps.c wps-display.c settings.c status.c 69 playlist.c showtext.c wps.c wps-display.c settings.c status.c \
70 screens.c
70 71
71MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c 72MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c
72 73
@@ -197,6 +198,9 @@ $(OBJDIR)/sysfont.o: $(FIRMWAREDIR)/fonts/clR6x8.bdf
197$(OBJDIR)/status.o: $(APPDIR)/status.c 198$(OBJDIR)/status.o: $(APPDIR)/status.c
198 $(CC) $(APPCFLAGS) -c $< -o $@ 199 $(CC) $(APPCFLAGS) -c $< -o $@
199 200
201$(OBJDIR)/screens.o: $(APPDIR)/screens.c
202 $(CC) $(APPCFLAGS) -c $< -o $@
203
200$(OBJDIR)/version.o: $(FIRMWAREDIR)/version.c 204$(OBJDIR)/version.o: $(FIRMWAREDIR)/version.c
201 $(CC) $(CFLAGS) -c $< -o $@ 205 $(CC) $(CFLAGS) -c $< -o $@
202 206
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile
index 7ad005838d..fa65130555 100644
--- a/uisimulator/x11/Makefile
+++ b/uisimulator/x11/Makefile
@@ -81,7 +81,8 @@ FIRMSRCS = lcd-recorder.c sprintf.c id3.c debug.c usb.c mpeg.c power.c\
81 powermgmt.c font.c panic.c sysfont.c 81 powermgmt.c font.c panic.c sysfont.c
82 82
83APPS = main.c tree.c menu.c credits.c main_menu.c language.c\ 83APPS = main.c tree.c menu.c credits.c main_menu.c language.c\
84 playlist.c showtext.c wps.c wps-display.c settings.c status.c icons.c 84 playlist.c showtext.c wps.c wps-display.c settings.c status.c icons.c\
85 screens.c
85 86
86MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c 87MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c
87 88
@@ -237,6 +238,9 @@ $(OBJDIR)/settings.o: $(APPDIR)/settings.c
237$(OBJDIR)/status.o: $(APPDIR)/status.c 238$(OBJDIR)/status.o: $(APPDIR)/status.c
238 $(CC) $(APPCFLAGS) -c $< -o $@ 239 $(CC) $(APPCFLAGS) -c $< -o $@
239 240
241$(OBJDIR)/screens.o: $(APPDIR)/screens.c
242 $(CC) $(APPCFLAGS) -c $< -o $@
243
240$(OBJDIR)/id3.o: $(FIRMWAREDIR)/id3.c 244$(OBJDIR)/id3.o: $(FIRMWAREDIR)/id3.c
241 $(CC) $(APPCFLAGS) -c $< -o $@ 245 $(CC) $(APPCFLAGS) -c $< -o $@
242 246