diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-05-20 17:41:28 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-05-20 17:41:28 +0000 |
commit | 20e9d56ba5507021bdde898f4b0a0eb14f2af861 (patch) | |
tree | 20a1ff36d0cc0f530bc7c7648b1bca2f9127a5c8 /apps/plugins/metronome.c | |
parent | 97365803d390e44155fc41657bd03a7b121956aa (diff) | |
download | rockbox-20e9d56ba5507021bdde898f4b0a0eb14f2af861.tar.gz rockbox-20e9d56ba5507021bdde898f4b0a0eb14f2af861.zip |
S#10387 - Rework pluginlib actions
It changes pluginlib actions to contain only a single and simple context (and
other one for remote directional buttons),
consisting of 7(9) buttons: up/down/left/right, select OR short select and long
select, exit and cancel (plus 2 for scrollwheel targets).
This ensures contexts don't clash with other contexts and simplifies them, at
the expense of reduced versatility. However, the versatility made it largely unusable
due to the great number of targets.
This should allow for using pluginlib actions safely for the most simple plugins (e.g. almost all demos).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26202 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/metronome.c')
-rw-r--r-- | apps/plugins/metronome.c | 109 |
1 files changed, 45 insertions, 64 deletions
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c index c5d27faf3d..1af62554fb 100644 --- a/apps/plugins/metronome.c +++ b/apps/plugins/metronome.c | |||
@@ -608,62 +608,56 @@ static signed short sound[] = { | |||
608 | }; | 608 | }; |
609 | #endif | 609 | #endif |
610 | 610 | ||
611 | #define METRONOME_QUIT PLA_QUIT | 611 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) \ |
612 | #define METRONOME_VOL_UP PLA_INC | 612 | || (CONFIG_KEYPAD == SANSA_E200_PAD) || (CONFIG_KEYPAD == SAMSUNG_YH_PAD) |
613 | #define METRONOME_VOL_DOWN PLA_DEC | 613 | #define MET_SYNC |
614 | #define METRONOME_VOL_UP_REP PLA_INC_REPEAT | 614 | #endif |
615 | #define METRONOME_VOL_DOWN_REP PLA_DEC_REPEAT | 615 | |
616 | #define METRONOME_QUIT PLA_EXIT | ||
617 | |||
618 | #ifdef HAVE_SCROLLWHEEL | ||
619 | #define METRONOME_VOL_UP PLA_SCROLL_FWD | ||
620 | #define METRONOME_VOL_UP_REP PLA_SCROLL_FWD_REPEAT | ||
621 | #define METRONOME_VOL_DOWN PLA_SCROLL_BACK | ||
622 | #define METRONOME_VOL_DOWN_REP PLA_SCROLL_BACK_REPEAT | ||
623 | #else | ||
624 | #define METRONOME_VOL_UP PLA_UP | ||
625 | #define METRONOME_VOL_DOWN PLA_DOWN | ||
626 | #define METRONOME_VOL_UP_REP PLA_UP_REPEAT | ||
627 | #define METRONOME_VOL_DOWN_REP PLA_DOWN_REPEAT | ||
628 | #endif | ||
616 | #define METRONOME_LEFT PLA_LEFT | 629 | #define METRONOME_LEFT PLA_LEFT |
617 | #define METRONOME_RIGHT PLA_RIGHT | 630 | #define METRONOME_RIGHT PLA_RIGHT |
618 | #define METRONOME_LEFT_REP PLA_LEFT_REPEAT | 631 | #define METRONOME_LEFT_REP PLA_LEFT_REPEAT |
619 | #define METRONOME_RIGHT_REP PLA_RIGHT_REPEAT | 632 | #define METRONOME_RIGHT_REP PLA_RIGHT_REPEAT |
633 | #define METRONOME_TAP PLA_SELECT_REL | ||
634 | #define METRONOME_PAUSE PLA_CANCEL | ||
635 | #define METRONOME_PLAY PLA_SELECT_REPEAT | ||
636 | |||
637 | #if defined(MET_SYNC) | ||
620 | enum { | 638 | enum { |
621 | METRONOME_PLAY_TAP = LAST_PLUGINLIB_ACTION+1, | 639 | METRONOME_SYNC = LAST_PLUGINLIB_ACTION+1, |
622 | #if CONFIG_KEYPAD == ONDIO_PAD | ||
623 | METRONOME_PAUSE, | ||
624 | #endif /* ONDIO_PAD */ | ||
625 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
626 | METRONOME_SYNC | ||
627 | #endif /* IRIVER_H100_PAD||IRIVER_H300_PAD */ | ||
628 | }; | 640 | }; |
641 | #endif /* IRIVER_H100_PAD||IRIVER_H300_PAD */ | ||
629 | 642 | ||
630 | 643 | ||
631 | #if CONFIG_KEYPAD == ONDIO_PAD | 644 | #define METRONOME_MSG_START "start: press select" |
632 | #define METRONOME_TAP PLA_START | 645 | #define METRONOME_MSG_STOP "start: hold select" |
633 | #define METRONOME_MSG_START "start: mode" | ||
634 | #define METRONOME_MSG_STOP "pause: hold mode" | ||
635 | static const struct button_mapping ondio_action[] = | ||
636 | { | ||
637 | {METRONOME_PLAY_TAP, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, | ||
638 | {METRONOME_PAUSE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE }, | ||
639 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_PLUGIN) | ||
640 | }; | ||
641 | #else /* !ONDIO_PAD */ | ||
642 | #define METRONOME_TAP PLA_FIRE | ||
643 | #define METRONOME_PLAYPAUSE PLA_START | ||
644 | #define METRONOME_MSG_START "press play" | ||
645 | #define METRONOME_MSG_STOP "press pause" | ||
646 | 646 | ||
647 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | 647 | #ifdef MET_SYNC |
648 | #define MET_SYNC | ||
649 | static const struct button_mapping iriver_syncaction[] = | 648 | static const struct button_mapping iriver_syncaction[] = |
650 | { | 649 | { |
651 | {METRONOME_SYNC, BUTTON_REC, BUTTON_NONE }, | 650 | {METRONOME_SYNC, BUTTON_REC, BUTTON_NONE }, |
652 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_PLUGIN) | 651 | LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_PLUGIN) |
653 | }; | 652 | }; |
654 | #endif /* IRIVER_H100_PAD||IRIVER_H300_PAD */ | 653 | #endif /* IRIVER_H100_PAD||IRIVER_H300_PAD */ |
655 | #endif /* #if CONFIG_KEYPAD == ONDIO_PAD */ | ||
656 | 654 | ||
657 | const struct button_mapping *plugin_contexts[] = | 655 | const struct button_mapping *plugin_contexts[] = |
658 | { | 656 | { |
659 | generic_increase_decrease, | 657 | pla_main_ctx, |
660 | generic_directions, | 658 | #if defined(MET_SYNC) |
661 | #if CONFIG_KEYPAD == ONDIO_PAD | ||
662 | ondio_action, | ||
663 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
664 | iriver_syncaction, | 659 | iriver_syncaction, |
665 | #endif | 660 | #endif |
666 | generic_actions | ||
667 | }; | 661 | }; |
668 | #define PLA_ARRAY_COUNT sizeof(plugin_contexts)/sizeof(plugin_contexts[0]) | 662 | #define PLA_ARRAY_COUNT sizeof(plugin_contexts)/sizeof(plugin_contexts[0]) |
669 | 663 | ||
@@ -890,6 +884,7 @@ void tap(void) | |||
890 | enum plugin_status plugin_start(const void* parameter) | 884 | enum plugin_status plugin_start(const void* parameter) |
891 | { | 885 | { |
892 | int button; | 886 | int button; |
887 | static int last_button = BUTTON_NONE; | ||
893 | enum plugin_status status; | 888 | enum plugin_status status; |
894 | 889 | ||
895 | (void)parameter; | 890 | (void)parameter; |
@@ -918,7 +913,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
918 | while (true){ | 913 | while (true){ |
919 | reset_tap = true; | 914 | reset_tap = true; |
920 | #if CONFIG_CODEC == SWCODEC | 915 | #if CONFIG_CODEC == SWCODEC |
921 | button = pluginlib_getaction(1,plugin_contexts,PLA_ARRAY_COUNT); | 916 | button = pluginlib_getaction(TIMEOUT_NOBLOCK,plugin_contexts,PLA_ARRAY_COUNT); |
922 | if (need_to_play) | 917 | if (need_to_play) |
923 | { | 918 | { |
924 | need_to_play = false; | 919 | need_to_play = false; |
@@ -936,35 +931,25 @@ enum plugin_status plugin_start(const void* parameter) | |||
936 | status = PLUGIN_OK; | 931 | status = PLUGIN_OK; |
937 | goto metronome_exit; | 932 | goto metronome_exit; |
938 | 933 | ||
939 | #if CONFIG_KEYPAD == ONDIO_PAD | ||
940 | case METRONOME_PLAY_TAP: | ||
941 | if(sound_paused) { | ||
942 | sound_paused = false; | ||
943 | calc_period(); | ||
944 | draw_display(); | ||
945 | } | ||
946 | else | ||
947 | tap(); | ||
948 | break; | ||
949 | |||
950 | case METRONOME_PAUSE: | 934 | case METRONOME_PAUSE: |
951 | if(!sound_paused) { | 935 | if(!sound_paused) |
936 | { | ||
952 | sound_paused = true; | 937 | sound_paused = true; |
953 | draw_display(); | 938 | draw_display(); |
954 | } | 939 | } |
955 | break; | 940 | break; |
956 | 941 | case METRONOME_PLAY: | |
957 | #else | ||
958 | case METRONOME_PLAYPAUSE: | ||
959 | if(sound_paused) | 942 | if(sound_paused) |
943 | { | ||
960 | sound_paused = false; | 944 | sound_paused = false; |
961 | else | 945 | calc_period(); |
962 | sound_paused = true; | 946 | draw_display(); |
963 | calc_period(); | 947 | } |
964 | draw_display(); | 948 | break; |
949 | case METRONOME_TAP: | ||
950 | if (last_button != METRONOME_PLAY) | ||
951 | tap(); | ||
965 | break; | 952 | break; |
966 | #endif /* ONDIO_PAD */ | ||
967 | |||
968 | case METRONOME_VOL_UP: | 953 | case METRONOME_VOL_UP: |
969 | case METRONOME_VOL_UP_REP: | 954 | case METRONOME_VOL_UP_REP: |
970 | change_volume(1); | 955 | change_volume(1); |
@@ -989,12 +974,6 @@ enum plugin_status plugin_start(const void* parameter) | |||
989 | change_bpm(1); | 974 | change_bpm(1); |
990 | break; | 975 | break; |
991 | 976 | ||
992 | #ifdef METRONOME_TAP | ||
993 | case METRONOME_TAP: | ||
994 | tap(); | ||
995 | break; | ||
996 | #endif | ||
997 | |||
998 | #ifdef MET_SYNC | 977 | #ifdef MET_SYNC |
999 | case METRONOME_SYNC: | 978 | case METRONOME_SYNC: |
1000 | minitick = period; | 979 | minitick = period; |
@@ -1012,6 +991,8 @@ enum plugin_status plugin_start(const void* parameter) | |||
1012 | break; | 991 | break; |
1013 | 992 | ||
1014 | } | 993 | } |
994 | if (button) | ||
995 | last_button = button; | ||
1015 | if (reset_tap) { | 996 | if (reset_tap) { |
1016 | tap_count = 0; | 997 | tap_count = 0; |
1017 | } | 998 | } |