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"
65 #include "playlist_viewer.h"
67 #include "statusbar-skinned.h"
69 #define RESTORE_WPS_INSTANTLY 0l
70 #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
72 #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
73 /* 3% of 30min file == 54s step size */
74 #define MIN_FF_REWIND_STEP 500
76 /* initial setup of wps_data */
77 static void wps_state_init(void);
78 static void track_changed_callback(void *param
);
79 static void nextid3available_callback(void* param
);
81 #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps"
82 #ifdef HAVE_REMOTE_LCD
83 #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps"
84 #define DEFAULT_WPS(screen) ((screen) == SCREEN_MAIN ? \
85 WPS_DEFAULTCFG:RWPS_DEFAULTCFG)
87 #define DEFAULT_WPS(screen) (WPS_DEFAULTCFG)
90 char* wps_default_skin(enum screen_type screen
)
92 static char *skin_buf
[NB_SCREENS
] = {
93 #ifdef HAVE_LCD_BITMAP
97 "%s%?it<%?in<%in. |>%it|%fn>\n"
98 "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
99 "%s%?id<%id|%?d(1)<%d(1)|%(root%)>> %?iy<%(%iy%)|>\n\n"
100 "%al%pc/%pt%ar[%pp:%pe]\n"
101 "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
104 "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d(2)> - %?id<%id|%d(1)>\n"
107 #ifdef HAVE_REMOTE_LCD
108 #if LCD_REMOTE_DEPTH > 1
111 "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n"
112 "%s%?it<%?in<%in. |>%it|%fn>\n"
113 "%al%pc/%pt%ar[%pp:%pe]\n"
114 "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n"
118 return skin_buf
[screen
];
121 static void update_non_static(void)
124 skin_update(WPS
, i
, SKIN_REFRESH_NON_STATIC
);
127 void pause_action(bool may_fade
, bool updatewps
)
129 #if CONFIG_CODEC == SWCODEC
130 /* Do audio first, then update, unless skin were to use its local
131 status in which case, reverse it */
137 if (may_fade
&& global_settings
.fade_on_stop
)
138 fade(false, updatewps
);
143 if (global_settings
.pause_rewind
) {
146 #if (CONFIG_CODEC == SWCODEC)
147 audio_pre_ff_rewind();
149 newpos
= audio_current_track()->elapsed
150 - global_settings
.pause_rewind
* 1000;
151 audio_ff_rewind(newpos
> 0 ? newpos
: 0);
157 void unpause_action(bool may_fade
, bool updatewps
)
159 #if CONFIG_CODEC == SWCODEC
160 /* Do audio first, then update, unless skin were to use its local
161 status in which case, reverse it */
167 if (may_fade
&& global_settings
.fade_on_stop
)
168 fade(true, updatewps
);
176 #if CONFIG_CODEC != SWCODEC
177 void fade(bool fade_in
, bool updatewps
)
179 int fp_global_vol
= global_settings
.volume
<< 8;
180 int fp_min_vol
= sound_min(SOUND_VOLUME
) << 8;
181 int fp_step
= (fp_global_vol
- fp_min_vol
) / 10;
183 skin_get_global_state()->is_fading
= !fade_in
;
186 int fp_volume
= fp_min_vol
;
188 /* zero out the sound */
189 sound_set_volume(fp_min_vol
>> 8);
191 sleep(HZ
/10); /* let audio thread run */
197 while (fp_volume
< fp_global_vol
- fp_step
) {
198 fp_volume
+= fp_step
;
199 sound_set_volume(fp_volume
>> 8);
202 sound_set_volume(global_settings
.volume
);
206 int fp_volume
= fp_global_vol
;
211 while (fp_volume
> fp_min_vol
+ fp_step
) {
212 fp_volume
-= fp_step
;
213 sound_set_volume(fp_volume
>> 8);
218 skin_get_global_state()->is_fading
= false;
219 #if CONFIG_CODEC != SWCODEC
221 /* let audio thread run and wait for the mas to run out of data */
222 while (!mp3_pause_done())
227 /* reset volume to what it was before the fade */
228 sound_set_volume(global_settings
.volume
);
233 static bool update_onvol_change(enum screen_type screen
)
235 skin_update(WPS
, screen
, SKIN_REFRESH_NON_STATIC
);
237 #ifdef HAVE_LCD_CHARCELLS
238 splashf(0, "Vol: %3d dB",
239 sound_val2phys(SOUND_VOLUME
, global_settings
.volume
));
246 #ifdef HAVE_TOUCHSCREEN
247 static int skintouch_to_wps(struct wps_data
*data
)
250 struct touchregion
*region
;
251 int button
= skin_get_touchaction(data
, &offset
, ®ion
);
254 case ACTION_STD_PREV
:
255 return ACTION_WPS_SKIPPREV
;
256 case ACTION_STD_PREVREPEAT
:
257 return ACTION_WPS_SEEKBACK
;
258 case ACTION_STD_NEXT
:
259 return ACTION_WPS_SKIPNEXT
;
260 case ACTION_STD_NEXTREPEAT
:
261 return ACTION_WPS_SEEKFWD
;
262 case ACTION_STD_MENU
:
263 return ACTION_WPS_MENU
;
264 case ACTION_STD_CONTEXT
:
265 return ACTION_WPS_CONTEXT
;
266 case ACTION_STD_QUICKSCREEN
:
267 return ACTION_WPS_QUICKSCREEN
;
269 case ACTION_STD_HOTKEY
:
270 return ACTION_WPS_HOTKEY
;
272 case ACTION_TOUCH_SCROLLBAR
:
273 skin_get_global_state()->id3
->elapsed
= skin_get_global_state()->id3
->length
*offset
/100;
274 #if (CONFIG_CODEC == SWCODEC)
275 audio_pre_ff_rewind();
277 if (!skin_get_global_state()->paused
)
280 audio_ff_rewind(skin_get_global_state()->id3
->elapsed
);
281 #if (CONFIG_CODEC != SWCODEC)
282 if (!skin_get_global_state()->paused
)
285 return ACTION_TOUCHSCREEN
;
286 case ACTION_TOUCH_VOLUME
:
288 const int min_vol
= sound_min(SOUND_VOLUME
);
289 const int max_vol
= sound_max(SOUND_VOLUME
);
290 global_settings
.volume
= (offset
* (max_vol
- min_vol
)) / 100;
291 global_settings
.volume
+= min_vol
;
294 return ACTION_TOUCHSCREEN
;
298 #endif /* HAVE_TOUCHSCREEN */
300 bool ffwd_rew(int button
)
302 unsigned int step
= 0; /* current ff/rewind step */
303 unsigned int max_step
= 0; /* maximum ff/rewind step */
304 int ff_rewind_count
= 0; /* current ff/rewind count (in ticks) */
305 int direction
= -1; /* forward=1 or backward=-1 */
308 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
310 if (button
== ACTION_NONE
)
312 status_set_ffmode(0);
319 case ACTION_WPS_SEEKFWD
:
321 case ACTION_WPS_SEEKBACK
:
322 if (skin_get_global_state()->ff_rewind
)
326 /* fast forwarding, calc max step relative to end */
327 max_step
= (skin_get_global_state()->id3
->length
-
328 (skin_get_global_state()->id3
->elapsed
+
330 FF_REWIND_MAX_PERCENT
/ 100;
334 /* rewinding, calc max step relative to start */
335 max_step
= (skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) *
336 FF_REWIND_MAX_PERCENT
/ 100;
339 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
344 ff_rewind_count
+= step
* direction
;
346 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
347 step
+= step
>> ff_rw_accel
;
351 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
352 skin_get_global_state()->id3
&& skin_get_global_state()->id3
->length
)
354 #if (CONFIG_CODEC == SWCODEC)
355 audio_pre_ff_rewind();
357 if (!skin_get_global_state()->paused
)
360 #if CONFIG_KEYPAD == PLAYER_PAD
362 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
365 status_set_ffmode(STATUS_FASTFORWARD
);
367 status_set_ffmode(STATUS_FASTBACKWARD
);
369 skin_get_global_state()->ff_rewind
= true;
371 step
= 1000 * global_settings
.ff_rewind_min_step
;
378 if ((skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) >
379 skin_get_global_state()->id3
->length
)
380 ff_rewind_count
= skin_get_global_state()->id3
->length
-
381 skin_get_global_state()->id3
->elapsed
;
384 if ((int)(skin_get_global_state()->id3
->elapsed
+ ff_rewind_count
) < 0)
385 ff_rewind_count
= -skin_get_global_state()->id3
->elapsed
;
388 /* set the wps state ff_rewind_count so the progess info
390 skin_get_global_state()->ff_rewind_count
= ff_rewind_count
;
395 SKIN_REFRESH_PLAYER_PROGRESS
|
396 SKIN_REFRESH_DYNAMIC
);
401 case ACTION_WPS_STOPSEEK
:
402 skin_get_global_state()->id3
->elapsed
= skin_get_global_state()->id3
->elapsed
+ff_rewind_count
;
403 audio_ff_rewind(skin_get_global_state()->id3
->elapsed
);
404 skin_get_global_state()->ff_rewind_count
= 0;
405 skin_get_global_state()->ff_rewind
= false;
406 status_set_ffmode(0);
407 #if (CONFIG_CODEC != SWCODEC)
408 if (!skin_get_global_state()->paused
)
411 #ifdef HAVE_LCD_CHARCELLS
413 skin_update(WPS
, i
, SKIN_REFRESH_ALL
);
419 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
420 status_set_ffmode(0);
428 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_BLOCK
);
429 #ifdef HAVE_TOUCHSCREEN
430 if (button
== ACTION_TOUCHSCREEN
)
431 button
= skintouch_to_wps(skin_get_gwps(WPS
, SCREEN_MAIN
)->data
);
433 if (button
!= ACTION_WPS_SEEKFWD
&&
434 button
!= ACTION_WPS_SEEKBACK
)
435 button
= ACTION_WPS_STOPSEEK
;
441 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
442 static void gwps_caption_backlight(struct wps_state
*state
)
444 if (state
&& state
->id3
)
446 #ifdef HAVE_BACKLIGHT
447 if (global_settings
.caption_backlight
)
449 /* turn on backlight n seconds before track ends, and turn it off n
450 seconds into the new track. n == backlight_timeout, or 5s */
451 int n
= global_settings
.backlight_timeout
* 1000;
454 n
= 5000; /* use 5s if backlight is always on or off */
456 if (((state
->id3
->elapsed
< 1000) ||
457 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
458 (state
->paused
== false))
462 #ifdef HAVE_REMOTE_LCD
463 if (global_settings
.remote_caption_backlight
)
465 /* turn on remote backlight n seconds before track ends, and turn it
466 off n seconds into the new track. n == remote_backlight_timeout,
468 int n
= global_settings
.remote_backlight_timeout
* 1000;
471 n
= 5000; /* use 5s if backlight is always on or off */
473 if (((state
->id3
->elapsed
< 1000) ||
474 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
475 (state
->paused
== false))
476 remote_backlight_on();
484 static void change_dir(int direction
)
486 if (global_settings
.prevent_skip
)
491 else if (direction
> 0)
493 /* prevent the next dir to immediatly start being ffw'd */
494 action_wait_for_release();
497 static void prev_track(unsigned long skip_thresh
)
499 struct wps_state
*state
= skin_get_global_state();
500 if (state
->id3
->elapsed
< skip_thresh
)
507 if (state
->id3
->cuesheet
)
509 curr_cuesheet_skip(state
->id3
->cuesheet
, -1, state
->id3
->elapsed
);
513 #if (CONFIG_CODEC == SWCODEC)
514 audio_pre_ff_rewind();
522 #if (CONFIG_CODEC != SWCODEC)
529 static void next_track(void)
531 struct wps_state
*state
= skin_get_global_state();
532 /* take care of if we're playing a cuesheet */
533 if (state
->id3
->cuesheet
)
535 if (curr_cuesheet_skip(state
->id3
->cuesheet
, 1, state
->id3
->elapsed
))
537 /* if the result was false, then we really want
538 to skip to the next track */
546 static void play_hop(int direction
)
548 struct wps_state
*state
= skin_get_global_state();
549 struct cuesheet
*cue
= state
->id3
->cuesheet
;
550 long step
= global_settings
.skip_length
*1000;
551 long elapsed
= state
->id3
->elapsed
;
552 long remaining
= state
->id3
->length
- elapsed
;
554 /* if cuesheet is active, then we want the current tracks end instead of
556 if (cue
&& (cue
->curr_track_idx
+1 < cue
->track_count
))
558 int next
= cue
->curr_track_idx
+1;
559 struct cue_track_info
*t
= &cue
->tracks
[next
];
560 remaining
= t
->offset
- elapsed
;
567 prev_track(DEFAULT_SKIP_TRESH
);
570 else if (remaining
< DEFAULT_SKIP_TRESH
*2)
576 elapsed
+= (remaining
- DEFAULT_SKIP_TRESH
*2);
578 else if (!global_settings
.prevent_skip
&&
580 (direction
> 0 && step
>= remaining
) ||
581 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
582 { /* Do normal track skipping */
585 else if (direction
< 0)
586 prev_track(DEFAULT_SKIP_TRESH
);
589 else if (direction
== 1 && step
>= remaining
)
591 #if CONFIG_CODEC == SWCODEC
592 system_sound_play(SOUND_TRACK_NO_MORE
);
596 else if ((direction
== -1 && elapsed
< step
))
602 elapsed
+= step
* direction
;
604 if(audio_status() & AUDIO_STATUS_PLAY
)
606 #if (CONFIG_CODEC == SWCODEC)
607 audio_pre_ff_rewind();
614 #if (CONFIG_CODEC == SWCODEC)
615 audio_ff_rewind(elapsed
);
617 audio_ff_rewind(state
->id3
->elapsed
= elapsed
);
624 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
626 * If the user is unable to see the wps, because the display is deactivated,
627 * we suppress updates until the wps is activated again (the lcd driver will
628 * call this hook to issue an instant update)
630 static void wps_lcd_activation_hook(void *param
)
633 skin_request_full_update(WPS
);
634 /* force timeout in wps main loop, so that the update is instantly */
635 queue_post(&button_queue
, BUTTON_NONE
, 0);
639 static void gwps_leave_wps(void)
643 skin_get_gwps(WPS
, i
)->display
->stop_scroll();
644 #ifdef HAVE_BACKDROP_IMAGE
645 skin_backdrop_show(sb_get_backdrop(i
));
647 viewportmanager_theme_undo(i
, skin_has_sbs(i
, skin_get_gwps(WPS
, i
)->data
));
651 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
652 /* Play safe and unregister the hook */
653 remove_event(LCD_EVENT_ACTIVATION
, wps_lcd_activation_hook
);
655 /* unhandle statusbar update delay */
656 sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY
);
657 #ifdef HAVE_TOUCHSCREEN
658 touchscreen_set_mode(global_settings
.touch_mode
);
663 * display the wps on entering or restoring */
664 static void gwps_enter_wps(void)
666 struct gui_wps
*gwps
;
667 struct screen
*display
;
670 gwps
= skin_get_gwps(WPS
, i
);
671 display
= gwps
->display
;
672 display
->stop_scroll();
673 viewportmanager_theme_enable(i
, skin_has_sbs(i
, skin_get_gwps(WPS
, i
)->data
), NULL
);
675 /* Update the values in the first (default) viewport - in case the user
676 has modified the statusbar or colour settings */
678 if (display
->depth
> 1)
680 struct skin_viewport
*svp
= skin_find_item(VP_DEFAULT_LABEL_STRING
,
681 SKIN_FIND_VP
, gwps
->data
);
684 struct viewport
*vp
= &svp
->vp
;
685 vp
->fg_pattern
= display
->get_foreground();
686 vp
->bg_pattern
= display
->get_background();
690 /* make the backdrop actually take effect */
691 #ifdef HAVE_BACKDROP_IMAGE
692 skin_backdrop_show(gwps
->data
->backdrop_id
);
694 display
->clear_display();
695 skin_update(WPS
, i
, SKIN_REFRESH_ALL
);
698 #ifdef HAVE_TOUCHSCREEN
699 gwps
= skin_get_gwps(WPS
, SCREEN_MAIN
);
700 skin_disarm_touchregions(gwps
->data
);
701 if (gwps
->data
->touchregions
< 0)
702 touchscreen_set_mode(TOUCHSCREEN_BUTTON
);
704 /* force statusbar/skin update since we just cleared the whole screen */
705 send_event(GUI_EVENT_ACTIONUPDATE
, (void*)1);
708 void wps_do_playpause(bool updatewps
)
710 struct wps_state
*state
= skin_get_global_state();
713 state
->paused
= false;
714 unpause_action(true, updatewps
);
718 state
->paused
= true;
719 pause_action(true, updatewps
);
721 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
722 call_storage_idle_notifys(true); /* make sure resume info is saved */
728 /* The WPS can be left in two ways:
729 * a) call a function, which draws over the wps. In this case, the wps
730 * will be still active (i.e. the below function didn't return)
731 * b) return with a value evaluated by root_menu.c, in this case the wps
732 * is really left, and root_menu will handle the next screen
734 * In either way, call gwps_leave_wps(), in order to restore the correct
735 * "main screen" backdrops and statusbars
737 long gui_wps_show(void)
741 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
743 bool bookmark
= false;
745 bool vol_changed
= false;
746 long last_left
= 0, last_right
= 0;
747 struct wps_state
*state
= skin_get_global_state();
749 #ifdef HAVE_LCD_CHARCELLS
750 status_set_audio(true);
751 status_set_param(false);
754 #ifdef AB_REPEAT_ENABLE
762 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
764 /* did someone else (i.e power thread) change audio pause mode? */
765 if (state
->paused
!= audio_paused
) {
766 state
->paused
= audio_paused
;
768 /* if another thread paused audio, we are probably in car mode,
769 about to shut down. lets save the settings. */
772 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
773 call_storage_idle_notifys(true);
777 button
= skin_wait_for_action(WPS
, CONTEXT_WPS
|ALLOW_SOFTLOCK
,
780 /* Exit if audio has stopped playing. This happens e.g. at end of
781 playlist or if using the sleep timer. */
782 if (!(audio_status() & AUDIO_STATUS_PLAY
))
784 #ifdef HAVE_TOUCHSCREEN
785 if (button
== ACTION_TOUCHSCREEN
)
786 button
= skintouch_to_wps(skin_get_gwps(WPS
, SCREEN_MAIN
)->data
);
788 /* The iPods/X5/M5 use a single button for the A-B mode markers,
789 defined as ACTION_WPSAB_SINGLE in their config files. */
790 #ifdef ACTION_WPSAB_SINGLE
791 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
793 static int wps_ab_state
= 0;
794 if (button
== ACTION_WPSAB_SINGLE
)
796 switch (wps_ab_state
)
798 case 0: /* set the A spot */
799 button
= ACTION_WPS_ABSETA_PREVDIR
;
801 case 1: /* set the B spot */
802 button
= ACTION_WPS_ABSETB_NEXTDIR
;
805 button
= ACTION_WPS_ABRESET
;
808 wps_ab_state
= (wps_ab_state
+1) % 3;
815 case ACTION_WPS_HOTKEY
:
816 if (!global_settings
.hotkey_wps
)
820 case ACTION_WPS_CONTEXT
:
822 bool hotkey
= button
== ACTION_WPS_HOTKEY
;
824 int retval
= onplay(state
->id3
->path
,
825 FILE_ATTR_AUDIO
, CONTEXT_WPS
, hotkey
);
826 /* if music is stopped in the context menu we want to exit the wps */
827 if (retval
== ONPLAY_MAINMENU
830 else if (retval
== ONPLAY_PLAYLIST
)
831 return GO_TO_PLAYLIST_VIEWER
;
832 #ifdef HAVE_PICTUREFLOW_INTEGRATION
833 else if (retval
== ONPLAY_PICTUREFLOW
)
834 return GO_TO_PICTUREFLOW
;
840 case ACTION_WPS_BROWSE
:
841 #ifdef HAVE_LCD_CHARCELLS
842 status_set_record(false);
843 status_set_audio(false);
846 return GO_TO_PREVIOUS_BROWSER
;
850 case ACTION_WPS_PLAY
:
851 if (global_settings
.party_mode
)
853 wps_do_playpause(true);
856 case ACTION_WPS_VOLUP
:
857 global_settings
.volume
++;
860 case ACTION_WPS_VOLDOWN
:
861 global_settings
.volume
--;
865 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
866 case ACTION_WPS_SEEKFWD
:
867 if (global_settings
.party_mode
)
869 if (current_tick
-last_right
< HZ
)
871 if (state
->id3
->cuesheet
)
881 ffwd_rew(ACTION_WPS_SEEKFWD
);
882 last_right
= last_left
= 0;
885 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
886 case ACTION_WPS_SEEKBACK
:
887 if (global_settings
.party_mode
)
889 if (current_tick
-last_left
< HZ
)
891 if (state
->id3
->cuesheet
)
893 #if (CONFIG_CODEC == SWCODEC)
894 audio_pre_ff_rewind();
907 ffwd_rew(ACTION_WPS_SEEKBACK
);
908 last_left
= last_right
= 0;
912 case ACTION_WPS_SKIPPREV
:
913 if (global_settings
.party_mode
)
915 last_left
= current_tick
;
916 #ifdef AB_REPEAT_ENABLE
917 /* if we're in A/B repeat mode and the current position
918 is past the A marker, jump back to the A marker... */
919 if ( ab_repeat_mode_enabled() )
921 if ( ab_after_A_marker(state
->id3
->elapsed
) )
923 ab_jump_to_A_marker();
928 /* ...otherwise, do it normally */
934 OR if skip length set, hop by predetermined amount. */
935 case ACTION_WPS_SKIPNEXT
:
936 if (global_settings
.party_mode
)
938 last_right
= current_tick
;
939 #ifdef AB_REPEAT_ENABLE
940 /* if we're in A/B repeat mode and the current position is
941 before the A marker, jump to the A marker... */
942 if ( ab_repeat_mode_enabled() )
944 if ( ab_before_A_marker(state
->id3
->elapsed
) )
946 ab_jump_to_A_marker();
951 /* ...otherwise, do it normally */
955 /* next / prev directories */
956 /* and set A-B markers if in a-b mode */
957 case ACTION_WPS_ABSETB_NEXTDIR
:
958 if (global_settings
.party_mode
)
960 #if defined(AB_REPEAT_ENABLE)
961 if (ab_repeat_mode_enabled())
963 ab_set_B_marker(state
->id3
->elapsed
);
964 ab_jump_to_A_marker();
972 case ACTION_WPS_ABSETA_PREVDIR
:
973 if (global_settings
.party_mode
)
975 #if defined(AB_REPEAT_ENABLE)
976 if (ab_repeat_mode_enabled())
977 ab_set_A_marker(state
->id3
->elapsed
);
984 /* menu key functions */
985 case ACTION_WPS_MENU
:
991 #ifdef HAVE_QUICKSCREEN
992 case ACTION_WPS_QUICKSCREEN
:
995 if (quick_screen_quick(button
))
1000 #endif /* HAVE_QUICKSCREEN */
1002 /* screen settings */
1007 if (quick_screen_f3(BUTTON_F3
))
1012 #endif /* BUTTON_F3 */
1015 #ifdef HAVE_PITCHSCREEN
1016 case ACTION_WPS_PITCHSCREEN
:
1019 if (1 == gui_syncpitchscreen_run())
1024 #endif /* HAVE_PITCHSCREEN */
1026 #ifdef AB_REPEAT_ENABLE
1027 /* reset A&B markers */
1028 case ACTION_WPS_ABRESET
:
1029 if (ab_repeat_mode_enabled())
1035 #endif /* AB_REPEAT_ENABLE */
1037 /* stop and exit wps */
1038 case ACTION_WPS_STOP
:
1039 if (global_settings
.party_mode
)
1045 case ACTION_WPS_ID3SCREEN
:
1053 /* this case is used by the softlock feature
1054 * it requests a full update here */
1056 skin_request_full_update(WPS
);
1058 case ACTION_NONE
: /* Timeout, do a partial update */
1060 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1062 #ifdef HAVE_RECORDING
1063 case ACTION_WPS_REC
:
1067 case ACTION_WPS_VIEW_PLAYLIST
:
1069 return GO_TO_PLAYLIST_VIEWER
;
1072 switch(default_event_handler(button
))
1073 { /* music has been stopped by the default handler */
1074 case SYS_USB_CONNECTED
:
1075 case SYS_CALL_INCOMING
:
1076 case BUTTON_MULTIMEDIA_STOP
:
1087 vol_changed
= false;
1091 if(update_onvol_change(i
))
1096 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
1102 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1103 TIME_AFTER(current_tick
, restoretimer
)))
1106 restoretimer
= RESTORE_WPS_INSTANTLY
;
1107 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1108 add_event(LCD_EVENT_ACTIVATION
, false, wps_lcd_activation_hook
);
1110 /* we remove the update delay since it's not very usable in the wps,
1111 * e.g. during volume changing or ffwd/rewind */
1112 sb_skin_set_update_delay(0);
1113 skin_request_full_update(WPS
);
1119 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1120 gwps_caption_backlight(state
);
1124 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1125 /* currently, all remotes are readable without backlight
1126 * so still update those */
1127 if (lcd_active() || (i
!= SCREEN_MAIN
))
1130 bool full_update
= skin_do_full_update(WPS
, i
);
1131 if (update
|| full_update
)
1133 skin_update(WPS
, i
, full_update
?
1134 SKIN_REFRESH_ALL
: SKIN_REFRESH_NON_STATIC
);
1142 #ifdef HAVE_LCD_CHARCELLS
1143 status_set_record(false);
1144 status_set_audio(false);
1146 #if CONFIG_CODEC != SWCODEC
1147 if (global_settings
.fade_on_stop
)
1151 update_non_static();
1154 bookmark_autobookmark(true);
1156 #ifdef AB_REPEAT_ENABLE
1160 #ifdef HAVE_RECORDING
1161 if (button
== ACTION_WPS_REC
)
1162 return GO_TO_RECSCREEN
;
1164 if (global_settings
.browse_current
)
1165 return GO_TO_PREVIOUS_BROWSER
;
1166 return GO_TO_PREVIOUS
;
1169 if (button
&& !IS_SYSEVENT(button
) )
1172 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1175 /* this is called from the playback thread so NO DRAWING! */
1176 static void track_changed_callback(void *param
)
1178 struct wps_state
*state
= skin_get_global_state();
1179 state
->id3
= (struct mp3entry
*)param
;
1180 state
->nid3
= audio_next_track();
1181 if (state
->id3
->cuesheet
)
1183 cue_find_current_track(state
->id3
->cuesheet
, state
->id3
->elapsed
);
1185 skin_request_full_update(WPS
);
1187 static void nextid3available_callback(void* param
)
1190 skin_get_global_state()->nid3
= audio_next_track();
1191 skin_request_full_update(WPS
);
1194 #ifdef AUDIO_FAST_SKIP_PREVIEW
1195 /* this is called on the audio_skip caller thread */
1196 static void track_skip_callback(void *param
)
1198 struct wps_state
*state
= skin_get_global_state();
1199 state
->id3
= audio_current_track();
1200 state
->nid3
= audio_next_track();
1201 skin_request_full_update(WPS
);
1204 #endif /* AUDIO_FAST_SKIP_PREVIEW */
1206 static void wps_state_init(void)
1208 struct wps_state
*state
= skin_get_global_state();
1209 state
->ff_rewind
= false;
1210 state
->paused
= false;
1211 if(audio_status() & AUDIO_STATUS_PLAY
)
1213 state
->id3
= audio_current_track();
1214 state
->nid3
= audio_next_track();
1221 /* We'll be updating due to restore initialized with true */
1222 skin_request_full_update(WPS
);
1223 /* add the WPS track event callbacks */
1224 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1225 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1226 #if CONFIG_CODEC == SWCODEC
1227 /* Use the same callback as ..._TRACK_CHANGE for when remaining handles have
1229 add_event(PLAYBACK_EVENT_CUR_TRACK_READY
, false, track_changed_callback
);
1231 #ifdef AUDIO_FAST_SKIP_PREVIEW
1232 add_event(PLAYBACK_EVENT_TRACK_SKIP
, false, track_skip_callback
);
1237 #ifdef IPOD_ACCESSORY_PROTOCOL
1238 bool is_wps_fading(void)
1240 return skin_get_global_state()->is_fading
;
1243 int wps_get_ff_rewind_count(void)
1245 return skin_get_global_state()->ff_rewind_count
;