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 "settings.h" |
Jonathan Gordon | b5442f8 | 2009-08-03 04:57:43 +0000 | [diff] [blame] | 35 | #include "skin_engine/skin_engine.h" |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 36 | #include "mp3_playback.h" |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 37 | #include "audio.h" |
| 38 | #include "usb.h" |
| 39 | #include "status.h" |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 40 | #include "storage.h" |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 41 | #include "screens.h" |
| 42 | #include "playlist.h" |
| 43 | #ifdef HAVE_LCD_BITMAP |
| 44 | #include "icons.h" |
| 45 | #include "peakmeter.h" |
| 46 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 47 | #include "lang.h" |
| 48 | #include "bookmark.h" |
| 49 | #include "misc.h" |
| 50 | #include "sound.h" |
| 51 | #include "onplay.h" |
| 52 | #include "abrepeat.h" |
| 53 | #include "playback.h" |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 54 | #include "splash.h" |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 55 | #include "cuesheet.h" |
Jonathan Gordon | d9f7ac2 | 2006-11-08 02:23:01 +0000 | [diff] [blame] | 56 | #include "ata_idle_notify.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 57 | #include "root_menu.h" |
Nicolas Pennequin | 1cf2ec3 | 2007-04-25 22:08:00 +0000 | [diff] [blame] | 58 | #include "backdrop.h" |
Jonathan Gordon | ea664e0 | 2008-05-03 12:30:40 +0000 | [diff] [blame] | 59 | #include "quickscreen.h" |
Jonathan Gordon | 1da2f01 | 2008-10-05 13:01:54 +0000 | [diff] [blame] | 60 | #include "pitchscreen.h" |
Jonathan Gordon | 71898e5 | 2008-10-16 10:38:03 +0000 | [diff] [blame] | 61 | #include "appevents.h" |
Jonathan Gordon | b86f2d0 | 2009-01-02 01:43:00 +0000 | [diff] [blame] | 62 | #include "viewport.h" |
Thomas Martitz | 74aba34 | 2009-03-12 18:50:24 +0000 | [diff] [blame] | 63 | #include "pcmbuf.h" |
Jonathan Gordon | c1267dc | 2009-05-15 05:36:16 +0000 | [diff] [blame] | 64 | #include "option_select.h" |
| 65 | #include "dsp.h" |
Thomas Martitz | 5c9fe52 | 2009-07-22 22:10:25 +0000 | [diff] [blame] | 66 | #include "playlist_viewer.h" |
Jonathan Gordon | b5442f8 | 2009-08-03 04:57:43 +0000 | [diff] [blame] | 67 | #include "wps.h" |
Thomas Martitz | 1016ee4 | 2009-10-19 15:28:15 +0000 | [diff] [blame] | 68 | #include "statusbar-skinned.h" |
Nicolas Pennequin | 1cf2ec3 | 2007-04-25 22:08:00 +0000 | [diff] [blame] | 69 | |
Thomas Martitz | aad712d | 2009-03-17 01:56:20 +0000 | [diff] [blame] | 70 | #define RESTORE_WPS_INSTANTLY 0l |
| 71 | #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick)) |
Thomas Martitz | 218b312 | 2009-08-03 22:39:27 +0000 | [diff] [blame] | 72 | |
| 73 | #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ |
| 74 | /* 3% of 30min file == 54s step size */ |
| 75 | #define MIN_FF_REWIND_STEP 500 |
| 76 | |
Nils Wallménius | 20338ca | 2006-12-13 11:52:21 +0000 | [diff] [blame] | 77 | /* initial setup of wps_data */ |
| 78 | static void wps_state_init(void); |
Jonathan Gordon | 843c7ef | 2009-04-06 00:39:43 +0000 | [diff] [blame] | 79 | static void track_changed_callback(void *param); |
| 80 | static void nextid3available_callback(void* param); |
Thomas Martitz | ec7a0c5 | 2009-04-14 22:13:29 +0000 | [diff] [blame] | 81 | |
Thomas Martitz | e510de1 | 2009-08-20 14:29:03 +0000 | [diff] [blame] | 82 | #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" |
| 83 | #ifdef HAVE_REMOTE_LCD |
| 84 | #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps" |
| 85 | #define DEFAULT_WPS(screen) ((screen) == SCREEN_MAIN ? \ |
| 86 | WPS_DEFAULTCFG:RWPS_DEFAULTCFG) |
| 87 | #else |
| 88 | #define DEFAULT_WPS(screen) (WPS_DEFAULTCFG) |
| 89 | #endif |
| 90 | |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 91 | char* wps_default_skin(enum screen_type screen) |
Thomas Martitz | 3b75c86 | 2009-08-03 15:06:30 +0000 | [diff] [blame] | 92 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 93 | static char *skin_buf[NB_SCREENS] = { |
Thomas Martitz | 218b312 | 2009-08-03 22:39:27 +0000 | [diff] [blame] | 94 | #ifdef HAVE_LCD_BITMAP |
Jonathan Gordon | eee5423 | 2010-01-29 07:52:13 +0000 | [diff] [blame] | 95 | #if LCD_DEPTH > 1 |
Jonathan Gordon | 5b0521c | 2010-06-07 03:44:11 +0000 | [diff] [blame] | 96 | "%X(d)\n" |
Jonathan Gordon | eee5423 | 2010-01-29 07:52:13 +0000 | [diff] [blame] | 97 | #endif |
Thomas Martitz | 218b312 | 2009-08-03 22:39:27 +0000 | [diff] [blame] | 98 | "%s%?it<%?in<%in. |>%it|%fn>\n" |
Jonathan Gordon | 5b0521c | 2010-06-07 03:44:11 +0000 | [diff] [blame] | 99 | "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n" |
| 100 | "%s%?id<%id|%?d(1)<%d(1)|%(root%)>> %?iy<%(%iy%)|>\n\n" |
Thomas Martitz | 218b312 | 2009-08-03 22:39:27 +0000 | [diff] [blame] | 101 | "%al%pc/%pt%ar[%pp:%pe]\n" |
Jonathan Gordon | 5b0521c | 2010-06-07 03:44:11 +0000 | [diff] [blame] | 102 | "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n" |
Thomas Martitz | 218b312 | 2009-08-03 22:39:27 +0000 | [diff] [blame] | 103 | "%pb\n%pm\n", |
| 104 | #else |
Jonathan Gordon | 5b0521c | 2010-06-07 03:44:11 +0000 | [diff] [blame] | 105 | "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d(2)> - %?id<%id|%d(1)>\n" |
Thomas Martitz | 218b312 | 2009-08-03 22:39:27 +0000 | [diff] [blame] | 106 | "%pc%?ps<*|/>%pt\n", |
| 107 | #endif |
| 108 | #ifdef HAVE_REMOTE_LCD |
Jonathan Gordon | eee5423 | 2010-01-29 07:52:13 +0000 | [diff] [blame] | 109 | #if LCD_REMOTE_DEPTH > 1 |
Jonathan Gordon | 5b0521c | 2010-06-07 03:44:11 +0000 | [diff] [blame] | 110 | "%X(d)\n" |
Jonathan Gordon | eee5423 | 2010-01-29 07:52:13 +0000 | [diff] [blame] | 111 | #endif |
Jonathan Gordon | 5b0521c | 2010-06-07 03:44:11 +0000 | [diff] [blame] | 112 | "%s%?ia<%ia|%?d(2)<%d(2)|%(root%)>>\n" |
Thomas Martitz | 218b312 | 2009-08-03 22:39:27 +0000 | [diff] [blame] | 113 | "%s%?it<%?in<%in. |>%it|%fn>\n" |
| 114 | "%al%pc/%pt%ar[%pp:%pe]\n" |
Jonathan Gordon | 5b0521c | 2010-06-07 03:44:11 +0000 | [diff] [blame] | 115 | "%fbkBit %?fv<avg|> %?iv<%(id3v%iv%)|%(no id3%)>\n" |
Thomas Martitz | 218b312 | 2009-08-03 22:39:27 +0000 | [diff] [blame] | 116 | "%pb\n", |
| 117 | #endif |
| 118 | }; |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 119 | return skin_buf[screen]; |
Thomas Martitz | 3b75c86 | 2009-08-03 15:06:30 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 122 | static void update_non_static(void) |
| 123 | { |
| 124 | int i; |
| 125 | FOR_NB_SCREENS(i) |
| 126 | skin_update(WPS, i, SKIN_REFRESH_NON_STATIC); |
| 127 | } |
| 128 | |
Michael Hohmuth | 84301c1 | 2011-05-09 12:59:46 +0000 | [diff] [blame] | 129 | void pause_action(bool may_fade, bool updatewps) |
| 130 | { |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 131 | #if CONFIG_CODEC == SWCODEC |
| 132 | /* Do audio first, then update, unless skin were to use its local |
| 133 | status in which case, reverse it */ |
| 134 | audio_pause(); |
| 135 | |
| 136 | if (updatewps) |
| 137 | update_non_static(); |
| 138 | #else |
Michael Hohmuth | 84301c1 | 2011-05-09 12:59:46 +0000 | [diff] [blame] | 139 | if (may_fade && global_settings.fade_on_stop) |
| 140 | fade(false, updatewps); |
| 141 | else |
| 142 | audio_pause(); |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 143 | #endif |
Michael Hohmuth | 5aec3c2 | 2011-05-13 22:28:47 +0000 | [diff] [blame] | 144 | |
| 145 | if (global_settings.pause_rewind) { |
| 146 | long newpos; |
| 147 | |
| 148 | #if (CONFIG_CODEC == SWCODEC) |
| 149 | audio_pre_ff_rewind(); |
| 150 | #endif |
| 151 | newpos = audio_current_track()->elapsed |
| 152 | - global_settings.pause_rewind * 1000; |
| 153 | audio_ff_rewind(newpos > 0 ? newpos : 0); |
| 154 | } |
Michael Sevakis | a2b6703 | 2011-06-29 06:37:04 +0000 | [diff] [blame] | 155 | |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 156 | (void)may_fade; |
Michael Hohmuth | 84301c1 | 2011-05-09 12:59:46 +0000 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | void unpause_action(bool may_fade, bool updatewps) |
| 160 | { |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 161 | #if CONFIG_CODEC == SWCODEC |
| 162 | /* Do audio first, then update, unless skin were to use its local |
| 163 | status in which case, reverse it */ |
| 164 | audio_resume(); |
| 165 | |
| 166 | if (updatewps) |
| 167 | update_non_static(); |
| 168 | #else |
Michael Hohmuth | 84301c1 | 2011-05-09 12:59:46 +0000 | [diff] [blame] | 169 | if (may_fade && global_settings.fade_on_stop) |
| 170 | fade(true, updatewps); |
| 171 | else |
| 172 | audio_resume(); |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 173 | #endif |
| 174 | |
| 175 | (void)may_fade; |
Michael Hohmuth | 84301c1 | 2011-05-09 12:59:46 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Michael Sevakis | a2b6703 | 2011-06-29 06:37:04 +0000 | [diff] [blame] | 178 | #if CONFIG_CODEC != SWCODEC |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 179 | void fade(bool fade_in, bool updatewps) |
| 180 | { |
| 181 | int fp_global_vol = global_settings.volume << 8; |
| 182 | int fp_min_vol = sound_min(SOUND_VOLUME) << 8; |
Björn Stenberg | b8f29c7 | 2011-03-10 22:25:18 +0000 | [diff] [blame] | 183 | int fp_step = (fp_global_vol - fp_min_vol) / 10; |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 184 | |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 185 | skin_get_global_state()->is_fading = !fade_in; |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 186 | if (fade_in) { |
| 187 | /* fade in */ |
| 188 | int fp_volume = fp_min_vol; |
| 189 | |
| 190 | /* zero out the sound */ |
| 191 | sound_set_volume(fp_min_vol >> 8); |
| 192 | |
| 193 | sleep(HZ/10); /* let audio thread run */ |
| 194 | audio_resume(); |
| 195 | |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 196 | if (updatewps) |
| 197 | update_non_static(); |
Björn Stenberg | b8f29c7 | 2011-03-10 22:25:18 +0000 | [diff] [blame] | 198 | |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 199 | while (fp_volume < fp_global_vol - fp_step) { |
| 200 | fp_volume += fp_step; |
| 201 | sound_set_volume(fp_volume >> 8); |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 202 | sleep(1); |
| 203 | } |
| 204 | sound_set_volume(global_settings.volume); |
| 205 | } |
| 206 | else { |
| 207 | /* fade out */ |
| 208 | int fp_volume = fp_global_vol; |
| 209 | |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 210 | if (updatewps) |
| 211 | update_non_static(); |
Björn Stenberg | b8f29c7 | 2011-03-10 22:25:18 +0000 | [diff] [blame] | 212 | |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 213 | while (fp_volume > fp_min_vol + fp_step) { |
| 214 | fp_volume -= fp_step; |
| 215 | sound_set_volume(fp_volume >> 8); |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 216 | sleep(1); |
| 217 | } |
| 218 | audio_pause(); |
Björn Stenberg | b8f29c7 | 2011-03-10 22:25:18 +0000 | [diff] [blame] | 219 | |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 220 | skin_get_global_state()->is_fading = false; |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 221 | #if CONFIG_CODEC != SWCODEC |
| 222 | #ifndef SIMULATOR |
| 223 | /* let audio thread run and wait for the mas to run out of data */ |
| 224 | while (!mp3_pause_done()) |
| 225 | #endif |
| 226 | sleep(HZ/10); |
| 227 | #endif |
| 228 | |
| 229 | /* reset volume to what it was before the fade */ |
| 230 | sound_set_volume(global_settings.volume); |
| 231 | } |
| 232 | } |
Michael Sevakis | a2b6703 | 2011-06-29 06:37:04 +0000 | [diff] [blame] | 233 | #endif /* SWCODEC */ |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 234 | |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 235 | static bool update_onvol_change(enum screen_type screen) |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 236 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 237 | skin_update(WPS, screen, SKIN_REFRESH_NON_STATIC); |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 238 | |
| 239 | #ifdef HAVE_LCD_CHARCELLS |
| 240 | splashf(0, "Vol: %3d dB", |
| 241 | sound_val2phys(SOUND_VOLUME, global_settings.volume)); |
| 242 | return true; |
| 243 | #endif |
| 244 | return false; |
| 245 | } |
| 246 | |
Thomas Martitz | 3b75c86 | 2009-08-03 15:06:30 +0000 | [diff] [blame] | 247 | |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 248 | #ifdef HAVE_TOUCHSCREEN |
Bertrik Sikken | 76f4c02 | 2010-07-31 13:41:06 +0000 | [diff] [blame] | 249 | static int skintouch_to_wps(struct wps_data *data) |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 250 | { |
| 251 | int offset = 0; |
Jonathan Gordon | 4caa832 | 2010-09-06 13:33:49 +0000 | [diff] [blame] | 252 | struct touchregion *region; |
| 253 | int button = skin_get_touchaction(data, &offset, ®ion); |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 254 | switch (button) |
| 255 | { |
| 256 | case ACTION_STD_PREV: |
| 257 | return ACTION_WPS_SKIPPREV; |
| 258 | case ACTION_STD_PREVREPEAT: |
| 259 | return ACTION_WPS_SEEKBACK; |
| 260 | case ACTION_STD_NEXT: |
| 261 | return ACTION_WPS_SKIPNEXT; |
| 262 | case ACTION_STD_NEXTREPEAT: |
| 263 | return ACTION_WPS_SEEKFWD; |
| 264 | case ACTION_STD_MENU: |
| 265 | return ACTION_WPS_MENU; |
| 266 | case ACTION_STD_CONTEXT: |
| 267 | return ACTION_WPS_CONTEXT; |
| 268 | case ACTION_STD_QUICKSCREEN: |
| 269 | return ACTION_WPS_QUICKSCREEN; |
Jonathan Gordon | c201772 | 2010-06-21 12:14:16 +0000 | [diff] [blame] | 270 | #ifdef HAVE_HOTKEY |
| 271 | case ACTION_STD_HOTKEY: |
| 272 | return ACTION_WPS_HOTKEY; |
| 273 | #endif |
Jonathan Gordon | 443b134 | 2011-03-27 07:23:38 +0000 | [diff] [blame] | 274 | case ACTION_TOUCH_SCROLLBAR: |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 275 | skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100; |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 276 | #if (CONFIG_CODEC == SWCODEC) |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 277 | audio_pre_ff_rewind(); |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 278 | #else |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 279 | if (!skin_get_global_state()->paused) |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 280 | audio_pause(); |
| 281 | #endif |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 282 | audio_ff_rewind(skin_get_global_state()->id3->elapsed); |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 283 | #if (CONFIG_CODEC != SWCODEC) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 284 | if (!skin_get_global_state()->paused) |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 285 | audio_resume(); |
| 286 | #endif |
| 287 | return ACTION_TOUCHSCREEN; |
Jonathan Gordon | 443b134 | 2011-03-27 07:23:38 +0000 | [diff] [blame] | 288 | case ACTION_TOUCH_VOLUME: |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 289 | { |
| 290 | const int min_vol = sound_min(SOUND_VOLUME); |
| 291 | const int max_vol = sound_max(SOUND_VOLUME); |
| 292 | global_settings.volume = (offset * (max_vol - min_vol)) / 100; |
| 293 | global_settings.volume += min_vol; |
| 294 | setvol(); |
| 295 | } |
| 296 | return ACTION_TOUCHSCREEN; |
| 297 | } |
| 298 | return button; |
| 299 | } |
Bertrik Sikken | 76f4c02 | 2010-07-31 13:41:06 +0000 | [diff] [blame] | 300 | #endif /* HAVE_TOUCHSCREEN */ |
Jonathan Gordon | a398c28 | 2010-06-21 06:04:19 +0000 | [diff] [blame] | 301 | |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 302 | bool ffwd_rew(int button) |
| 303 | { |
| 304 | unsigned int step = 0; /* current ff/rewind step */ |
| 305 | unsigned int max_step = 0; /* maximum ff/rewind step */ |
| 306 | int ff_rewind_count = 0; /* current ff/rewind count (in ticks) */ |
| 307 | int direction = -1; /* forward=1 or backward=-1 */ |
| 308 | bool exit = false; |
| 309 | bool usb = false; |
| 310 | int i = 0; |
| 311 | const long ff_rw_accel = (global_settings.ff_rewind_accel + 3); |
| 312 | |
| 313 | if (button == ACTION_NONE) |
| 314 | { |
| 315 | status_set_ffmode(0); |
| 316 | return usb; |
| 317 | } |
| 318 | while (!exit) |
| 319 | { |
| 320 | switch ( button ) |
| 321 | { |
| 322 | case ACTION_WPS_SEEKFWD: |
| 323 | direction = 1; |
| 324 | case ACTION_WPS_SEEKBACK: |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 325 | if (skin_get_global_state()->ff_rewind) |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 326 | { |
| 327 | if (direction == 1) |
| 328 | { |
| 329 | /* fast forwarding, calc max step relative to end */ |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 330 | max_step = (skin_get_global_state()->id3->length - |
| 331 | (skin_get_global_state()->id3->elapsed + |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 332 | ff_rewind_count)) * |
| 333 | FF_REWIND_MAX_PERCENT / 100; |
| 334 | } |
| 335 | else |
| 336 | { |
| 337 | /* rewinding, calc max step relative to start */ |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 338 | max_step = (skin_get_global_state()->id3->elapsed + ff_rewind_count) * |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 339 | FF_REWIND_MAX_PERCENT / 100; |
| 340 | } |
| 341 | |
| 342 | max_step = MAX(max_step, MIN_FF_REWIND_STEP); |
| 343 | |
| 344 | if (step > max_step) |
| 345 | step = max_step; |
| 346 | |
| 347 | ff_rewind_count += step * direction; |
| 348 | |
| 349 | /* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */ |
| 350 | step += step >> ff_rw_accel; |
| 351 | } |
| 352 | else |
| 353 | { |
| 354 | if ( (audio_status() & AUDIO_STATUS_PLAY) && |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 355 | skin_get_global_state()->id3 && skin_get_global_state()->id3->length ) |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 356 | { |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 357 | #if (CONFIG_CODEC == SWCODEC) |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 358 | audio_pre_ff_rewind(); |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 359 | #else |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 360 | if (!skin_get_global_state()->paused) |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 361 | audio_pause(); |
| 362 | #endif |
| 363 | #if CONFIG_KEYPAD == PLAYER_PAD |
| 364 | FOR_NB_SCREENS(i) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 365 | skin_get_gwps(WPS, i)->display->stop_scroll(); |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 366 | #endif |
| 367 | if (direction > 0) |
| 368 | status_set_ffmode(STATUS_FASTFORWARD); |
| 369 | else |
| 370 | status_set_ffmode(STATUS_FASTBACKWARD); |
| 371 | |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 372 | skin_get_global_state()->ff_rewind = true; |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 373 | |
| 374 | step = 1000 * global_settings.ff_rewind_min_step; |
| 375 | } |
| 376 | else |
| 377 | break; |
| 378 | } |
| 379 | |
| 380 | if (direction > 0) { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 381 | if ((skin_get_global_state()->id3->elapsed + ff_rewind_count) > |
| 382 | skin_get_global_state()->id3->length) |
| 383 | ff_rewind_count = skin_get_global_state()->id3->length - |
| 384 | skin_get_global_state()->id3->elapsed; |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 385 | } |
| 386 | else { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 387 | if ((int)(skin_get_global_state()->id3->elapsed + ff_rewind_count) < 0) |
| 388 | ff_rewind_count = -skin_get_global_state()->id3->elapsed; |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 389 | } |
| 390 | |
Jonathan Gordon | b5442f8 | 2009-08-03 04:57:43 +0000 | [diff] [blame] | 391 | /* set the wps state ff_rewind_count so the progess info |
| 392 | displays corectly */ |
Andree Buschmann | 4c38572 | 2011-01-25 21:40:55 +0000 | [diff] [blame] | 393 | skin_get_global_state()->ff_rewind_count = ff_rewind_count; |
| 394 | |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 395 | FOR_NB_SCREENS(i) |
Jonathan Gordon | b5442f8 | 2009-08-03 04:57:43 +0000 | [diff] [blame] | 396 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 397 | skin_update(WPS, i, |
Jonathan Gordon | 2d31d77 | 2010-07-29 12:37:48 +0000 | [diff] [blame] | 398 | SKIN_REFRESH_PLAYER_PROGRESS | |
| 399 | SKIN_REFRESH_DYNAMIC); |
Jonathan Gordon | b5442f8 | 2009-08-03 04:57:43 +0000 | [diff] [blame] | 400 | } |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 401 | |
| 402 | break; |
| 403 | |
| 404 | case ACTION_WPS_STOPSEEK: |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 405 | skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->elapsed+ff_rewind_count; |
| 406 | audio_ff_rewind(skin_get_global_state()->id3->elapsed); |
| 407 | skin_get_global_state()->ff_rewind_count = 0; |
| 408 | skin_get_global_state()->ff_rewind = false; |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 409 | status_set_ffmode(0); |
| 410 | #if (CONFIG_CODEC != SWCODEC) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 411 | if (!skin_get_global_state()->paused) |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 412 | audio_resume(); |
| 413 | #endif |
| 414 | #ifdef HAVE_LCD_CHARCELLS |
| 415 | FOR_NB_SCREENS(i) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 416 | skin_update(WPS, i, SKIN_REFRESH_ALL); |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 417 | #endif |
| 418 | exit = true; |
| 419 | break; |
| 420 | |
| 421 | default: |
| 422 | if(default_event_handler(button) == SYS_USB_CONNECTED) { |
| 423 | status_set_ffmode(0); |
| 424 | usb = true; |
| 425 | exit = true; |
| 426 | } |
| 427 | break; |
| 428 | } |
| 429 | if (!exit) |
| 430 | { |
| 431 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK); |
| 432 | #ifdef HAVE_TOUCHSCREEN |
| 433 | if (button == ACTION_TOUCHSCREEN) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 434 | button = skintouch_to_wps(skin_get_gwps(WPS, SCREEN_MAIN)->data); |
Jonathan Gordon | eada090 | 2010-06-20 13:17:24 +0000 | [diff] [blame] | 435 | if (button != ACTION_WPS_SEEKFWD && |
| 436 | button != ACTION_WPS_SEEKBACK) |
| 437 | button = ACTION_WPS_STOPSEEK; |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 438 | #endif |
Teruaki Kawashima | 5b2a599 | 2009-08-29 16:25:04 +0000 | [diff] [blame] | 439 | } |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 440 | } |
| 441 | return usb; |
| 442 | } |
| 443 | |
| 444 | |
| 445 | void display_keylock_text(bool locked) |
| 446 | { |
| 447 | int i; |
| 448 | FOR_NB_SCREENS(i) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 449 | skin_get_gwps(WPS, i)->display->stop_scroll(); |
Jonathan Gordon | 5e5fc64 | 2009-07-27 07:21:05 +0000 | [diff] [blame] | 450 | |
| 451 | splash(HZ, locked ? ID2P(LANG_KEYLOCK_ON) : ID2P(LANG_KEYLOCK_OFF)); |
| 452 | } |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
Thomas Martitz | ec7a0c5 | 2009-04-14 22:13:29 +0000 | [diff] [blame] | 457 | #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) |
| 458 | static void gwps_caption_backlight(struct wps_state *state) |
| 459 | { |
| 460 | if (state && state->id3) |
| 461 | { |
| 462 | #ifdef HAVE_BACKLIGHT |
| 463 | if (global_settings.caption_backlight) |
| 464 | { |
| 465 | /* turn on backlight n seconds before track ends, and turn it off n |
| 466 | seconds into the new track. n == backlight_timeout, or 5s */ |
| 467 | int n = global_settings.backlight_timeout * 1000; |
| 468 | |
| 469 | if ( n < 1000 ) |
| 470 | n = 5000; /* use 5s if backlight is always on or off */ |
| 471 | |
| 472 | if (((state->id3->elapsed < 1000) || |
| 473 | ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && |
| 474 | (state->paused == false)) |
| 475 | backlight_on(); |
| 476 | } |
| 477 | #endif |
| 478 | #ifdef HAVE_REMOTE_LCD |
| 479 | if (global_settings.remote_caption_backlight) |
| 480 | { |
| 481 | /* turn on remote backlight n seconds before track ends, and turn it |
| 482 | off n seconds into the new track. n == remote_backlight_timeout, |
| 483 | or 5s */ |
| 484 | int n = global_settings.remote_backlight_timeout * 1000; |
| 485 | |
| 486 | if ( n < 1000 ) |
| 487 | n = 5000; /* use 5s if backlight is always on or off */ |
| 488 | |
| 489 | if (((state->id3->elapsed < 1000) || |
| 490 | ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && |
| 491 | (state->paused == false)) |
| 492 | remote_backlight_on(); |
| 493 | } |
| 494 | #endif |
| 495 | } |
| 496 | } |
| 497 | #endif |
| 498 | |
| 499 | |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 500 | static void change_dir(int direction) |
| 501 | { |
| 502 | if (global_settings.prevent_skip) |
| 503 | return; |
| 504 | |
| 505 | if (direction < 0) |
| 506 | audio_prev_dir(); |
| 507 | else if (direction > 0) |
| 508 | audio_next_dir(); |
Jonathan Gordon | 0e445fc | 2009-07-03 05:08:33 +0000 | [diff] [blame] | 509 | /* prevent the next dir to immediatly start being ffw'd */ |
| 510 | action_wait_for_release(); |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | static void prev_track(unsigned long skip_thresh) |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 514 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 515 | struct wps_state *state = skin_get_global_state(); |
| 516 | if (state->id3->elapsed < skip_thresh) |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 517 | { |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 518 | audio_prev(); |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 519 | return; |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 520 | } |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 521 | else |
| 522 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 523 | if (state->id3->cuesheet) |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 524 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 525 | curr_cuesheet_skip(state->id3->cuesheet, -1, state->id3->elapsed); |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 526 | return; |
| 527 | } |
| 528 | |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 529 | #if (CONFIG_CODEC == SWCODEC) |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 530 | audio_pre_ff_rewind(); |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 531 | #else |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 532 | if (!state->paused) |
Mustapha Senhaji | ccad6d0 | 2011-01-18 00:37:17 +0000 | [diff] [blame] | 533 | audio_pause(); |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 534 | #endif |
| 535 | |
| 536 | audio_ff_rewind(0); |
| 537 | |
| 538 | #if (CONFIG_CODEC != SWCODEC) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 539 | if (!state->paused) |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 540 | audio_resume(); |
| 541 | #endif |
| 542 | } |
| 543 | } |
| 544 | |
Bertrik Sikken | 7835a20 | 2008-05-08 20:37:26 +0000 | [diff] [blame] | 545 | static void next_track(void) |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 546 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 547 | struct wps_state *state = skin_get_global_state(); |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 548 | /* take care of if we're playing a cuesheet */ |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 549 | if (state->id3->cuesheet) |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 550 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 551 | if (curr_cuesheet_skip(state->id3->cuesheet, 1, state->id3->elapsed)) |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 552 | { |
| 553 | /* if the result was false, then we really want |
| 554 | to skip to the next track */ |
| 555 | return; |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | audio_next(); |
| 560 | } |
Thomas Martitz | 74aba34 | 2009-03-12 18:50:24 +0000 | [diff] [blame] | 561 | |
| 562 | static void play_hop(int direction) |
| 563 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 564 | struct wps_state *state = skin_get_global_state(); |
Thomas Martitz | a7c888c | 2009-10-17 16:05:23 +0000 | [diff] [blame] | 565 | long step = global_settings.skip_length*1000; |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 566 | long elapsed = state->id3->elapsed; |
| 567 | long remaining = state->id3->length - elapsed; |
Thomas Martitz | 74aba34 | 2009-03-12 18:50:24 +0000 | [diff] [blame] | 568 | |
Thomas Martitz | a7c888c | 2009-10-17 16:05:23 +0000 | [diff] [blame] | 569 | if (step < 0) |
| 570 | { |
| 571 | if (direction < 0) |
| 572 | { |
| 573 | prev_track(DEFAULT_SKIP_TRESH); |
| 574 | return; |
| 575 | } |
| 576 | else if (remaining < DEFAULT_SKIP_TRESH*2) |
| 577 | { |
| 578 | next_track(); |
| 579 | return; |
| 580 | } |
| 581 | else |
| 582 | elapsed += (remaining - DEFAULT_SKIP_TRESH*2); |
| 583 | } |
| 584 | else if (!global_settings.prevent_skip && |
Alexander Levin | be7f525 | 2009-04-05 19:29:21 +0000 | [diff] [blame] | 585 | (!step || |
| 586 | (direction > 0 && step >= remaining) || |
| 587 | (direction < 0 && elapsed < DEFAULT_SKIP_TRESH))) |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 588 | { /* Do normal track skipping */ |
| 589 | if (direction > 0) |
Thomas Martitz | 8d59821 | 2009-03-27 13:57:56 +0000 | [diff] [blame] | 590 | next_track(); |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 591 | else if (direction < 0) |
| 592 | prev_track(DEFAULT_SKIP_TRESH); |
| 593 | return; |
| 594 | } |
Thomas Martitz | a7c888c | 2009-10-17 16:05:23 +0000 | [diff] [blame] | 595 | else if (direction == 1 && step >= remaining) |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 596 | { |
Thomas Martitz | 74aba34 | 2009-03-12 18:50:24 +0000 | [diff] [blame] | 597 | #if CONFIG_CODEC == SWCODEC |
Michael Sevakis | 5663e1c | 2011-07-08 22:31:15 +0000 | [diff] [blame] | 598 | system_sound_play(SOUND_TRACK_NO_MORE); |
Thomas Martitz | 74aba34 | 2009-03-12 18:50:24 +0000 | [diff] [blame] | 599 | #endif |
| 600 | return; |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 601 | } |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 602 | else if ((direction == -1 && elapsed < step)) |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 603 | { |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 604 | elapsed = 0; |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 605 | } |
| 606 | else |
| 607 | { |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 608 | elapsed += step * direction; |
Thomas Martitz | 74aba34 | 2009-03-12 18:50:24 +0000 | [diff] [blame] | 609 | } |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 610 | if(audio_status() & AUDIO_STATUS_PLAY) |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 611 | { |
Thomas Martitz | 74aba34 | 2009-03-12 18:50:24 +0000 | [diff] [blame] | 612 | #if (CONFIG_CODEC == SWCODEC) |
| 613 | audio_pre_ff_rewind(); |
| 614 | #else |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 615 | if (!state->paused) |
| 616 | audio_pause(); |
Thomas Martitz | 74aba34 | 2009-03-12 18:50:24 +0000 | [diff] [blame] | 617 | #endif |
| 618 | } |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 619 | |
| 620 | #if (CONFIG_CODEC == SWCODEC) |
| 621 | audio_ff_rewind(elapsed); |
| 622 | #else |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 623 | audio_ff_rewind(state->id3->elapsed = elapsed); |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 624 | if (!state->paused) |
Thomas Martitz | 74aba34 | 2009-03-12 18:50:24 +0000 | [diff] [blame] | 625 | audio_resume(); |
| 626 | #endif |
| 627 | } |
| 628 | |
Jonathan Gordon | 036fb05 | 2009-02-01 13:43:08 +0000 | [diff] [blame] | 629 | |
Thomas Martitz | 7ce12e6 | 2009-04-09 08:30:05 +0000 | [diff] [blame] | 630 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) |
| 631 | /* |
| 632 | * If the user is unable to see the wps, because the display is deactivated, |
Thomas Martitz | 2ad5e24 | 2009-07-10 16:27:24 +0000 | [diff] [blame] | 633 | * we suppress updates until the wps is activated again (the lcd driver will |
Thomas Martitz | 29cf2e1 | 2009-04-25 19:23:40 +0000 | [diff] [blame] | 634 | * call this hook to issue an instant update) |
Thomas Martitz | 7ce12e6 | 2009-04-09 08:30:05 +0000 | [diff] [blame] | 635 | * */ |
Thomas Martitz | d85c3ec | 2009-10-20 21:54:59 +0000 | [diff] [blame] | 636 | static void wps_lcd_activation_hook(void *param) |
Thomas Martitz | 7ce12e6 | 2009-04-09 08:30:05 +0000 | [diff] [blame] | 637 | { |
Thomas Martitz | d85c3ec | 2009-10-20 21:54:59 +0000 | [diff] [blame] | 638 | (void)param; |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 639 | skin_request_full_update(WPS); |
Thomas Martitz | 7ce12e6 | 2009-04-09 08:30:05 +0000 | [diff] [blame] | 640 | /* force timeout in wps main loop, so that the update is instantly */ |
| 641 | queue_post(&button_queue, BUTTON_NONE, 0); |
| 642 | } |
| 643 | #endif |
Thomas Martitz | 6809909 | 2009-03-17 01:39:20 +0000 | [diff] [blame] | 644 | |
Thomas Martitz | aad712d | 2009-03-17 01:56:20 +0000 | [diff] [blame] | 645 | static void gwps_leave_wps(void) |
| 646 | { |
Jonathan Gordon | b2eb44c | 2009-12-09 07:25:46 +0000 | [diff] [blame] | 647 | int i; |
Thomas Martitz | aad712d | 2009-03-17 01:56:20 +0000 | [diff] [blame] | 648 | |
Thomas Martitz | ce6b116 | 2009-03-19 23:04:39 +0000 | [diff] [blame] | 649 | FOR_NB_SCREENS(i) |
Thomas Martitz | 4764ee0 | 2009-08-06 00:14:40 +0000 | [diff] [blame] | 650 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 651 | skin_get_gwps(WPS, i)->display->stop_scroll(); |
Jonathan Gordon | 54ca765 | 2010-02-08 09:47:08 +0000 | [diff] [blame] | 652 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 653 | skin_backdrop_show(sb_get_backdrop(i)); |
Jonathan Gordon | 54ca765 | 2010-02-08 09:47:08 +0000 | [diff] [blame] | 654 | #endif |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 655 | viewportmanager_theme_undo(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data)); |
Jonathan Gordon | 9d1832c | 2009-12-21 05:19:12 +0000 | [diff] [blame] | 656 | |
Thomas Martitz | 4764ee0 | 2009-08-06 00:14:40 +0000 | [diff] [blame] | 657 | } |
Thomas Martitz | aad712d | 2009-03-17 01:56:20 +0000 | [diff] [blame] | 658 | |
Thomas Martitz | 7ce12e6 | 2009-04-09 08:30:05 +0000 | [diff] [blame] | 659 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) |
| 660 | /* Play safe and unregister the hook */ |
Thomas Martitz | d85c3ec | 2009-10-20 21:54:59 +0000 | [diff] [blame] | 661 | remove_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook); |
Thomas Martitz | 7ce12e6 | 2009-04-09 08:30:05 +0000 | [diff] [blame] | 662 | #endif |
Thomas Martitz | 1016ee4 | 2009-10-19 15:28:15 +0000 | [diff] [blame] | 663 | /* unhandle statusbar update delay */ |
| 664 | sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY); |
Jonathan Gordon | f0611f8 | 2010-08-04 12:00:18 +0000 | [diff] [blame] | 665 | #ifdef HAVE_TOUCHSCREEN |
| 666 | touchscreen_set_mode(global_settings.touch_mode); |
| 667 | #endif |
Thomas Martitz | aad712d | 2009-03-17 01:56:20 +0000 | [diff] [blame] | 668 | } |
| 669 | |
Thomas Martitz | bdf2961 | 2009-11-16 01:38:30 +0000 | [diff] [blame] | 670 | /* |
| 671 | * display the wps on entering or restoring */ |
| 672 | static void gwps_enter_wps(void) |
| 673 | { |
| 674 | int i; |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 675 | struct gui_wps *gwps; |
| 676 | struct screen *display; |
Thomas Martitz | bdf2961 | 2009-11-16 01:38:30 +0000 | [diff] [blame] | 677 | FOR_NB_SCREENS(i) |
| 678 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 679 | gwps = skin_get_gwps(WPS, i); |
| 680 | display = gwps->display; |
Jonathan Gordon | 7e6f124 | 2010-02-08 09:38:03 +0000 | [diff] [blame] | 681 | display->stop_scroll(); |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 682 | viewportmanager_theme_enable(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data), NULL); |
Thomas Martitz | bdf2961 | 2009-11-16 01:38:30 +0000 | [diff] [blame] | 683 | |
Thomas Martitz | bdf2961 | 2009-11-16 01:38:30 +0000 | [diff] [blame] | 684 | /* Update the values in the first (default) viewport - in case the user |
| 685 | has modified the statusbar or colour settings */ |
| 686 | #if LCD_DEPTH > 1 |
| 687 | if (display->depth > 1) |
| 688 | { |
Jonathan Gordon | 343001b | 2011-03-07 12:45:45 +0000 | [diff] [blame] | 689 | struct skin_viewport *svp = skin_find_item(VP_DEFAULT_LABEL, |
| 690 | SKIN_FIND_VP, gwps->data); |
Jonathan Gordon | 489962d | 2010-08-10 14:15:03 +0000 | [diff] [blame] | 691 | if (svp) |
| 692 | { |
| 693 | struct viewport *vp = &svp->vp; |
| 694 | vp->fg_pattern = display->get_foreground(); |
| 695 | vp->bg_pattern = display->get_background(); |
| 696 | } |
Thomas Martitz | bdf2961 | 2009-11-16 01:38:30 +0000 | [diff] [blame] | 697 | } |
Jonathan Gordon | 2565389 | 2010-01-27 06:47:56 +0000 | [diff] [blame] | 698 | #endif |
Thomas Martitz | e8ae70a | 2010-01-26 21:29:08 +0000 | [diff] [blame] | 699 | /* make the backdrop actually take effect */ |
Alex Parker | 3e4e67b | 2010-02-08 22:34:04 +0000 | [diff] [blame] | 700 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 701 | skin_backdrop_show(gwps->data->backdrop_id); |
Alex Parker | 3e4e67b | 2010-02-08 22:34:04 +0000 | [diff] [blame] | 702 | #endif |
Thomas Martitz | e8ae70a | 2010-01-26 21:29:08 +0000 | [diff] [blame] | 703 | display->clear_display(); |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 704 | skin_update(WPS, i, SKIN_REFRESH_ALL); |
Jonathan Gordon | 31fb4f6 | 2010-02-24 06:19:25 +0000 | [diff] [blame] | 705 | |
Thomas Martitz | bdf2961 | 2009-11-16 01:38:30 +0000 | [diff] [blame] | 706 | } |
Jonathan Gordon | f0611f8 | 2010-08-04 12:00:18 +0000 | [diff] [blame] | 707 | #ifdef HAVE_TOUCHSCREEN |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 708 | gwps = skin_get_gwps(WPS, SCREEN_MAIN); |
| 709 | skin_disarm_touchregions(gwps->data); |
| 710 | if (!gwps->data->touchregions) |
Jonathan Gordon | f0611f8 | 2010-08-04 12:00:18 +0000 | [diff] [blame] | 711 | touchscreen_set_mode(TOUCHSCREEN_BUTTON); |
| 712 | #endif |
Thomas Martitz | e8ae70a | 2010-01-26 21:29:08 +0000 | [diff] [blame] | 713 | /* force statusbar/skin update since we just cleared the whole screen */ |
| 714 | send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); |
Thomas Martitz | bdf2961 | 2009-11-16 01:38:30 +0000 | [diff] [blame] | 715 | } |
| 716 | |
Jonathan Gordon | 98881fd | 2011-03-22 09:31:45 +0000 | [diff] [blame] | 717 | void wps_do_playpause(bool updatewps) |
| 718 | { |
| 719 | struct wps_state *state = skin_get_global_state(); |
| 720 | if ( state->paused ) |
| 721 | { |
| 722 | state->paused = false; |
Michael Hohmuth | 84301c1 | 2011-05-09 12:59:46 +0000 | [diff] [blame] | 723 | unpause_action(true, updatewps); |
Jonathan Gordon | 98881fd | 2011-03-22 09:31:45 +0000 | [diff] [blame] | 724 | } |
| 725 | else |
| 726 | { |
| 727 | state->paused = true; |
Michael Hohmuth | 84301c1 | 2011-05-09 12:59:46 +0000 | [diff] [blame] | 728 | pause_action(true, updatewps); |
Jonathan Gordon | 98881fd | 2011-03-22 09:31:45 +0000 | [diff] [blame] | 729 | settings_save(); |
| 730 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) |
| 731 | call_storage_idle_notifys(true); /* make sure resume info is saved */ |
| 732 | #endif |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | |
Thomas Martitz | 6809909 | 2009-03-17 01:39:20 +0000 | [diff] [blame] | 737 | /* The WPS can be left in two ways: |
| 738 | * a) call a function, which draws over the wps. In this case, the wps |
| 739 | * will be still active (i.e. the below function didn't return) |
| 740 | * b) return with a value evaluated by root_menu.c, in this case the wps |
| 741 | * is really left, and root_menu will handle the next screen |
| 742 | * |
| 743 | * In either way, call gwps_leave_wps(), in order to restore the correct |
| 744 | * "main screen" backdrops and statusbars |
| 745 | */ |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 746 | long gui_wps_show(void) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 747 | { |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 748 | long button = 0; |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 749 | bool restore = true; |
Thomas Martitz | aad712d | 2009-03-17 01:56:20 +0000 | [diff] [blame] | 750 | long restoretimer = RESTORE_WPS_INSTANTLY; /* timer to delay screen redraw temporarily */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 751 | bool exit = false; |
Magnus Holmgren | a50c2b1 | 2007-08-22 16:33:34 +0000 | [diff] [blame] | 752 | bool bookmark = false; |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 753 | bool update = false; |
Thomas Martitz | 28aef1f | 2009-10-31 14:55:13 +0000 | [diff] [blame] | 754 | bool vol_changed = false; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 755 | int i; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 756 | long last_left = 0, last_right = 0; |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 757 | struct wps_state *state = skin_get_global_state(); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 758 | |
| 759 | #ifdef HAVE_LCD_CHARCELLS |
| 760 | status_set_audio(true); |
| 761 | status_set_param(false); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 762 | #endif |
| 763 | |
| 764 | #ifdef AB_REPEAT_ENABLE |
| 765 | ab_repeat_init(); |
| 766 | ab_reset_markers(); |
| 767 | #endif |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 768 | wps_state_init(); |
Jonathan Gordon | b2eb44c | 2009-12-09 07:25:46 +0000 | [diff] [blame] | 769 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 770 | while ( 1 ) |
| 771 | { |
| 772 | bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 773 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 774 | /* did someone else (i.e power thread) change audio pause mode? */ |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 775 | if (state->paused != audio_paused) { |
| 776 | state->paused = audio_paused; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 777 | |
| 778 | /* if another thread paused audio, we are probably in car mode, |
| 779 | about to shut down. lets save the settings. */ |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 780 | if (state->paused) { |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 781 | settings_save(); |
Dave Chapman | 5009c9c | 2005-12-04 13:05:56 +0000 | [diff] [blame] | 782 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 783 | call_storage_idle_notifys(true); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 784 | #endif |
| 785 | } |
| 786 | } |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 787 | button = skin_wait_for_action(WPS, CONTEXT_WPS|ALLOW_SOFTLOCK, |
Jonathan Gordon | 1bd072c | 2010-05-12 10:38:00 +0000 | [diff] [blame] | 788 | restore ? 1 : HZ/5); |
Jonathan Gordon | c41bd04 | 2008-11-16 09:56:38 +0000 | [diff] [blame] | 789 | |
Jens Arnold | ae61b94 | 2009-03-29 17:58:24 +0000 | [diff] [blame] | 790 | /* Exit if audio has stopped playing. This happens e.g. at end of |
| 791 | playlist or if using the sleep timer. */ |
| 792 | if (!(audio_status() & AUDIO_STATUS_PLAY)) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 793 | exit = true; |
Jonathan Gordon | 0eb5dc6 | 2009-04-20 01:41:56 +0000 | [diff] [blame] | 794 | #ifdef HAVE_TOUCHSCREEN |
| 795 | if (button == ACTION_TOUCHSCREEN) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 796 | button = skintouch_to_wps(skin_get_gwps(WPS, SCREEN_MAIN)->data); |
Jonathan Gordon | 0eb5dc6 | 2009-04-20 01:41:56 +0000 | [diff] [blame] | 797 | #endif |
Marc Guay | 2bfcb95 | 2008-07-07 05:17:15 +0000 | [diff] [blame] | 798 | /* The iPods/X5/M5 use a single button for the A-B mode markers, |
| 799 | defined as ACTION_WPSAB_SINGLE in their config files. */ |
Jonathan Gordon | 7258b5e | 2006-12-22 05:19:56 +0000 | [diff] [blame] | 800 | #ifdef ACTION_WPSAB_SINGLE |
| 801 | if (!global_settings.party_mode && ab_repeat_mode_enabled()) |
| 802 | { |
| 803 | static int wps_ab_state = 0; |
| 804 | if (button == ACTION_WPSAB_SINGLE) |
| 805 | { |
| 806 | switch (wps_ab_state) |
| 807 | { |
| 808 | case 0: /* set the A spot */ |
| 809 | button = ACTION_WPS_ABSETA_PREVDIR; |
| 810 | break; |
| 811 | case 1: /* set the B spot */ |
| 812 | button = ACTION_WPS_ABSETB_NEXTDIR; |
| 813 | break; |
| 814 | case 2: |
Marcoen Hirschberg | 5d2b1e3 | 2007-04-13 15:42:25 +0000 | [diff] [blame] | 815 | button = ACTION_WPS_ABRESET; |
Jonathan Gordon | 7258b5e | 2006-12-22 05:19:56 +0000 | [diff] [blame] | 816 | break; |
| 817 | } |
| 818 | wps_ab_state = (wps_ab_state+1) % 3; |
| 819 | } |
| 820 | } |
| 821 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 822 | switch(button) |
| 823 | { |
Jeffrey Goode | 847bd28 | 2010-05-09 02:07:42 +0000 | [diff] [blame] | 824 | #ifdef HAVE_HOTKEY |
Jeffrey Goode | d5e6bc7 | 2010-04-01 03:14:44 +0000 | [diff] [blame] | 825 | case ACTION_WPS_HOTKEY: |
Jeffrey Goode | 1ad76ff | 2010-05-09 02:02:51 +0000 | [diff] [blame] | 826 | if (!global_settings.hotkey_wps) |
| 827 | break; |
| 828 | /* fall through */ |
Jeffrey Goode | 847bd28 | 2010-05-09 02:07:42 +0000 | [diff] [blame] | 829 | #endif |
Jeffrey Goode | 1ad76ff | 2010-05-09 02:02:51 +0000 | [diff] [blame] | 830 | case ACTION_WPS_CONTEXT: |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 831 | { |
Jeffrey Goode | d5e6bc7 | 2010-04-01 03:14:44 +0000 | [diff] [blame] | 832 | bool hotkey = button == ACTION_WPS_HOTKEY; |
Thomas Martitz | 6809909 | 2009-03-17 01:39:20 +0000 | [diff] [blame] | 833 | gwps_leave_wps(); |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 834 | int retval = onplay(state->id3->path, |
Jeffrey Goode | d5e6bc7 | 2010-04-01 03:14:44 +0000 | [diff] [blame] | 835 | FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); |
Jonathan Gordon | a6f2b82 | 2007-11-04 12:40:18 +0000 | [diff] [blame] | 836 | /* if music is stopped in the context menu we want to exit the wps */ |
Thomas Martitz | c19e536 | 2010-02-20 19:06:39 +0000 | [diff] [blame] | 837 | if (retval == ONPLAY_MAINMENU |
Jonathan Gordon | a6f2b82 | 2007-11-04 12:40:18 +0000 | [diff] [blame] | 838 | || !audio_status()) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 839 | return GO_TO_ROOT; |
Thomas Martitz | c19e536 | 2010-02-20 19:06:39 +0000 | [diff] [blame] | 840 | else if (retval == ONPLAY_PLAYLIST) |
| 841 | return GO_TO_PLAYLIST_VIEWER; |
Jonathan Gordon | 10e24d2 | 2010-06-09 08:51:29 +0000 | [diff] [blame] | 842 | #ifdef HAVE_PICTUREFLOW_INTEGRATION |
Jonathan Gordon | d871ff8 | 2010-06-09 04:25:41 +0000 | [diff] [blame] | 843 | else if (retval == ONPLAY_PICTUREFLOW) |
| 844 | return GO_TO_PICTUREFLOW; |
Jonathan Gordon | 881a5b9 | 2010-06-09 08:14:41 +0000 | [diff] [blame] | 845 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 846 | restore = true; |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 847 | } |
| 848 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 849 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 850 | case ACTION_WPS_BROWSE: |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 851 | #ifdef HAVE_LCD_CHARCELLS |
Jonathan Gordon | c41bd04 | 2008-11-16 09:56:38 +0000 | [diff] [blame] | 852 | status_set_record(false); |
| 853 | status_set_audio(false); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 854 | #endif |
Thomas Martitz | ce6b116 | 2009-03-19 23:04:39 +0000 | [diff] [blame] | 855 | gwps_leave_wps(); |
Jonathan Gordon | c41bd04 | 2008-11-16 09:56:38 +0000 | [diff] [blame] | 856 | return GO_TO_PREVIOUS_BROWSER; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 857 | break; |
| 858 | |
| 859 | /* play/pause */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 860 | case ACTION_WPS_PLAY: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 861 | if (global_settings.party_mode) |
| 862 | break; |
Jonathan Gordon | 98881fd | 2011-03-22 09:31:45 +0000 | [diff] [blame] | 863 | wps_do_playpause(true); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 864 | break; |
| 865 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 866 | case ACTION_WPS_VOLUP: |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 867 | global_settings.volume++; |
Thomas Martitz | 28aef1f | 2009-10-31 14:55:13 +0000 | [diff] [blame] | 868 | vol_changed = true; |
| 869 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 870 | case ACTION_WPS_VOLDOWN: |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 871 | global_settings.volume--; |
Thomas Martitz | 28aef1f | 2009-10-31 14:55:13 +0000 | [diff] [blame] | 872 | vol_changed = true; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 873 | break; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 874 | /* fast forward |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 875 | OR next dir if this is straight after ACTION_WPS_SKIPNEXT */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 876 | case ACTION_WPS_SEEKFWD: |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 877 | if (global_settings.party_mode) |
| 878 | break; |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 879 | if (current_tick -last_right < HZ) |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 880 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 881 | if (state->id3->cuesheet) |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 882 | { |
| 883 | audio_next(); |
| 884 | } |
| 885 | else |
| 886 | { |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 887 | change_dir(1); |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 888 | } |
| 889 | } |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 890 | else |
| 891 | ffwd_rew(ACTION_WPS_SEEKFWD); |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 892 | last_right = last_left = 0; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 893 | break; |
| 894 | /* fast rewind |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 895 | OR prev dir if this is straight after ACTION_WPS_SKIPPREV,*/ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 896 | case ACTION_WPS_SEEKBACK: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 897 | if (global_settings.party_mode) |
| 898 | break; |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 899 | if (current_tick -last_left < HZ) |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 900 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 901 | if (state->id3->cuesheet) |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 902 | { |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 903 | #if (CONFIG_CODEC == SWCODEC) |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 904 | audio_pre_ff_rewind(); |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 905 | #else |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 906 | if (!state->paused) |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 907 | audio_pause(); |
| 908 | #endif |
| 909 | audio_ff_rewind(0); |
| 910 | } |
| 911 | else |
| 912 | { |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 913 | change_dir(-1); |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 914 | } |
| 915 | } |
Thomas Martitz | 62f3e95 | 2009-03-27 13:53:29 +0000 | [diff] [blame] | 916 | else |
| 917 | ffwd_rew(ACTION_WPS_SEEKBACK); |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 918 | last_left = last_right = 0; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 919 | break; |
| 920 | |
| 921 | /* prev / restart */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 922 | case ACTION_WPS_SKIPPREV: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 923 | if (global_settings.party_mode) |
| 924 | break; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 925 | last_left = current_tick; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 926 | #ifdef AB_REPEAT_ENABLE |
| 927 | /* if we're in A/B repeat mode and the current position |
| 928 | is past the A marker, jump back to the A marker... */ |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 929 | if ( ab_repeat_mode_enabled() ) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 930 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 931 | if ( ab_after_A_marker(state->id3->elapsed) ) |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 932 | { |
| 933 | ab_jump_to_A_marker(); |
| 934 | break; |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 935 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 936 | } |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 937 | else |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 938 | /* ...otherwise, do it normally */ |
| 939 | #endif |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 940 | play_hop(-1); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 941 | break; |
| 942 | |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 943 | /* next |
Thom Johansen | 4a7e0c7 | 2008-07-14 20:39:30 +0000 | [diff] [blame] | 944 | OR if skip length set, hop by predetermined amount. */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 945 | case ACTION_WPS_SKIPNEXT: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 946 | if (global_settings.party_mode) |
| 947 | break; |
Jonathan Gordon | 89ed855 | 2006-08-22 07:57:40 +0000 | [diff] [blame] | 948 | last_right = current_tick; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 949 | #ifdef AB_REPEAT_ENABLE |
| 950 | /* if we're in A/B repeat mode and the current position is |
| 951 | before the A marker, jump to the A marker... */ |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 952 | if ( ab_repeat_mode_enabled() ) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 953 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 954 | if ( ab_before_A_marker(state->id3->elapsed) ) |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 955 | { |
| 956 | ab_jump_to_A_marker(); |
| 957 | break; |
Brandon Low | 8d5a660 | 2006-01-21 23:43:57 +0000 | [diff] [blame] | 958 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 959 | } |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 960 | else |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 961 | /* ...otherwise, do it normally */ |
| 962 | #endif |
Stéphane Doyon | ab0f7e1 | 2008-05-04 13:47:58 +0000 | [diff] [blame] | 963 | play_hop(1); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 964 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 965 | /* next / prev directories */ |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 966 | /* and set A-B markers if in a-b mode */ |
| 967 | case ACTION_WPS_ABSETB_NEXTDIR: |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 968 | if (global_settings.party_mode) |
| 969 | break; |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 970 | #if defined(AB_REPEAT_ENABLE) |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 971 | if (ab_repeat_mode_enabled()) |
| 972 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 973 | ab_set_B_marker(state->id3->elapsed); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 974 | ab_jump_to_A_marker(); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 975 | } |
| 976 | else |
| 977 | #endif |
| 978 | { |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 979 | change_dir(1); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 980 | } |
| 981 | break; |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 982 | case ACTION_WPS_ABSETA_PREVDIR: |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 983 | if (global_settings.party_mode) |
| 984 | break; |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 985 | #if defined(AB_REPEAT_ENABLE) |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 986 | if (ab_repeat_mode_enabled()) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 987 | ab_set_A_marker(state->id3->elapsed); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 988 | else |
| 989 | #endif |
| 990 | { |
Thomas Martitz | 23489be | 2009-04-04 20:33:38 +0000 | [diff] [blame] | 991 | change_dir(-1); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 992 | } |
| 993 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 994 | /* menu key functions */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 995 | case ACTION_WPS_MENU: |
Thomas Martitz | ce6b116 | 2009-03-19 23:04:39 +0000 | [diff] [blame] | 996 | gwps_leave_wps(); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 997 | return GO_TO_ROOT; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 998 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 999 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1000 | |
Zakk Roberts | 2f943b0 | 2006-04-10 03:51:17 +0000 | [diff] [blame] | 1001 | #ifdef HAVE_QUICKSCREEN |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 1002 | case ACTION_WPS_QUICKSCREEN: |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 1003 | { |
Thomas Martitz | 6809909 | 2009-03-17 01:39:20 +0000 | [diff] [blame] | 1004 | gwps_leave_wps(); |
Kevin Ferrare | f57d022 | 2005-11-22 21:55:05 +0000 | [diff] [blame] | 1005 | if (quick_screen_quick(button)) |
Teruaki Kawashima | 5b2a599 | 2009-08-29 16:25:04 +0000 | [diff] [blame] | 1006 | return GO_TO_ROOT; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1007 | restore = true; |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 1008 | } |
| 1009 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 1010 | #endif /* HAVE_QUICKSCREEN */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1011 | |
| 1012 | /* screen settings */ |
| 1013 | #ifdef BUTTON_F3 |
Jonathan Gordon | cbcc9db | 2006-08-22 08:23:24 +0000 | [diff] [blame] | 1014 | case ACTION_F3: |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 1015 | { |
Thomas Martitz | 6809909 | 2009-03-17 01:39:20 +0000 | [diff] [blame] | 1016 | gwps_leave_wps(); |
Jonathan Gordon | cbcc9db | 2006-08-22 08:23:24 +0000 | [diff] [blame] | 1017 | if (quick_screen_f3(BUTTON_F3)) |
Teruaki Kawashima | 5b2a599 | 2009-08-29 16:25:04 +0000 | [diff] [blame] | 1018 | return GO_TO_ROOT; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1019 | restore = true; |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 1020 | } |
| 1021 | break; |
Jonathan Gordon | 5e5bfab | 2006-08-16 13:25:45 +0000 | [diff] [blame] | 1022 | #endif /* BUTTON_F3 */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1023 | |
| 1024 | /* pitch screen */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 1025 | #ifdef HAVE_PITCHSCREEN |
| 1026 | case ACTION_WPS_PITCHSCREEN: |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 1027 | { |
Thomas Martitz | 6809909 | 2009-03-17 01:39:20 +0000 | [diff] [blame] | 1028 | gwps_leave_wps(); |
Jonathan Gordon | 1da2f01 | 2008-10-05 13:01:54 +0000 | [diff] [blame] | 1029 | if (1 == gui_syncpitchscreen_run()) |
Teruaki Kawashima | 5b2a599 | 2009-08-29 16:25:04 +0000 | [diff] [blame] | 1030 | return GO_TO_ROOT; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1031 | restore = true; |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 1032 | } |
| 1033 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 1034 | #endif /* HAVE_PITCHSCREEN */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1035 | |
| 1036 | #ifdef AB_REPEAT_ENABLE |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1037 | /* reset A&B markers */ |
Marcoen Hirschberg | 5d2b1e3 | 2007-04-13 15:42:25 +0000 | [diff] [blame] | 1038 | case ACTION_WPS_ABRESET: |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1039 | if (ab_repeat_mode_enabled()) |
| 1040 | { |
| 1041 | ab_reset_markers(); |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 1042 | update = true; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1043 | } |
| 1044 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1045 | #endif /* AB_REPEAT_ENABLE */ |
| 1046 | |
| 1047 | /* stop and exit wps */ |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 1048 | case ACTION_WPS_STOP: |
Björn Stenberg | fc390af | 2006-03-19 08:40:31 +0000 | [diff] [blame] | 1049 | if (global_settings.party_mode) |
| 1050 | break; |
Magnus Holmgren | a50c2b1 | 2007-08-22 16:33:34 +0000 | [diff] [blame] | 1051 | bookmark = true; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1052 | exit = true; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1053 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1054 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 1055 | case ACTION_WPS_ID3SCREEN: |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 1056 | { |
Thomas Martitz | 6809909 | 2009-03-17 01:39:20 +0000 | [diff] [blame] | 1057 | gwps_leave_wps(); |
Teruaki Kawashima | 5b2a599 | 2009-08-29 16:25:04 +0000 | [diff] [blame] | 1058 | if (browse_id3()) |
| 1059 | return GO_TO_ROOT; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1060 | restore = true; |
Jonathan Gordon | 9296126 | 2009-01-02 01:29:13 +0000 | [diff] [blame] | 1061 | } |
| 1062 | break; |
Thomas Martitz | 989ed2b | 2009-07-10 11:53:15 +0000 | [diff] [blame] | 1063 | /* this case is used by the softlock feature |
| 1064 | * it requests a full update here */ |
| 1065 | case ACTION_REDRAW: |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1066 | skin_request_full_update(WPS); |
Marianne Arnold | 49c9ab8 | 2009-06-18 13:50:11 +0000 | [diff] [blame] | 1067 | break; |
| 1068 | case ACTION_NONE: /* Timeout, do a partial update */ |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 1069 | update = true; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 1070 | ffwd_rew(button); /* hopefully fix the ffw/rwd bug */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1071 | break; |
Jonathan Gordon | 73336e9 | 2007-08-02 12:13:20 +0000 | [diff] [blame] | 1072 | #ifdef HAVE_RECORDING |
| 1073 | case ACTION_WPS_REC: |
| 1074 | exit = true; |
| 1075 | break; |
| 1076 | #endif |
Thomas Martitz | 5c9fe52 | 2009-07-22 22:10:25 +0000 | [diff] [blame] | 1077 | case ACTION_WPS_VIEW_PLAYLIST: |
| 1078 | gwps_leave_wps(); |
Thomas Martitz | c19e536 | 2010-02-20 19:06:39 +0000 | [diff] [blame] | 1079 | return GO_TO_PLAYLIST_VIEWER; |
Thomas Martitz | 5c9fe52 | 2009-07-22 22:10:25 +0000 | [diff] [blame] | 1080 | break; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1081 | default: |
Thomas Martitz | 49f1ec8 | 2010-10-31 15:32:57 +0000 | [diff] [blame] | 1082 | switch(default_event_handler(button)) |
| 1083 | { /* music has been stopped by the default handler */ |
| 1084 | case SYS_USB_CONNECTED: |
| 1085 | case SYS_CALL_INCOMING: |
| 1086 | case BUTTON_MULTIMEDIA_STOP: |
| 1087 | gwps_leave_wps(); |
| 1088 | return GO_TO_ROOT; |
Teruaki Kawashima | 5b2a599 | 2009-08-29 16:25:04 +0000 | [diff] [blame] | 1089 | } |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 1090 | update = true; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1091 | break; |
| 1092 | } |
| 1093 | |
Thomas Martitz | 28aef1f | 2009-10-31 14:55:13 +0000 | [diff] [blame] | 1094 | if (vol_changed) |
| 1095 | { |
Thomas Martitz | 28aef1f | 2009-10-31 14:55:13 +0000 | [diff] [blame] | 1096 | bool res = false; |
Teruaki Kawashima | 139694c | 2009-11-04 12:46:31 +0000 | [diff] [blame] | 1097 | vol_changed = false; |
Thomas Martitz | 28aef1f | 2009-10-31 14:55:13 +0000 | [diff] [blame] | 1098 | setvol(); |
| 1099 | FOR_NB_SCREENS(i) |
| 1100 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1101 | if(update_onvol_change(i)) |
Thomas Martitz | 28aef1f | 2009-10-31 14:55:13 +0000 | [diff] [blame] | 1102 | res = true; |
| 1103 | } |
| 1104 | if (res) { |
| 1105 | restore = true; |
| 1106 | restoretimer = RESTORE_WPS_NEXT_SECOND; |
| 1107 | } |
| 1108 | } |
| 1109 | |
Thomas Martitz | cc697a8 | 2009-11-16 01:38:33 +0000 | [diff] [blame] | 1110 | |
Thomas Martitz | 19ec4ff | 2009-11-16 01:38:36 +0000 | [diff] [blame] | 1111 | if (restore && |
Thomas Martitz | cc697a8 | 2009-11-16 01:38:33 +0000 | [diff] [blame] | 1112 | ((restoretimer == RESTORE_WPS_INSTANTLY) || |
| 1113 | TIME_AFTER(current_tick, restoretimer))) |
| 1114 | { |
| 1115 | restore = false; |
| 1116 | restoretimer = RESTORE_WPS_INSTANTLY; |
| 1117 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) |
| 1118 | add_event(LCD_EVENT_ACTIVATION, false, wps_lcd_activation_hook); |
| 1119 | #endif |
| 1120 | /* we remove the update delay since it's not very usable in the wps, |
| 1121 | * e.g. during volume changing or ffwd/rewind */ |
| 1122 | sb_skin_set_update_delay(0); |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1123 | skin_request_full_update(WPS); |
| 1124 | update = true; |
Jonathan Gordon | b2eb44c | 2009-12-09 07:25:46 +0000 | [diff] [blame] | 1125 | gwps_enter_wps(); |
Thomas Martitz | cc697a8 | 2009-11-16 01:38:33 +0000 | [diff] [blame] | 1126 | } |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1127 | else |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1128 | { |
Thomas Martitz | ec7a0c5 | 2009-04-14 22:13:29 +0000 | [diff] [blame] | 1129 | #if defined(HAVE_BACKLIGHT) || defined(HAVE_REMOTE_LCD) |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1130 | gwps_caption_backlight(state); |
Thomas Martitz | ec7a0c5 | 2009-04-14 22:13:29 +0000 | [diff] [blame] | 1131 | #endif |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 1132 | FOR_NB_SCREENS(i) |
Thomas Martitz | 725733c | 2009-04-12 00:30:28 +0000 | [diff] [blame] | 1133 | { |
Thomas Martitz | 7ce12e6 | 2009-04-09 08:30:05 +0000 | [diff] [blame] | 1134 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) |
Thomas Martitz | 7ce12e6 | 2009-04-09 08:30:05 +0000 | [diff] [blame] | 1135 | /* currently, all remotes are readable without backlight |
| 1136 | * so still update those */ |
Thomas Martitz | d85c3ec | 2009-10-20 21:54:59 +0000 | [diff] [blame] | 1137 | if (lcd_active() || (i != SCREEN_MAIN)) |
Thomas Martitz | 7ce12e6 | 2009-04-09 08:30:05 +0000 | [diff] [blame] | 1138 | #endif |
Thomas Martitz | 725733c | 2009-04-12 00:30:28 +0000 | [diff] [blame] | 1139 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1140 | bool full_update = skin_do_full_update(WPS, i); |
| 1141 | if (update || full_update) |
Jonathan Gordon | 75556fd | 2010-08-02 14:12:44 +0000 | [diff] [blame] | 1142 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1143 | skin_update(WPS, i, full_update ? |
Jonathan Gordon | 75556fd | 2010-08-02 14:12:44 +0000 | [diff] [blame] | 1144 | SKIN_REFRESH_ALL : SKIN_REFRESH_NON_STATIC); |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1145 | } |
Thomas Martitz | 725733c | 2009-04-12 00:30:28 +0000 | [diff] [blame] | 1146 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1147 | } |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 1148 | update = false; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
| 1151 | if (exit) { |
| 1152 | #ifdef HAVE_LCD_CHARCELLS |
| 1153 | status_set_record(false); |
| 1154 | status_set_audio(false); |
| 1155 | #endif |
Michael Sevakis | a2b6703 | 2011-06-29 06:37:04 +0000 | [diff] [blame] | 1156 | #if CONFIG_CODEC != SWCODEC |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1157 | if (global_settings.fade_on_stop) |
Jonathan Gordon | 4982b87 | 2008-06-23 02:45:55 +0000 | [diff] [blame] | 1158 | fade(false, true); |
Michael Sevakis | a2b6703 | 2011-06-29 06:37:04 +0000 | [diff] [blame] | 1159 | #else |
| 1160 | audio_pause(); |
Michael Sevakis | 5078d46 | 2011-08-23 01:37:59 +0000 | [diff] [blame^] | 1161 | update_non_static(); |
Michael Sevakis | a2b6703 | 2011-06-29 06:37:04 +0000 | [diff] [blame] | 1162 | #endif |
Magnus Holmgren | a50c2b1 | 2007-08-22 16:33:34 +0000 | [diff] [blame] | 1163 | if (bookmark) |
Torne Wuff | 05ace8e | 2010-03-28 23:27:49 +0000 | [diff] [blame] | 1164 | bookmark_autobookmark(true); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1165 | audio_stop(); |
| 1166 | #ifdef AB_REPEAT_ENABLE |
| 1167 | ab_reset_markers(); |
| 1168 | #endif |
Thomas Martitz | 7147106 | 2009-03-19 14:33:22 +0000 | [diff] [blame] | 1169 | gwps_leave_wps(); |
Jonathan Gordon | 73336e9 | 2007-08-02 12:13:20 +0000 | [diff] [blame] | 1170 | #ifdef HAVE_RECORDING |
| 1171 | if (button == ACTION_WPS_REC) |
| 1172 | return GO_TO_RECSCREEN; |
| 1173 | #endif |
Jonathan Gordon | fad3ad6 | 2007-04-08 02:11:33 +0000 | [diff] [blame] | 1174 | if (global_settings.browse_current) |
| 1175 | return GO_TO_PREVIOUS_BROWSER; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 1176 | return GO_TO_PREVIOUS; |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1177 | } |
Zakk Roberts | 87afd0b | 2006-03-21 07:59:23 +0000 | [diff] [blame] | 1178 | |
Jonathan Gordon | a02702c | 2009-01-01 05:12:27 +0000 | [diff] [blame] | 1179 | if (button && !IS_SYSEVENT(button) ) |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 1180 | storage_spin(); |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1181 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 1182 | return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1183 | } |
| 1184 | |
Jonathan Gordon | 843c7ef | 2009-04-06 00:39:43 +0000 | [diff] [blame] | 1185 | /* this is called from the playback thread so NO DRAWING! */ |
| 1186 | static void track_changed_callback(void *param) |
| 1187 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1188 | struct wps_state *state = skin_get_global_state(); |
| 1189 | state->id3 = (struct mp3entry*)param; |
| 1190 | state->nid3 = audio_next_track(); |
| 1191 | if (state->id3->cuesheet) |
Jonathan Gordon | 843c7ef | 2009-04-06 00:39:43 +0000 | [diff] [blame] | 1192 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1193 | cue_find_current_track(state->id3->cuesheet, state->id3->elapsed); |
Jonathan Gordon | 843c7ef | 2009-04-06 00:39:43 +0000 | [diff] [blame] | 1194 | } |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1195 | skin_request_full_update(WPS); |
Jonathan Gordon | 843c7ef | 2009-04-06 00:39:43 +0000 | [diff] [blame] | 1196 | } |
| 1197 | static void nextid3available_callback(void* param) |
| 1198 | { |
| 1199 | (void)param; |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1200 | skin_get_global_state()->nid3 = audio_next_track(); |
| 1201 | skin_request_full_update(WPS); |
Jonathan Gordon | 843c7ef | 2009-04-06 00:39:43 +0000 | [diff] [blame] | 1202 | } |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1203 | |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 1204 | #ifdef AUDIO_FAST_SKIP_PREVIEW |
| 1205 | /* this is called on the audio_skip caller thread */ |
| 1206 | static void track_skip_callback(void *param) |
| 1207 | { |
| 1208 | struct wps_state *state = skin_get_global_state(); |
| 1209 | state->id3 = audio_current_track(); |
| 1210 | state->nid3 = audio_next_track(); |
| 1211 | skin_request_full_update(WPS); |
| 1212 | (void)param; |
| 1213 | } |
| 1214 | #endif /* AUDIO_FAST_SKIP_PREVIEW */ |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1215 | |
Nils Wallménius | 20338ca | 2006-12-13 11:52:21 +0000 | [diff] [blame] | 1216 | static void wps_state_init(void) |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1217 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1218 | struct wps_state *state = skin_get_global_state(); |
| 1219 | state->ff_rewind = false; |
| 1220 | state->paused = false; |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 1221 | if(audio_status() & AUDIO_STATUS_PLAY) |
| 1222 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1223 | state->id3 = audio_current_track(); |
| 1224 | state->nid3 = audio_next_track(); |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 1225 | } |
| 1226 | else |
| 1227 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1228 | state->id3 = NULL; |
| 1229 | state->nid3 = NULL; |
Thomas Martitz | 1d52b72 | 2009-04-08 17:11:50 +0000 | [diff] [blame] | 1230 | } |
| 1231 | /* We'll be updating due to restore initialized with true */ |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1232 | skin_request_full_update(WPS); |
Jonathan Gordon | 843c7ef | 2009-04-06 00:39:43 +0000 | [diff] [blame] | 1233 | /* add the WPS track event callbacks */ |
| 1234 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback); |
| 1235 | add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback); |
Michael Sevakis | caf907e | 2011-05-25 08:35:31 +0000 | [diff] [blame] | 1236 | #if CONFIG_CODEC == SWCODEC |
| 1237 | /* Use the same callback as ..._TRACK_CHANGE for when remaining handles have |
| 1238 | finished */ |
| 1239 | add_event(PLAYBACK_EVENT_CUR_TRACK_READY, false, track_changed_callback); |
| 1240 | #endif |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame] | 1241 | #ifdef AUDIO_FAST_SKIP_PREVIEW |
| 1242 | add_event(PLAYBACK_EVENT_TRACK_SKIP, false, track_skip_callback); |
| 1243 | #endif |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1244 | } |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 1245 | |
Christi Scarborough | f8cc321 | 2005-11-17 20:20:01 +0000 | [diff] [blame] | 1246 | |
Thomas Martitz | cc05424 | 2009-08-03 15:46:21 +0000 | [diff] [blame] | 1247 | #ifdef IPOD_ACCESSORY_PROTOCOL |
Thomas Martitz | 6db726c | 2009-11-01 13:36:52 +0000 | [diff] [blame] | 1248 | bool is_wps_fading(void) |
| 1249 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1250 | return skin_get_global_state()->is_fading; |
Thomas Martitz | 6db726c | 2009-11-01 13:36:52 +0000 | [diff] [blame] | 1251 | } |
| 1252 | |
Thomas Martitz | cc05424 | 2009-08-03 15:46:21 +0000 | [diff] [blame] | 1253 | int wps_get_ff_rewind_count(void) |
| 1254 | { |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 1255 | return skin_get_global_state()->ff_rewind_count; |
Thomas Martitz | cc05424 | 2009-08-03 15:46:21 +0000 | [diff] [blame] | 1256 | } |
| 1257 | #endif |