diff options
Diffstat (limited to 'apps/gui/wps.c')
-rw-r--r-- | apps/gui/wps.c | 580 |
1 files changed, 319 insertions, 261 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c index cdb34ab447..260730c4a1 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -53,6 +53,7 @@ #include "root_menu.h" #include "backdrop.h" #include "quickscreen.h" +#include "shortcuts.h" #include "pitchscreen.h" #include "appevents.h" #include "viewport.h" @@ -61,14 +62,15 @@ #include "playlist_viewer.h" #include "wps.h" #include "statusbar-skinned.h" - -#define RESTORE_WPS_INSTANTLY 0l -#define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick)) +#include "skin_engine/wps_internals.h" +#include "open_plugin.h" #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ /* 3% of 30min file == 54s step size */ #define MIN_FF_REWIND_STEP 500 +static struct wps_state wps_state; + /* initial setup of wps_data */ static void wps_state_init(void); static void track_info_callback(unsigned short id, void *param); @@ -114,7 +116,7 @@ static void update_non_static(void) skin_update(WPS, i, SKIN_REFRESH_NON_STATIC); } -void pause_action(bool may_fade, bool updatewps) +void pause_action(bool updatewps) { /* Do audio first, then update, unless skin were to use its local status in which case, reverse it */ @@ -131,11 +133,9 @@ void pause_action(bool may_fade, bool updatewps) - global_settings.pause_rewind * 1000; audio_ff_rewind(newpos > 0 ? newpos : 0); } - - (void)may_fade; } -void unpause_action(bool may_fade, bool updatewps) +void unpause_action(bool updatewps) { /* Do audio first, then update, unless skin were to use its local status in which case, reverse it */ @@ -143,24 +143,15 @@ void unpause_action(bool may_fade, bool updatewps) if (updatewps) update_non_static(); - - (void)may_fade; -} - -static bool update_onvol_change(enum screen_type screen) -{ - skin_update(WPS, screen, SKIN_REFRESH_NON_STATIC); - - return false; } - #ifdef HAVE_TOUCHSCREEN -static int skintouch_to_wps(struct wps_data *data) +static int skintouch_to_wps(void) { int offset = 0; - struct touchregion *region; - int button = skin_get_touchaction(data, &offset, ®ion); + struct wps_state *gstate = get_wps_state(); + struct gui_wps *gwps = skin_get_gwps(WPS, SCREEN_MAIN); + int button = skin_get_touchaction(gwps, &offset); switch (button) { case ACTION_STD_PREV: @@ -182,17 +173,17 @@ static int skintouch_to_wps(struct wps_data *data) return ACTION_WPS_HOTKEY; #endif case ACTION_TOUCH_SCROLLBAR: - skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/1000; + gstate->id3->elapsed = gstate->id3->length*offset/1000; audio_pre_ff_rewind(); - audio_ff_rewind(skin_get_global_state()->id3->elapsed); + audio_ff_rewind(gstate->id3->elapsed); return ACTION_TOUCHSCREEN; case ACTION_TOUCH_VOLUME: { const int min_vol = sound_min(SOUND_VOLUME); const int max_vol = sound_max(SOUND_VOLUME); const int step_vol = sound_steps(SOUND_VOLUME); - global_settings.volume = (offset * (max_vol - min_vol)) / 1000; - global_settings.volume += min_vol; + + global_settings.volume = from_normalized_volume(offset, min_vol, max_vol, 1000); global_settings.volume -= (global_settings.volume % step_vol); setvol(); } @@ -202,7 +193,7 @@ static int skintouch_to_wps(struct wps_data *data) } #endif /* HAVE_TOUCHSCREEN */ -bool ffwd_rew(int button) +static bool ffwd_rew(int button, bool seek_from_end) { unsigned int step = 0; /* current ff/rewind step */ unsigned int max_step = 0; /* maximum ff/rewind step */ @@ -210,7 +201,10 @@ bool ffwd_rew(int button) int direction = -1; /* forward=1 or backward=-1 */ bool exit = false; bool usb = false; + bool ff_rewind = false; const long ff_rw_accel = (global_settings.ff_rewind_accel + 3); + struct wps_state *gstate = get_wps_state(); + struct mp3entry *old_id3 = gstate->id3; if (button == ACTION_NONE) { @@ -219,27 +213,37 @@ bool ffwd_rew(int button) } while (!exit) { + struct mp3entry *id3 = gstate->id3; + if (id3 != old_id3) + { + ff_rewind = false; + ff_rewind_count = 0; + old_id3 = id3; + } + if (id3 && seek_from_end) + id3->elapsed = id3->length; + switch ( button ) { case ACTION_WPS_SEEKFWD: direction = 1; /* Fallthrough */ case ACTION_WPS_SEEKBACK: - if (skin_get_global_state()->ff_rewind) + if (ff_rewind) { if (direction == 1) { /* fast forwarding, calc max step relative to end */ - max_step = (skin_get_global_state()->id3->length - - (skin_get_global_state()->id3->elapsed + + max_step = (id3->length - + (id3->elapsed + ff_rewind_count)) * FF_REWIND_MAX_PERCENT / 100; } else { /* rewinding, calc max step relative to start */ - max_step = (skin_get_global_state()->id3->elapsed + ff_rewind_count) * - FF_REWIND_MAX_PERCENT / 100; + max_step = (id3->elapsed + ff_rewind_count) * + FF_REWIND_MAX_PERCENT / 100; } max_step = MAX(max_step, MIN_FF_REWIND_STEP); @@ -254,8 +258,7 @@ bool ffwd_rew(int button) } else { - if ( (audio_status() & AUDIO_STATUS_PLAY) && - skin_get_global_state()->id3 && skin_get_global_state()->id3->length ) + if ((audio_status() & AUDIO_STATUS_PLAY) && id3 && id3->length ) { audio_pre_ff_rewind(); if (direction > 0) @@ -263,7 +266,7 @@ bool ffwd_rew(int button) else status_set_ffmode(STATUS_FASTBACKWARD); - skin_get_global_state()->ff_rewind = true; + ff_rewind = true; step = 1000 * global_settings.ff_rewind_min_step; } @@ -272,19 +275,17 @@ bool ffwd_rew(int button) } if (direction > 0) { - if ((skin_get_global_state()->id3->elapsed + ff_rewind_count) > - skin_get_global_state()->id3->length) - ff_rewind_count = skin_get_global_state()->id3->length - - skin_get_global_state()->id3->elapsed; + if ((id3->elapsed + ff_rewind_count) > id3->length) + ff_rewind_count = id3->length - id3->elapsed; } else { - if ((int)(skin_get_global_state()->id3->elapsed + ff_rewind_count) < 0) - ff_rewind_count = -skin_get_global_state()->id3->elapsed; + if ((int)(id3->elapsed + ff_rewind_count) < 0) + ff_rewind_count = -id3->elapsed; } /* set the wps state ff_rewind_count so the progess info displays corectly */ - skin_get_global_state()->ff_rewind_count = ff_rewind_count; + gstate->ff_rewind_count = ff_rewind_count; FOR_NB_SCREENS(i) { @@ -296,10 +297,10 @@ bool ffwd_rew(int button) break; case ACTION_WPS_STOPSEEK: - skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->elapsed+ff_rewind_count; - audio_ff_rewind(skin_get_global_state()->id3->elapsed); - skin_get_global_state()->ff_rewind_count = 0; - skin_get_global_state()->ff_rewind = false; + id3->elapsed = id3->elapsed + ff_rewind_count; + audio_ff_rewind(id3->elapsed); + gstate->ff_rewind_count = 0; + ff_rewind = false; status_set_ffmode(0); exit = true; break; @@ -317,20 +318,21 @@ bool ffwd_rew(int button) button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK); #ifdef HAVE_TOUCHSCREEN if (button == ACTION_TOUCHSCREEN) - button = skintouch_to_wps(skin_get_gwps(WPS, SCREEN_MAIN)->data); + button = skintouch_to_wps(); #endif - if (button != ACTION_WPS_SEEKFWD && - button != ACTION_WPS_SEEKBACK) + if (button != ACTION_WPS_SEEKFWD + && button != ACTION_WPS_SEEKBACK + && button != 0 && !IS_SYSEVENT(button)) button = ACTION_WPS_STOPSEEK; } } return usb; } -#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) static void gwps_caption_backlight(struct wps_state *state) { - if (state && state->id3) +#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) + if (state->id3) { #ifdef HAVE_BACKLIGHT if (global_settings.caption_backlight) @@ -366,9 +368,10 @@ static void gwps_caption_backlight(struct wps_state *state) } #endif } +#else + (void) state; +#endif /* def HAVE_BACKLIGHT || def HAVE_REMOTE_LCD */ } -#endif - static void change_dir(int direction) { @@ -385,7 +388,7 @@ static void change_dir(int direction) static void prev_track(unsigned long skip_thresh) { - struct wps_state *state = skin_get_global_state(); + struct wps_state *state = get_wps_state(); if (state->id3->elapsed < skip_thresh) { audio_prev(); @@ -406,7 +409,7 @@ static void prev_track(unsigned long skip_thresh) static void next_track(void) { - struct wps_state *state = skin_get_global_state(); + struct wps_state *state = get_wps_state(); /* take care of if we're playing a cuesheet */ if (state->id3->cuesheet) { @@ -423,7 +426,7 @@ static void next_track(void) static void play_hop(int direction) { - struct wps_state *state = skin_get_global_state(); + struct wps_state *state = get_wps_state(); struct cuesheet *cue = state->id3->cuesheet; long step = global_settings.skip_length*1000; long elapsed = state->id3->elapsed; @@ -442,26 +445,40 @@ static void play_hop(int direction) { if (direction < 0) { - prev_track(DEFAULT_SKIP_TRESH); + prev_track(DEFAULT_SKIP_THRESH); return; } - else if (remaining < DEFAULT_SKIP_TRESH*2) + else if (remaining < DEFAULT_SKIP_THRESH*2) { next_track(); return; } else - elapsed += (remaining - DEFAULT_SKIP_TRESH*2); + elapsed += (remaining - DEFAULT_SKIP_THRESH*2); } else if (!global_settings.prevent_skip && (!step || (direction > 0 && step >= remaining) || - (direction < 0 && elapsed < DEFAULT_SKIP_TRESH))) + (direction < 0 && elapsed < DEFAULT_SKIP_THRESH))) { /* Do normal track skipping */ if (direction > 0) next_track(); else if (direction < 0) - prev_track(DEFAULT_SKIP_TRESH); + { + if (step > 0 && global_settings.rewind_across_tracks && elapsed < DEFAULT_SKIP_THRESH && playlist_check(-1)) + { + bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; + if (!audio_paused) + audio_pause(); + audio_prev(); + audio_ff_rewind(-step); + if (!audio_paused) + audio_resume(); + return; + } + + prev_track(DEFAULT_SKIP_THRESH); + } return; } else if (direction == 1 && step >= remaining) @@ -485,7 +502,6 @@ static void play_hop(int direction) audio_ff_rewind(elapsed); } - #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) /* * If the user is unable to see the wps, because the display is deactivated, @@ -502,16 +518,19 @@ static void wps_lcd_activation_hook(unsigned short id, void *param) } #endif -static void gwps_leave_wps(void) +static void gwps_leave_wps(bool theme_enabled) { FOR_NB_SCREENS(i) { - skin_get_gwps(WPS, i)->display->scroll_stop(); + struct gui_wps *gwps = skin_get_gwps(WPS, i); + gwps->display->scroll_stop(); + if (theme_enabled) + { #ifdef HAVE_BACKDROP_IMAGE - skin_backdrop_show(sb_get_backdrop(i)); + skin_backdrop_show(sb_get_backdrop(i)); #endif - viewportmanager_theme_undo(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data)); - + viewportmanager_theme_undo(i, skin_has_sbs(gwps)); + } } #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) @@ -525,19 +544,30 @@ static void gwps_leave_wps(void) #endif } +static void restore_theme(void) +{ + FOR_NB_SCREENS(i) + { + struct gui_wps *gwps = skin_get_gwps(WPS, i); + struct screen *display = gwps->display; + display->scroll_stop(); + viewportmanager_theme_enable(i, skin_has_sbs(gwps), NULL); + } +} + /* * display the wps on entering or restoring */ -static void gwps_enter_wps(void) +static void gwps_enter_wps(bool theme_enabled) { struct gui_wps *gwps; struct screen *display; + if (theme_enabled) + restore_theme(); FOR_NB_SCREENS(i) { gwps = skin_get_gwps(WPS, i); display = gwps->display; display->scroll_stop(); - viewportmanager_theme_enable(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data), NULL); - /* Update the values in the first (default) viewport - in case the user has modified the statusbar or colour settings */ #if LCD_DEPTH > 1 @@ -563,7 +593,7 @@ static void gwps_enter_wps(void) } #ifdef HAVE_TOUCHSCREEN gwps = skin_get_gwps(WPS, SCREEN_MAIN); - skin_disarm_touchregions(gwps->data); + skin_disarm_touchregions(gwps); if (gwps->data->touchregions < 0) touchscreen_set_mode(TOUCHSCREEN_BUTTON); #endif @@ -573,16 +603,16 @@ static void gwps_enter_wps(void) void wps_do_playpause(bool updatewps) { - struct wps_state *state = skin_get_global_state(); + struct wps_state *state = get_wps_state(); if ( state->paused ) { state->paused = false; - unpause_action(true, updatewps); + unpause_action(updatewps); } else { state->paused = true; - pause_action(true, updatewps); + pause_action(updatewps); settings_save(); #if !defined(HAVE_SW_POWEROFF) call_storage_idle_notifys(true); /* make sure resume info is saved */ @@ -590,6 +620,57 @@ void wps_do_playpause(bool updatewps) } } +static long do_wps_exit(long action, bool bookmark) +{ + audio_pause(); + update_non_static(); + if (bookmark) + bookmark_autobookmark(true); + audio_stop(); + + ab_reset_markers(); + + gwps_leave_wps(true); +#ifdef HAVE_RECORDING + if (action == ACTION_WPS_REC) + return GO_TO_RECSCREEN; +#else + (void)action; +#endif + if (global_settings.browse_current) + return GO_TO_PREVIOUS_BROWSER; + return GO_TO_PREVIOUS; +} + +static long do_party_mode(long action) +{ + if (global_settings.party_mode) + { + switch (action) + { +#ifdef ACTION_WPSAB_SINGLE + case ACTION_WPSAB_SINGLE: + if (!ab_repeat_mode_enabled()) + break; + /* Note: currently all targets use ACTION_WPS_BROWSE + * if mapped to any of below actions this will cause problems */ +#endif + case ACTION_WPS_PLAY: + case ACTION_WPS_SEEKFWD: + case ACTION_WPS_SEEKBACK: + case ACTION_WPS_SKIPPREV: + case ACTION_WPS_SKIPNEXT: + case ACTION_WPS_ABSETB_NEXTDIR: + case ACTION_WPS_ABSETA_PREVDIR: + case ACTION_WPS_STOP: + return ACTION_NONE; + break; + default: + break; + } + } + return action; +} /* The WPS can be left in two ways: * a) call a function, which draws over the wps. In this case, the wps @@ -597,31 +678,28 @@ void wps_do_playpause(bool updatewps) * b) return with a value evaluated by root_menu.c, in this case the wps * is really left, and root_menu will handle the next screen * - * In either way, call gwps_leave_wps(), in order to restore the correct + * In either way, call gwps_leave_wps(true), in order to restore the correct * "main screen" backdrops and statusbars */ long gui_wps_show(void) { long button = 0; bool restore = true; - long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */ bool exit = false; bool bookmark = false; bool update = false; - bool vol_changed = false; + bool theme_enabled = true; long last_left = 0, last_right = 0; - struct wps_state *state = skin_get_global_state(); + struct wps_state *state = get_wps_state(); -#ifdef AB_REPEAT_ENABLE ab_repeat_init(); ab_reset_markers(); -#endif - wps_state_init(); + wps_state_init(); while ( 1 ) { + bool hotkey = false; bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; - /* did someone else (i.e power thread) change audio pause mode? */ if (state->paused != audio_paused) { state->paused = audio_paused; @@ -635,8 +713,53 @@ long gui_wps_show(void) #endif } } - button = skin_wait_for_action(WPS, CONTEXT_WPS|ALLOW_SOFTLOCK, - restore ? 1 : HZ/5); + + if (restore) + { + restore = false; +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + add_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook); +#endif + /* we remove the update delay since it's not very usable in the wps, + * e.g. during volume changing or ffwd/rewind */ + sb_skin_set_update_delay(0); + skin_request_full_update(WPS); + update = true; + gwps_enter_wps(theme_enabled); + theme_enabled = true; + } + else + { + gwps_caption_backlight(state); + + FOR_NB_SCREENS(i) + { +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + /* currently, all remotes are readable without backlight + * so still update those */ + if (lcd_active() || (i != SCREEN_MAIN)) +#endif + { + bool full_update = skin_do_full_update(WPS, i); + if (update || full_update) + { + skin_update(WPS, i, full_update ? + SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC); + } + } + } + update = false; + } + + if (exit) + { + return do_wps_exit(button, bookmark); + } + + if (button && !IS_SYSEVENT(button) ) + storage_spin(); + + button = skin_wait_for_action(WPS, CONTEXT_WPS|ALLOW_SOFTLOCK, HZ/5); /* Exit if audio has stopped playing. This happens e.g. at end of playlist or if using the sleep timer. */ @@ -644,46 +767,64 @@ long gui_wps_show(void) exit = true; #ifdef HAVE_TOUCHSCREEN if (button == ACTION_TOUCHSCREEN) - button = skintouch_to_wps(skin_get_gwps(WPS, SCREEN_MAIN)->data); + button = skintouch_to_wps(); #endif + button = do_party_mode(button); /* block select actions in party mode */ + /* The iPods/X5/M5 use a single button for the A-B mode markers, defined as ACTION_WPSAB_SINGLE in their config files. */ #ifdef ACTION_WPSAB_SINGLE - if (!global_settings.party_mode && ab_repeat_mode_enabled()) + static int wps_ab_state = 0; + if (button == ACTION_WPSAB_SINGLE && ab_repeat_mode_enabled()) { - static int wps_ab_state = 0; - if (button == ACTION_WPSAB_SINGLE) + switch (wps_ab_state) { - switch (wps_ab_state) - { - case 0: /* set the A spot */ - button = ACTION_WPS_ABSETA_PREVDIR; - break; - case 1: /* set the B spot */ - button = ACTION_WPS_ABSETB_NEXTDIR; - break; - case 2: - button = ACTION_WPS_ABRESET; - break; - } - wps_ab_state = (wps_ab_state+1) % 3; + case 0: /* set the A spot */ + button = ACTION_WPS_ABSETA_PREVDIR; + break; + case 1: /* set the B spot */ + button = ACTION_WPS_ABSETB_NEXTDIR; + break; + case 2: + button = ACTION_WPS_ABRESET; + break; } + wps_ab_state = (wps_ab_state+1) % 3; } -#endif +#endif /* def ACTION_WPSAB_SINGLE */ + switch(button) { #ifdef HAVE_HOTKEY case ACTION_WPS_HOTKEY: + { + hotkey = true; if (!global_settings.hotkey_wps) break; - /* fall through */ -#endif + if (get_hotkey(global_settings.hotkey_wps)->flags & HOTKEY_FLAG_NOSBS) + { + /* leave WPS without re-enabling theme */ + theme_enabled = false; + gwps_leave_wps(theme_enabled); + onplay(state->id3->path, + FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); + if (!audio_status()) + { + /* re-enable theme since we're returning to SBS */ + gwps_leave_wps(true); + return GO_TO_ROOT; + } + restore = true; + break; + } + } + /* fall through */ +#endif /* def HAVE_HOTKEY */ case ACTION_WPS_CONTEXT: { - bool hotkey = button == ACTION_WPS_HOTKEY; - gwps_leave_wps(); + gwps_leave_wps(true); int retval = onplay(state->id3->path, - FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); + FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); /* if music is stopped in the context menu we want to exit the wps */ if (retval == ONPLAY_MAINMENU || !audio_status()) @@ -691,39 +832,46 @@ long gui_wps_show(void) else if (retval == ONPLAY_PLAYLIST) return GO_TO_PLAYLIST_VIEWER; else if (retval == ONPLAY_PLUGIN) - return GO_TO_PLUGIN; + { + restore_theme(); + theme_enabled = false; + open_plugin_run(ID2P(LANG_OPEN_PLUGIN_SET_WPS_CONTEXT_PLUGIN)); + } + restore = true; } break; case ACTION_WPS_BROWSE: - gwps_leave_wps(); + gwps_leave_wps(true); return GO_TO_PREVIOUS_BROWSER; break; /* play/pause */ case ACTION_WPS_PLAY: - if (global_settings.party_mode) - break; wps_do_playpause(true); break; - case ACTION_WPS_VOLUP: - global_settings.volume += sound_steps(SOUND_VOLUME); - vol_changed = true; - break; + case ACTION_WPS_VOLUP: /* fall through */ case ACTION_WPS_VOLDOWN: - global_settings.volume -= sound_steps(SOUND_VOLUME); - vol_changed = true; + if (button == ACTION_WPS_VOLUP) + adjust_volume(1); + else + adjust_volume(-1); + + setvol(); + FOR_NB_SCREENS(i) + { + skin_update(WPS, i, SKIN_REFRESH_NON_STATIC); + } + update = false; break; /* fast forward OR next dir if this is straight after ACTION_WPS_SKIPNEXT */ case ACTION_WPS_SEEKFWD: - if (global_settings.party_mode) - break; if (current_tick -last_right < HZ) { - if (state->id3->cuesheet) + if (state->id3->cuesheet && playlist_check(1)) { audio_next(); } @@ -733,37 +881,42 @@ long gui_wps_show(void) } } else - ffwd_rew(ACTION_WPS_SEEKFWD); + ffwd_rew(ACTION_WPS_SEEKFWD, false); last_right = last_left = 0; break; /* fast rewind OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/ case ACTION_WPS_SEEKBACK: - if (global_settings.party_mode) - break; - if (current_tick -last_left < HZ) + if (current_tick - last_left < HZ) { - if (state->id3->cuesheet) + if (state->id3->cuesheet && playlist_check(-1)) { - audio_pre_ff_rewind(); - audio_ff_rewind(0); + audio_prev(); } else { change_dir(-1); } + } else if (global_settings.rewind_across_tracks + && get_wps_state()->id3->elapsed < DEFAULT_SKIP_THRESH + && playlist_check(-1)) + { + if (!audio_paused) + audio_pause(); + audio_prev(); + ffwd_rew(ACTION_WPS_SEEKBACK, true); + if (!audio_paused) + audio_resume(); } else - ffwd_rew(ACTION_WPS_SEEKBACK); + ffwd_rew(ACTION_WPS_SEEKBACK, false); last_left = last_right = 0; break; /* prev / restart */ case ACTION_WPS_SKIPPREV: - if (global_settings.party_mode) - break; last_left = current_tick; -#ifdef AB_REPEAT_ENABLE + /* if we're in A/B repeat mode and the current position is past the A marker, jump back to the A marker... */ if ( ab_repeat_mode_enabled() && ab_after_A_marker(state->id3->elapsed) ) @@ -771,19 +924,15 @@ long gui_wps_show(void) ab_jump_to_A_marker(); break; } - else - /* ...otherwise, do it normally */ -#endif + else /* ...otherwise, do it normally */ play_hop(-1); break; /* next OR if skip length set, hop by predetermined amount. */ case ACTION_WPS_SKIPNEXT: - if (global_settings.party_mode) - break; last_right = current_tick; -#ifdef AB_REPEAT_ENABLE + /* if we're in A/B repeat mode and the current position is before the A marker, jump to the A marker... */ if ( ab_repeat_mode_enabled() ) @@ -794,43 +943,33 @@ long gui_wps_show(void) break; } } - else - /* ...otherwise, do it normally */ -#endif + else /* ...otherwise, do it normally */ play_hop(1); break; /* next / prev directories */ /* and set A-B markers if in a-b mode */ case ACTION_WPS_ABSETB_NEXTDIR: - if (global_settings.party_mode) - break; -#if defined(AB_REPEAT_ENABLE) if (ab_repeat_mode_enabled()) { ab_set_B_marker(state->id3->elapsed); ab_jump_to_A_marker(); } else -#endif { change_dir(1); } break; case ACTION_WPS_ABSETA_PREVDIR: - if (global_settings.party_mode) - break; -#if defined(AB_REPEAT_ENABLE) if (ab_repeat_mode_enabled()) ab_set_A_marker(state->id3->elapsed); else -#endif { change_dir(-1); } break; /* menu key functions */ case ACTION_WPS_MENU: - gwps_leave_wps(); + gwps_leave_wps(true); return GO_TO_ROOT; break; @@ -838,16 +977,25 @@ long gui_wps_show(void) #ifdef HAVE_QUICKSCREEN case ACTION_WPS_QUICKSCREEN: { - gwps_leave_wps(); - if (global_settings.shortcuts_replaces_qs) + gwps_leave_wps(true); + bool enter_shortcuts_menu = global_settings.shortcuts_replaces_qs; + if (!enter_shortcuts_menu) { - global_status.last_screen = GO_TO_SHORTCUTMENU; int ret = quick_screen_quick(button); + if (ret == QUICKSCREEN_IN_USB) + return GO_TO_ROOT; + else if (ret == QUICKSCREEN_GOTO_SHORTCUTS_MENU) + enter_shortcuts_menu = true; + else + restore = true; + } + + if (enter_shortcuts_menu) /* enter_shortcuts_menu */ + { + global_status.last_screen = GO_TO_SHORTCUTMENU; + int ret = do_shortcut_menu(NULL); return (ret == GO_TO_PREVIOUS ? GO_TO_WPS : ret); } - else if (quick_screen_quick(button) > 0) - return GO_TO_ROOT; - restore = true; } break; #endif /* HAVE_QUICKSCREEN */ @@ -858,7 +1006,7 @@ long gui_wps_show(void) #ifdef HAVE_PITCHCONTROL case ACTION_WPS_PITCHSCREEN: { - gwps_leave_wps(); + gwps_leave_wps(true); if (1 == gui_syncpitchscreen_run()) return GO_TO_ROOT; restore = true; @@ -866,7 +1014,6 @@ long gui_wps_show(void) break; #endif /* HAVE_PITCHCONTROL */ -#ifdef AB_REPEAT_ENABLE /* reset A&B markers */ case ACTION_WPS_ABRESET: if (ab_repeat_mode_enabled()) @@ -875,18 +1022,15 @@ long gui_wps_show(void) update = true; } break; -#endif /* AB_REPEAT_ENABLE */ /* stop and exit wps */ case ACTION_WPS_STOP: - if (global_settings.party_mode) - break; bookmark = true; exit = true; break; case ACTION_WPS_LIST_BOOKMARKS: - gwps_leave_wps(); + gwps_leave_wps(true); if (bookmark_load_menu() == BOOKMARK_USB_CONNECTED) { return GO_TO_ROOT; @@ -895,15 +1039,17 @@ long gui_wps_show(void) break; case ACTION_WPS_CREATE_BOOKMARK: - gwps_leave_wps(); + gwps_leave_wps(true); bookmark_create_menu(); restore = true; break; case ACTION_WPS_ID3SCREEN: { - gwps_leave_wps(); - if (browse_id3()) + gwps_leave_wps(true); + if (browse_id3(audio_current_track(), + playlist_get_display_index(), + playlist_amount(), NULL, 1)) return GO_TO_ROOT; restore = true; } @@ -915,7 +1061,7 @@ long gui_wps_show(void) break; case ACTION_NONE: /* Timeout, do a partial update */ update = true; - ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ + ffwd_rew(button, false); /* hopefully fix the ffw/rwd bug */ break; #ifdef HAVE_RECORDING case ACTION_WPS_REC: @@ -923,7 +1069,7 @@ long gui_wps_show(void) break; #endif case ACTION_WPS_VIEW_PLAYLIST: - gwps_leave_wps(); + gwps_leave_wps(true); return GO_TO_PLAYLIST_VIEWER; break; default: @@ -932,99 +1078,25 @@ long gui_wps_show(void) case SYS_USB_CONNECTED: case SYS_CALL_INCOMING: case BUTTON_MULTIMEDIA_STOP: - gwps_leave_wps(); + gwps_leave_wps(true); return GO_TO_ROOT; } update = true; break; } - - if (vol_changed) - { - bool res = false; - vol_changed = false; - setvol(); - FOR_NB_SCREENS(i) - { - if(update_onvol_change(i)) - res = true; - } - if (res) { - restore = true; - restoretimer = RESTORE_WPS_NEXT_SECOND; - } - } - - - if (restore && - ((restoretimer == RESTORE_WPS_INSTANTLY) || - TIME_AFTER(current_tick, restoretimer))) - { - restore = false; - restoretimer = RESTORE_WPS_INSTANTLY; -#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) - add_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook); -#endif - /* we remove the update delay since it's not very usable in the wps, - * e.g. during volume changing or ffwd/rewind */ - sb_skin_set_update_delay(0); - skin_request_full_update(WPS); - update = true; - gwps_enter_wps(); - } - else - { -#if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) - gwps_caption_backlight(state); -#endif - FOR_NB_SCREENS(i) - { -#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) - /* currently, all remotes are readable without backlight - * so still update those */ - if (lcd_active() || (i != SCREEN_MAIN)) -#endif - { - bool full_update = skin_do_full_update(WPS, i); - if (update || full_update) - { - skin_update(WPS, i, full_update ? - SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC); - } - } - } - update = false; - } - - if (exit) { - audio_pause(); - update_non_static(); - if (bookmark) - bookmark_autobookmark(true); - audio_stop(); -#ifdef AB_REPEAT_ENABLE - ab_reset_markers(); -#endif - gwps_leave_wps(); -#ifdef HAVE_RECORDING - if (button == ACTION_WPS_REC) - return GO_TO_RECSCREEN; -#endif - if (global_settings.browse_current) - return GO_TO_PREVIOUS_BROWSER; - return GO_TO_PREVIOUS; - } - - if (button && !IS_SYSEVENT(button) ) - storage_spin(); } return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ } +struct wps_state *get_wps_state(void) +{ + return &wps_state; +} + /* this is called from the playback thread so NO DRAWING! */ static void track_info_callback(unsigned short id, void *param) { - struct wps_state *state = skin_get_global_state(); + struct wps_state *state = get_wps_state(); if (id == PLAYBACK_EVENT_TRACK_CHANGE || id == PLAYBACK_EVENT_CUR_TRACK_READY) { @@ -1040,14 +1112,13 @@ static void track_info_callback(unsigned short id, void *param) state->id3 = audio_current_track(); } #endif - skin_get_global_state()->nid3 = audio_next_track(); + state->nid3 = audio_next_track(); skin_request_full_update(WPS); } static void wps_state_init(void) { - struct wps_state *state = skin_get_global_state(); - state->ff_rewind = false; + struct wps_state *state = get_wps_state(); state->paused = false; if(audio_status() & AUDIO_STATUS_PLAY) { @@ -1071,16 +1142,3 @@ static void wps_state_init(void) add_event(PLAYBACK_EVENT_TRACK_SKIP, track_info_callback); #endif } - - -#ifdef IPOD_ACCESSORY_PROTOCOL -bool is_wps_fading(void) -{ - return skin_get_global_state()->is_fading; -} - -int wps_get_ff_rewind_count(void) -{ - return skin_get_global_state()->ff_rewind_count; -} -#endif |