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 pause_action(bool may_fade
, bool updatewps
)
124 if (may_fade
&& global_settings
.fade_on_stop
)
125 fade(false, updatewps
);
129 if (global_settings
.pause_rewind
) {
132 #if (CONFIG_CODEC == SWCODEC)
133 audio_pre_ff_rewind();
135 newpos
= audio_current_track()->elapsed
136 - global_settings
.pause_rewind
* 1000;
137 audio_ff_rewind(newpos
> 0 ? newpos
: 0);
141 void unpause_action(bool may_fade
, bool updatewps
)
143 if (may_fade
&& global_settings
.fade_on_stop
)
144 fade(true, updatewps
);
149 void fade(bool fade_in
, bool updatewps
)
151 int fp_global_vol
= global_settings
.volume
<< 8;
152 int fp_min_vol
= sound_min(SOUND_VOLUME
) << 8;
153 int fp_step
= (fp_global_vol
- fp_min_vol
) / 10;
155 skin_get_global_state()->is_fading
= !fade_in
;
158 int fp_volume
= fp_min_vol
;
160 /* zero out the sound */
161 sound_set_volume(fp_min_vol
>> 8);
163 sleep(HZ
/10); /* let audio thread run */
168 skin_update(WPS
, i
, SKIN_REFRESH_NON_STATIC
);
171 while (fp_volume
< fp_global_vol
- fp_step
) {
172 fp_volume
+= fp_step
;
173 sound_set_volume(fp_volume
>> 8);
176 sound_set_volume(global_settings
.volume
);
180 int fp_volume
= fp_global_vol
;
184 skin_update(WPS
, i
, SKIN_REFRESH_NON_STATIC
);
187 while (fp_volume
> fp_min_vol
+ fp_step
) {
188 fp_volume
-= fp_step
;
189 sound_set_volume(fp_volume
>> 8);
194 skin_get_global_state()->is_fading
= false;
195 #if CONFIG_CODEC != SWCODEC
197 /* let audio thread run and wait for the mas to run out of data */
198 while (!mp3_pause_done())
203 /* reset volume to what it was before the fade */
204 sound_set_volume(global_settings
.volume
);
208 static bool update_onvol_change(enum screen_type screen
)
210 skin_update(WPS
, screen
, SKIN_REFRESH_NON_STATIC
);
212 #ifdef HAVE_LCD_CHARCELLS
213 splashf(0, "Vol: %3d dB",
214 sound_val2phys(SOUND_VOLUME
, global_settings
.volume
));
221 #ifdef HAVE_TOUCHSCREEN
222 static int skintouch_to_wps(struct wps_data
*data
)
225 struct touchregion
*region
;
226 int button
= skin_get_touchaction(data
, &offset
, ®ion
);
229 case ACTION_STD_PREV
:
230 return ACTION_WPS_SKIPPREV
;
231 case ACTION_STD_PREVREPEAT
:
232 return ACTION_WPS_SEEKBACK
;
233 case ACTION_STD_NEXT
:
234 return ACTION_WPS_SKIPNEXT
;
235 case ACTION_STD_NEXTREPEAT
:
236 return ACTION_WPS_SEEKFWD
;
237 case ACTION_STD_MENU
:
238 return ACTION_WPS_MENU
;
239 case ACTION_STD_CONTEXT
:
240 return ACTION_WPS_CONTEXT
;
241 case ACTION_STD_QUICKSCREEN
:
242 return ACTION_WPS_QUICKSCREEN
;
244 case ACTION_STD_HOTKEY
:
245 return ACTION_WPS_HOTKEY
;
247 case ACTION_TOUCH_SCROLLBAR
:
248 skin_get_global_state()->id3
->elapsed
= skin_get_global_state()->id3
->length
*offset
/100;
249 #if (CONFIG_CODEC == SWCODEC)
250 audio_pre_ff_rewind();
252 if (!skin_get_global_state()->paused
)
255 audio_ff_rewind(skin_get_global_state()->id3
->elapsed
);
256 #if (CONFIG_CODEC != SWCODEC)
257 if (!skin_get_global_state()->paused
)
260 return ACTION_TOUCHSCREEN
;
261 case ACTION_TOUCH_VOLUME
:
263 const int min_vol
= sound_min(SOUND_VOLUME
);
264 const int max_vol
= sound_max(SOUND_VOLUME
);
265 global_settings
.volume
= (offset
* (max_vol
- min_vol
)) / 100;
266 global_settings
.volume
+= min_vol
;
269 return ACTION_TOUCHSCREEN
;
273 #endif /* HAVE_TOUCHSCREEN */
275 bool ffwd_rew(int button
)
277 unsigned int step
= 0; /* current ff/rewind step */
278 unsigned int max_step
= 0; /* maximum ff/rewind step */
279 int ff_rewind_count
= 0; /* current ff/rewind count (in ticks) */
280 int direction
= -1; /* forward=1 or backward=-1 */
284 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
286 if (button
== ACTION_NONE
)
288 status_set_ffmode(0);
295 case ACTION_WPS_SEEKFWD
:
297 case ACTION_WPS_SEEKBACK
:
298 if (skin_get_global_state()->ff_rewind
)
302 /* fast forwarding, calc max step relative to end */
303 max_step
= (skin_get_global_state()->id3
->length
-
304 (skin_get_global_state()->id3
->elapsed
+
306 FF_REWIND_MAX_PERCENT
/ 100;
310 /* rewinding, calc max step relative to start */
311 max_step
= (skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) *
312 FF_REWIND_MAX_PERCENT
/ 100;
315 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
320 ff_rewind_count
+= step
* direction
;
322 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
323 step
+= step
>> ff_rw_accel
;
327 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
328 skin_get_global_state()->id3
&& skin_get_global_state()->id3
->length
)
330 #if (CONFIG_CODEC == SWCODEC)
331 audio_pre_ff_rewind();
333 if (!skin_get_global_state()->paused
)
336 #if CONFIG_KEYPAD == PLAYER_PAD
338 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
341 status_set_ffmode(STATUS_FASTFORWARD
);
343 status_set_ffmode(STATUS_FASTBACKWARD
);
345 skin_get_global_state()->ff_rewind
= true;
347 step
= 1000 * global_settings
.ff_rewind_min_step
;
354 if ((skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) >
355 skin_get_global_state()->id3
->length
)
356 ff_rewind_count
= skin_get_global_state()->id3
->length
-
357 skin_get_global_state()->id3
->elapsed
;
360 if ((int)(skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) < 0)
361 ff_rewind_count
= -skin_get_global_state()->id3
->elapsed
;
364 /* set the wps state ff_rewind_count so the progess info
366 skin_get_global_state()->ff_rewind_count
= ff_rewind_count
;
371 SKIN_REFRESH_PLAYER_PROGRESS
|
372 SKIN_REFRESH_DYNAMIC
);
377 case ACTION_WPS_STOPSEEK
:
378 skin_get_global_state()->id3
->elapsed
= skin_get_global_state()->id3
->elapsed
+ff_rewind_count
;
379 audio_ff_rewind(skin_get_global_state()->id3
->elapsed
);
380 skin_get_global_state()->ff_rewind_count
= 0;
381 skin_get_global_state()->ff_rewind
= false;
382 status_set_ffmode(0);
383 #if (CONFIG_CODEC != SWCODEC)
384 if (!skin_get_global_state()->paused
)
387 #ifdef HAVE_LCD_CHARCELLS
389 skin_update(WPS
, i
, SKIN_REFRESH_ALL
);
395 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
396 status_set_ffmode(0);
404 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_BLOCK
);
405 #ifdef HAVE_TOUCHSCREEN
406 if (button
== ACTION_TOUCHSCREEN
)
407 button
= skintouch_to_wps(skin_get_gwps(WPS
, SCREEN_MAIN
)->data
);
408 if (button
!= ACTION_WPS_SEEKFWD
&&
409 button
!= ACTION_WPS_SEEKBACK
)
410 button
= ACTION_WPS_STOPSEEK
;
418 void display_keylock_text(bool locked
)
422 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
424 splash(HZ
, locked
? ID2P(LANG_KEYLOCK_ON
) : ID2P(LANG_KEYLOCK_OFF
));
430 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
431 static void gwps_caption_backlight(struct wps_state
*state
)
433 if (state
&& state
->id3
)
435 #ifdef HAVE_BACKLIGHT
436 if (global_settings
.caption_backlight
)
438 /* turn on backlight n seconds before track ends, and turn it off n
439 seconds into the new track. n == backlight_timeout, or 5s */
440 int n
= global_settings
.backlight_timeout
* 1000;
443 n
= 5000; /* use 5s if backlight is always on or off */
445 if (((state
->id3
->elapsed
< 1000) ||
446 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
447 (state
->paused
== false))
451 #ifdef HAVE_REMOTE_LCD
452 if (global_settings
.remote_caption_backlight
)
454 /* turn on remote backlight n seconds before track ends, and turn it
455 off n seconds into the new track. n == remote_backlight_timeout,
457 int n
= global_settings
.remote_backlight_timeout
* 1000;
460 n
= 5000; /* use 5s if backlight is always on or off */
462 if (((state
->id3
->elapsed
< 1000) ||
463 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
464 (state
->paused
== false))
465 remote_backlight_on();
473 static void change_dir(int direction
)
475 if (global_settings
.prevent_skip
)
480 else if (direction
> 0)
482 /* prevent the next dir to immediatly start being ffw'd */
483 action_wait_for_release();
486 static void prev_track(unsigned long skip_thresh
)
488 struct wps_state
*state
= skin_get_global_state();
489 if (state
->id3
->elapsed
< skip_thresh
)
496 if (state
->id3
->cuesheet
)
498 curr_cuesheet_skip(state
->id3
->cuesheet
, -1, state
->id3
->elapsed
);
502 #if (CONFIG_CODEC == SWCODEC)
503 audio_pre_ff_rewind();
511 #if (CONFIG_CODEC != SWCODEC)
518 static void next_track(void)
520 struct wps_state
*state
= skin_get_global_state();
521 /* take care of if we're playing a cuesheet */
522 if (state
->id3
->cuesheet
)
524 if (curr_cuesheet_skip(state
->id3
->cuesheet
, 1, state
->id3
->elapsed
))
526 /* if the result was false, then we really want
527 to skip to the next track */
535 static void play_hop(int direction
)
537 struct wps_state
*state
= skin_get_global_state();
538 long step
= global_settings
.skip_length
*1000;
539 long elapsed
= state
->id3
->elapsed
;
540 long remaining
= state
->id3
->length
- elapsed
;
546 prev_track(DEFAULT_SKIP_TRESH
);
549 else if (remaining
< DEFAULT_SKIP_TRESH
*2)
555 elapsed
+= (remaining
- DEFAULT_SKIP_TRESH
*2);
557 else if (!global_settings
.prevent_skip
&&
559 (direction
> 0 && step
>= remaining
) ||
560 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
561 { /* Do normal track skipping */
564 else if (direction
< 0)
565 prev_track(DEFAULT_SKIP_TRESH
);
568 else if (direction
== 1 && step
>= remaining
)
570 #if CONFIG_CODEC == SWCODEC
571 if(global_settings
.beep
)
572 pcmbuf_beep(1000, 150, 1500*global_settings
.beep
);
576 else if ((direction
== -1 && elapsed
< step
))
582 elapsed
+= step
* direction
;
584 if(audio_status() & AUDIO_STATUS_PLAY
)
586 #if (CONFIG_CODEC == SWCODEC)
587 audio_pre_ff_rewind();
594 #if (CONFIG_CODEC == SWCODEC)
595 audio_ff_rewind(elapsed
);
597 audio_ff_rewind(state
->id3
->elapsed
= elapsed
);
604 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
606 * If the user is unable to see the wps, because the display is deactivated,
607 * we suppress updates until the wps is activated again (the lcd driver will
608 * call this hook to issue an instant update)
610 static void wps_lcd_activation_hook(void *param
)
613 skin_request_full_update(WPS
);
614 /* force timeout in wps main loop, so that the update is instantly */
615 queue_post(&button_queue
, BUTTON_NONE
, 0);
619 static void gwps_leave_wps(void)
625 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
626 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
627 skin_backdrop_show(sb_get_backdrop(i
));
629 viewportmanager_theme_undo(i
, skin_has_sbs(i
, skin_get_gwps(WPS
, i
)->data
));
633 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
634 /* Play safe and unregister the hook */
635 remove_event(LCD_EVENT_ACTIVATION
, wps_lcd_activation_hook
);
637 /* unhandle statusbar update delay */
638 sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY
);
639 #ifdef HAVE_TOUCHSCREEN
640 touchscreen_set_mode(global_settings
.touch_mode
);
645 * display the wps on entering or restoring */
646 static void gwps_enter_wps(void)
649 struct gui_wps
*gwps
;
650 struct screen
*display
;
653 gwps
= skin_get_gwps(WPS
, i
);
654 display
= gwps
->display
;
655 display
->stop_scroll();
656 viewportmanager_theme_enable(i
, skin_has_sbs(i
, skin_get_gwps(WPS
, i
)->data
), NULL
);
658 /* Update the values in the first (default) viewport - in case the user
659 has modified the statusbar or colour settings */
661 if (display
->depth
> 1)
663 struct skin_viewport
*svp
= skin_find_item(VP_DEFAULT_LABEL
,
664 SKIN_FIND_VP
, gwps
->data
);
667 struct viewport
*vp
= &svp
->vp
;
668 vp
->fg_pattern
= display
->get_foreground();
669 vp
->bg_pattern
= display
->get_background();
673 /* make the backdrop actually take effect */
674 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
675 skin_backdrop_show(gwps
->data
->backdrop_id
);
677 display
->clear_display();
678 skin_update(WPS
, i
, SKIN_REFRESH_ALL
);
681 #ifdef HAVE_TOUCHSCREEN
682 gwps
= skin_get_gwps(WPS
, SCREEN_MAIN
);
683 skin_disarm_touchregions(gwps
->data
);
684 if (!gwps
->data
->touchregions
)
685 touchscreen_set_mode(TOUCHSCREEN_BUTTON
);
687 /* force statusbar/skin update since we just cleared the whole screen */
688 send_event(GUI_EVENT_ACTIONUPDATE
, (void*)1);
691 void wps_do_playpause(bool updatewps
)
693 struct wps_state
*state
= skin_get_global_state();
696 state
->paused
= false;
697 unpause_action(true, updatewps
);
701 state
->paused
= true;
702 pause_action(true, updatewps
);
704 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
705 call_storage_idle_notifys(true); /* make sure resume info is saved */
711 /* The WPS can be left in two ways:
712 * a) call a function, which draws over the wps. In this case, the wps
713 * will be still active (i.e. the below function didn't return)
714 * b) return with a value evaluated by root_menu.c, in this case the wps
715 * is really left, and root_menu will handle the next screen
717 * In either way, call gwps_leave_wps(), in order to restore the correct
718 * "main screen" backdrops and statusbars
720 long gui_wps_show(void)
724 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
726 bool bookmark
= false;
728 bool vol_changed
= false;
730 long last_left
= 0, last_right
= 0;
731 struct wps_state
*state
= skin_get_global_state();
733 #ifdef HAVE_LCD_CHARCELLS
734 status_set_audio(true);
735 status_set_param(false);
738 #ifdef AB_REPEAT_ENABLE
746 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
748 /* did someone else (i.e power thread) change audio pause mode? */
749 if (state
->paused
!= audio_paused
) {
750 state
->paused
= audio_paused
;
752 /* if another thread paused audio, we are probably in car mode,
753 about to shut down. lets save the settings. */
756 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
757 call_storage_idle_notifys(true);
761 button
= skin_wait_for_action(WPS
, CONTEXT_WPS
|ALLOW_SOFTLOCK
,
764 /* Exit if audio has stopped playing. This happens e.g. at end of
765 playlist or if using the sleep timer. */
766 if (!(audio_status() & AUDIO_STATUS_PLAY
))
768 #ifdef HAVE_TOUCHSCREEN
769 if (button
== ACTION_TOUCHSCREEN
)
770 button
= skintouch_to_wps(skin_get_gwps(WPS
, SCREEN_MAIN
)->data
);
772 /* The iPods/X5/M5 use a single button for the A-B mode markers,
773 defined as ACTION_WPSAB_SINGLE in their config files. */
774 #ifdef ACTION_WPSAB_SINGLE
775 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
777 static int wps_ab_state
= 0;
778 if (button
== ACTION_WPSAB_SINGLE
)
780 switch (wps_ab_state
)
782 case 0: /* set the A spot */
783 button
= ACTION_WPS_ABSETA_PREVDIR
;
785 case 1: /* set the B spot */
786 button
= ACTION_WPS_ABSETB_NEXTDIR
;
789 button
= ACTION_WPS_ABRESET
;
792 wps_ab_state
= (wps_ab_state
+1) % 3;
799 case ACTION_WPS_HOTKEY
:
800 if (!global_settings
.hotkey_wps
)
804 case ACTION_WPS_CONTEXT
:
806 bool hotkey
= button
== ACTION_WPS_HOTKEY
;
808 int retval
= onplay(state
->id3
->path
,
809 FILE_ATTR_AUDIO
, CONTEXT_WPS
, hotkey
);
810 /* if music is stopped in the context menu we want to exit the wps */
811 if (retval
== ONPLAY_MAINMENU
814 else if (retval
== ONPLAY_PLAYLIST
)
815 return GO_TO_PLAYLIST_VIEWER
;
816 #ifdef HAVE_PICTUREFLOW_INTEGRATION
817 else if (retval
== ONPLAY_PICTUREFLOW
)
818 return GO_TO_PICTUREFLOW
;
824 case ACTION_WPS_BROWSE
:
825 #ifdef HAVE_LCD_CHARCELLS
826 status_set_record(false);
827 status_set_audio(false);
830 return GO_TO_PREVIOUS_BROWSER
;
834 case ACTION_WPS_PLAY
:
835 if (global_settings
.party_mode
)
837 wps_do_playpause(true);
840 case ACTION_WPS_VOLUP
:
841 global_settings
.volume
++;
844 case ACTION_WPS_VOLDOWN
:
845 global_settings
.volume
--;
849 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
850 case ACTION_WPS_SEEKFWD
:
851 if (global_settings
.party_mode
)
853 if (current_tick
-last_right
< HZ
)
855 if (state
->id3
->cuesheet
)
865 ffwd_rew(ACTION_WPS_SEEKFWD
);
866 last_right
= last_left
= 0;
869 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
870 case ACTION_WPS_SEEKBACK
:
871 if (global_settings
.party_mode
)
873 if (current_tick
-last_left
< HZ
)
875 if (state
->id3
->cuesheet
)
877 #if (CONFIG_CODEC == SWCODEC)
878 audio_pre_ff_rewind();
891 ffwd_rew(ACTION_WPS_SEEKBACK
);
892 last_left
= last_right
= 0;
896 case ACTION_WPS_SKIPPREV
:
897 if (global_settings
.party_mode
)
899 last_left
= current_tick
;
900 #ifdef AB_REPEAT_ENABLE
901 /* if we're in A/B repeat mode and the current position
902 is past the A marker, jump back to the A marker... */
903 if ( ab_repeat_mode_enabled() )
905 if ( ab_after_A_marker(state
->id3
->elapsed
) )
907 ab_jump_to_A_marker();
912 /* ...otherwise, do it normally */
918 OR if skip length set, hop by predetermined amount. */
919 case ACTION_WPS_SKIPNEXT
:
920 if (global_settings
.party_mode
)
922 last_right
= current_tick
;
923 #ifdef AB_REPEAT_ENABLE
924 /* if we're in A/B repeat mode and the current position is
925 before the A marker, jump to the A marker... */
926 if ( ab_repeat_mode_enabled() )
928 if ( ab_before_A_marker(state
->id3
->elapsed
) )
930 ab_jump_to_A_marker();
935 /* ...otherwise, do it normally */
939 /* next / prev directories */
940 /* and set A-B markers if in a-b mode */
941 case ACTION_WPS_ABSETB_NEXTDIR
:
942 if (global_settings
.party_mode
)
944 #if defined(AB_REPEAT_ENABLE)
945 if (ab_repeat_mode_enabled())
947 ab_set_B_marker(state
->id3
->elapsed
);
948 ab_jump_to_A_marker();
956 case ACTION_WPS_ABSETA_PREVDIR
:
957 if (global_settings
.party_mode
)
959 #if defined(AB_REPEAT_ENABLE)
960 if (ab_repeat_mode_enabled())
961 ab_set_A_marker(state
->id3
->elapsed
);
968 /* menu key functions */
969 case ACTION_WPS_MENU
:
975 #ifdef HAVE_QUICKSCREEN
976 case ACTION_WPS_QUICKSCREEN
:
979 if (quick_screen_quick(button
))
984 #endif /* HAVE_QUICKSCREEN */
986 /* screen settings */
991 if (quick_screen_f3(BUTTON_F3
))
996 #endif /* BUTTON_F3 */
999 #ifdef HAVE_PITCHSCREEN
1000 case ACTION_WPS_PITCHSCREEN
:
1003 if (1 == gui_syncpitchscreen_run())
1008 #endif /* HAVE_PITCHSCREEN */
1010 #ifdef AB_REPEAT_ENABLE
1011 /* reset A&B markers */
1012 case ACTION_WPS_ABRESET
:
1013 if (ab_repeat_mode_enabled())
1019 #endif /* AB_REPEAT_ENABLE */
1021 /* stop and exit wps */
1022 case ACTION_WPS_STOP
:
1023 if (global_settings
.party_mode
)
1029 case ACTION_WPS_ID3SCREEN
:
1037 /* this case is used by the softlock feature
1038 * it requests a full update here */
1040 skin_request_full_update(WPS
);
1042 case ACTION_NONE
: /* Timeout, do a partial update */
1044 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1046 #ifdef HAVE_RECORDING
1047 case ACTION_WPS_REC
:
1051 case ACTION_WPS_VIEW_PLAYLIST
:
1053 return GO_TO_PLAYLIST_VIEWER
;
1056 switch(default_event_handler(button
))
1057 { /* music has been stopped by the default handler */
1058 case SYS_USB_CONNECTED
:
1059 case SYS_CALL_INCOMING
:
1060 case BUTTON_MULTIMEDIA_STOP
:
1071 vol_changed
= false;
1075 if(update_onvol_change(i
))
1080 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
1086 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1087 TIME_AFTER(current_tick
, restoretimer
)))
1090 restoretimer
= RESTORE_WPS_INSTANTLY
;
1091 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1092 add_event(LCD_EVENT_ACTIVATION
, false, wps_lcd_activation_hook
);
1094 /* we remove the update delay since it's not very usable in the wps,
1095 * e.g. during volume changing or ffwd/rewind */
1096 sb_skin_set_update_delay(0);
1097 skin_request_full_update(WPS
);
1103 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1104 gwps_caption_backlight(state
);
1108 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1109 /* currently, all remotes are readable without backlight
1110 * so still update those */
1111 if (lcd_active() || (i
!= SCREEN_MAIN
))
1114 bool full_update
= skin_do_full_update(WPS
, i
);
1115 if (update
|| full_update
)
1117 skin_update(WPS
, i
, full_update
?
1118 SKIN_REFRESH_ALL
: SKIN_REFRESH_NON_STATIC
);
1126 #ifdef HAVE_LCD_CHARCELLS
1127 status_set_record(false);
1128 status_set_audio(false);
1130 if (global_settings
.fade_on_stop
)
1134 bookmark_autobookmark(true);
1136 #ifdef AB_REPEAT_ENABLE
1140 #ifdef HAVE_RECORDING
1141 if (button
== ACTION_WPS_REC
)
1142 return GO_TO_RECSCREEN
;
1144 if (global_settings
.browse_current
)
1145 return GO_TO_PREVIOUS_BROWSER
;
1146 return GO_TO_PREVIOUS
;
1149 if (button
&& !IS_SYSEVENT(button
) )
1152 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1155 /* this is called from the playback thread so NO DRAWING! */
1156 static void track_changed_callback(void *param
)
1158 struct wps_state
*state
= skin_get_global_state();
1159 state
->id3
= (struct mp3entry
*)param
;
1160 state
->nid3
= audio_next_track();
1161 if (state
->id3
->cuesheet
)
1163 cue_find_current_track(state
->id3
->cuesheet
, state
->id3
->elapsed
);
1165 skin_request_full_update(WPS
);
1167 static void nextid3available_callback(void* param
)
1170 skin_get_global_state()->nid3
= audio_next_track();
1171 skin_request_full_update(WPS
);
1174 #ifdef AUDIO_FAST_SKIP_PREVIEW
1175 /* this is called on the audio_skip caller thread */
1176 static void track_skip_callback(void *param
)
1178 struct wps_state
*state
= skin_get_global_state();
1179 state
->id3
= audio_current_track();
1180 state
->nid3
= audio_next_track();
1181 skin_request_full_update(WPS
);
1184 #endif /* AUDIO_FAST_SKIP_PREVIEW */
1186 static void wps_state_init(void)
1188 struct wps_state
*state
= skin_get_global_state();
1189 state
->ff_rewind
= false;
1190 state
->paused
= false;
1191 if(audio_status() & AUDIO_STATUS_PLAY
)
1193 state
->id3
= audio_current_track();
1194 state
->nid3
= audio_next_track();
1201 /* We'll be updating due to restore initialized with true */
1202 skin_request_full_update(WPS
);
1203 /* add the WPS track event callbacks */
1204 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1205 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1206 #if CONFIG_CODEC == SWCODEC
1207 /* Use the same callback as ..._TRACK_CHANGE for when remaining handles have
1209 add_event(PLAYBACK_EVENT_CUR_TRACK_READY
, false, track_changed_callback
);
1211 #ifdef AUDIO_FAST_SKIP_PREVIEW
1212 add_event(PLAYBACK_EVENT_TRACK_SKIP
, false, track_skip_callback
);
1217 #ifdef IPOD_ACCESSORY_PROTOCOL
1218 bool is_wps_fading(void)
1220 return skin_get_global_state()->is_fading
;
1223 int wps_get_ff_rewind_count(void)
1225 return skin_get_global_state()->ff_rewind_count
;