summaryrefslogtreecommitdiff
path: root/apps/gui/gwps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/gwps.c')
-rw-r--r--apps/gui/gwps.c316
1 files changed, 65 insertions, 251 deletions
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 1b19c13547..bd9bb5e07b 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -25,7 +25,7 @@
25#include "lcd.h" 25#include "lcd.h"
26#include "font.h" 26#include "font.h"
27#include "backlight.h" 27#include "backlight.h"
28#include "button.h" 28#include "action.h"
29#include "kernel.h" 29#include "kernel.h"
30#include "tree.h" 30#include "tree.h"
31#include "debug.h" 31#include "debug.h"
@@ -84,14 +84,11 @@ static void gui_wps_set_margin(struct gui_wps *gwps)
84 84
85long gui_wps_show(void) 85long gui_wps_show(void)
86{ 86{
87 long button = 0, lastbutton = 0; 87 long button = 0;
88 bool ignore_keyup = true;
89 bool restore = false; 88 bool restore = false;
90 long restoretimer = 0; /* timer to delay screen redraw temporarily */ 89 long restoretimer = 0; /* timer to delay screen redraw temporarily */
91 bool exit = false; 90 bool exit = false;
92 bool update_track = false; 91 bool update_track = false;
93 unsigned long right_lastclick = 0;
94 unsigned long left_lastclick = 0;
95 int i; 92 int i;
96 93
97 wps_state_init(); 94 wps_state_init();
@@ -163,8 +160,8 @@ long gui_wps_show(void)
163 long next_big_refresh = current_tick + HZ / 5; 160 long next_big_refresh = current_tick + HZ / 5;
164 button = BUTTON_NONE; 161 button = BUTTON_NONE;
165 while (TIME_BEFORE(current_tick, next_big_refresh)) { 162 while (TIME_BEFORE(current_tick, next_big_refresh)) {
166 button = button_get(false); 163 button = get_action(CONTEXT_WPS,TIMEOUT_NOBLOCK);
167 if (button != BUTTON_NONE) { 164 if (button != ACTION_NONE) {
168 break; 165 break;
169 } 166 }
170 peak_meter_peek(); 167 peak_meter_peek();
@@ -186,35 +183,10 @@ long gui_wps_show(void)
186 /* The peak meter is disabled 183 /* The peak meter is disabled
187 -> no additional screen updates needed */ 184 -> no additional screen updates needed */
188 else { 185 else {
189 button = button_get_w_tmo(HZ/5); 186 button = get_action(CONTEXT_WPS,HZ/5);
190 } 187 }
191#else 188#else
192 button = button_get_w_tmo(HZ/5); 189 button = get_action(CONTEXT_WPS,HZ/5);
193#endif
194
195 /* discard first event if it's a button release */
196 if (button && ignore_keyup)
197 {
198 ignore_keyup = false;
199 /* Negative events are system events */
200 if (button >= 0 && button & BUTTON_REL )
201 continue;
202 }
203
204#ifdef WPS_KEYLOCK
205 /* ignore non-remote buttons when keys are locked */
206 if (keys_locked &&
207 ! ((button < 0) ||
208 (button == BUTTON_NONE) ||
209 ((button & WPS_KEYLOCK) == WPS_KEYLOCK) ||
210 (button & BUTTON_REMOTE)
211 ))
212 {
213 if (!(button & BUTTON_REL))
214 display_keylock_text(true);
215 restore = true;
216 button = BUTTON_NONE;
217 }
218#endif 190#endif
219 191
220 /* Exit if audio has stopped playing. This can happen if using the 192 /* Exit if audio has stopped playing. This can happen if using the
@@ -222,17 +194,14 @@ long gui_wps_show(void)
222 from F1 */ 194 from F1 */
223 if (!audio_status()) 195 if (!audio_status())
224 exit = true; 196 exit = true;
225 197
226 switch(button) 198 switch(button)
227 { 199 {
228#ifdef WPS_CONTEXT 200 case ACTION_WPS_CONTEXT:
229 case WPS_CONTEXT:
230#ifdef WPS_RC_CONTEXT
231 case WPS_RC_CONTEXT:
232#endif
233#ifdef HAVE_LCD_COLOR 201#ifdef HAVE_LCD_COLOR
234 show_main_backdrop(); 202 show_main_backdrop();
235#endif 203#endif
204 action_signalscreenchange();
236 onplay(wps_state.id3->path, TREE_ATTR_MPA, CONTEXT_WPS); 205 onplay(wps_state.id3->path, TREE_ATTR_MPA, CONTEXT_WPS);
237#ifdef HAVE_LCD_COLOR 206#ifdef HAVE_LCD_COLOR
238 show_wps_backdrop(); 207 show_wps_backdrop();
@@ -245,20 +214,8 @@ long gui_wps_show(void)
245#endif 214#endif
246 restore = true; 215 restore = true;
247 break; 216 break;
248#endif
249 217
250#ifdef WPS_RC_BROWSE 218 case ACTION_WPS_BROWSE:
251 case WPS_RC_BROWSE:
252#endif
253 case WPS_BROWSE:
254#ifdef WPS_BROWSE_PRE
255 if ((lastbutton != WPS_BROWSE_PRE)
256#ifdef WPS_RC_BROWSE_PRE
257 && (lastbutton != WPS_RC_BROWSE_PRE)
258#endif
259 )
260 break;
261#endif
262#ifdef HAVE_LCD_CHARCELLS 219#ifdef HAVE_LCD_CHARCELLS
263 status_set_record(false); 220 status_set_record(false);
264 status_set_audio(false); 221 status_set_audio(false);
@@ -270,26 +227,14 @@ long gui_wps_show(void)
270 if (global_settings.browse_current && 227 if (global_settings.browse_current &&
271 wps_state.current_track_path[0] != '\0') 228 wps_state.current_track_path[0] != '\0')
272 set_current_file(wps_state.current_track_path); 229 set_current_file(wps_state.current_track_path);
273 230 action_signalscreenchange();
274 return 0; 231 return 0;
275 break; 232 break;
276 233
277 /* play/pause */ 234 /* play/pause */
278 case WPS_PAUSE: 235 case ACTION_WPS_PLAY:
279#ifdef WPS_PAUSE_PRE
280 if (lastbutton != WPS_PAUSE_PRE)
281 break;
282#endif
283#ifdef WPS_RC_PAUSE
284 case WPS_RC_PAUSE:
285 if (global_settings.party_mode) 236 if (global_settings.party_mode)
286 break; 237 break;
287#ifdef WPS_RC_PAUSE_PRE
288 if ((button == WPS_RC_PAUSE) &&
289 (lastbutton != WPS_RC_PAUSE_PRE))
290 break;
291#endif
292#endif
293 if ( wps_state.paused ) 238 if ( wps_state.paused )
294 { 239 {
295 wps_state.paused = false; 240 wps_state.paused = false;
@@ -313,12 +258,7 @@ long gui_wps_show(void)
313 break; 258 break;
314 259
315 /* volume up */ 260 /* volume up */
316 case WPS_INCVOL: 261 case ACTION_WPS_VOLUP:
317 case WPS_INCVOL | BUTTON_REPEAT:
318#ifdef WPS_RC_INCVOL
319 case WPS_RC_INCVOL:
320 case WPS_RC_INCVOL | BUTTON_REPEAT:
321#endif
322 { 262 {
323 global_settings.volume++; 263 global_settings.volume++;
324 bool res = false; 264 bool res = false;
@@ -336,12 +276,7 @@ long gui_wps_show(void)
336 break; 276 break;
337 277
338 /* volume down */ 278 /* volume down */
339 case WPS_DECVOL: 279 case ACTION_WPS_VOLDOWN:
340 case WPS_DECVOL | BUTTON_REPEAT:
341#ifdef WPS_RC_DECVOL
342 case WPS_RC_DECVOL:
343 case WPS_RC_DECVOL | BUTTON_REPEAT:
344#endif
345 { 280 {
346 global_settings.volume--; 281 global_settings.volume--;
347 setvol(); 282 setvol();
@@ -357,59 +292,18 @@ long gui_wps_show(void)
357 } 292 }
358 } 293 }
359 break; 294 break;
360
361 /* fast forward / rewind */ 295 /* fast forward / rewind */
362#ifdef WPS_RC_FFWD 296 case ACTION_WPS_SEEKFWD:
363 case WPS_RC_FFWD: 297 case ACTION_WPS_SEEKBACK:
364#endif
365 case WPS_FFWD:
366 if (global_settings.party_mode)
367 break;
368
369#ifdef HAVE_DIR_NAVIGATION
370 if (current_tick - right_lastclick < HZ)
371 {
372 audio_next_dir();
373 right_lastclick = 0;
374 break;
375 }
376#endif
377
378#ifdef WPS_RC_REW
379 case WPS_RC_REW:
380#endif
381 case WPS_REW:
382 if (global_settings.party_mode) 298 if (global_settings.party_mode)
383 break; 299 break;
384
385#ifdef HAVE_DIR_NAVIGATION
386 if (current_tick - left_lastclick < HZ)
387 {
388 audio_prev_dir();
389 left_lastclick = 0;
390 break;
391 }
392#endif
393
394 ffwd_rew(button); 300 ffwd_rew(button);
395 break; 301 break;
396 302
397 /* prev / restart */ 303 /* prev / restart */
398 case WPS_PREV: 304 case ACTION_WPS_SKIPPREV:
399#ifdef WPS_PREV_PRE
400 if (lastbutton != WPS_PREV_PRE)
401 break;
402#endif
403#ifdef WPS_RC_PREV
404 case WPS_RC_PREV:
405 if (global_settings.party_mode) 305 if (global_settings.party_mode)
406 break; 306 break;
407#ifdef WPS_RC_PREV_PRE
408 if ((button == WPS_RC_PREV) && (lastbutton != WPS_RC_PREV_PRE))
409 break;
410#endif
411#endif
412 left_lastclick = current_tick;
413 update_track = true; 307 update_track = true;
414 308
415#ifdef AB_REPEAT_ENABLE 309#ifdef AB_REPEAT_ENABLE
@@ -450,61 +344,10 @@ long gui_wps_show(void)
450 } 344 }
451 break; 345 break;
452 346
453#ifdef WPS_NEXT_DIR
454#ifdef WPS_RC_NEXT_DIR
455 case WPS_RC_NEXT_DIR:
456#endif
457 case WPS_NEXT_DIR:
458 if (global_settings.party_mode)
459 break;
460#if defined(AB_REPEAT_ENABLE) && defined(WPS_AB_SHARE_DIR_BUTTONS)
461 if (ab_repeat_mode_enabled())
462 {
463 ab_set_B_marker(wps_state.id3->elapsed);
464 ab_jump_to_A_marker();
465 update_track = true;
466 }
467 else
468#endif
469 {
470 audio_next_dir();
471 }
472 break;
473#endif
474#ifdef WPS_PREV_DIR
475#ifdef WPS_RC_PREV_DIR
476 case WPS_RC_PREV_DIR:
477#endif
478 case WPS_PREV_DIR:
479 if (global_settings.party_mode)
480 break;
481#if defined(AB_REPEAT_ENABLE) && defined(WPS_AB_SHARE_DIR_BUTTONS)
482 if (ab_repeat_mode_enabled())
483 ab_set_A_marker(wps_state.id3->elapsed);
484 else
485#endif
486 {
487 audio_prev_dir();
488 }
489 break;
490#endif
491
492 /* next */ 347 /* next */
493 case WPS_NEXT: 348 case ACTION_WPS_SKIPNEXT:
494#ifdef WPS_NEXT_PRE
495 if (lastbutton != WPS_NEXT_PRE)
496 break;
497#endif
498#ifdef WPS_RC_NEXT
499 case WPS_RC_NEXT:
500 if (global_settings.party_mode) 349 if (global_settings.party_mode)
501 break; 350 break;
502#ifdef WPS_RC_NEXT_PRE
503 if ((button == WPS_RC_NEXT) && (lastbutton != WPS_RC_NEXT_PRE))
504 break;
505#endif
506#endif
507 right_lastclick = current_tick;
508 update_track = true; 351 update_track = true;
509 352
510#ifdef AB_REPEAT_ENABLE 353#ifdef AB_REPEAT_ENABLE
@@ -527,27 +370,44 @@ long gui_wps_show(void)
527 370
528 audio_next(); 371 audio_next();
529 break; 372 break;
530 373 /* next / prev directories */
531#ifdef WPS_MENU 374 case ACTION_WPS_NEXTDIR:
532 /* menu key functions */ 375 if (global_settings.party_mode)
533 case WPS_MENU:
534#ifdef WPS_MENU_PRE
535 if (lastbutton != WPS_MENU_PRE)
536 break; 376 break;
377#if defined(AB_REPEAT_ENABLE) && defined(WPS_AB_SHARE_DIR_BUTTONS)
378 if (ab_repeat_mode_enabled())
379 {
380 ab_set_B_marker(wps_state.id3->elapsed);
381 ab_jump_to_A_marker();
382 update_track = true;
383 }
384 else
537#endif 385#endif
538#ifdef WPS_RC_MENU 386 {
539 case WPS_RC_MENU: 387 audio_next_dir();
540#ifdef WPS_RC_MENU_PRE 388 }
541 if ((button == WPS_RC_MENU) && (lastbutton != WPS_RC_MENU_PRE)) 389 break;
390 case ACTION_WPS_PREVDIR:
391 if (global_settings.party_mode)
542 break; 392 break;
393#if defined(AB_REPEAT_ENABLE) && defined(WPS_AB_SHARE_DIR_BUTTONS)
394 if (ab_repeat_mode_enabled())
395 ab_set_A_marker(wps_state.id3->elapsed);
396 else
543#endif 397#endif
544#endif 398 {
399 audio_prev_dir();
400 }
401 break;
402 /* menu key functions */
403 case ACTION_WPS_MENU:
545 FOR_NB_SCREENS(i) 404 FOR_NB_SCREENS(i)
546 gui_wps[i].display->stop_scroll(); 405 gui_wps[i].display->stop_scroll();
547 406
548#ifdef HAVE_LCD_COLOR 407#ifdef HAVE_LCD_COLOR
549 show_main_backdrop(); 408 show_main_backdrop();
550#endif 409#endif
410 action_signalscreenchange();
551 if (main_menu()) 411 if (main_menu())
552 return true; 412 return true;
553#ifdef HAVE_LCD_COLOR 413#ifdef HAVE_LCD_COLOR
@@ -561,25 +421,17 @@ long gui_wps_show(void)
561#endif 421#endif
562 restore = true; 422 restore = true;
563 break; 423 break;
564#endif /* WPS_MENU */
565 424
566#ifdef WPS_KEYLOCK
567 /* key lock */ 425 /* key lock */
568 case WPS_KEYLOCK: 426 case ACTION_STD_KEYLOCK:
569 case WPS_KEYLOCK | BUTTON_REPEAT: 427 action_setsoftwarekeylock(ACTION_STD_KEYLOCK,true);
570 keys_locked = !keys_locked; 428 display_keylock_text(true);
571 display_keylock_text(keys_locked);
572 restore = true; 429 restore = true;
573 waitfor_nokey();
574 break; 430 break;
575#endif 431
576 432
577#ifdef HAVE_QUICKSCREEN 433#ifdef HAVE_QUICKSCREEN
578 /* play settings */ 434 case ACTION_WPS_QUICKSCREEN:
579 case WPS_QUICK:
580#ifdef WPS_RC_QUICK
581 case WPS_RC_QUICK:
582#endif
583#ifdef HAVE_LCD_COLOR 435#ifdef HAVE_LCD_COLOR
584 show_main_backdrop(); 436 show_main_backdrop();
585#endif 437#endif
@@ -595,8 +447,8 @@ long gui_wps_show(void)
595 } 447 }
596#endif 448#endif
597 restore = true; 449 restore = true;
598 lastbutton = 0;
599 break; 450 break;
451#endif /* HAVE_QUICKSCREEN */
600 452
601 /* screen settings */ 453 /* screen settings */
602#ifdef BUTTON_F3 454#ifdef BUTTON_F3
@@ -611,17 +463,14 @@ long gui_wps_show(void)
611 { 463 {
612 gui_wps_set_margin(&gui_wps[i]); 464 gui_wps_set_margin(&gui_wps[i]);
613 } 465 }
614#endif 466#endif /* BUTTON_F3 */
615 restore = true; 467 restore = true;
616 lastbutton = 0;
617 break; 468 break;
618#endif 469#endif
619 470
620 /* pitch screen */ 471 /* pitch screen */
621#if CONFIG_KEYPAD == RECORDER_PAD || CONFIG_KEYPAD == IRIVER_H100_PAD \ 472#ifdef HAVE_PITCHSCREEN
622 || CONFIG_KEYPAD == IRIVER_H300_PAD 473 case ACTION_WPS_PITCHSCREEN:
623 case BUTTON_ON | BUTTON_UP:
624 case BUTTON_ON | BUTTON_DOWN:
625#ifdef HAVE_LCD_COLOR 474#ifdef HAVE_LCD_COLOR
626 show_main_backdrop(); 475 show_main_backdrop();
627#endif 476#endif
@@ -632,17 +481,10 @@ long gui_wps_show(void)
632#endif 481#endif
633 restore = true; 482 restore = true;
634 break; 483 break;
635#endif 484#endif /* HAVE_PITCHSCREEN */
636#endif
637 485
638#ifdef AB_REPEAT_ENABLE 486#ifdef AB_REPEAT_ENABLE
639 487 case ACTION_WPSAB_SINGLE:
640#ifdef WPS_AB_SINGLE
641 case WPS_AB_SINGLE:
642#ifdef WPS_AB_SINGLE_PRE
643 if (lastbutton != WPS_AB_SINGLE_PRE)
644 break;
645#endif
646/* If we are using the menu option to enable ab_repeat mode, don't do anything 488/* If we are using the menu option to enable ab_repeat mode, don't do anything
647 * when it's disabled */ 489 * when it's disabled */
648#if (AB_REPEAT_ENABLE == 1) 490#if (AB_REPEAT_ENABLE == 1)
@@ -661,20 +503,15 @@ long gui_wps_show(void)
661 } 503 }
662 ab_set_A_marker(wps_state.id3->elapsed); 504 ab_set_A_marker(wps_state.id3->elapsed);
663 break; 505 break;
664#endif
665 506
666 507
667#ifdef WPS_AB_SET_A_MARKER
668 /* set A marker for A-B repeat */ 508 /* set A marker for A-B repeat */
669 case WPS_AB_SET_A_MARKER: 509 case ACTION_WPSAB_SETA:
670 if (ab_repeat_mode_enabled()) 510 if (ab_repeat_mode_enabled())
671 ab_set_A_marker(wps_state.id3->elapsed); 511 ab_set_A_marker(wps_state.id3->elapsed);
672 break; 512 break;
673#endif
674
675#ifdef WPS_AB_SET_B_MARKER
676 /* set B marker for A-B repeat and jump to A */ 513 /* set B marker for A-B repeat and jump to A */
677 case WPS_AB_SET_B_MARKER: 514 case ACTION_WPSAB_SETB:
678 if (ab_repeat_mode_enabled()) 515 if (ab_repeat_mode_enabled())
679 { 516 {
680 ab_set_B_marker(wps_state.id3->elapsed); 517 ab_set_B_marker(wps_state.id3->elapsed);
@@ -682,46 +519,24 @@ long gui_wps_show(void)
682 update_track = true; 519 update_track = true;
683 } 520 }
684 break; 521 break;
685#endif
686
687#ifdef WPS_AB_RESET_AB_MARKERS
688 /* reset A&B markers */ 522 /* reset A&B markers */
689 case WPS_AB_RESET_AB_MARKERS: 523 case ACTION_WPSAB_RESET:
690 if (ab_repeat_mode_enabled()) 524 if (ab_repeat_mode_enabled())
691 { 525 {
692 ab_reset_markers(); 526 ab_reset_markers();
693 update_track = true; 527 update_track = true;
694 } 528 }
695 break; 529 break;
696#endif
697
698#endif /* AB_REPEAT_ENABLE */ 530#endif /* AB_REPEAT_ENABLE */
699 531
700 /* stop and exit wps */ 532 /* stop and exit wps */
701#ifdef WPS_EXIT 533 case ACTION_WPS_STOP:
702 case WPS_EXIT:
703# ifdef WPS_EXIT_PRE
704 if ((lastbutton & ~BUTTON_REPEAT) != WPS_EXIT_PRE)
705 break;
706# endif
707 if (global_settings.party_mode)
708 break;
709 exit = true;
710#ifdef WPS_RC_EXIT
711 case WPS_RC_EXIT:
712#ifdef WPS_RC_EXIT_PRE
713 if ((lastbutton & ~BUTTON_REPEAT) != WPS_RC_EXIT_PRE)
714 break;
715#endif
716 if (global_settings.party_mode) 534 if (global_settings.party_mode)
717 break; 535 break;
718 exit = true; 536 exit = true;
719#endif
720 break; 537 break;
721#endif
722 538
723#ifdef WPS_ID3 539 case ACTION_WPS_ID3SCREEN:
724 case WPS_ID3:
725#ifdef HAVE_LCD_COLOR 540#ifdef HAVE_LCD_COLOR
726 show_main_backdrop(); 541 show_main_backdrop();
727#endif 542#endif
@@ -737,10 +552,10 @@ long gui_wps_show(void)
737#endif 552#endif
738 restore = true; 553 restore = true;
739 break; 554 break;
740#endif
741 555
742 case BUTTON_NONE: /* Timeout */ 556 case ACTION_NONE: /* Timeout */
743 update_track = true; 557 update_track = true;
558 ffwd_rew(button); /* hopefully fix the ffw/rwd bug */
744 break; 559 break;
745 560
746 case SYS_POWEROFF: 561 case SYS_POWEROFF:
@@ -779,6 +594,7 @@ long gui_wps_show(void)
779 } 594 }
780 595
781 if (exit) { 596 if (exit) {
597 action_signalscreenchange();
782#ifdef HAVE_LCD_CHARCELLS 598#ifdef HAVE_LCD_CHARCELLS
783 status_set_record(false); 599 status_set_record(false);
784 status_set_audio(false); 600 status_set_audio(false);
@@ -830,8 +646,6 @@ long gui_wps_show(void)
830 gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC); 646 gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC);
831 } 647 }
832 } 648 }
833 if (button != BUTTON_NONE)
834 lastbutton = button;
835 } 649 }
836 return 0; /* unreachable - just to reduce compiler warnings */ 650 return 0; /* unreachable - just to reduce compiler warnings */
837} 651}