1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Jerome Kuptz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
30 #include "backlight.h"
33 #include "filetypes.h"
35 #include "skin_engine/skin_engine.h"
36 #include "mp3_playback.h"
43 #ifdef HAVE_LCD_BITMAP
45 #include "peakmeter.h"
56 #include "ata_idle_notify.h"
57 #include "root_menu.h"
59 #include "quickscreen.h"
60 #include "pitchscreen.h"
61 #include "appevents.h"
64 #include "option_select.h"
66 #include "playlist_viewer.h"
68 #include "statusbar-skinned.h"
70 #define RESTORE_WPS_INSTANTLY 0l
71 #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
73 #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
74 /* 3% of 30min file == 54s step size */
75 #define MIN_FF_REWIND_STEP 500
77 /* initial setup of wps_data */
78 static void wps_state_init(void);
79 static void track_changed_callback(void *param
);
80 static void nextid3available_callback(void* param
);
82 #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps"
83 #ifdef HAVE_REMOTE_LCD
84 #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps"
85 #define DEFAULT_WPS(screen) ((screen) == SCREEN_MAIN ? \
86 WPS_DEFAULTCFG:RWPS_DEFAULTCFG)
88 #define DEFAULT_WPS(screen) (WPS_DEFAULTCFG)
91 char* wps_default_skin(enum screen_type screen
)
93 static char *skin_buf
[NB_SCREENS
] = {
94 #ifdef HAVE_LCD_BITMAP
98 "%s%?it<%?in<%in. |>%it|%fn>\n"
99 "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
100 "%s%?id<%id|%?d(1)<%d(1)|%(root%)>> %?iy<%(%iy%)|>\n\n"
101 "%al%pc/%pt%ar[%pp:%pe]\n"
102 "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
105 "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d(2)> - %?id<%id|%d(1)>\n"
108 #ifdef HAVE_REMOTE_LCD
109 #if LCD_REMOTE_DEPTH > 1
112 "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
113 "%s%?it<%?in<%in. |>%it|%fn>\n"
114 "%al%pc/%pt%ar[%pp:%pe]\n"
115 "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
119 return skin_buf
[screen
];
122 void fade(bool fade_in
, bool updatewps
)
124 int fp_global_vol
= global_settings
.volume
<< 8;
125 int fp_min_vol
= sound_min(SOUND_VOLUME
) << 8;
126 int fp_step
= (fp_global_vol
- fp_min_vol
) / 10;
128 skin_get_global_state()->is_fading
= !fade_in
;
131 int fp_volume
= fp_min_vol
;
133 /* zero out the sound */
134 sound_set_volume(fp_min_vol
>> 8);
136 sleep(HZ
/10); /* let audio thread run */
141 skin_update(WPS
, i
, SKIN_REFRESH_NON_STATIC
);
144 while (fp_volume
< fp_global_vol
- fp_step
) {
145 fp_volume
+= fp_step
;
146 sound_set_volume(fp_volume
>> 8);
149 sound_set_volume(global_settings
.volume
);
153 int fp_volume
= fp_global_vol
;
157 skin_update(WPS
, i
, SKIN_REFRESH_NON_STATIC
);
160 while (fp_volume
> fp_min_vol
+ fp_step
) {
161 fp_volume
-= fp_step
;
162 sound_set_volume(fp_volume
>> 8);
167 skin_get_global_state()->is_fading
= false;
168 #if CONFIG_CODEC != SWCODEC
170 /* let audio thread run and wait for the mas to run out of data */
171 while (!mp3_pause_done())
176 /* reset volume to what it was before the fade */
177 sound_set_volume(global_settings
.volume
);
181 static bool update_onvol_change(enum screen_type screen
)
183 skin_update(WPS
, screen
, SKIN_REFRESH_NON_STATIC
);
185 #ifdef HAVE_LCD_CHARCELLS
186 splashf(0, "Vol: %3d dB",
187 sound_val2phys(SOUND_VOLUME
, global_settings
.volume
));
194 #ifdef HAVE_TOUCHSCREEN
195 static int skintouch_to_wps(struct wps_data
*data
)
198 struct touchregion
*region
;
199 int button
= skin_get_touchaction(data
, &offset
, ®ion
);
202 case ACTION_STD_PREV
:
203 return ACTION_WPS_SKIPPREV
;
204 case ACTION_STD_PREVREPEAT
:
205 return ACTION_WPS_SEEKBACK
;
206 case ACTION_STD_NEXT
:
207 return ACTION_WPS_SKIPNEXT
;
208 case ACTION_STD_NEXTREPEAT
:
209 return ACTION_WPS_SEEKFWD
;
210 case ACTION_STD_MENU
:
211 return ACTION_WPS_MENU
;
212 case ACTION_STD_CONTEXT
:
213 return ACTION_WPS_CONTEXT
;
214 case ACTION_STD_QUICKSCREEN
:
215 return ACTION_WPS_QUICKSCREEN
;
217 case ACTION_STD_HOTKEY
:
218 return ACTION_WPS_HOTKEY
;
220 case WPS_TOUCHREGION_SCROLLBAR
:
221 skin_get_global_state()->id3
->elapsed
= skin_get_global_state()->id3
->length
*offset
/100;
222 if (!skin_get_global_state()->paused
)
223 #if (CONFIG_CODEC == SWCODEC)
224 audio_pre_ff_rewind();
228 audio_ff_rewind(skin_get_global_state()->id3
->elapsed
);
229 #if (CONFIG_CODEC != SWCODEC)
230 if (!skin_get_global_state()->paused
)
233 return ACTION_TOUCHSCREEN
;
234 case WPS_TOUCHREGION_VOLUME
:
236 const int min_vol
= sound_min(SOUND_VOLUME
);
237 const int max_vol
= sound_max(SOUND_VOLUME
);
238 global_settings
.volume
= (offset
* (max_vol
- min_vol
)) / 100;
239 global_settings
.volume
+= min_vol
;
242 return ACTION_TOUCHSCREEN
;
246 #endif /* HAVE_TOUCHSCREEN */
248 bool ffwd_rew(int button
)
250 unsigned int step
= 0; /* current ff/rewind step */
251 unsigned int max_step
= 0; /* maximum ff/rewind step */
252 int ff_rewind_count
= 0; /* current ff/rewind count (in ticks) */
253 int direction
= -1; /* forward=1 or backward=-1 */
257 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
259 if (button
== ACTION_NONE
)
261 status_set_ffmode(0);
268 case ACTION_WPS_SEEKFWD
:
270 case ACTION_WPS_SEEKBACK
:
271 if (skin_get_global_state()->ff_rewind
)
275 /* fast forwarding, calc max step relative to end */
276 max_step
= (skin_get_global_state()->id3
->length
-
277 (skin_get_global_state()->id3
->elapsed
+
279 FF_REWIND_MAX_PERCENT
/ 100;
283 /* rewinding, calc max step relative to start */
284 max_step
= (skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) *
285 FF_REWIND_MAX_PERCENT
/ 100;
288 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
293 ff_rewind_count
+= step
* direction
;
295 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
296 step
+= step
>> ff_rw_accel
;
300 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
301 skin_get_global_state()->id3
&& skin_get_global_state()->id3
->length
)
303 if (!skin_get_global_state()->paused
)
304 #if (CONFIG_CODEC == SWCODEC)
305 audio_pre_ff_rewind();
309 #if CONFIG_KEYPAD == PLAYER_PAD
311 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
314 status_set_ffmode(STATUS_FASTFORWARD
);
316 status_set_ffmode(STATUS_FASTBACKWARD
);
318 skin_get_global_state()->ff_rewind
= true;
320 step
= 1000 * global_settings
.ff_rewind_min_step
;
327 if ((skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) >
328 skin_get_global_state()->id3
->length
)
329 ff_rewind_count
= skin_get_global_state()->id3
->length
-
330 skin_get_global_state()->id3
->elapsed
;
333 if ((int)(skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) < 0)
334 ff_rewind_count
= -skin_get_global_state()->id3
->elapsed
;
337 /* set the wps state ff_rewind_count so the progess info
339 skin_get_global_state()->ff_rewind_count
= ff_rewind_count
;
344 SKIN_REFRESH_PLAYER_PROGRESS
|
345 SKIN_REFRESH_DYNAMIC
);
350 case ACTION_WPS_STOPSEEK
:
351 skin_get_global_state()->id3
->elapsed
= skin_get_global_state()->id3
->elapsed
+ff_rewind_count
;
352 audio_ff_rewind(skin_get_global_state()->id3
->elapsed
);
353 skin_get_global_state()->ff_rewind_count
= 0;
354 skin_get_global_state()->ff_rewind
= false;
355 status_set_ffmode(0);
356 #if (CONFIG_CODEC != SWCODEC)
357 if (!skin_get_global_state()->paused
)
360 #ifdef HAVE_LCD_CHARCELLS
362 skin_update(WPS
, i
, SKIN_REFRESH_ALL
);
368 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
369 status_set_ffmode(0);
377 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_BLOCK
);
378 #ifdef HAVE_TOUCHSCREEN
379 if (button
== ACTION_TOUCHSCREEN
)
380 button
= skintouch_to_wps(skin_get_gwps(WPS
, SCREEN_MAIN
)->data
);
381 if (button
!= ACTION_WPS_SEEKFWD
&&
382 button
!= ACTION_WPS_SEEKBACK
)
383 button
= ACTION_WPS_STOPSEEK
;
391 void display_keylock_text(bool locked
)
395 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
397 splash(HZ
, locked
? ID2P(LANG_KEYLOCK_ON
) : ID2P(LANG_KEYLOCK_OFF
));
403 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
404 static void gwps_caption_backlight(struct wps_state
*state
)
406 if (state
&& state
->id3
)
408 #ifdef HAVE_BACKLIGHT
409 if (global_settings
.caption_backlight
)
411 /* turn on backlight n seconds before track ends, and turn it off n
412 seconds into the new track. n == backlight_timeout, or 5s */
413 int n
= global_settings
.backlight_timeout
* 1000;
416 n
= 5000; /* use 5s if backlight is always on or off */
418 if (((state
->id3
->elapsed
< 1000) ||
419 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
420 (state
->paused
== false))
424 #ifdef HAVE_REMOTE_LCD
425 if (global_settings
.remote_caption_backlight
)
427 /* turn on remote backlight n seconds before track ends, and turn it
428 off n seconds into the new track. n == remote_backlight_timeout,
430 int n
= global_settings
.remote_backlight_timeout
* 1000;
433 n
= 5000; /* use 5s if backlight is always on or off */
435 if (((state
->id3
->elapsed
< 1000) ||
436 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
437 (state
->paused
== false))
438 remote_backlight_on();
446 static void change_dir(int direction
)
448 if (global_settings
.prevent_skip
)
453 else if (direction
> 0)
455 /* prevent the next dir to immediatly start being ffw'd */
456 action_wait_for_release();
459 static void prev_track(unsigned long skip_thresh
)
461 struct wps_state
*state
= skin_get_global_state();
462 if (state
->id3
->elapsed
< skip_thresh
)
469 if (state
->id3
->cuesheet
)
471 curr_cuesheet_skip(state
->id3
->cuesheet
, -1, state
->id3
->elapsed
);
476 #if (CONFIG_CODEC == SWCODEC)
477 audio_pre_ff_rewind();
484 #if (CONFIG_CODEC != SWCODEC)
491 static void next_track(void)
493 struct wps_state
*state
= skin_get_global_state();
494 /* take care of if we're playing a cuesheet */
495 if (state
->id3
->cuesheet
)
497 if (curr_cuesheet_skip(state
->id3
->cuesheet
, 1, state
->id3
->elapsed
))
499 /* if the result was false, then we really want
500 to skip to the next track */
508 static void play_hop(int direction
)
510 struct wps_state
*state
= skin_get_global_state();
511 long step
= global_settings
.skip_length
*1000;
512 long elapsed
= state
->id3
->elapsed
;
513 long remaining
= state
->id3
->length
- elapsed
;
519 prev_track(DEFAULT_SKIP_TRESH
);
522 else if (remaining
< DEFAULT_SKIP_TRESH
*2)
528 elapsed
+= (remaining
- DEFAULT_SKIP_TRESH
*2);
530 else if (!global_settings
.prevent_skip
&&
532 (direction
> 0 && step
>= remaining
) ||
533 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
534 { /* Do normal track skipping */
537 else if (direction
< 0)
538 prev_track(DEFAULT_SKIP_TRESH
);
541 else if (direction
== 1 && step
>= remaining
)
543 #if CONFIG_CODEC == SWCODEC
544 if(global_settings
.beep
)
545 pcmbuf_beep(1000, 150, 1500*global_settings
.beep
);
549 else if ((direction
== -1 && elapsed
< step
))
555 elapsed
+= step
* direction
;
557 if((audio_status() & AUDIO_STATUS_PLAY
) && !state
->paused
)
559 #if (CONFIG_CODEC == SWCODEC)
560 audio_pre_ff_rewind();
565 audio_ff_rewind(state
->id3
->elapsed
= elapsed
);
566 #if (CONFIG_CODEC != SWCODEC)
573 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
575 * If the user is unable to see the wps, because the display is deactivated,
576 * we suppress updates until the wps is activated again (the lcd driver will
577 * call this hook to issue an instant update)
579 static void wps_lcd_activation_hook(void *param
)
582 skin_request_full_update(WPS
);
583 /* force timeout in wps main loop, so that the update is instantly */
584 queue_post(&button_queue
, BUTTON_NONE
, 0);
588 static void gwps_leave_wps(void)
594 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
595 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
596 skin_backdrop_show(sb_get_backdrop(i
));
598 viewportmanager_theme_undo(i
, skin_has_sbs(i
, skin_get_gwps(WPS
, i
)->data
));
602 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
603 /* Play safe and unregister the hook */
604 remove_event(LCD_EVENT_ACTIVATION
, wps_lcd_activation_hook
);
606 /* unhandle statusbar update delay */
607 sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY
);
608 #ifdef HAVE_TOUCHSCREEN
609 touchscreen_set_mode(global_settings
.touch_mode
);
614 * display the wps on entering or restoring */
615 static void gwps_enter_wps(void)
618 struct gui_wps
*gwps
;
619 struct screen
*display
;
622 gwps
= skin_get_gwps(WPS
, i
);
623 display
= gwps
->display
;
624 display
->stop_scroll();
625 viewportmanager_theme_enable(i
, skin_has_sbs(i
, skin_get_gwps(WPS
, i
)->data
), NULL
);
627 /* Update the values in the first (default) viewport - in case the user
628 has modified the statusbar or colour settings */
630 if (display
->depth
> 1)
632 struct skin_viewport
*svp
= skin_find_item(VP_DEFAULT_LABEL
,
633 SKIN_FIND_VP
, gwps
->data
);
636 struct viewport
*vp
= &svp
->vp
;
637 vp
->fg_pattern
= display
->get_foreground();
638 vp
->bg_pattern
= display
->get_background();
642 /* make the backdrop actually take effect */
643 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
644 skin_backdrop_show(gwps
->data
->backdrop_id
);
646 display
->clear_display();
647 skin_update(WPS
, i
, SKIN_REFRESH_ALL
);
650 #ifdef HAVE_TOUCHSCREEN
651 gwps
= skin_get_gwps(WPS
, SCREEN_MAIN
);
652 skin_disarm_touchregions(gwps
->data
);
653 if (!gwps
->data
->touchregions
)
654 touchscreen_set_mode(TOUCHSCREEN_BUTTON
);
656 /* force statusbar/skin update since we just cleared the whole screen */
657 send_event(GUI_EVENT_ACTIONUPDATE
, (void*)1);
660 void wps_do_playpause(bool updatewps
)
662 struct wps_state
*state
= skin_get_global_state();
665 state
->paused
= false;
666 if ( global_settings
.fade_on_stop
)
667 fade(true, updatewps
);
673 state
->paused
= true;
674 if ( global_settings
.fade_on_stop
)
675 fade(false, updatewps
);
679 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
680 call_storage_idle_notifys(true); /* make sure resume info is saved */
686 /* The WPS can be left in two ways:
687 * a) call a function, which draws over the wps. In this case, the wps
688 * will be still active (i.e. the below function didn't return)
689 * b) return with a value evaluated by root_menu.c, in this case the wps
690 * is really left, and root_menu will handle the next screen
692 * In either way, call gwps_leave_wps(), in order to restore the correct
693 * "main screen" backdrops and statusbars
695 long gui_wps_show(void)
699 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
701 bool bookmark
= false;
703 bool vol_changed
= false;
705 long last_left
= 0, last_right
= 0;
706 struct wps_state
*state
= skin_get_global_state();
708 #ifdef HAVE_LCD_CHARCELLS
709 status_set_audio(true);
710 status_set_param(false);
713 #ifdef AB_REPEAT_ENABLE
721 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
723 /* did someone else (i.e power thread) change audio pause mode? */
724 if (state
->paused
!= audio_paused
) {
725 state
->paused
= audio_paused
;
727 /* if another thread paused audio, we are probably in car mode,
728 about to shut down. lets save the settings. */
731 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
732 call_storage_idle_notifys(true);
736 button
= skin_wait_for_action(WPS
, CONTEXT_WPS
|ALLOW_SOFTLOCK
,
739 /* Exit if audio has stopped playing. This happens e.g. at end of
740 playlist or if using the sleep timer. */
741 if (!(audio_status() & AUDIO_STATUS_PLAY
))
743 #ifdef HAVE_TOUCHSCREEN
744 if (button
== ACTION_TOUCHSCREEN
)
745 button
= skintouch_to_wps(skin_get_gwps(WPS
, SCREEN_MAIN
)->data
);
747 /* The iPods/X5/M5 use a single button for the A-B mode markers,
748 defined as ACTION_WPSAB_SINGLE in their config files. */
749 #ifdef ACTION_WPSAB_SINGLE
750 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
752 static int wps_ab_state
= 0;
753 if (button
== ACTION_WPSAB_SINGLE
)
755 switch (wps_ab_state
)
757 case 0: /* set the A spot */
758 button
= ACTION_WPS_ABSETA_PREVDIR
;
760 case 1: /* set the B spot */
761 button
= ACTION_WPS_ABSETB_NEXTDIR
;
764 button
= ACTION_WPS_ABRESET
;
767 wps_ab_state
= (wps_ab_state
+1) % 3;
774 case ACTION_WPS_HOTKEY
:
775 if (!global_settings
.hotkey_wps
)
779 case ACTION_WPS_CONTEXT
:
781 bool hotkey
= button
== ACTION_WPS_HOTKEY
;
783 int retval
= onplay(state
->id3
->path
,
784 FILE_ATTR_AUDIO
, CONTEXT_WPS
, hotkey
);
785 /* if music is stopped in the context menu we want to exit the wps */
786 if (retval
== ONPLAY_MAINMENU
789 else if (retval
== ONPLAY_PLAYLIST
)
790 return GO_TO_PLAYLIST_VIEWER
;
791 #ifdef HAVE_PICTUREFLOW_INTEGRATION
792 else if (retval
== ONPLAY_PICTUREFLOW
)
793 return GO_TO_PICTUREFLOW
;
799 case ACTION_WPS_BROWSE
:
800 #ifdef HAVE_LCD_CHARCELLS
801 status_set_record(false);
802 status_set_audio(false);
805 return GO_TO_PREVIOUS_BROWSER
;
809 case ACTION_WPS_PLAY
:
810 if (global_settings
.party_mode
)
812 wps_do_playpause(true);
815 case ACTION_WPS_VOLUP
:
816 global_settings
.volume
++;
819 case ACTION_WPS_VOLDOWN
:
820 global_settings
.volume
--;
824 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
825 case ACTION_WPS_SEEKFWD
:
826 if (global_settings
.party_mode
)
828 if (current_tick
-last_right
< HZ
)
830 if (state
->id3
->cuesheet
)
840 ffwd_rew(ACTION_WPS_SEEKFWD
);
841 last_right
= last_left
= 0;
844 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
845 case ACTION_WPS_SEEKBACK
:
846 if (global_settings
.party_mode
)
848 if (current_tick
-last_left
< HZ
)
850 if (state
->id3
->cuesheet
)
853 #if (CONFIG_CODEC == SWCODEC)
854 audio_pre_ff_rewind();
866 ffwd_rew(ACTION_WPS_SEEKBACK
);
867 last_left
= last_right
= 0;
871 case ACTION_WPS_SKIPPREV
:
872 if (global_settings
.party_mode
)
874 last_left
= current_tick
;
875 #ifdef AB_REPEAT_ENABLE
876 /* if we're in A/B repeat mode and the current position
877 is past the A marker, jump back to the A marker... */
878 if ( ab_repeat_mode_enabled() )
880 if ( ab_after_A_marker(state
->id3
->elapsed
) )
882 ab_jump_to_A_marker();
887 /* ...otherwise, do it normally */
893 OR if skip length set, hop by predetermined amount. */
894 case ACTION_WPS_SKIPNEXT
:
895 if (global_settings
.party_mode
)
897 last_right
= current_tick
;
898 #ifdef AB_REPEAT_ENABLE
899 /* if we're in A/B repeat mode and the current position is
900 before the A marker, jump to the A marker... */
901 if ( ab_repeat_mode_enabled() )
903 if ( ab_before_A_marker(state
->id3
->elapsed
) )
905 ab_jump_to_A_marker();
910 /* ...otherwise, do it normally */
914 /* next / prev directories */
915 /* and set A-B markers if in a-b mode */
916 case ACTION_WPS_ABSETB_NEXTDIR
:
917 if (global_settings
.party_mode
)
919 #if defined(AB_REPEAT_ENABLE)
920 if (ab_repeat_mode_enabled())
922 ab_set_B_marker(state
->id3
->elapsed
);
923 ab_jump_to_A_marker();
931 case ACTION_WPS_ABSETA_PREVDIR
:
932 if (global_settings
.party_mode
)
934 #if defined(AB_REPEAT_ENABLE)
935 if (ab_repeat_mode_enabled())
936 ab_set_A_marker(state
->id3
->elapsed
);
943 /* menu key functions */
944 case ACTION_WPS_MENU
:
950 #ifdef HAVE_QUICKSCREEN
951 case ACTION_WPS_QUICKSCREEN
:
954 if (quick_screen_quick(button
))
959 #endif /* HAVE_QUICKSCREEN */
961 /* screen settings */
966 if (quick_screen_f3(BUTTON_F3
))
971 #endif /* BUTTON_F3 */
974 #ifdef HAVE_PITCHSCREEN
975 case ACTION_WPS_PITCHSCREEN
:
978 if (1 == gui_syncpitchscreen_run())
983 #endif /* HAVE_PITCHSCREEN */
985 #ifdef AB_REPEAT_ENABLE
986 /* reset A&B markers */
987 case ACTION_WPS_ABRESET
:
988 if (ab_repeat_mode_enabled())
994 #endif /* AB_REPEAT_ENABLE */
996 /* stop and exit wps */
997 case ACTION_WPS_STOP
:
998 if (global_settings
.party_mode
)
1004 case ACTION_WPS_ID3SCREEN
:
1012 #ifdef HAVE_TOUCHSCREEN
1013 case ACTION_TOUCH_SHUFFLE
: /* toggle shuffle mode */
1015 global_settings
.playlist_shuffle
=
1016 !global_settings
.playlist_shuffle
;
1017 #if CONFIG_CODEC == SWCODEC
1018 dsp_set_replaygain();
1020 if (global_settings
.playlist_shuffle
)
1021 playlist_randomise(NULL
, current_tick
, true);
1023 playlist_sort(NULL
, true);
1026 case ACTION_TOUCH_REPMODE
: /* cycle the repeat mode setting */
1028 const struct settings_list
*rep_setting
=
1029 find_setting(&global_settings
.repeat_mode
, NULL
);
1030 option_select_next_val(rep_setting
, false, true);
1031 audio_flush_and_reload_tracks();
1034 #endif /* HAVE_TOUCHSCREEN */
1035 /* this case is used by the softlock feature
1036 * it requests a full update here */
1038 skin_request_full_update(WPS
);
1040 case ACTION_NONE
: /* Timeout, do a partial update */
1042 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1044 #ifdef HAVE_RECORDING
1045 case ACTION_WPS_REC
:
1049 case ACTION_WPS_VIEW_PLAYLIST
:
1051 return GO_TO_PLAYLIST_VIEWER
;
1054 switch(default_event_handler(button
))
1055 { /* music has been stopped by the default handler */
1056 case SYS_USB_CONNECTED
:
1057 case SYS_CALL_INCOMING
:
1058 case BUTTON_MULTIMEDIA_STOP
:
1069 vol_changed
= false;
1073 if(update_onvol_change(i
))
1078 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
1084 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1085 TIME_AFTER(current_tick
, restoretimer
)))
1088 restoretimer
= RESTORE_WPS_INSTANTLY
;
1089 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1090 add_event(LCD_EVENT_ACTIVATION
, false, wps_lcd_activation_hook
);
1092 /* we remove the update delay since it's not very usable in the wps,
1093 * e.g. during volume changing or ffwd/rewind */
1094 sb_skin_set_update_delay(0);
1095 skin_request_full_update(WPS
);
1101 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1102 gwps_caption_backlight(state
);
1106 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1107 /* currently, all remotes are readable without backlight
1108 * so still update those */
1109 if (lcd_active() || (i
!= SCREEN_MAIN
))
1112 bool full_update
= skin_do_full_update(WPS
, i
);
1113 if (update
|| full_update
)
1115 skin_update(WPS
, i
, full_update
?
1116 SKIN_REFRESH_ALL
: SKIN_REFRESH_NON_STATIC
);
1124 #ifdef HAVE_LCD_CHARCELLS
1125 status_set_record(false);
1126 status_set_audio(false);
1128 if (global_settings
.fade_on_stop
)
1132 bookmark_autobookmark(true);
1134 #ifdef AB_REPEAT_ENABLE
1138 #ifdef HAVE_RECORDING
1139 if (button
== ACTION_WPS_REC
)
1140 return GO_TO_RECSCREEN
;
1142 if (global_settings
.browse_current
)
1143 return GO_TO_PREVIOUS_BROWSER
;
1144 return GO_TO_PREVIOUS
;
1147 if (button
&& !IS_SYSEVENT(button
) )
1150 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1153 /* this is called from the playback thread so NO DRAWING! */
1154 static void track_changed_callback(void *param
)
1156 struct wps_state
*state
= skin_get_global_state();
1157 state
->id3
= (struct mp3entry
*)param
;
1158 state
->nid3
= audio_next_track();
1159 if (state
->id3
->cuesheet
)
1161 cue_find_current_track(state
->id3
->cuesheet
, state
->id3
->elapsed
);
1163 skin_request_full_update(WPS
);
1165 static void nextid3available_callback(void* param
)
1168 skin_get_global_state()->nid3
= audio_next_track();
1169 skin_request_full_update(WPS
);
1173 static void wps_state_init(void)
1175 struct wps_state
*state
= skin_get_global_state();
1176 state
->ff_rewind
= false;
1177 state
->paused
= false;
1178 if(audio_status() & AUDIO_STATUS_PLAY
)
1180 state
->id3
= audio_current_track();
1181 state
->nid3
= audio_next_track();
1188 /* We'll be updating due to restore initialized with true */
1189 skin_request_full_update(WPS
);
1190 /* add the WPS track event callbacks */
1191 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1192 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1196 #ifdef IPOD_ACCESSORY_PROTOCOL
1197 bool is_wps_fading(void)
1199 return skin_get_global_state()->is_fading
;
1202 int wps_get_ff_rewind_count(void)
1204 return skin_get_global_state()->ff_rewind_count
;