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"
37 #include "skin_engine/skin_engine.h"
38 #include "mp3_playback.h"
45 #ifdef HAVE_LCD_BITMAP
47 #include "peakmeter.h"
58 #include "ata_idle_notify.h"
59 #include "root_menu.h"
61 #include "quickscreen.h"
62 #include "pitchscreen.h"
63 #include "appevents.h"
66 #include "option_select.h"
68 #include "playlist_viewer.h"
71 #define RESTORE_WPS_INSTANTLY 0l
72 #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick))
74 #define DEFAULT_SKIP_TRESH 3000ul
77 #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
78 /* 3% of 30min file == 54s step size */
79 #define MIN_FF_REWIND_STEP 500
81 /* this is for the viewportmanager */
83 /* currently only one wps_state is needed */
84 static struct wps_state wps_state
;
85 static struct gui_wps gui_wps
[NB_SCREENS
];
86 static struct wps_data wps_datas
[NB_SCREENS
];
88 /* initial setup of wps_data */
89 static void wps_state_init(void);
90 static void track_changed_callback(void *param
);
91 static void nextid3available_callback(void* param
);
92 static void statusbar_toggle_handler(void *data
);
95 #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps"
96 #ifdef HAVE_REMOTE_LCD
97 #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps"
98 #define DEFAULT_WPS(screen) ((screen) == SCREEN_MAIN ? \
99 WPS_DEFAULTCFG:RWPS_DEFAULTCFG)
101 #define DEFAULT_WPS(screen) (WPS_DEFAULTCFG)
104 void wps_data_load(enum screen_type screen
, const char *buf
, bool isfile
)
108 screens
[screen
].backdrop_unload(BACKDROP_SKIN_WPS
);
112 * Hardcode loading WPS_DEFAULTCFG to cause a reset ideally this
113 * wants to be a virtual file. Feel free to modify dirbrowse()
114 * if you're feeling brave.
117 if (! strcmp(buf
, DEFAULT_WPS(screen
)) )
119 #ifdef HAVE_REMOTE_LCD
120 if (screen
== SCREEN_REMOTE
)
121 global_settings
.rwps_file
[0] = '\0';
124 global_settings
.wps_file
[0] = '\0';
128 #endif /* __PCTOOL__ */
130 loaded_ok
= buf
&& skin_data_load(gui_wps
[screen
].data
,
131 &screens
[screen
], buf
, isfile
);
132 if (!loaded_ok
) /* load the hardcoded default */
134 char *skin_buf
[NB_SCREENS
] = {
135 #ifdef HAVE_LCD_BITMAP
136 "%s%?it<%?in<%in. |>%it|%fn>\n"
137 "%s%?ia<%ia|%?d2<%d2|(root)>>\n"
138 "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n\n"
139 "%al%pc/%pt%ar[%pp:%pe]\n"
140 "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n"
143 "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n"
146 #ifdef HAVE_REMOTE_LCD
147 "%s%?ia<%ia|%?d2<%d2|(root)>>\n"
148 "%s%?it<%?in<%in. |>%it|%fn>\n"
149 "%al%pc/%pt%ar[%pp:%pe]\n"
150 "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n"
154 skin_data_load(gui_wps
[screen
].data
, &screens
[screen
],
155 skin_buf
[screen
], false);
157 #ifdef HAVE_REMOVE_LCD
158 gui_wps
[screen
].data
->remote_wps
= !(screen
== SCREEN_MAIN
);
162 void wps_data_init(enum screen_type screen
)
164 skin_data_init(gui_wps
[screen
].data
);
168 static bool wps_fading_out
= false;
169 void fade(bool fade_in
, bool updatewps
)
171 int fp_global_vol
= global_settings
.volume
<< 8;
172 int fp_min_vol
= sound_min(SOUND_VOLUME
) << 8;
173 int fp_step
= (fp_global_vol
- fp_min_vol
) / 30;
175 wps_fading_out
= !fade_in
;
178 int fp_volume
= fp_min_vol
;
180 /* zero out the sound */
181 sound_set_volume(fp_min_vol
>> 8);
183 sleep(HZ
/10); /* let audio thread run */
186 while (fp_volume
< fp_global_vol
- fp_step
) {
187 fp_volume
+= fp_step
;
188 sound_set_volume(fp_volume
>> 8);
192 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
196 sound_set_volume(global_settings
.volume
);
200 int fp_volume
= fp_global_vol
;
202 while (fp_volume
> fp_min_vol
+ fp_step
) {
203 fp_volume
-= fp_step
;
204 sound_set_volume(fp_volume
>> 8);
208 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
213 wps_fading_out
= false;
214 #if CONFIG_CODEC != SWCODEC
216 /* let audio thread run and wait for the mas to run out of data */
217 while (!mp3_pause_done())
222 /* reset volume to what it was before the fade */
223 sound_set_volume(global_settings
.volume
);
226 bool is_wps_fading(void)
228 return wps_fading_out
;
231 static bool update_onvol_change(struct gui_wps
* gwps
)
233 skin_update(gwps
, WPS_REFRESH_NON_STATIC
);
235 #ifdef HAVE_LCD_CHARCELLS
236 splashf(0, "Vol: %3d dB",
237 sound_val2phys(SOUND_VOLUME
, global_settings
.volume
));
244 bool ffwd_rew(int button
)
246 unsigned int step
= 0; /* current ff/rewind step */
247 unsigned int max_step
= 0; /* maximum ff/rewind step */
248 int ff_rewind_count
= 0; /* current ff/rewind count (in ticks) */
249 int direction
= -1; /* forward=1 or backward=-1 */
253 const long ff_rw_accel
= (global_settings
.ff_rewind_accel
+ 3);
255 if (button
== ACTION_NONE
)
257 status_set_ffmode(0);
264 case ACTION_WPS_SEEKFWD
:
266 case ACTION_WPS_SEEKBACK
:
267 if (wps_state
.ff_rewind
)
271 /* fast forwarding, calc max step relative to end */
272 max_step
= (wps_state
.id3
->length
-
273 (wps_state
.id3
->elapsed
+
275 FF_REWIND_MAX_PERCENT
/ 100;
279 /* rewinding, calc max step relative to start */
280 max_step
= (wps_state
.id3
->elapsed
+ ff_rewind_count
) *
281 FF_REWIND_MAX_PERCENT
/ 100;
284 max_step
= MAX(max_step
, MIN_FF_REWIND_STEP
);
289 ff_rewind_count
+= step
* direction
;
291 /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
292 step
+= step
>> ff_rw_accel
;
296 if ( (audio_status() & AUDIO_STATUS_PLAY
) &&
297 wps_state
.id3
&& wps_state
.id3
->length
)
299 if (!wps_state
.paused
)
300 #if (CONFIG_CODEC == SWCODEC)
301 audio_pre_ff_rewind();
305 #if CONFIG_KEYPAD == PLAYER_PAD
307 gui_wps
[i
].display
->stop_scroll();
310 status_set_ffmode(STATUS_FASTFORWARD
);
312 status_set_ffmode(STATUS_FASTBACKWARD
);
314 wps_state
.ff_rewind
= true;
316 step
= 1000 * global_settings
.ff_rewind_min_step
;
323 if ((wps_state
.id3
->elapsed
+ ff_rewind_count
) >
324 wps_state
.id3
->length
)
325 ff_rewind_count
= wps_state
.id3
->length
-
326 wps_state
.id3
->elapsed
;
329 if ((int)(wps_state
.id3
->elapsed
+ ff_rewind_count
) < 0)
330 ff_rewind_count
= -wps_state
.id3
->elapsed
;
333 /* set the wps state ff_rewind_count so the progess info
335 wps_state
.ff_rewind_count
= (wps_state
.wps_time_countup
== false)?
336 ff_rewind_count
:-ff_rewind_count
;
339 skin_update(&gui_wps
[i
],
340 WPS_REFRESH_PLAYER_PROGRESS
|
341 WPS_REFRESH_DYNAMIC
);
346 case ACTION_WPS_STOPSEEK
:
347 wps_state
.id3
->elapsed
= wps_state
.id3
->elapsed
+ff_rewind_count
;
348 audio_ff_rewind(wps_state
.id3
->elapsed
);
349 wps_state
.ff_rewind_count
= 0;
350 wps_state
.ff_rewind
= false;
351 status_set_ffmode(0);
352 #if (CONFIG_CODEC != SWCODEC)
353 if (!wps_state
.paused
)
356 #ifdef HAVE_LCD_CHARCELLS
358 skin_update(&gui_wps
[i
], WPS_REFRESH_ALL
);
364 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
365 status_set_ffmode(0);
373 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_BLOCK
);
374 #ifdef HAVE_TOUCHSCREEN
375 if (button
== ACTION_TOUCHSCREEN
)
376 button
= wps_get_touchaction(gui_wps
[SCREEN_MAIN
].data
);
384 void display_keylock_text(bool locked
)
388 gui_wps
[i
].display
->stop_scroll();
390 splash(HZ
, locked
? ID2P(LANG_KEYLOCK_ON
) : ID2P(LANG_KEYLOCK_OFF
));
396 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
397 static void gwps_caption_backlight(struct wps_state
*state
)
399 if (state
&& state
->id3
)
401 #ifdef HAVE_BACKLIGHT
402 if (global_settings
.caption_backlight
)
404 /* turn on backlight n seconds before track ends, and turn it off n
405 seconds into the new track. n == backlight_timeout, or 5s */
406 int n
= global_settings
.backlight_timeout
* 1000;
409 n
= 5000; /* use 5s if backlight is always on or off */
411 if (((state
->id3
->elapsed
< 1000) ||
412 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
413 (state
->paused
== false))
417 #ifdef HAVE_REMOTE_LCD
418 if (global_settings
.remote_caption_backlight
)
420 /* turn on remote backlight n seconds before track ends, and turn it
421 off n seconds into the new track. n == remote_backlight_timeout,
423 int n
= global_settings
.remote_backlight_timeout
* 1000;
426 n
= 5000; /* use 5s if backlight is always on or off */
428 if (((state
->id3
->elapsed
< 1000) ||
429 ((state
->id3
->length
- state
->id3
->elapsed
) < (unsigned)n
)) &&
430 (state
->paused
== false))
431 remote_backlight_on();
439 static void change_dir(int direction
)
441 if (global_settings
.prevent_skip
)
446 else if (direction
> 0)
448 /* prevent the next dir to immediatly start being ffw'd */
449 action_wait_for_release();
452 static void prev_track(unsigned long skip_thresh
)
454 if (wps_state
.id3
->elapsed
< skip_thresh
)
461 if (wps_state
.id3
->cuesheet
)
463 curr_cuesheet_skip(wps_state
.id3
->cuesheet
, -1, wps_state
.id3
->elapsed
);
467 if (!wps_state
.paused
)
468 #if (CONFIG_CODEC == SWCODEC)
469 audio_pre_ff_rewind();
476 #if (CONFIG_CODEC != SWCODEC)
477 if (!wps_state
.paused
)
483 static void next_track(void)
485 /* take care of if we're playing a cuesheet */
486 if (wps_state
.id3
->cuesheet
)
488 if (curr_cuesheet_skip(wps_state
.id3
->cuesheet
, 1, wps_state
.id3
->elapsed
))
490 /* if the result was false, then we really want
491 to skip to the next track */
499 static void play_hop(int direction
)
501 unsigned long step
= ((unsigned long)global_settings
.skip_length
)*1000;
502 unsigned long elapsed
= wps_state
.id3
->elapsed
;
503 unsigned long remaining
= wps_state
.id3
->length
- elapsed
;
505 if (!global_settings
.prevent_skip
&&
507 (direction
> 0 && step
>= remaining
) ||
508 (direction
< 0 && elapsed
< DEFAULT_SKIP_TRESH
)))
509 { /* Do normal track skipping */
512 else if (direction
< 0)
513 prev_track(DEFAULT_SKIP_TRESH
);
517 if (direction
== 1 && step
>= remaining
)
519 #if CONFIG_CODEC == SWCODEC
520 if(global_settings
.beep
)
521 pcmbuf_beep(1000, 150, 1500*global_settings
.beep
);
525 else if ((direction
== -1 && elapsed
< step
))
531 elapsed
+= step
* direction
;
533 if((audio_status() & AUDIO_STATUS_PLAY
) && !wps_state
.paused
)
535 #if (CONFIG_CODEC == SWCODEC)
536 audio_pre_ff_rewind();
541 audio_ff_rewind(wps_state
.id3
->elapsed
= elapsed
);
542 #if (CONFIG_CODEC != SWCODEC)
543 if (!wps_state
.paused
)
549 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
551 * If the user is unable to see the wps, because the display is deactivated,
552 * we suppress updates until the wps is activated again (the lcd driver will
553 * call this hook to issue an instant update)
555 static void wps_lcd_activation_hook(void)
557 wps_state
.do_full_update
= true;
558 /* force timeout in wps main loop, so that the update is instantly */
559 queue_post(&button_queue
, BUTTON_NONE
, 0);
563 static void gwps_leave_wps(void)
565 int i
, oldbars
= VP_SB_HIDE_ALL
;
569 gui_wps
[i
].display
->stop_scroll();
570 gui_wps
[i
].display
->backdrop_show(BACKDROP_MAIN
);
571 if (statusbar_position(i
) != STATUSBAR_OFF
)
572 oldbars
|= VP_SB_ONSCREEN(i
);
575 viewportmanager_set_statusbar(oldbars
);
576 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
577 /* Play safe and unregister the hook */
578 lcd_activation_set_hook(NULL
);
580 send_event(GUI_EVENT_REFRESH
, NULL
);
583 #ifdef HAVE_TOUCHSCREEN
584 int wps_get_touchaction(struct wps_data
*data
)
588 int type
= action_get_touchscreen_press(&x
, &y
);
589 static int last_action
= ACTION_NONE
;
590 struct touchregion
*r
;
591 bool repeated
= (type
== BUTTON_REPEAT
);
592 bool released
= (type
== BUTTON_REL
);
593 struct skin_token_list
*regions
= data
->touchregions
;
596 r
= (struct touchregion
*)regions
->token
->value
.data
;
597 /* make sure this region's viewport is visible */
598 if (r
->wvp
->hidden_flags
&VP_DRAW_HIDDEN
)
600 regions
= regions
->next
;
603 /* reposition the touch inside the viewport */
604 vx
= x
- r
->wvp
->vp
.x
;
605 vy
= y
- r
->wvp
->vp
.y
;
606 /* check if it's inside this viewport */
607 if (vx
>= 0 && vx
< r
->wvp
->vp
.x
+ r
->wvp
->vp
.width
&&
608 vy
>= 0 && vy
< r
->wvp
->vp
.y
+ r
->wvp
->vp
.height
)
610 /* now see if the point is inside this region */
611 if (vx
>= r
->x
&& vx
< r
->x
+r
->width
&&
612 vy
>= r
->y
&& vy
< r
->y
+r
->height
)
614 /* reposition the touch within the area */
620 case WPS_TOUCHREGION_ACTION
:
621 if ((repeated
&& r
->repeat
) || (released
&& !r
->repeat
))
623 last_action
= r
->action
;
627 case WPS_TOUCHREGION_SCROLLBAR
:
628 if(r
->width
> r
->height
)
630 wps_state
.id3
->elapsed
= (vx
*
631 wps_state
.id3
->length
) / r
->width
;
634 wps_state
.id3
->elapsed
= (vy
*
635 wps_state
.id3
->length
) / r
->height
;
637 audio_ff_rewind(wps_state
.id3
->elapsed
);
639 case WPS_TOUCHREGION_VOLUME
:
642 const int min_vol
= sound_min(SOUND_VOLUME
);
643 const int max_vol
= sound_max(SOUND_VOLUME
);
644 if(r
->width
> r
->height
)
646 global_settings
.volume
= (vx
*
647 (max_vol
- min_vol
)) / r
->width
;
650 global_settings
.volume
= (vy
*
651 (max_vol
-min_vol
)) / r
->height
;
653 global_settings
.volume
+= min_vol
;
657 gui_wps
[i
].data
->button_time_volume
= current_tick
;
659 return ACTION_REDRAW
;
664 regions
= regions
->next
;
667 if ((last_action
== ACTION_WPS_SEEKBACK
|| last_action
== ACTION_WPS_SEEKFWD
))
668 return ACTION_WPS_STOPSEEK
;
669 last_action
= ACTION_TOUCHSCREEN
;
670 return ACTION_TOUCHSCREEN
;
673 /* The WPS can be left in two ways:
674 * a) call a function, which draws over the wps. In this case, the wps
675 * will be still active (i.e. the below function didn't return)
676 * b) return with a value evaluated by root_menu.c, in this case the wps
677 * is really left, and root_menu will handle the next screen
679 * In either way, call gwps_leave_wps(), in order to restore the correct
680 * "main screen" backdrops and statusbars
682 long gui_wps_show(void)
686 long restoretimer
= RESTORE_WPS_INSTANTLY
; /* timer to delay screen redraw temporarily */
688 bool bookmark
= false;
691 long last_left
= 0, last_right
= 0;
693 #ifdef HAVE_LCD_CHARCELLS
694 status_set_audio(true);
695 status_set_param(false);
698 #ifdef AB_REPEAT_ENABLE
703 statusbar_toggle_handler(NULL
);
707 bool audio_paused
= (audio_status() & AUDIO_STATUS_PAUSE
)?true:false;
709 /* did someone else (i.e power thread) change audio pause mode? */
710 if (wps_state
.paused
!= audio_paused
) {
711 wps_state
.paused
= audio_paused
;
713 /* if another thread paused audio, we are probably in car mode,
714 about to shut down. lets save the settings. */
715 if (wps_state
.paused
) {
717 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
718 call_storage_idle_notifys(true);
723 #ifdef HAVE_LCD_BITMAP
724 /* when the peak meter is enabled we want to have a
725 few extra updates to make it look smooth. On the
726 other hand we don't want to waste energy if it
731 if(gui_wps
[i
].data
->peak_meter_enabled
)
736 long next_refresh
= current_tick
;
737 long next_big_refresh
= current_tick
+ HZ
/ 5;
738 button
= BUTTON_NONE
;
739 while (TIME_BEFORE(current_tick
, next_big_refresh
)) {
740 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,TIMEOUT_NOBLOCK
);
741 if (button
!= ACTION_NONE
) {
745 sleep(0); /* Sleep until end of current tick. */
747 if (TIME_AFTER(current_tick
, next_refresh
)) {
750 if(gui_wps
[i
].data
->peak_meter_enabled
)
751 skin_update(&gui_wps
[i
], WPS_REFRESH_PEAK_METER
);
752 next_refresh
+= HZ
/ PEAK_METER_FPS
;
759 /* The peak meter is disabled
760 -> no additional screen updates needed */
764 button
= get_action(CONTEXT_WPS
|ALLOW_SOFTLOCK
,
765 restore
? HZ
/100 : HZ
/5);
768 /* Exit if audio has stopped playing. This happens e.g. at end of
769 playlist or if using the sleep timer. */
770 if (!(audio_status() & AUDIO_STATUS_PLAY
))
772 #ifdef HAVE_TOUCHSCREEN
773 if (button
== ACTION_TOUCHSCREEN
)
774 button
= wps_get_touchaction(gui_wps
[SCREEN_MAIN
].data
);
776 /* The iPods/X5/M5 use a single button for the A-B mode markers,
777 defined as ACTION_WPSAB_SINGLE in their config files. */
778 #ifdef ACTION_WPSAB_SINGLE
779 if (!global_settings
.party_mode
&& ab_repeat_mode_enabled())
781 static int wps_ab_state
= 0;
782 if (button
== ACTION_WPSAB_SINGLE
)
784 switch (wps_ab_state
)
786 case 0: /* set the A spot */
787 button
= ACTION_WPS_ABSETA_PREVDIR
;
789 case 1: /* set the B spot */
790 button
= ACTION_WPS_ABSETB_NEXTDIR
;
793 button
= ACTION_WPS_ABRESET
;
796 wps_ab_state
= (wps_ab_state
+1) % 3;
802 case ACTION_WPS_CONTEXT
:
805 /* if music is stopped in the context menu we want to exit the wps */
806 if (onplay(wps_state
.id3
->path
,
807 FILE_ATTR_AUDIO
, CONTEXT_WPS
) == ONPLAY_MAINMENU
814 case ACTION_WPS_BROWSE
:
815 #ifdef HAVE_LCD_CHARCELLS
816 status_set_record(false);
817 status_set_audio(false);
820 return GO_TO_PREVIOUS_BROWSER
;
824 case ACTION_WPS_PLAY
:
825 if (global_settings
.party_mode
)
827 if ( wps_state
.paused
)
829 wps_state
.paused
= false;
830 if ( global_settings
.fade_on_stop
)
837 wps_state
.paused
= true;
838 if ( global_settings
.fade_on_stop
)
843 #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
844 call_storage_idle_notifys(true); /* make sure resume info is saved */
849 case ACTION_WPS_VOLUP
:
852 gui_wps
[i
].data
->button_time_volume
= current_tick
;
853 global_settings
.volume
++;
858 if(update_onvol_change(&gui_wps
[i
]))
863 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
867 case ACTION_WPS_VOLDOWN
:
870 gui_wps
[i
].data
->button_time_volume
= current_tick
;
871 global_settings
.volume
--;
876 if(update_onvol_change(&gui_wps
[i
]))
881 restoretimer
= RESTORE_WPS_NEXT_SECOND
;
886 OR next dir if this is straight after ACTION_WPS_SKIPNEXT */
887 case ACTION_WPS_SEEKFWD
:
888 if (global_settings
.party_mode
)
890 if (current_tick
-last_right
< HZ
)
892 if (wps_state
.id3
->cuesheet
)
902 ffwd_rew(ACTION_WPS_SEEKFWD
);
903 last_right
= last_left
= 0;
906 OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/
907 case ACTION_WPS_SEEKBACK
:
908 if (global_settings
.party_mode
)
910 if (current_tick
-last_left
< HZ
)
912 if (wps_state
.id3
->cuesheet
)
914 if (!wps_state
.paused
)
915 #if (CONFIG_CODEC == SWCODEC)
916 audio_pre_ff_rewind();
928 ffwd_rew(ACTION_WPS_SEEKBACK
);
929 last_left
= last_right
= 0;
933 case ACTION_WPS_SKIPPREV
:
934 if (global_settings
.party_mode
)
936 last_left
= current_tick
;
937 #ifdef AB_REPEAT_ENABLE
938 /* if we're in A/B repeat mode and the current position
939 is past the A marker, jump back to the A marker... */
940 if ( ab_repeat_mode_enabled() )
942 if ( ab_after_A_marker(wps_state
.id3
->elapsed
) )
944 ab_jump_to_A_marker();
946 #if (AB_REPEAT_ENABLE == 2)
953 /* ...otherwise, do it normally */
959 OR if skip length set, hop by predetermined amount. */
960 case ACTION_WPS_SKIPNEXT
:
961 if (global_settings
.party_mode
)
963 last_right
= current_tick
;
964 #ifdef AB_REPEAT_ENABLE
965 /* if we're in A/B repeat mode and the current position is
966 before the A marker, jump to the A marker... */
967 if ( ab_repeat_mode_enabled() )
969 if ( ab_before_A_marker(wps_state
.id3
->elapsed
) )
971 ab_jump_to_A_marker();
973 #if (AB_REPEAT_ENABLE == 2)
980 /* ...otherwise, do it normally */
984 /* next / prev directories */
985 /* and set A-B markers if in a-b mode */
986 case ACTION_WPS_ABSETB_NEXTDIR
:
987 if (global_settings
.party_mode
)
989 #if defined(AB_REPEAT_ENABLE)
990 if (ab_repeat_mode_enabled())
992 ab_set_B_marker(wps_state
.id3
->elapsed
);
993 ab_jump_to_A_marker();
1001 case ACTION_WPS_ABSETA_PREVDIR
:
1002 if (global_settings
.party_mode
)
1004 #if defined(AB_REPEAT_ENABLE)
1005 if (ab_repeat_mode_enabled())
1006 ab_set_A_marker(wps_state
.id3
->elapsed
);
1013 /* menu key functions */
1014 case ACTION_WPS_MENU
:
1020 #ifdef HAVE_QUICKSCREEN
1021 case ACTION_WPS_QUICKSCREEN
:
1024 if (quick_screen_quick(button
))
1025 return SYS_USB_CONNECTED
;
1029 #endif /* HAVE_QUICKSCREEN */
1031 /* screen settings */
1036 if (quick_screen_f3(BUTTON_F3
))
1037 return SYS_USB_CONNECTED
;
1041 #endif /* BUTTON_F3 */
1044 #ifdef HAVE_PITCHSCREEN
1045 case ACTION_WPS_PITCHSCREEN
:
1048 if (1 == gui_syncpitchscreen_run())
1049 return SYS_USB_CONNECTED
;
1053 #endif /* HAVE_PITCHSCREEN */
1055 #ifdef AB_REPEAT_ENABLE
1056 /* reset A&B markers */
1057 case ACTION_WPS_ABRESET
:
1058 if (ab_repeat_mode_enabled())
1064 #endif /* AB_REPEAT_ENABLE */
1066 /* stop and exit wps */
1067 case ACTION_WPS_STOP
:
1068 if (global_settings
.party_mode
)
1074 case ACTION_WPS_ID3SCREEN
:
1081 #ifdef HAVE_TOUCHSCREEN
1082 case ACTION_TOUCH_SHUFFLE
: /* toggle shuffle mode */
1084 global_settings
.playlist_shuffle
=
1085 !global_settings
.playlist_shuffle
;
1086 #if CONFIG_CODEC == SWCODEC
1087 dsp_set_replaygain();
1089 if (global_settings
.playlist_shuffle
)
1090 playlist_randomise(NULL
, current_tick
, true);
1092 playlist_sort(NULL
, true);
1095 case ACTION_TOUCH_REPMODE
: /* cycle the repeat mode setting */
1097 const struct settings_list
*rep_setting
=
1098 find_setting(&global_settings
.repeat_mode
, NULL
);
1099 option_select_next_val(rep_setting
, false, true);
1100 audio_flush_and_reload_tracks();
1103 #endif /* HAVE_TOUCHSCREEN */
1104 /* this case is used by the softlock feature
1105 * it requests a full update here */
1107 wps_state
.do_full_update
= true;
1109 case ACTION_NONE
: /* Timeout, do a partial update */
1111 ffwd_rew(button
); /* hopefully fix the ffw/rwd bug */
1113 #ifdef HAVE_RECORDING
1114 case ACTION_WPS_REC
:
1119 default_event_handler(SYS_POWEROFF
);
1121 case ACTION_WPS_VIEW_PLAYLIST
:
1123 if (playlist_viewer()) /* true if USB connected */
1124 return SYS_USB_CONNECTED
;
1128 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
1134 if (wps_state
.do_full_update
|| update
)
1136 #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD)
1137 gwps_caption_backlight(&wps_state
);
1141 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1143 #ifdef HAVE_REMOTE_LCD
1144 /* currently, all remotes are readable without backlight
1145 * so still update those */
1146 || (i
== SCREEN_REMOTE
)
1151 skin_update(&gui_wps
[i
], WPS_REFRESH_NON_STATIC
);
1154 wps_state
.do_full_update
= false;
1158 if (restore
&& wps_state
.id3
&&
1159 ((restoretimer
== RESTORE_WPS_INSTANTLY
) ||
1160 TIME_AFTER(current_tick
, restoretimer
)))
1163 restoretimer
= RESTORE_WPS_INSTANTLY
;
1164 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
1165 lcd_activation_set_hook(wps_lcd_activation_hook
);
1169 screens
[i
].stop_scroll();
1170 gui_wps_display(&gui_wps
[i
]);
1175 #ifdef HAVE_LCD_CHARCELLS
1176 status_set_record(false);
1177 status_set_audio(false);
1179 if (global_settings
.fade_on_stop
)
1183 bookmark_autobookmark();
1185 #ifdef AB_REPEAT_ENABLE
1189 #ifdef HAVE_RECORDING
1190 if (button
== ACTION_WPS_REC
)
1191 return GO_TO_RECSCREEN
;
1193 if (global_settings
.browse_current
)
1194 return GO_TO_PREVIOUS_BROWSER
;
1195 return GO_TO_PREVIOUS
;
1198 if (button
&& !IS_SYSEVENT(button
) )
1201 return GO_TO_ROOT
; /* unreachable - just to reduce compiler warnings */
1204 /* this is called from the playback thread so NO DRAWING! */
1205 static void track_changed_callback(void *param
)
1207 wps_state
.id3
= (struct mp3entry
*)param
;
1208 wps_state
.nid3
= audio_next_track();
1209 if (wps_state
.id3
->cuesheet
)
1211 cue_find_current_track(wps_state
.id3
->cuesheet
, wps_state
.id3
->elapsed
);
1212 cue_spoof_id3(wps_state
.id3
->cuesheet
, wps_state
.id3
);
1214 wps_state
.do_full_update
= true;
1216 static void nextid3available_callback(void* param
)
1219 wps_state
.nid3
= audio_next_track();
1220 wps_state
.do_full_update
= true;
1224 static void wps_state_init(void)
1226 wps_state
.ff_rewind
= false;
1227 wps_state
.paused
= false;
1228 if(audio_status() & AUDIO_STATUS_PLAY
)
1230 wps_state
.id3
= audio_current_track();
1231 wps_state
.nid3
= audio_next_track();
1235 wps_state
.id3
= NULL
;
1236 wps_state
.nid3
= NULL
;
1238 /* We'll be updating due to restore initialized with true */
1239 wps_state
.do_full_update
= false;
1240 /* add the WPS track event callbacks */
1241 add_event(PLAYBACK_EVENT_TRACK_CHANGE
, false, track_changed_callback
);
1242 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE
, false, nextid3available_callback
);
1246 #ifdef HAVE_LCD_BITMAP
1247 static void statusbar_toggle_handler(void *data
)
1252 wpsbars
= VP_SB_HIDE_ALL
;
1254 { /* fix viewports if needed */
1255 skin_statusbar_changed(&gui_wps
[i
]);
1259 /* fix up gui_wps::statusbars, so that the viewportmanager accepts it*/
1260 if (gui_wps
[i
].data
->wps_sb_tag
)
1261 draw
= gui_wps
[i
].data
->show_sb_on_wps
;
1262 else if (statusbar_position(i
) != STATUSBAR_OFF
)
1266 (VP_SB_ONSCREEN(i
) | VP_SB_IGNORE_SETTING(i
));
1271 void gui_sync_wps_init(void)
1276 skin_data_init(&wps_datas
[i
]);
1277 #ifdef HAVE_ALBUMART
1278 wps_datas
[i
].wps_uses_albumart
= 0;
1280 #ifdef HAVE_REMOTE_LCD
1281 wps_datas
[i
].remote_wps
= (i
== SCREEN_REMOTE
);
1283 gui_wps
[i
].data
= &wps_datas
[i
];
1284 gui_wps
[i
].display
= &screens
[i
];
1285 /* Currently no seperate wps_state needed/possible
1286 so use the only available ( "global" ) one */
1287 gui_wps
[i
].state
= &wps_state
;
1288 gui_wps
[i
].display
->backdrop_unload(BACKDROP_SKIN_WPS
);
1289 /* only one wpsbars needed/wanted */
1290 gui_wps
[i
].statusbars
= &wpsbars
;
1292 *(gui_wps
[SCREEN_MAIN
].statusbars
) =VP_SB_ALLSCREENS
;
1293 #ifdef HAVE_LCD_BITMAP
1294 add_event(GUI_EVENT_STATUSBAR_TOGGLE
, false, statusbar_toggle_handler
);
1298 #ifdef HAVE_ALBUMART
1299 bool wps_uses_albumart(int *width
, int *height
)
1303 struct gui_wps
*gwps
= &gui_wps
[i
];
1304 if (gwps
->data
&& (gwps
->data
->wps_uses_albumart
!= WPS_ALBUMART_NONE
))
1307 *width
= gui_wps
[0].data
->albumart_max_width
;
1309 *height
= gui_wps
[0].data
->albumart_max_height
;
1318 #ifdef IPOD_ACCESSORY_PROTOCOL
1319 int wps_get_ff_rewind_count(void)
1321 return wps_state
.ff_rewind_count
;