Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 Jerome Kuptz |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 21 | #include <stdio.h> |
| 22 | #include <string.h> |
| 23 | #include <stdlib.h> |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 24 | #include "config.h" |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 25 | |
| 26 | #include "system.h" |
| 27 | #include "file.h" |
| 28 | #include "lcd.h" |
| 29 | #include "font.h" |
| 30 | #include "backlight.h" |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 31 | #include "action.h" |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 32 | #include "kernel.h" |
Jonathan Gordon | 36a2e30 | 2007-04-18 13:03:01 +0000 | [diff] [blame] | 33 | #include "filetypes.h" |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 34 | #include "debug.h" |
| 35 | #include "sprintf.h" |
| 36 | #include "settings.h" |
| 37 | #include "gwps.h" |
| 38 | #include "gwps-common.h" |
| 39 | #include "audio.h" |
| 40 | #include "usb.h" |
| 41 | #include "status.h" |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 42 | #include "ata.h" |
| 43 | #include "screens.h" |
| 44 | #include "playlist.h" |
| 45 | #ifdef HAVE_LCD_BITMAP |
| 46 | #include "icons.h" |
| 47 | #include "peakmeter.h" |
| 48 | #endif |
| 49 | #include "action.h" |
| 50 | #include "lang.h" |
| 51 | #include "bookmark.h" |
| 52 | #include "misc.h" |
| 53 | #include "sound.h" |
| 54 | #include "onplay.h" |
| 55 | #include "abrepeat.h" |
| 56 | #include "playback.h" |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 57 | #include "splash.h" |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 58 | #include "cuesheet.h" |
Jonathan Gordon | d9f7ac2 | 2006-11-08 02:23:01 +0000 | [diff] [blame] | 59 | #include "ata_idle_notify.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 60 | #include "root_menu.h" |
Nicolas Pennequin | 1cf2ec3 | 2007-04-25 22:08:00 +0000 | [diff] [blame] | 61 | #include "backdrop.h" |
Jonathan Gordon | ea664e0 | 2008-05-03 12:30:40 +0000 | [diff] [blame] | 62 | #include "quickscreen.h" |
Nicolas Pennequin | 1cf2ec3 | 2007-04-25 22:08:00 +0000 | [diff] [blame] | 63 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 64 | /* currently only on wps_state is needed */ |
| 65 | struct wps_state wps_state; |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 66 | struct gui_wps gui_wps[NB_SCREENS]; |
| 67 | static struct wps_data wps_datas[NB_SCREENS]; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 68 | |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 69 | /* change the path to the current played track */ |
| 70 | static void wps_state_update_ctp(const char *path); |
Nils Wallménius | 20338ca | 2006-12-13 11:52:21 +0000 | [diff] [blame] | 71 | /* initial setup of wps_data */ |
| 72 | static void wps_state_init(void); |
| 73 | /* initial setup of a wps */ |
| 74 | static void gui_wps_init(struct gui_wps *gui_wps); |
| 75 | /* connects a wps with a format-description of the displayed content */ |
| 76 | static void gui_wps_set_data(struct gui_wps *gui_wps, struct wps_data *data); |
| 77 | /* connects a wps with a screen */ |
| 78 | static void gui_wps_set_disp(struct gui_wps *gui_wps, struct screen *display); |
| 79 | /* connects a wps with a statusbar*/ |
| 80 | static void gui_wps_set_statusbar(struct gui_wps *gui_wps, struct gui_statusbar *statusbar); |
| 81 | |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 82 | static void prev_track(unsigned skip_thresh) |
| 83 | { |
| 84 | if (!wps_state.id3 || (wps_state.id3->elapsed < skip_thresh*1000)) { |
| 85 | audio_prev(); |
| 86 | } |
| 87 | else { |
| 88 | if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) |
| 89 | { |
| 90 | curr_cuesheet_skip(-1, wps_state.id3->elapsed); |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | if (!wps_state.paused) |
| 95 | #if (CONFIG_CODEC == SWCODEC) |
| 96 | audio_pre_ff_rewind(); |
| 97 | #else |
| 98 | audio_pause(); |
| 99 | #endif |
| 100 | |
| 101 | audio_ff_rewind(0); |
| 102 | |
| 103 | #if (CONFIG_CODEC != SWCODEC) |
| 104 | if (!wps_state.paused) |
| 105 | audio_resume(); |
| 106 | #endif |
| 107 | } |
| 108 | } |
| 109 | |
Bertrik Sikken | 7835a20 | 2008-05-08 20:37:26 +0000 | [diff] [blame] | 110 | static void next_track(void) |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 111 | { |
| 112 | /* take care of if we're playing a cuesheet */ |
| 113 | if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) |
| 114 | { |
| 115 | if (curr_cuesheet_skip(1, wps_state.id3->elapsed)) |
| 116 | { |
| 117 | /* if the result was false, then we really want |
| 118 | to skip to the next track */ |
| 119 | return; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | audio_next(); |
| 124 | } |
| 125 | |
| 126 | |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 127 | long gui_wps_show(void) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 128 | { |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 129 | long button = 0; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 130 | bool restore = false; |
| 131 | long restoretimer = 0; /* timer to delay screen redraw temporarily */ |
| 132 | bool exit = false; |
Magnus Holmgren | a50c2b1 | 2007-08-22 16:33:34 +0000 | [diff] [blame] | 133 | bool bookmark = false; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 134 | bool update_track = false; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 135 | int i; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 136 | long last_left = 0, last_right = 0; |
Linus Nielsen Feltzing | 75765df | 2006-08-16 13:03:50 +0000 | [diff] [blame] | 137 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 138 | wps_state_init(); |
| 139 | |
| 140 | #ifdef HAVE_LCD_CHARCELLS |
| 141 | status_set_audio(true); |
| 142 | status_set_param(false); |
| 143 | #else |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 144 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 145 | show_wps_backdrop(); |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 146 | #endif /* LCD_DEPTH > 1 */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 147 | #endif |
| 148 | |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 149 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 150 | show_remote_wps_backdrop(); |
| 151 | #endif |
| 152 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 153 | #ifdef AB_REPEAT_ENABLE |
| 154 | ab_repeat_init(); |
| 155 | ab_reset_markers(); |
| 156 | #endif |
| 157 | |
| 158 | if(audio_status() & AUDIO_STATUS_PLAY) |
| 159 | { |
| 160 | wps_state.id3 = audio_current_track(); |
| 161 | wps_state.nid3 = audio_next_track(); |
| 162 | if (wps_state.id3) { |
| 163 | if (gui_wps_display()) |
| 164 | return 0; |
| 165 | FOR_NB_SCREENS(i) |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 166 | gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 167 | wps_state_update_ctp(wps_state.id3->path); |
| 168 | } |
| 169 | |
| 170 | restore = true; |
| 171 | } |
| 172 | while ( 1 ) |
| 173 | { |
| 174 | bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 175 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 176 | /* did someone else (i.e power thread) change audio pause mode? */ |
| 177 | if (wps_state.paused != audio_paused) { |
| 178 | wps_state.paused = audio_paused; |
| 179 | |
| 180 | /* if another thread paused audio, we are probably in car mode, |
| 181 | about to shut down. lets save the settings. */ |
| 182 | if (wps_state.paused) { |
| 183 | settings_save(); |
Dave Chapman | 5009c9c | 2005-12-04 13:05:56 +0000 | [diff] [blame] | 184 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) |
Jonathan Gordon | 4049d44 | 2006-11-26 09:53:42 +0000 | [diff] [blame] | 185 | call_ata_idle_notifys(true); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 186 | #endif |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | #ifdef HAVE_LCD_BITMAP |
| 191 | /* when the peak meter is enabled we want to have a |
| 192 | few extra updates to make it look smooth. On the |
| 193 | other hand we don't want to waste energy if it |
| 194 | isn't displayed */ |
| 195 | bool pm=false; |
| 196 | FOR_NB_SCREENS(i) |
| 197 | { |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 198 | if(gui_wps[i].data->peak_meter_enabled) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 199 | pm = true; |
| 200 | } |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 201 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 202 | if (pm) { |
| 203 | long next_refresh = current_tick; |
| 204 | long next_big_refresh = current_tick + HZ / 5; |
| 205 | button = BUTTON_NONE; |
| 206 | while (TIME_BEFORE(current_tick, next_big_refresh)) { |
Jonathan Gordon | f178131 | 2006-08-17 12:33:36 +0000 | [diff] [blame] | 207 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_NOBLOCK); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 208 | if (button != ACTION_NONE) { |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 209 | break; |
| 210 | } |
| 211 | peak_meter_peek(); |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 212 | sleep(0); /* Sleep until end of current tick. */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 213 | |
| 214 | if (TIME_AFTER(current_tick, next_refresh)) { |
| 215 | FOR_NB_SCREENS(i) |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 216 | { |
| 217 | if(gui_wps[i].data->peak_meter_enabled) |
| 218 | gui_wps_refresh(&gui_wps[i], 0, |
| 219 | WPS_REFRESH_PEAK_METER); |
| 220 | next_refresh += HZ / PEAK_METER_FPS; |
| 221 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | |
| 225 | } |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 226 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 227 | /* The peak meter is disabled |
| 228 | -> no additional screen updates needed */ |
| 229 | else { |
Jonathan Gordon | f178131 | 2006-08-17 12:33:36 +0000 | [diff] [blame] | 230 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 231 | } |
| 232 | #else |
Jonathan Gordon | f178131 | 2006-08-17 12:33:36 +0000 | [diff] [blame] | 233 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,HZ/5); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 234 | #endif |
| 235 | |
| 236 | /* Exit if audio has stopped playing. This can happen if using the |
| 237 | sleep timer with the charger plugged or if starting a recording |
| 238 | from F1 */ |
| 239 | if (!audio_status()) |
| 240 | exit = true; |
Jonathan Gordon | 7258b5e | 2006-12-22 05:19:56 +0000 | [diff] [blame] | 241 | #ifdef ACTION_WPSAB_SINGLE |
| 242 | if (!global_settings.party_mode && ab_repeat_mode_enabled()) |
| 243 | { |
| 244 | static int wps_ab_state = 0; |
| 245 | if (button == ACTION_WPSAB_SINGLE) |
| 246 | { |
| 247 | switch (wps_ab_state) |
| 248 | { |
| 249 | case 0: /* set the A spot */ |
| 250 | button = ACTION_WPS_ABSETA_PREVDIR; |
| 251 | break; |
| 252 | case 1: /* set the B spot */ |
| 253 | button = ACTION_WPS_ABSETB_NEXTDIR; |
| 254 | break; |
| 255 | case 2: |
Marcoen Hirschberg | 5d2b1e3 | 2007-04-13 15:42:25 +0000 | [diff] [blame] | 256 | button = ACTION_WPS_ABRESET; |
Jonathan Gordon | 7258b5e | 2006-12-22 05:19:56 +0000 | [diff] [blame] | 257 | break; |
| 258 | } |
| 259 | wps_ab_state = (wps_ab_state+1) % 3; |
| 260 | } |
| 261 | } |
| 262 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 263 | switch(button) |
| 264 | { |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 265 | case ACTION_WPS_CONTEXT: |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 266 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 267 | show_main_backdrop(); |
Dave Chapman | d9e5b67 | 2006-02-02 20:42:56 +0000 | [diff] [blame] | 268 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 269 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 270 | show_remote_main_backdrop(); |
| 271 | #endif |
Jonathan Gordon | a6f2b82 | 2007-11-04 12:40:18 +0000 | [diff] [blame] | 272 | /* if music is stopped in the context menu we want to exit the wps */ |
| 273 | if (onplay(wps_state.id3->path, |
| 274 | FILE_ATTR_AUDIO, CONTEXT_WPS) == ONPLAY_MAINMENU |
| 275 | || !audio_status()) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 276 | return GO_TO_ROOT; |
Nicolas Pennequin | 523f88e | 2008-02-10 23:07:01 +0000 | [diff] [blame] | 277 | |
| 278 | /* track might have changed */ |
| 279 | update_track = true; |
| 280 | |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 281 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 282 | show_wps_backdrop(); |
Dave Chapman | d9e5b67 | 2006-02-02 20:42:56 +0000 | [diff] [blame] | 283 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 284 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 285 | show_remote_wps_backdrop(); |
| 286 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 287 | restore = true; |
| 288 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 289 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 290 | case ACTION_WPS_BROWSE: |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 291 | #ifdef HAVE_LCD_CHARCELLS |
| 292 | status_set_record(false); |
| 293 | status_set_audio(false); |
| 294 | #endif |
| 295 | FOR_NB_SCREENS(i) |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 296 | gui_wps[i].display->stop_scroll(); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 297 | return GO_TO_PREVIOUS_BROWSER; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 298 | break; |
| 299 | |
| 300 | /* play/pause */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 301 | case ACTION_WPS_PLAY: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 302 | if (global_settings.party_mode) |
| 303 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 304 | if ( wps_state.paused ) |
| 305 | { |
| 306 | wps_state.paused = false; |
| 307 | if ( global_settings.fade_on_stop ) |
Jonathan Gordon | 4982b87 | 2008-06-23 02:45:55 +0000 | [diff] [blame] | 308 | fade(true, true); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 309 | else |
| 310 | audio_resume(); |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | wps_state.paused = true; |
| 315 | if ( global_settings.fade_on_stop ) |
Jonathan Gordon | 4982b87 | 2008-06-23 02:45:55 +0000 | [diff] [blame] | 316 | fade(false, true); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 317 | else |
| 318 | audio_pause(); |
| 319 | settings_save(); |
Dave Chapman | 5009c9c | 2005-12-04 13:05:56 +0000 | [diff] [blame] | 320 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) |
Jonathan Gordon | 4049d44 | 2006-11-26 09:53:42 +0000 | [diff] [blame] | 321 | call_ata_idle_notifys(true); /* make sure resume info is saved */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 322 | #endif |
| 323 | } |
| 324 | break; |
| 325 | |
| 326 | /* volume up */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 327 | case ACTION_WPS_VOLUP: |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 328 | { |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 329 | global_settings.volume++; |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 330 | bool res = false; |
| 331 | setvol(); |
| 332 | FOR_NB_SCREENS(i) |
| 333 | { |
| 334 | if(update_onvol_change(&gui_wps[i])) |
| 335 | res = true; |
| 336 | } |
| 337 | if (res) { |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 338 | restore = true; |
| 339 | restoretimer = current_tick + HZ; |
| 340 | } |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 341 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 342 | break; |
| 343 | |
| 344 | /* volume down */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 345 | case ACTION_WPS_VOLDOWN: |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 346 | { |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 347 | global_settings.volume--; |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 348 | setvol(); |
| 349 | bool res = false; |
| 350 | FOR_NB_SCREENS(i) |
| 351 | { |
| 352 | if(update_onvol_change(&gui_wps[i])) |
| 353 | res = true; |
| 354 | } |
| 355 | if (res) { |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 356 | restore = true; |
| 357 | restoretimer = current_tick + HZ; |
| 358 | } |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 359 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 360 | break; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 361 | /* fast forward |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 362 | OR next dir if this is straight after ACTION_WPS_SKIPNEXT |
| 363 | OR in study mode, next track if straight after SKIPPREV. */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 364 | case ACTION_WPS_SEEKFWD: |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 365 | if (global_settings.party_mode) |
| 366 | break; |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 367 | if (!global_settings.study_mode |
| 368 | && current_tick -last_right < HZ) |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 369 | { |
| 370 | if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) |
| 371 | { |
| 372 | audio_next(); |
| 373 | } |
| 374 | else |
| 375 | { |
| 376 | audio_next_dir(); |
| 377 | } |
| 378 | } |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 379 | else if(global_settings.study_mode |
| 380 | && current_tick -last_left < HZ) { |
| 381 | next_track(); |
| 382 | update_track = true; |
| 383 | } |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 384 | else ffwd_rew(ACTION_WPS_SEEKFWD); |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 385 | last_right = last_left = 0; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 386 | break; |
| 387 | /* fast rewind |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 388 | OR prev dir if this is straight after ACTION_WPS_SKIPPREV, |
| 389 | OR in study mode, beg of track or prev track if this is |
| 390 | straight after SKIPPREV */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 391 | case ACTION_WPS_SEEKBACK: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 392 | if (global_settings.party_mode) |
| 393 | break; |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 394 | if (!global_settings.study_mode |
| 395 | && current_tick -last_left < HZ) |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 396 | { |
| 397 | if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type) |
| 398 | { |
| 399 | if (!wps_state.paused) |
| 400 | #if (CONFIG_CODEC == SWCODEC) |
| 401 | audio_pre_ff_rewind(); |
| 402 | #else |
| 403 | audio_pause(); |
| 404 | #endif |
| 405 | audio_ff_rewind(0); |
| 406 | } |
| 407 | else |
| 408 | { |
| 409 | audio_prev_dir(); |
| 410 | } |
| 411 | } |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 412 | else if(global_settings.study_mode |
| 413 | && current_tick -last_right < HZ) |
| 414 | { |
| 415 | prev_track(3+global_settings.study_hop_step); |
| 416 | update_track = true; |
| 417 | } |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 418 | else ffwd_rew(ACTION_WPS_SEEKBACK); |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 419 | last_left = last_right = 0; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 420 | break; |
| 421 | |
| 422 | /* prev / restart */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 423 | case ACTION_WPS_SKIPPREV: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 424 | if (global_settings.party_mode) |
| 425 | break; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 426 | last_left = current_tick; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 427 | update_track = true; |
| 428 | |
| 429 | #ifdef AB_REPEAT_ENABLE |
| 430 | /* if we're in A/B repeat mode and the current position |
| 431 | is past the A marker, jump back to the A marker... */ |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 432 | if ( ab_repeat_mode_enabled() ) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 433 | { |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 434 | if ( ab_after_A_marker(wps_state.id3->elapsed) ) |
| 435 | { |
| 436 | ab_jump_to_A_marker(); |
| 437 | break; |
| 438 | #if (AB_REPEAT_ENABLE == 2) |
| 439 | } else { |
| 440 | ab_reset_markers(); |
| 441 | #endif |
| 442 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 443 | } |
| 444 | /* ...otherwise, do it normally */ |
| 445 | #endif |
| 446 | |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 447 | if(global_settings.study_mode) |
| 448 | play_hop(-1); |
| 449 | else prev_track(3); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 450 | break; |
| 451 | |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 452 | /* next |
| 453 | OR in study mode, hop by predetermined amount. */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 454 | case ACTION_WPS_SKIPNEXT: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 455 | if (global_settings.party_mode) |
| 456 | break; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 457 | last_right = current_tick; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 458 | update_track = true; |
| 459 | |
| 460 | #ifdef AB_REPEAT_ENABLE |
| 461 | /* if we're in A/B repeat mode and the current position is |
| 462 | before the A marker, jump to the A marker... */ |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 463 | if ( ab_repeat_mode_enabled() ) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 464 | { |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 465 | if ( ab_before_A_marker(wps_state.id3->elapsed) ) |
| 466 | { |
| 467 | ab_jump_to_A_marker(); |
| 468 | break; |
| 469 | #if (AB_REPEAT_ENABLE == 2) |
| 470 | } else { |
| 471 | ab_reset_markers(); |
| 472 | #endif |
| 473 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 474 | } |
| 475 | /* ...otherwise, do it normally */ |
| 476 | #endif |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 477 | |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 478 | if(global_settings.study_mode) |
| 479 | play_hop(1); |
| 480 | else next_track(); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 481 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 482 | /* next / prev directories */ |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 483 | /* and set A-B markers if in a-b mode */ |
| 484 | case ACTION_WPS_ABSETB_NEXTDIR: |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 485 | if (global_settings.party_mode) |
| 486 | break; |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 487 | #if defined(AB_REPEAT_ENABLE) |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 488 | if (ab_repeat_mode_enabled()) |
| 489 | { |
| 490 | ab_set_B_marker(wps_state.id3->elapsed); |
| 491 | ab_jump_to_A_marker(); |
| 492 | update_track = true; |
| 493 | } |
| 494 | else |
| 495 | #endif |
| 496 | { |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 497 | if(global_settings.study_mode) |
| 498 | next_track(); |
| 499 | else audio_next_dir(); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 500 | } |
| 501 | break; |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 502 | case ACTION_WPS_ABSETA_PREVDIR: |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 503 | if (global_settings.party_mode) |
| 504 | break; |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 505 | #if defined(AB_REPEAT_ENABLE) |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 506 | if (ab_repeat_mode_enabled()) |
| 507 | ab_set_A_marker(wps_state.id3->elapsed); |
| 508 | else |
| 509 | #endif |
| 510 | { |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 511 | if(global_settings.study_mode) |
| 512 | prev_track(3); |
| 513 | else audio_prev_dir(); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 514 | } |
| 515 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 516 | /* menu key functions */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 517 | case ACTION_WPS_MENU: |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 518 | FOR_NB_SCREENS(i) |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 519 | gui_wps[i].display->stop_scroll(); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 520 | return GO_TO_ROOT; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 521 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 522 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 523 | |
Zakk Roberts | 2f943b0 | 2006-04-10 03:51:17 +0000 | [diff] [blame] | 524 | #ifdef HAVE_QUICKSCREEN |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 525 | case ACTION_WPS_QUICKSCREEN: |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 526 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 527 | show_main_backdrop(); |
Dave Chapman | d9e5b67 | 2006-02-02 20:42:56 +0000 | [diff] [blame] | 528 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 529 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 530 | show_remote_main_backdrop(); |
| 531 | #endif |
Kevin Ferrare | f57d022 | 2005-11-22 21:55:05 +0000 | [diff] [blame] | 532 | if (quick_screen_quick(button)) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 533 | return SYS_USB_CONNECTED; |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 534 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 535 | show_wps_backdrop(); |
Dave Chapman | d9e5b67 | 2006-02-02 20:42:56 +0000 | [diff] [blame] | 536 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 537 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 538 | show_remote_wps_backdrop(); |
| 539 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 540 | restore = true; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 541 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 542 | #endif /* HAVE_QUICKSCREEN */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 543 | |
| 544 | /* screen settings */ |
| 545 | #ifdef BUTTON_F3 |
Jonathan Gordon | cbcc9db | 2006-08-22 08:23:24 +0000 | [diff] [blame] | 546 | case ACTION_F3: |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 547 | #if LCD_DEPTH > 1 |
Linus Nielsen Feltzing | c26a085 | 2006-07-01 14:03:07 +0000 | [diff] [blame] | 548 | show_main_backdrop(); |
| 549 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 550 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 551 | show_remote_main_backdrop(); |
| 552 | #endif |
Jonathan Gordon | cbcc9db | 2006-08-22 08:23:24 +0000 | [diff] [blame] | 553 | if (quick_screen_f3(BUTTON_F3)) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 554 | return SYS_USB_CONNECTED; |
| 555 | restore = true; |
| 556 | break; |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 557 | #endif /* BUTTON_F3 */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 558 | |
| 559 | /* pitch screen */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 560 | #ifdef HAVE_PITCHSCREEN |
| 561 | case ACTION_WPS_PITCHSCREEN: |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 562 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 563 | show_main_backdrop(); |
Dave Chapman | d9e5b67 | 2006-02-02 20:42:56 +0000 | [diff] [blame] | 564 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 565 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 566 | show_remote_main_backdrop(); |
| 567 | #endif |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 568 | if (1 == pitch_screen()) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 569 | return SYS_USB_CONNECTED; |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 570 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 571 | show_wps_backdrop(); |
Dave Chapman | d9e5b67 | 2006-02-02 20:42:56 +0000 | [diff] [blame] | 572 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 573 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 574 | show_remote_wps_backdrop(); |
| 575 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 576 | restore = true; |
| 577 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 578 | #endif /* HAVE_PITCHSCREEN */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 579 | |
| 580 | #ifdef AB_REPEAT_ENABLE |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 581 | /* reset A&B markers */ |
Marcoen Hirschberg | 5d2b1e3 | 2007-04-13 15:42:25 +0000 | [diff] [blame] | 582 | case ACTION_WPS_ABRESET: |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 583 | if (ab_repeat_mode_enabled()) |
| 584 | { |
| 585 | ab_reset_markers(); |
| 586 | update_track = true; |
| 587 | } |
| 588 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 589 | #endif /* AB_REPEAT_ENABLE */ |
| 590 | |
| 591 | /* stop and exit wps */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 592 | case ACTION_WPS_STOP: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 593 | if (global_settings.party_mode) |
| 594 | break; |
Magnus Holmgren | a50c2b1 | 2007-08-22 16:33:34 +0000 | [diff] [blame] | 595 | bookmark = true; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 596 | exit = true; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 597 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 598 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 599 | case ACTION_WPS_ID3SCREEN: |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 600 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 601 | show_main_backdrop(); |
Linus Nielsen Feltzing | ab1019a | 2006-03-21 11:31:53 +0000 | [diff] [blame] | 602 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 603 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 604 | show_remote_main_backdrop(); |
| 605 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 606 | browse_id3(); |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 607 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 608 | show_wps_backdrop(); |
Linus Nielsen Feltzing | ab1019a | 2006-03-21 11:31:53 +0000 | [diff] [blame] | 609 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 610 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 611 | show_remote_wps_backdrop(); |
| 612 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 613 | restore = true; |
| 614 | break; |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 615 | |
Jonathan Gordon | f178131 | 2006-08-17 12:33:36 +0000 | [diff] [blame] | 616 | case ACTION_REDRAW: /* yes are locked, just redraw */ |
| 617 | restore = true; |
| 618 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 619 | case ACTION_NONE: /* Timeout */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 620 | update_track = true; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 621 | ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 622 | break; |
Jonathan Gordon | 73336e9 | 2007-08-02 12:13:20 +0000 | [diff] [blame] | 623 | #ifdef HAVE_RECORDING |
| 624 | case ACTION_WPS_REC: |
| 625 | exit = true; |
| 626 | break; |
| 627 | #endif |
Linus Nielsen Feltzing | 313cfc0 | 2005-11-18 09:43:42 +0000 | [diff] [blame] | 628 | case SYS_POWEROFF: |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 629 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 630 | show_main_backdrop(); |
Peter D'Hoye | 9fe9a4f | 2006-05-01 14:24:06 +0000 | [diff] [blame] | 631 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 632 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 633 | show_remote_main_backdrop(); |
| 634 | #endif |
Linus Nielsen Feltzing | 313cfc0 | 2005-11-18 09:43:42 +0000 | [diff] [blame] | 635 | default_event_handler(SYS_POWEROFF); |
| 636 | break; |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 637 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 638 | default: |
| 639 | if(default_event_handler(button) == SYS_USB_CONNECTED) |
Jonathan Gordon | a9a9999 | 2007-03-01 23:46:01 +0000 | [diff] [blame] | 640 | return GO_TO_ROOT; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 641 | update_track = true; |
| 642 | break; |
| 643 | } |
| 644 | |
| 645 | if (update_track) |
| 646 | { |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 647 | FOR_NB_SCREENS(i) |
| 648 | { |
| 649 | if(update(&gui_wps[i])) |
Jens Arnold | 5070f41 | 2007-04-22 12:38:11 +0000 | [diff] [blame] | 650 | exit = true; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 651 | } |
| 652 | update_track = false; |
| 653 | } |
| 654 | |
Jens Arnold | 5070f41 | 2007-04-22 12:38:11 +0000 | [diff] [blame] | 655 | if (restore && |
| 656 | ((restoretimer == 0) || |
| 657 | (restoretimer < current_tick))) |
| 658 | { |
| 659 | restore = false; |
| 660 | restoretimer = 0; |
| 661 | if (gui_wps_display()) { |
| 662 | exit = true; |
| 663 | } |
| 664 | else if (wps_state.id3){ |
| 665 | FOR_NB_SCREENS(i) |
| 666 | gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC); |
| 667 | } |
| 668 | } |
| 669 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 670 | if (exit) { |
| 671 | #ifdef HAVE_LCD_CHARCELLS |
| 672 | status_set_record(false); |
| 673 | status_set_audio(false); |
| 674 | #endif |
| 675 | if (global_settings.fade_on_stop) |
Jonathan Gordon | 4982b87 | 2008-06-23 02:45:55 +0000 | [diff] [blame] | 676 | fade(false, true); |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 677 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 678 | FOR_NB_SCREENS(i) |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 679 | gui_wps[i].display->stop_scroll(); |
Magnus Holmgren | a50c2b1 | 2007-08-22 16:33:34 +0000 | [diff] [blame] | 680 | if (bookmark) |
| 681 | bookmark_autobookmark(); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 682 | audio_stop(); |
| 683 | #ifdef AB_REPEAT_ENABLE |
| 684 | ab_reset_markers(); |
| 685 | #endif |
Jonathan Gordon | 73336e9 | 2007-08-02 12:13:20 +0000 | [diff] [blame] | 686 | #ifdef HAVE_RECORDING |
| 687 | if (button == ACTION_WPS_REC) |
| 688 | return GO_TO_RECSCREEN; |
| 689 | #endif |
Jonathan Gordon | fad3ad6 | 2007-04-08 02:11:33 +0000 | [diff] [blame] | 690 | if (global_settings.browse_current) |
| 691 | return GO_TO_PREVIOUS_BROWSER; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 692 | return GO_TO_PREVIOUS; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 693 | } |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 694 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 695 | if ( button ) |
| 696 | ata_spin(); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 697 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 698 | return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | /* needs checking if needed end*/ |
| 702 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 703 | /* wps_state */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 704 | |
Nils Wallménius | 20338ca | 2006-12-13 11:52:21 +0000 | [diff] [blame] | 705 | static void wps_state_init(void) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 706 | { |
| 707 | wps_state.ff_rewind = false; |
| 708 | wps_state.paused = false; |
| 709 | wps_state.id3 = NULL; |
| 710 | wps_state.nid3 = NULL; |
| 711 | wps_state.current_track_path[0] = '\0'; |
| 712 | } |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 713 | |
| 714 | #if 0 |
| 715 | /* these are obviously not used? */ |
| 716 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 717 | void wps_state_update_ff_rew(bool ff_rew) |
| 718 | { |
| 719 | wps_state.ff_rewind = ff_rew; |
| 720 | } |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 721 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 722 | void wps_state_update_paused(bool paused) |
| 723 | { |
| 724 | wps_state.paused = paused; |
| 725 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 726 | void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3) |
| 727 | { |
| 728 | wps_state.id3 = id3; |
| 729 | wps_state.nid3 = nid3; |
| 730 | } |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 731 | #endif |
| 732 | |
| 733 | static void wps_state_update_ctp(const char *path) |
| 734 | { |
Steve Bavin | 276ff3b | 2007-07-06 22:34:18 +0000 | [diff] [blame] | 735 | strncpy(wps_state.current_track_path, path, |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 736 | sizeof(wps_state.current_track_path)); |
Steve Bavin | 276ff3b | 2007-07-06 22:34:18 +0000 | [diff] [blame] | 737 | wps_state.current_track_path[sizeof(wps_state.current_track_path)-1] = '\0'; |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 738 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 739 | /* wps_state end*/ |
| 740 | |
| 741 | /* initial setup of a wps */ |
Nils Wallménius | 20338ca | 2006-12-13 11:52:21 +0000 | [diff] [blame] | 742 | static void gui_wps_init(struct gui_wps *gui_wps) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 743 | { |
| 744 | gui_wps->data = NULL; |
| 745 | gui_wps->display = NULL; |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 746 | gui_wps->statusbar = NULL; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 747 | /* Currently no seperate wps_state needed/possible |
| 748 | so use the only aviable ( "global" ) one */ |
| 749 | gui_wps->state = &wps_state; |
| 750 | } |
| 751 | |
| 752 | /* connects a wps with a format-description of the displayed content */ |
Nils Wallménius | 20338ca | 2006-12-13 11:52:21 +0000 | [diff] [blame] | 753 | static void gui_wps_set_data(struct gui_wps *gui_wps, struct wps_data *data) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 754 | { |
| 755 | gui_wps->data = data; |
| 756 | } |
| 757 | |
| 758 | /* connects a wps with a screen */ |
Nils Wallménius | 20338ca | 2006-12-13 11:52:21 +0000 | [diff] [blame] | 759 | static void gui_wps_set_disp(struct gui_wps *gui_wps, struct screen *display) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 760 | { |
| 761 | gui_wps->display = display; |
| 762 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 763 | |
Nils Wallménius | 20338ca | 2006-12-13 11:52:21 +0000 | [diff] [blame] | 764 | static void gui_wps_set_statusbar(struct gui_wps *gui_wps, struct gui_statusbar *statusbar) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 765 | { |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 766 | gui_wps->statusbar = statusbar; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 767 | } |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 768 | /* gui_wps end */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 769 | |
| 770 | void gui_sync_wps_screen_init(void) |
| 771 | { |
| 772 | int i; |
| 773 | FOR_NB_SCREENS(i) |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 774 | gui_wps_set_disp(&gui_wps[i], &screens[i]); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 775 | } |
Jonathan Gordon | bdbdb97 | 2008-06-23 13:20:35 +0000 | [diff] [blame] | 776 | #ifdef HAVE_LCD_BITMAP |
| 777 | static void statusbar_toggle_handler(void *data) |
| 778 | { |
| 779 | (void)data; |
| 780 | int i; |
| 781 | bool draw = global_settings.statusbar; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 782 | |
Jonathan Gordon | bdbdb97 | 2008-06-23 13:20:35 +0000 | [diff] [blame] | 783 | FOR_NB_SCREENS(i) |
| 784 | { |
| 785 | struct wps_viewport *vp = &gui_wps[i].data->viewports[0]; |
| 786 | if (gui_wps[i].data->wps_sb_tag) |
| 787 | draw = gui_wps[i].data->show_sb_on_wps; |
| 788 | if (!global_settings.statusbar && !draw) |
| 789 | { |
| 790 | vp->vp.y = 0; |
| 791 | vp->vp.height = screens[i].height; |
| 792 | } |
| 793 | else |
| 794 | { |
| 795 | vp->vp.y = STATUSBAR_HEIGHT; |
| 796 | vp->vp.height = screens[i].height - STATUSBAR_HEIGHT; |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | #endif |
| 801 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 802 | void gui_sync_wps_init(void) |
| 803 | { |
| 804 | int i; |
| 805 | FOR_NB_SCREENS(i) |
| 806 | { |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 807 | wps_data_init(&wps_datas[i]); |
Nicolas Pennequin | 2a2b8d8 | 2007-04-25 13:09:56 +0000 | [diff] [blame] | 808 | #ifdef HAVE_REMOTE_LCD |
| 809 | wps_datas[i].remote_wps = (i != 0); |
| 810 | #endif |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 811 | gui_wps_init(&gui_wps[i]); |
| 812 | gui_wps_set_data(&gui_wps[i], &wps_datas[i]); |
Kevin Ferrare | 0d9c7b5 | 2005-11-20 22:13:52 +0000 | [diff] [blame] | 813 | gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 814 | } |
Jonathan Gordon | bdbdb97 | 2008-06-23 13:20:35 +0000 | [diff] [blame] | 815 | #ifdef HAVE_LCD_BITMAP |
| 816 | add_event(STATUSBAR_TOGGLE_EVENT, false, statusbar_toggle_handler); |
| 817 | #endif |
Jens Arnold | 0297873 | 2006-11-13 00:45:21 +0000 | [diff] [blame] | 818 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 819 | unload_wps_backdrop(); |
| 820 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 821 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 822 | unload_remote_wps_backdrop(); |
| 823 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 824 | } |
Nicolas Pennequin | 9d4bed7 | 2007-11-11 12:29:37 +0000 | [diff] [blame] | 825 | |
| 826 | #ifdef HAVE_ALBUMART |
| 827 | /* Returns true if at least one of the gui_wps screens has an album art |
| 828 | tag in its wps structure */ |
| 829 | bool gui_sync_wps_uses_albumart(void) |
| 830 | { |
| 831 | int i; |
| 832 | FOR_NB_SCREENS(i) { |
| 833 | struct gui_wps *gwps = &gui_wps[i]; |
| 834 | if (gwps->data && (gwps->data->wps_uses_albumart != WPS_ALBUMART_NONE)) |
| 835 | return true; |
| 836 | } |
| 837 | return false; |
| 838 | } |
| 839 | #endif |