diff options
author | Björn Stenberg <bjorn@haxx.se> | 2004-09-19 21:58:37 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2004-09-19 21:58:37 +0000 |
commit | 6c33c51a4ca9907d23e3154d956fd6781122f492 (patch) | |
tree | f0e598efaf064bb72c33c0a8a2edba4cf9ebb13c /apps/tree.c | |
parent | 17f54a40f100a3343a15a431d235699024aa76c8 (diff) | |
download | rockbox-6c33c51a4ca9907d23e3154d956fd6781122f492.tar.gz rockbox-6c33c51a4ca9907d23e3154d956fd6781122f492.zip |
Redesigned the button handling. The code now uses symbolic function defines instead of checking for specific buttons. This makes it easier to add support for new devices with different button layouts.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5091 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 115 |
1 files changed, 49 insertions, 66 deletions
diff --git a/apps/tree.c b/apps/tree.c index 90d7010d03..a83346b8d2 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -194,20 +194,6 @@ void tree_get_filetypes(const struct filetype** types, int* count) | |||
194 | 194 | ||
195 | #endif /* HAVE_LCD_BITMAP */ | 195 | #endif /* HAVE_LCD_BITMAP */ |
196 | 196 | ||
197 | #ifdef HAVE_RECORDER_KEYPAD | ||
198 | #define TREE_NEXT BUTTON_DOWN | ||
199 | #define TREE_PREV BUTTON_UP | ||
200 | #define TREE_EXIT BUTTON_LEFT | ||
201 | #define TREE_ENTER BUTTON_RIGHT | ||
202 | #define TREE_MENU BUTTON_F1 | ||
203 | #else | ||
204 | #define TREE_NEXT BUTTON_RIGHT | ||
205 | #define TREE_PREV BUTTON_LEFT | ||
206 | #define TREE_EXIT BUTTON_STOP | ||
207 | #define TREE_ENTER BUTTON_PLAY | ||
208 | #define TREE_MENU BUTTON_MENU | ||
209 | #endif /* HAVE_RECORDER_KEYPAD */ | ||
210 | |||
211 | /* talkbox hovering delay, to avoid immediate disk activity */ | 197 | /* talkbox hovering delay, to avoid immediate disk activity */ |
212 | #define HOVER_DELAY (HZ/2) | 198 | #define HOVER_DELAY (HZ/2) |
213 | 199 | ||
@@ -641,9 +627,9 @@ static bool ask_resume(bool ask_once) | |||
641 | while (!stop) { | 627 | while (!stop) { |
642 | button = button_get(true); | 628 | button = button_get(true); |
643 | switch (button) { | 629 | switch (button) { |
644 | case BUTTON_PLAY: | 630 | case TREE_RUN: |
645 | #ifdef BUTTON_RC_PLAY | 631 | #ifdef TREE_RC_RUN |
646 | case BUTTON_RC_PLAY: | 632 | case TREE_RC_RUN: |
647 | #endif | 633 | #endif |
648 | return true; | 634 | return true; |
649 | 635 | ||
@@ -771,9 +757,10 @@ void set_current_file(char *path) | |||
771 | } | 757 | } |
772 | } | 758 | } |
773 | 759 | ||
774 | #ifdef BUTTON_ON | 760 | #ifdef TREE_SHIFT |
775 | static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, | 761 | static bool handle_shift(int *ds, int *dc, int numentries, |
776 | const int *dirfilter) | 762 | int tree_max_on_screen, |
763 | const int *dirfilter) | ||
777 | { | 764 | { |
778 | bool exit = false; | 765 | bool exit = false; |
779 | bool used = false; | 766 | bool used = false; |
@@ -790,12 +777,12 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, | |||
790 | while (!exit) { | 777 | while (!exit) { |
791 | switch (button_get(true)) { | 778 | switch (button_get(true)) { |
792 | case TREE_PREV: | 779 | case TREE_PREV: |
793 | #ifdef BUTTON_RC_LEFT | 780 | #ifdef TREE_RC_PREV |
794 | case BUTTON_RC_LEFT: | 781 | case TREE_RC_PREV: |
795 | #endif | 782 | #endif |
796 | #ifdef BUTTON_ON | 783 | #ifdef TREE_SHIFT |
797 | case BUTTON_ON | TREE_PREV: | 784 | case TREE_SHIFT | TREE_PREV: |
798 | case BUTTON_ON | TREE_PREV | BUTTON_REPEAT: | 785 | case TREE_SHIFT | TREE_PREV | BUTTON_REPEAT: |
799 | #endif | 786 | #endif |
800 | used = true; | 787 | used = true; |
801 | if ( dirstart ) { | 788 | if ( dirstart ) { |
@@ -808,12 +795,12 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, | |||
808 | break; | 795 | break; |
809 | 796 | ||
810 | case TREE_NEXT: | 797 | case TREE_NEXT: |
811 | #ifdef BUTTON_RC_RIGHT | 798 | #ifdef TREE_RC_NEXT |
812 | case BUTTON_RC_RIGHT: | 799 | case TREE_RC_NEXT: |
813 | #endif | 800 | #endif |
814 | #ifdef BUTTON_ON | 801 | #ifdef TREE_SHIFT |
815 | case BUTTON_ON | TREE_NEXT: | 802 | case TREE_SHIFT | TREE_NEXT: |
816 | case BUTTON_ON | TREE_NEXT | BUTTON_REPEAT: | 803 | case TREE_SHIFT | TREE_NEXT | BUTTON_REPEAT: |
817 | #endif | 804 | #endif |
818 | used = true; | 805 | used = true; |
819 | if ( dirstart < numentries - tree_max_on_screen ) { | 806 | if ( dirstart < numentries - tree_max_on_screen ) { |
@@ -827,12 +814,12 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, | |||
827 | break; | 814 | break; |
828 | 815 | ||
829 | 816 | ||
830 | case BUTTON_PLAY: | 817 | case TREE_RUN: |
831 | #ifdef BUTTON_RC_PLAY | 818 | #ifdef TREE_RC_PLAY |
832 | case BUTTON_RC_PLAY: | 819 | case TREE_RC_RUN: |
833 | #endif | 820 | #endif |
834 | #ifdef BUTTON_ON | 821 | #ifdef TREE_SHIFT |
835 | case BUTTON_ON | BUTTON_PLAY: | 822 | case TREE_SHIFT | TREE_RUN: |
836 | #endif | 823 | #endif |
837 | { | 824 | { |
838 | int onplay_result; | 825 | int onplay_result; |
@@ -866,10 +853,10 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, | |||
866 | exit = true; | 853 | exit = true; |
867 | break; | 854 | break; |
868 | } | 855 | } |
869 | #ifdef BUTTON_ON | 856 | #ifdef TREE_SHIFT |
870 | case BUTTON_ON | BUTTON_REL: | 857 | case TREE_SHIFT | BUTTON_REL: |
871 | case BUTTON_ON | TREE_PREV | BUTTON_REL: | 858 | case TREE_SHIFT | TREE_PREV | BUTTON_REL: |
872 | case BUTTON_ON | TREE_NEXT | BUTTON_REL: | 859 | case TREE_SHIFT | TREE_NEXT | BUTTON_REL: |
873 | exit = true; | 860 | exit = true; |
874 | break; | 861 | break; |
875 | #endif | 862 | #endif |
@@ -969,7 +956,7 @@ static bool dirbrowse(const char *root, const int *dirfilter) | |||
969 | while (!stop) { | 956 | while (!stop) { |
970 | button = button_get(true); | 957 | button = button_get(true); |
971 | switch (button) { | 958 | switch (button) { |
972 | case BUTTON_PLAY: | 959 | case TREE_RUN: |
973 | rolo_load("/" BOOTFILE); | 960 | rolo_load("/" BOOTFILE); |
974 | stop = true; | 961 | stop = true; |
975 | break; | 962 | break; |
@@ -988,11 +975,9 @@ static bool dirbrowse(const char *root, const int *dirfilter) | |||
988 | 975 | ||
989 | switch ( button ) { | 976 | switch ( button ) { |
990 | case TREE_EXIT: | 977 | case TREE_EXIT: |
991 | #ifdef BUTTON_RC_STOP | 978 | case TREE_EXIT | BUTTON_REPEAT: |
992 | case BUTTON_RC_STOP: | 979 | #ifdef TREE_RC_EXIT |
993 | #endif | 980 | case TREE_RC_EXIT: |
994 | #ifdef HAVE_RECORDER_KEYPAD | ||
995 | case BUTTON_LEFT | BUTTON_REPEAT: | ||
996 | #endif | 981 | #endif |
997 | i=strlen(currdir); | 982 | i=strlen(currdir); |
998 | if (i>1) { | 983 | if (i>1) { |
@@ -1027,8 +1012,8 @@ static bool dirbrowse(const char *root, const int *dirfilter) | |||
1027 | } | 1012 | } |
1028 | break; | 1013 | break; |
1029 | 1014 | ||
1030 | #ifdef HAVE_RECORDER_KEYPAD | 1015 | #ifdef TREE_OFF |
1031 | case BUTTON_OFF: | 1016 | case TREE_OFF: |
1032 | /* Stop the music if it is playing, else show the shutdown | 1017 | /* Stop the music if it is playing, else show the shutdown |
1033 | screen */ | 1018 | screen */ |
1034 | if(mpeg_status()) | 1019 | if(mpeg_status()) |
@@ -1042,27 +1027,23 @@ static bool dirbrowse(const char *root, const int *dirfilter) | |||
1042 | restore = true; | 1027 | restore = true; |
1043 | } | 1028 | } |
1044 | break; | 1029 | break; |
1045 | #endif | ||
1046 | 1030 | ||
1047 | #ifdef HAVE_RECORDER_KEYPAD | 1031 | case TREE_OFF | BUTTON_REPEAT: |
1048 | case BUTTON_OFF | BUTTON_REPEAT: | ||
1049 | #else | ||
1050 | case BUTTON_STOP | BUTTON_REPEAT: | ||
1051 | #endif | ||
1052 | if (charger_inserted()) { | 1032 | if (charger_inserted()) { |
1053 | charging_splash(); | 1033 | charging_splash(); |
1054 | restore = true; | 1034 | restore = true; |
1055 | } | 1035 | } |
1056 | break; | 1036 | break; |
1037 | #endif | ||
1057 | 1038 | ||
1058 | case TREE_ENTER: | 1039 | case TREE_ENTER: |
1059 | case TREE_ENTER | BUTTON_REPEAT: | 1040 | case TREE_ENTER | BUTTON_REPEAT: |
1060 | #ifdef BUTTON_RC_PLAY | 1041 | #if defined TREE_RC_ENTER && (TREE_RC_ENTER != TREE_RC_RUN) |
1061 | case BUTTON_RC_PLAY: | 1042 | case TREE_RC_ENTER: |
1062 | #endif | 1043 | #endif |
1063 | #ifdef HAVE_RECORDER_KEYPAD | 1044 | #if defined TREE_RUN && (TREE_RUN != TREE_ENTER) |
1064 | case BUTTON_PLAY: | 1045 | case TREE_RUN: |
1065 | case BUTTON_PLAY | BUTTON_REPEAT: | 1046 | case TREE_RUN | BUTTON_REPEAT: |
1066 | #endif | 1047 | #endif |
1067 | if ( !numentries ) | 1048 | if ( !numentries ) |
1068 | break; | 1049 | break; |
@@ -1255,8 +1236,9 @@ static bool dirbrowse(const char *root, const int *dirfilter) | |||
1255 | 1236 | ||
1256 | case TREE_PREV: | 1237 | case TREE_PREV: |
1257 | case TREE_PREV | BUTTON_REPEAT: | 1238 | case TREE_PREV | BUTTON_REPEAT: |
1258 | #ifdef BUTTON_RC_LEFT | 1239 | #ifdef TREE_RC_PREV |
1259 | case BUTTON_RC_LEFT: | 1240 | case TREE_RC_PREV: |
1241 | case TREE_RC_PREV | BUTTON_REPEAT: | ||
1260 | #endif | 1242 | #endif |
1261 | if(filesindir) { | 1243 | if(filesindir) { |
1262 | if(dircursor) { | 1244 | if(dircursor) { |
@@ -1295,8 +1277,9 @@ static bool dirbrowse(const char *root, const int *dirfilter) | |||
1295 | 1277 | ||
1296 | case TREE_NEXT: | 1278 | case TREE_NEXT: |
1297 | case TREE_NEXT | BUTTON_REPEAT: | 1279 | case TREE_NEXT | BUTTON_REPEAT: |
1298 | #ifdef BUTTON_RC_RIGHT | 1280 | #ifdef TREE_RC_NEXT |
1299 | case BUTTON_RC_RIGHT: | 1281 | case TREE_RC_NEXT: |
1282 | case TREE_RC_NEXT | BUTTON_REPEAT: | ||
1300 | #endif | 1283 | #endif |
1301 | if(filesindir) | 1284 | if(filesindir) |
1302 | { | 1285 | { |
@@ -1340,11 +1323,11 @@ static bool dirbrowse(const char *root, const int *dirfilter) | |||
1340 | } | 1323 | } |
1341 | break; | 1324 | break; |
1342 | 1325 | ||
1343 | #ifdef BUTTON_ON /* I bet the folks without ON-button want this to | 1326 | #ifdef TREE_SHIFT /* I bet the folks without ON-button want this to |
1344 | work on a different button */ | 1327 | work on a different button */ |
1345 | case BUTTON_ON: | 1328 | case TREE_SHIFT: |
1346 | if (handle_on(&dirstart, &dircursor, numentries, | 1329 | if (handle_shift(&dirstart, &dircursor, numentries, |
1347 | tree_max_on_screen, dirfilter)) | 1330 | tree_max_on_screen, dirfilter)) |
1348 | { | 1331 | { |
1349 | /* start scroll */ | 1332 | /* start scroll */ |
1350 | restore = true; | 1333 | restore = true; |