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
55 #include "ata_idle_notify.h"
56 #include "root_menu.h"
58 #include "quickscreen.h"
59 #include "pitchscreen.h"
60 #include "appevents.h"
63 #include "option_select.h"
64 #include "playlist_viewer.h"
66 #include "statusbar-skinned.h"
68 #define RESTORE_WPS_INSTANTLY 0l
69 #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
71 #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
72 /* 3% of 30min file == 54s step size */
73 #define MIN_FF_REWIND_STEP 500
75 /* initial setup of wps_data */
76 static void wps_state_init(void);
77 static void track_changed_callback(void *param
);
78 static void nextid3available_callback(void* param
);
80 #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps"
81 #ifdef HAVE_REMOTE_LCD
82 #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps"
83 #define DEFAULT_WPS(screen) ((screen) == SCREEN_MAIN ? \
84 WPS_DEFAULTCFG:RWPS_DEFAULTCFG)
86 #define DEFAULT_WPS(screen) (WPS_DEFAULTCFG)
89 char* wps_default_skin(enum screen_type screen
)
91 static char *skin_buf
[NB_SCREENS
] = {
92 #ifdef HAVE_LCD_BITMAP
96 "%s%?it<%?in<%in. |>%it|%fn>\n"
97 "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
98 "%s%?id<%id|%?d(1)<%d(1)|%(root%)>> %?iy<%(%iy%)|>\n\n"
99 "%al%pc/%pt%ar[%pp:%pe]\n"
100 "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
103 "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d(2)> - %?id<%id|%d(1)>\n"
106 #ifdef HAVE_REMOTE_LCD
107 #if LCD_REMOTE_DEPTH > 1
110 "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
111 "%s%?it<%?in<%in. |>%it|%fn>\n"
112 "%al%pc/%pt%ar[%pp:%pe]\n"
113 "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
117 return skin_buf
[screen
];
120 static void update_non_static(void)
123 skin_update(WPS
, i
, SKIN_REFRESH_NON_STATIC
);
126 void pause_action(bool may_fade
, bool updatewps
)
128 #if CONFIG_CODEC == SWCODEC
129 /* Do audio first, then update, unless skin were to use its local
130 status in which case, reverse it */
136 if (may_fade
&& global_settings
.fade_on_stop
)
137 fade(false, updatewps
);
142 if (global_settings
.pause_rewind
) {
145 #if (CONFIG_CODEC == SWCODEC)
146 audio_pre_ff_rewind();
148 newpos
= audio_current_track()->elapsed
149 - global_settings
.pause_rewind
* 1000;
150 audio_ff_rewind(newpos
> 0 ? newpos
: 0);
156 void unpause_action(bool may_fade
, bool updatewps
)
158 #if CONFIG_CODEC == SWCODEC
159 /* Do audio first, then update, unless skin were to use its local
160 status in which case, reverse it */
166 if (may_fade
&& global_settings
.fade_on_stop
)
167 fade(true, updatewps
);
175 #if CONFIG_CODEC != SWCODEC
176 void fade(bool fade_in
, bool updatewps
)
178 int fp_global_vol
= global_settings
.volume
<< 8;
179 int fp_min_vol
= sound_min(SOUND_VOLUME
) << 8;
180 int fp_step
= (fp_global_vol
- fp_min_vol
) / 10;
182 skin_get_global_state()->is_fading
= !fade_in
;
185 int fp_volume
= fp_min_vol
;
187 /* zero out the sound */
188 sound_set_volume(fp_min_vol
>> 8);
190 sleep(HZ
/10); /* let audio thread run */
196 while (fp_volume
< fp_global_vol
- fp_step
) {
197 fp_volume
+= fp_step
;
198 sound_set_volume(fp_volume
>> 8);
201 sound_set_volume(global_settings
.volume
);
205 int fp_volume
= fp_global_vol
;
210 while (fp_volume
> fp_min_vol
+ fp_step
) {
211 fp_volume
-= fp_step
;
212 sound_set_volume(fp_volume
>> 8);
217 skin_get_global_state()->is_fading
= false;
218 #if CONFIG_CODEC != SWCODEC
220 /* let audio thread run and wait for the mas to run out of data */
221 while (!mp3_pause_done())
226 /* reset volume to what it was before the fade */
227 sound_set_volume(global_settings
.volume
);
232 static bool update_onvol_change(enum screen_type screen
)
234 skin_update(WPS
, screen
, SKIN_REFRESH_NON_STATIC
);
236 #ifdef HAVE_LCD_CHARCELLS
237 splashf(0, "Vol: %3d dB",
238 sound_val2phys(SOUND_VOLUME
, global_settings
.volume
));
245 #ifdef HAVE_TOUCHSCREEN
246 static int skintouch_to_wps(struct wps_data
*data
)
249 struct touchregion
*region
;
250 int button
= skin_get_touchaction(data
, &offset
, ®ion
);
253 case ACTION_STD_PREV
:
254 return ACTION_WPS_SKIPPREV
;
255 case ACTION_STD_PREVREPEAT
:
256 return ACTION_WPS_SEEKBACK
;
257 case ACTION_STD_NEXT
:
258 return ACTION_WPS_SKIPNEXT
;
259 case ACTION_STD_NEXTREPEAT
:
260 return ACTION_WPS_SEEKFWD
;
261 case ACTION_STD_MENU
:
262 return ACTION_WPS_MENU
;
263 case ACTION_STD_CONTEXT
:
264 return ACTION_WPS_CONTEXT
;
265 case ACTION_STD_QUICKSCREEN
:
266 return ACTION_WPS_QUICKSCREEN
;
268 case ACTION_STD_HOTKEY
:
269 return ACTION_WPS_HOTKEY
;
271 case ACTION_TOUCH_SCROLLBAR
:
272 skin_get_global_state()->id3
->elapsed
= skin_get_global_state()->id3
->length
*offset
/100;
273 #if (CONFIG_CODEC == SWCODEC)
274 audio_pre_ff_rewind();
276 if (!skin_get_global_state()->paused
)
279 audio_ff_rewind(skin_get_global_state()->id3
->elapsed
);
280 #if (CONFIG_CODEC != SWCODEC)
281 if (!skin_get_global_state()->paused
)
284 return ACTION_TOUCHSCREEN
;
285 case ACTION_TOUCH_VOLUME
:
287 const int min_vol
= sound_min(SOUND_VOLUME
);
288 const int max_vol
= sound_max(SOUND_VOLUME
);
289 global_settings
.volume
= (offset
* (max_vol
- min_vol
)) / 100;
290 global_settings
.volume
+= min_vol
;
293 return ACTION_TOUCHSCREEN
;
297 #endif /* HAVE_TOUCHSCREEN */
299 bool ffwd_rew(int button
)
301 unsigned int step
= 0; /* current ff/rewind step */
302 unsigned int max_step
= 0; /* maximum ff/rewind step */
303 int ff_rewind_count
= 0; /* current ff/rewind count (in ticks) */
304 int direction
= -1; /* forward=1 or backward=-1 */
307 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
309 if (button
== ACTION_NONE
)
311 status_set_ffmode(0);
318 case ACTION_WPS_SEEKFWD
:
320 case ACTION_WPS_SEEKBACK
:
321 if (skin_get_global_state()->ff_rewind
)
325 /* fast forwarding, calc max step relative to end */
326 max_step
= (skin_get_global_state()->id3
->length
-
327 (skin_get_global_state()->id3
->elapsed
+
329 FF_REWIND_MAX_PERCENT
/ 100;
333 /* rewinding, calc max step relative to start */
334 max_step
= (skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) *
335 FF_REWIND_MAX_PERCENT
/ 100;
338 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
343 ff_rewind_count
+= step
* direction
;
345 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
346 step
+= step
>> ff_rw_accel
;
350 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
351 skin_get_global_state()->id3
&& skin_get_global_state()->id3
->length
)
353 #if (CONFIG_CODEC == SWCODEC)
354 audio_pre_ff_rewind();
356 if (!skin_get_global_state()->paused
)
359 #if CONFIG_KEYPAD == PLAYER_PAD
361 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
364 status_set_ffmode(STATUS_FASTFORWARD
);
366 status_set_ffmode(STATUS_FASTBACKWARD
);
368 skin_get_global_state()->ff_rewind
= true;
370 step
= 1000 * global_settings
.ff_rewind_min_step
;
377 if ((skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) >
378 skin_get_global_state()->id3
->length
)
379 ff_rewind_count
= skin_get_global_state()->id3
->length
-
380 skin_get_global_state()->id3
->elapsed
;
383 if ((int)(skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) < 0)
384 ff_rewind_count
= -skin_get_global_state()->id3
->elapsed
;
387 /* set the wps state ff_rewind_count so the progess info
389 skin_get_global_state()->ff_rewind_count
= ff_rewind_count
;
394 SKIN_REFRESH_PLAYER_PROGRESS
|
395 SKIN_REFRESH_DYNAMIC
);
400 case ACTION_WPS_STOPSEEK
:
401 skin_get_global_state()->id3
->elapsed
= skin_get_global_state()->id3
->elapsed
+ff_rewind_count
;
402 audio_ff_rewind(skin_get_global_state()->id3
->elapsed
);
403 skin_get_global_state()->ff_rewind_count
= 0;
404 skin_get_global_state()->ff_rewind
= false;
405 status_set_ffmode(0);
406 #if (CONFIG_CODEC != SWCODEC)
407 if (!skin_get_global_state()->paused
)
410 #ifdef HAVE_LCD_CHARCELLS
412 skin_update(WPS
, i
, SKIN_REFRESH_ALL
);
418 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
419 status_set_ffmode(0);
427 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_BLOCK
);
428 #ifdef HAVE_TOUCHSCREEN
429 if (button
== ACTION_TOUCHSCREEN
)
430 button
= skintouch_to_wps(skin_get_gwps(WPS
, SCREEN_MAIN
)->data
);
432 if (button
!= ACTION_WPS_SEEKFWD
&&
433 button
!= ACTION_WPS_SEEKBACK
)
434 button
= ACTION_WPS_STOPSEEK
;
440 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
441 static void gwps_caption_backlight(struct wps_state
*state
)
443 if (state
&& state
->id3
)
445 #ifdef HAVE_BACKLIGHT
446 if (global_settings
.caption_backlight
)
448 /* turn on backlight n seconds before track ends, and turn it off n
449 seconds into the new track. n == backlight_timeout, or 5s */
450 int n
= global_settings
.backlight_timeout
* 1000;
453 n
= 5000; /* use 5s if backlight is always on or off */
455 if (((state
->id3
->elapsed
< 1000) ||
456 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
457 (state
->paused
== false))
461 #ifdef HAVE_REMOTE_LCD
462 if (global_settings
.remote_caption_backlight
)
464 /* turn on remote backlight n seconds before track ends, and turn it
465 off n seconds into the new track. n == remote_backlight_timeout,
467 int n
= global_settings
.remote_backlight_timeout
* 1000;
470 n
= 5000; /* use 5s if backlight is always on or off */
472 if (((state
->id3
->elapsed
< 1000) ||
473 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
474 (state
->paused
== false))
475 remote_backlight_on();
483 static void change_dir(int direction
)
485 if (global_settings
.prevent_skip
)
490 else if (direction
> 0)
492 /* prevent the next dir to immediatly start being ffw'd */
493 action_wait_for_release();
496 static void prev_track(unsigned long skip_thresh
)
498 struct wps_state
*state
= skin_get_global_state();
499 if (state
->id3
->elapsed
< skip_thresh
)
506 if (state
->id3
->cuesheet
)
508 curr_cuesheet_skip(state
->id3
->cuesheet
, -1, state
->id3
->elapsed
);
512 #if (CONFIG_CODEC == SWCODEC)
513 audio_pre_ff_rewind();
521 #if (CONFIG_CODEC != SWCODEC)
528 static void next_track(void)
530 struct wps_state
*state
= skin_get_global_state();
531 /* take care of if we're playing a cuesheet */
532 if (state
->id3
->cuesheet
)
534 if (curr_cuesheet_skip(state
->id3
->cuesheet
, 1, state
->id3
->elapsed
))
536 /* if the result was false, then we really want
537 to skip to the next track */
545 static void play_hop(int direction
)
547 struct wps_state
*state
= skin_get_global_state();
548 struct cuesheet
*cue
= state
->id3
->cuesheet
;
549 long step
= global_settings
.skip_length
*1000;
550 long elapsed
= state
->id3
->elapsed
;
551 long remaining
= state
->id3
->length
- elapsed
;
553 /* if cuesheet is active, then we want the current tracks end instead of
555 if (cue
&& (cue
->curr_track_idx
+1 < cue
->track_count
))
557 int next
= cue
->curr_track_idx
+1;
558 struct cue_track_info
*t
= &cue
->tracks
[next
];
559 remaining
= t
->offset
- elapsed
;
566 prev_track(DEFAULT_SKIP_TRESH
);
569 else if (remaining
< DEFAULT_SKIP_TRESH
*2)
575 elapsed
+= (remaining
- DEFAULT_SKIP_TRESH
*2);
577 else if (!global_settings
.prevent_skip
&&
579 (direction
> 0 && step
>= remaining
) ||
580 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
581 { /* Do normal track skipping */
584 else if (direction
< 0)
585 prev_track(DEFAULT_SKIP_TRESH
);
588 else if (direction
== 1 && step
>= remaining
)
590 #if CONFIG_CODEC == SWCODEC
591 system_sound_play(SOUND_TRACK_NO_MORE
);
595 else if (direction
== -1 && elapsed
< step
)
601 elapsed
+= step
* direction
;
603 if(audio_status() & AUDIO_STATUS_PLAY
)
605 #if (CONFIG_CODEC == SWCODEC)
606 audio_pre_ff_rewind();
613 #if (CONFIG_CODEC == SWCODEC)
614 audio_ff_rewind(elapsed
);
616 audio_ff_rewind(state
->id3
->elapsed
= elapsed
);
623 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
625 * If the user is unable to see the wps, because the display is deactivated,
626 * we suppress updates until the wps is activated again (the lcd driver will
627 * call this hook to issue an instant update)
629 static void wps_lcd_activation_hook(void *param
)
632 skin_request_full_update(WPS
);
633 /* force timeout in wps main loop, so that the update is instantly */
634 queue_post(&button_queue
, BUTTON_NONE
, 0);
638 static void gwps_leave_wps(void)
642 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
643 #ifdef HAVE_BACKDROP_IMAGE
644 skin_backdrop_show(sb_get_backdrop(i
));
646 viewportmanager_theme_undo(i
, skin_has_sbs(i
, skin_get_gwps(WPS
, i
)->data
));
650 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
651 /* Play safe and unregister the hook */
652 remove_event(LCD_EVENT_ACTIVATION
, wps_lcd_activation_hook
);
654 /* unhandle statusbar update delay */
655 sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY
);
656 #ifdef HAVE_TOUCHSCREEN
657 touchscreen_set_mode(global_settings
.touch_mode
);
662 * display the wps on entering or restoring */
663 static void gwps_enter_wps(void)
665 struct gui_wps
*gwps
;
666 struct screen
*display
;
669 gwps
= skin_get_gwps(WPS
, i
);
670 display
= gwps
->display
;
671 display
->stop_scroll();
672 viewportmanager_theme_enable(i
, skin_has_sbs(i
, skin_get_gwps(WPS
, i
)->data
), NULL
);
674 /* Update the values in the first (default) viewport - in case the user
675 has modified the statusbar or colour settings */
677 if (display
->depth
> 1)
679 struct skin_viewport
*svp
= skin_find_item(VP_DEFAULT_LABEL_STRING
,
680 SKIN_FIND_VP
, gwps
->data
);
683 struct viewport
*vp
= &svp
->vp
;
684 vp
->fg_pattern
= display
->get_foreground();
685 vp
->bg_pattern
= display
->get_background();
689 /* make the backdrop actually take effect */
690 #ifdef HAVE_BACKDROP_IMAGE
691 skin_backdrop_show(gwps
->data
->backdrop_id
);
693 display
->clear_display();
694 skin_update(WPS
, i
, SKIN_REFRESH_ALL
);
697 #ifdef HAVE_TOUCHSCREEN
698 gwps
= skin_get_gwps(WPS
, SCREEN_MAIN
);
699 skin_disarm_touchregions(gwps
->data
);
700 if (gwps
->data
->touchregions
< 0)
701 touchscreen_set_mode(TOUCHSCREEN_BUTTON
);
703 /* force statusbar/skin update since we just cleared the whole screen */
704 send_event(GUI_EVENT_ACTIONUPDATE
, (void*)1);
707 void wps_do_playpause(bool updatewps
)
709 struct wps_state
*state
= skin_get_global_state();
712 state
->paused
= false;
713 unpause_action(true, updatewps
);
717 state
->paused
= true;
718 pause_action(true, updatewps
);
720 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
721 call_storage_idle_notifys(true); /* make sure resume info is saved */
727 /* The WPS can be left in two ways:
728 * a) call a function, which draws over the wps. In this case, the wps
729 * will be still active (i.e. the below function didn't return)
730 * b) return with a value evaluated by root_menu.c, in this case the wps
731 * is really left, and root_menu will handle the next screen
733 * In either way, call gwps_leave_wps(), in order to restore the correct
734 * "main screen" backdrops and statusbars
736 long gui_wps_show(void)
740 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
742 bool bookmark
= false;
744 bool vol_changed
= false;
745 long last_left
= 0, last_right
= 0;
746 struct wps_state
*state
= skin_get_global_state();
748 #ifdef HAVE_LCD_CHARCELLS
749 status_set_audio(true);
750 status_set_param(false);
753 #ifdef AB_REPEAT_ENABLE
761 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
763 /* did someone else (i.e power thread) change audio pause mode? */
764 if (state
->paused
!= audio_paused
) {
765 state
->paused
= audio_paused
;
767 /* if another thread paused audio, we are probably in car mode,
768 about to shut down. lets save the settings. */
771 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
772 call_storage_idle_notifys(true);
776 button
= skin_wait_for_action(WPS
, CONTEXT_WPS
|ALLOW_SOFTLOCK
,
779 /* Exit if audio has stopped playing. This happens e.g. at end of
780 playlist or if using the sleep timer. */
781 if (!(audio_status() & AUDIO_STATUS_PLAY
))
783 #ifdef HAVE_TOUCHSCREEN
784 if (button
== ACTION_TOUCHSCREEN
)
785 button
= skintouch_to_wps(skin_get_gwps(WPS
, SCREEN_MAIN
)->data
);
787 /* The iPods/X5/M5 use a single button for the A-B mode markers,
788 defined as ACTION_WPSAB_SINGLE in their config files. */
789 #ifdef ACTION_WPSAB_SINGLE
790 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
792 static int wps_ab_state
= 0;
793 if (button
== ACTION_WPSAB_SINGLE
)
795 switch (wps_ab_state
)
797 case 0: /* set the A spot */
798 button
= ACTION_WPS_ABSETA_PREVDIR
;
800 case 1: /* set the B spot */
801 button
= ACTION_WPS_ABSETB_NEXTDIR
;
804 button
= ACTION_WPS_ABRESET
;
807 wps_ab_state
= (wps_ab_state
+1) % 3;
814 case ACTION_WPS_HOTKEY
:
815 if (!global_settings
.hotkey_wps
)
819 case ACTION_WPS_CONTEXT
:
821 bool hotkey
= button
== ACTION_WPS_HOTKEY
;
823 int retval
= onplay(state
->id3
->path
,
824 FILE_ATTR_AUDIO
, CONTEXT_WPS
, hotkey
);
825 /* if music is stopped in the context menu we want to exit the wps */
826 if (retval
== ONPLAY_MAINMENU
829 else if (retval
== ONPLAY_PLAYLIST
)
830 return GO_TO_PLAYLIST_VIEWER
;
831 #ifdef HAVE_PICTUREFLOW_INTEGRATION
832 else if (retval
== ONPLAY_PICTUREFLOW
)
833 return GO_TO_PICTUREFLOW
;
839 case ACTION_WPS_BROWSE
:
840 #ifdef HAVE_LCD_CHARCELLS
841 status_set_record(false);
842 status_set_audio(false);
845 return GO_TO_PREVIOUS_BROWSER
;
849 case ACTION_WPS_PLAY
:
850 if (global_settings
.party_mode
)
852 wps_do_playpause(true);
855 case ACTION_WPS_VOLUP
:
856 global_settings
.volume
++;
859 case ACTION_WPS_VOLDOWN
:
860 global_settings
.volume
--;
864 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
865 case ACTION_WPS_SEEKFWD
:
866 if (global_settings
.party_mode
)
868 if (current_tick
-last_right
< HZ
)
870 if (state
->id3
->cuesheet
)
880 ffwd_rew(ACTION_WPS_SEEKFWD
);
881 last_right
= last_left
= 0;
884 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
885 case ACTION_WPS_SEEKBACK
:
886 if (global_settings
.party_mode
)
888 if (current_tick
-last_left
< HZ
)
890 if (state
->id3
->cuesheet
)
892 #if (CONFIG_CODEC == SWCODEC)
893 audio_pre_ff_rewind();
906 ffwd_rew(ACTION_WPS_SEEKBACK
);
907 last_left
= last_right
= 0;
911 case ACTION_WPS_SKIPPREV
:
912 if (global_settings
.party_mode
)
914 last_left
= current_tick
;
915 #ifdef AB_REPEAT_ENABLE
916 /* if we're in A/B repeat mode and the current position
917 is past the A marker, jump back to the A marker... */
918 if ( ab_repeat_mode_enabled() )
920 if ( ab_after_A_marker(state
->id3
->elapsed
) )
922 ab_jump_to_A_marker();
927 /* ...otherwise, do it normally */
933 OR if skip length set, hop by predetermined amount. */
934 case ACTION_WPS_SKIPNEXT
:
935 if (global_settings
.party_mode
)
937 last_right
= current_tick
;
938 #ifdef AB_REPEAT_ENABLE
939 /* if we're in A/B repeat mode and the current position is
940 before the A marker, jump to the A marker... */
941 if ( ab_repeat_mode_enabled() )
943 if ( ab_before_A_marker(state
->id3
->elapsed
) )
945 ab_jump_to_A_marker();
950 /* ...otherwise, do it normally */
954 /* next / prev directories */
955 /* and set A-B markers if in a-b mode */
956 case ACTION_WPS_ABSETB_NEXTDIR
:
957 if (global_settings
.party_mode
)
959 #if defined(AB_REPEAT_ENABLE)
960 if (ab_repeat_mode_enabled())
962 ab_set_B_marker(state
->id3
->elapsed
);
963 ab_jump_to_A_marker();
971 case ACTION_WPS_ABSETA_PREVDIR
:
972 if (global_settings
.party_mode
)
974 #if defined(AB_REPEAT_ENABLE)
975 if (ab_repeat_mode_enabled())
976 ab_set_A_marker(state
->id3
->elapsed
);
983 /* menu key functions */
984 case ACTION_WPS_MENU
:
990 #ifdef HAVE_QUICKSCREEN
991 case ACTION_WPS_QUICKSCREEN
:
994 if (quick_screen_quick(button
))
999 #endif /* HAVE_QUICKSCREEN */
1001 /* screen settings */
1006 if (quick_screen_f3(BUTTON_F3
))
1011 #endif /* BUTTON_F3 */
1014 #ifdef HAVE_PITCHCONTROL
1015 case ACTION_WPS_PITCHSCREEN
:
1018 if (1 == gui_syncpitchscreen_run())
1023 #endif /* HAVE_PITCHCONTROL */
1025 #ifdef AB_REPEAT_ENABLE
1026 /* reset A&B markers */
1027 case ACTION_WPS_ABRESET
:
1028 if (ab_repeat_mode_enabled())
1034 #endif /* AB_REPEAT_ENABLE */
1036 /* stop and exit wps */
1037 case ACTION_WPS_STOP
:
1038 if (global_settings
.party_mode
)
1044 case ACTION_WPS_LIST_BOOKMARKS
:
1046 if (bookmark_load_menu() == BOOKMARK_USB_CONNECTED
)
1053 case ACTION_WPS_CREATE_BOOKMARK
:
1055 bookmark_create_menu();
1059 case ACTION_WPS_ID3SCREEN
:
1067 /* this case is used by the softlock feature
1068 * it requests a full update here */
1070 skin_request_full_update(WPS
);
1072 case ACTION_NONE
: /* Timeout, do a partial update */
1074 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1076 #ifdef HAVE_RECORDING
1077 case ACTION_WPS_REC
:
1081 case ACTION_WPS_VIEW_PLAYLIST
:
1083 return GO_TO_PLAYLIST_VIEWER
;
1086 switch(default_event_handler(button
))
1087 { /* music has been stopped by the default handler */
1088 case SYS_USB_CONNECTED
:
1089 case SYS_CALL_INCOMING
:
1090 case BUTTON_MULTIMEDIA_STOP
:
1101 vol_changed
= false;
1105 if(update_onvol_change(i
))
1110 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
1116 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1117 TIME_AFTER(current_tick
, restoretimer
)))
1120 restoretimer
= RESTORE_WPS_INSTANTLY
;
1121 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1122 add_event(LCD_EVENT_ACTIVATION
, false, wps_lcd_activation_hook
);
1124 /* we remove the update delay since it's not very usable in the wps,
1125 * e.g. during volume changing or ffwd/rewind */
1126 sb_skin_set_update_delay(0);
1127 skin_request_full_update(WPS
);
1133 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1134 gwps_caption_backlight(state
);
1138 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1139 /* currently, all remotes are readable without backlight
1140 * so still update those */
1141 if (lcd_active() || (i
!= SCREEN_MAIN
))
1144 bool full_update
= skin_do_full_update(WPS
, i
);
1145 if (update
|| full_update
)
1147 skin_update(WPS
, i
, full_update
?
1148 SKIN_REFRESH_ALL
: SKIN_REFRESH_NON_STATIC
);
1156 #ifdef HAVE_LCD_CHARCELLS
1157 status_set_record(false);
1158 status_set_audio(false);
1160 #if CONFIG_CODEC != SWCODEC
1161 if (global_settings
.fade_on_stop
)
1165 update_non_static();
1168 bookmark_autobookmark(true);
1170 #ifdef AB_REPEAT_ENABLE
1174 #ifdef HAVE_RECORDING
1175 if (button
== ACTION_WPS_REC
)
1176 return GO_TO_RECSCREEN
;
1178 if (global_settings
.browse_current
)
1179 return GO_TO_PREVIOUS_BROWSER
;
1180 return GO_TO_PREVIOUS
;
1183 if (button
&& !IS_SYSEVENT(button
) )
1186 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1189 /* this is called from the playback thread so NO DRAWING! */
1190 static void track_changed_callback(void *param
)
1192 struct wps_state
*state
= skin_get_global_state();
1193 state
->id3
= (struct mp3entry
*)param
;
1194 state
->nid3
= audio_next_track();
1195 if (state
->id3
->cuesheet
)
1197 cue_find_current_track(state
->id3
->cuesheet
, state
->id3
->elapsed
);
1199 skin_request_full_update(WPS
);
1201 static void nextid3available_callback(void* param
)
1204 skin_get_global_state()->nid3
= audio_next_track();
1205 skin_request_full_update(WPS
);
1208 #ifdef AUDIO_FAST_SKIP_PREVIEW
1209 /* this is called on the audio_skip caller thread */
1210 static void track_skip_callback(void *param
)
1212 struct wps_state
*state
= skin_get_global_state();
1213 state
->id3
= audio_current_track();
1214 state
->nid3
= audio_next_track();
1215 skin_request_full_update(WPS
);
1218 #endif /* AUDIO_FAST_SKIP_PREVIEW */
1220 static void wps_state_init(void)
1222 struct wps_state
*state
= skin_get_global_state();
1223 state
->ff_rewind
= false;
1224 state
->paused
= false;
1225 if(audio_status() & AUDIO_STATUS_PLAY
)
1227 state
->id3
= audio_current_track();
1228 state
->nid3
= audio_next_track();
1235 /* We'll be updating due to restore initialized with true */
1236 skin_request_full_update(WPS
);
1237 /* add the WPS track event callbacks */
1238 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1239 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1240 #if CONFIG_CODEC == SWCODEC
1241 /* Use the same callback as ..._TRACK_CHANGE for when remaining handles have
1243 add_event(PLAYBACK_EVENT_CUR_TRACK_READY
, false, track_changed_callback
);
1245 #ifdef AUDIO_FAST_SKIP_PREVIEW
1246 add_event(PLAYBACK_EVENT_TRACK_SKIP
, false, track_skip_callback
);
1251 #ifdef IPOD_ACCESSORY_PROTOCOL
1252 bool is_wps_fading(void)
1254 return skin_get_global_state()->is_fading
;
1257 int wps_get_ff_rewind_count(void)
1259 return skin_get_global_state()->ff_rewind_count
;