diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-09-24 17:22:12 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-09-24 17:22:12 +0000 |
commit | b1b8bd4dd159e90f9e197c8870953da079162639 (patch) | |
tree | 27238f1b5a1535de0604e423ca91236bb3e2f833 /apps/wps.c | |
parent | c909b4b42e88a8e797e58a5e3e5ecf3716ae4783 (diff) | |
download | rockbox-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
Diffstat (limited to 'apps/wps.c')
-rw-r--r-- | apps/wps.c | 288 |
1 files changed, 8 insertions, 280 deletions
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 @@ #include "status.h" #include "main_menu.h" #include "ata.h" +#include "screens.h" #ifdef HAVE_LCD_BITMAP #include "icons.h" #endif @@ -151,22 +152,6 @@ void display_mute_text(bool muted) sleep(HZ); } -static void handle_usb(void) -{ -#ifndef SIMULATOR - backlight_time(4); - - /* Tell the USB thread that we are safe */ - DEBUGF("wps got SYS_USB_CONNECTED\n"); - usb_acknowledge(SYS_USB_CONNECTED_ACK); - - /* Wait until the USB cable is extracted again */ - usb_wait_for_disconnect(&button_queue); - - backlight_time(global_settings.backlight); -#endif -} - static int browse_id3(void) { int button; @@ -298,12 +283,10 @@ static int browse_id3(void) exit = true; break; -#ifndef SIMULATOR case SYS_USB_CONNECTED: - handle_usb(); + usb_screen(); return SYS_USB_CONNECTED; break; -#endif } } return 0; @@ -413,7 +396,7 @@ static bool ffwd_rew(int button) break; case SYS_USB_CONNECTED: - handle_usb(); + usb_screen(); usb = true; exit = true; break; @@ -488,7 +471,7 @@ static bool keylock(void) break; case SYS_USB_CONNECTED: - handle_usb(); + usb_screen(); return true; case BUTTON_NONE: @@ -541,7 +524,8 @@ static bool menu(void) if ( !last_button ) { lcd_stop_scroll(); button_set_release(old_release_mask); - main_menu(); + if (main_menu()) + return true; #ifdef HAVE_LCD_BITMAP if(global_settings.statusbar) lcd_setmargins(0, STATUSBAR_HEIGHT); @@ -608,7 +592,7 @@ static bool menu(void) break; case SYS_USB_CONNECTED: - handle_usb(); + usb_screen(); return true; } last_button = button; @@ -623,260 +607,6 @@ static bool menu(void) return false; } -#ifdef HAVE_LCD_BITMAP -/* returns: - 0 if no key was pressed - 1 if a key was pressed (or if ON was held down long enough to repeat) - 2 if USB was connected */ -int on_screen(void) -{ - static int pitch = 100; - bool exit = false; - bool used = false; - - while (!exit) { - - if ( used ) { - char* ptr; - char buf[32]; - int w, h; - - lcd_scroll_pause(); - lcd_clear_display(); - - ptr = str(LANG_PITCH_UP); - lcd_getstringsize(ptr,FONT_UI,&w,&h); - lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr, FONT_UI); - lcd_bitmap(bitmap_icons_7x8[Icon_UpArrow], - LCD_WIDTH/2 - 3, h*2, 7, 8, true); - - snprintf(buf, sizeof buf, "%d%%", pitch); - lcd_getstringsize(buf,FONT_UI,&w,&h); - lcd_putsxy((LCD_WIDTH-w)/2, h, buf, FONT_UI); - - ptr = str(LANG_PITCH_DOWN); - lcd_getstringsize(ptr,FONT_UI,&w,&h); - lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr, FONT_UI); - lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow], - LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true); - - ptr = str(LANG_PAUSE); - lcd_getstringsize(ptr,FONT_UI,&w,&h); - lcd_putsxy((LCD_WIDTH-(w/2))/2, LCD_HEIGHT/2 - h/2, ptr, FONT_UI); - lcd_bitmap(bitmap_icons_7x8[Icon_Pause], - (LCD_WIDTH-(w/2))/2-10, LCD_HEIGHT/2 - h/2, 7, 8, true); - - lcd_update(); - } - - /* use lastbutton, so the main loop can decide whether to - exit to browser or not */ - switch (button_get(true)) { - case BUTTON_UP: - case BUTTON_ON | BUTTON_UP: - case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT: - used = true; - pitch++; - if ( pitch > 200 ) - pitch = 200; -#ifdef HAVE_MAS3587F - mpeg_set_pitch(pitch); -#endif - break; - - case BUTTON_DOWN: - case BUTTON_ON | BUTTON_DOWN: - case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT: - used = true; - pitch--; - if ( pitch < 50 ) - pitch = 50; -#ifdef HAVE_MAS3587F - mpeg_set_pitch(pitch); -#endif - break; - - case BUTTON_ON | BUTTON_PLAY: - mpeg_pause(); - used = true; - break; - - case BUTTON_PLAY | BUTTON_REL: - mpeg_resume(); - used = true; - break; - - case BUTTON_ON | BUTTON_PLAY | BUTTON_REL: - mpeg_resume(); - exit = true; - break; - -#ifdef SIMULATOR - case BUTTON_ON: -#else - case BUTTON_ON | BUTTON_REL: - case BUTTON_ON | BUTTON_UP | BUTTON_REL: - case BUTTON_ON | BUTTON_DOWN | BUTTON_REL: -#endif - exit = true; - break; - - case BUTTON_ON | BUTTON_REPEAT: - used = true; - break; - -#ifndef SIMULATOR - case SYS_USB_CONNECTED: - handle_usb(); - return 2; -#endif - } - } - - if ( used ) - return 1; - else - return 0; -} - -bool f2_screen(void) -{ - bool exit = false; - bool used = false; - int w, h; - char buf[32]; - - /* Get the font height */ - lcd_getstringsize("A",FONT_UI,&w,&h); - - lcd_stop_scroll(); - - while (!exit) { - lcd_clear_display(); - - lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE), FONT_UI); - lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE), FONT_UI); - lcd_putsxy(0, LCD_HEIGHT/2, - global_settings.playlist_shuffle ? str(LANG_ON) : str(LANG_OFF), FONT_UI); - lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward], - LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true); - - snprintf(buf, sizeof buf, str(LANG_DIR_FILTER), - global_settings.mp3filter ? str(LANG_ON) : str(LANG_OFF)); - - /* Get the string width and height */ - lcd_getstringsize(buf,FONT_UI,&w,&h); - lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf, FONT_UI); - lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow], - LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true); - - lcd_update(); - - switch (button_get(true)) { - case BUTTON_LEFT: - case BUTTON_F2 | BUTTON_LEFT: - global_settings.playlist_shuffle = - !global_settings.playlist_shuffle; - - if (global_settings.playlist_shuffle) - randomise_playlist(current_tick); - else - sort_playlist(true); - used = true; - break; - - case BUTTON_DOWN: - case BUTTON_F2 | BUTTON_DOWN: - global_settings.mp3filter = !global_settings.mp3filter; - used = true; - break; - - case BUTTON_F2 | BUTTON_REL: - if ( used ) - exit = true; - used = true; - break; - -#ifndef SIMULATOR - case SYS_USB_CONNECTED: - handle_usb(); - return true; -#endif - } - } - - settings_save(); - - return false; -} - -bool f3_screen(void) -{ - bool exit = false; - bool used = false; - - lcd_stop_scroll(); - - while (!exit) { - int w,h; - char* ptr; - - ptr = str(LANG_F3_STATUS); - lcd_getstringsize(ptr,FONT_UI,&w,&h); - lcd_clear_display(); - - lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_F3_SCROLL), FONT_UI); - lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI); - lcd_putsxy(0, LCD_HEIGHT/2, - global_settings.scrollbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI); - lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward], - LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true); - - lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr, FONT_UI); - lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI); - lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, - global_settings.statusbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI); - lcd_bitmap(bitmap_icons_7x8[Icon_FastForward], - LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true); - lcd_update(); - - switch (button_get(true)) { - case BUTTON_LEFT: - case BUTTON_F3 | BUTTON_LEFT: - global_settings.scrollbar = !global_settings.scrollbar; - used = true; - break; - - case BUTTON_RIGHT: - case BUTTON_F3 | BUTTON_RIGHT: - global_settings.statusbar = !global_settings.statusbar; - used = true; - break; - - case BUTTON_F3 | BUTTON_REL: - if ( used ) - exit = true; - used = true; - break; - -#ifndef SIMULATOR - case SYS_USB_CONNECTED: - handle_usb(); - return true; -#endif - } - } - - settings_save(); - if (global_settings.statusbar) - lcd_setmargins(0, STATUSBAR_HEIGHT); - else - lcd_setmargins(0, 0); - - return false; -} -#endif - /* demonstrates showing different formats from playtune */ int wps_show(void) { @@ -1088,11 +818,9 @@ int wps_show(void) button_set_release(old_release_mask); return 0; -#ifndef SIMULATOR case SYS_USB_CONNECTED: - handle_usb(); + usb_screen(); return SYS_USB_CONNECTED; -#endif case BUTTON_NONE: /* Timeout */ update(); |