diff options
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 128 |
1 files changed, 79 insertions, 49 deletions
diff --git a/apps/tree.c b/apps/tree.c index a173b9095a..62b9ce289f 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -67,7 +67,7 @@ static struct | |||
67 | char* extension; /* extension for which the file type is recognized */ | 67 | char* extension; /* extension for which the file type is recognized */ |
68 | int tree_attr; /* which identifier */ | 68 | int tree_attr; /* which identifier */ |
69 | int icon; /* the icon which shall be used for it, -1 if unknown */ | 69 | int icon; /* the icon which shall be used for it, -1 if unknown */ |
70 | /* To have it extendable, there could be more useful stuff in here, | 70 | /* To have it extendable, there could be more useful stuff in here, |
71 | like handler functions, plugin name, etc. */ | 71 | like handler functions, plugin name, etc. */ |
72 | } filetypes[] = { | 72 | } filetypes[] = { |
73 | { ".mp3", TREE_ATTR_MPA, File }, | 73 | { ".mp3", TREE_ATTR_MPA, File }, |
@@ -140,7 +140,7 @@ void browse_root(void) | |||
140 | #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) | 140 | #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) |
141 | 141 | ||
142 | /* position the entry-list starts at */ | 142 | /* position the entry-list starts at */ |
143 | #define LINE_X 0 | 143 | #define LINE_X 0 |
144 | #define LINE_Y (global_settings.statusbar ? 1 : 0) | 144 | #define LINE_Y (global_settings.statusbar ? 1 : 0) |
145 | 145 | ||
146 | #define CURSOR_X (global_settings.scrollbar && \ | 146 | #define CURSOR_X (global_settings.scrollbar && \ |
@@ -213,13 +213,13 @@ static int compare(const void* p1, const void* p2) | |||
213 | { | 213 | { |
214 | struct entry* e1 = (struct entry*)p1; | 214 | struct entry* e1 = (struct entry*)p1; |
215 | struct entry* e2 = (struct entry*)p2; | 215 | struct entry* e2 = (struct entry*)p2; |
216 | 216 | ||
217 | if (( e1->attr & ATTR_DIRECTORY ) == ( e2->attr & ATTR_DIRECTORY )) | 217 | if (( e1->attr & ATTR_DIRECTORY ) == ( e2->attr & ATTR_DIRECTORY )) |
218 | if (global_settings.sort_case) | 218 | if (global_settings.sort_case) |
219 | return strncmp(e1->name, e2->name, MAX_PATH); | 219 | return strncmp(e1->name, e2->name, MAX_PATH); |
220 | else | 220 | else |
221 | return strncasecmp(e1->name, e2->name, MAX_PATH); | 221 | return strncasecmp(e1->name, e2->name, MAX_PATH); |
222 | else | 222 | else |
223 | return ( e2->attr & ATTR_DIRECTORY ) - ( e1->attr & ATTR_DIRECTORY ); | 223 | return ( e2->attr & ATTR_DIRECTORY ) - ( e1->attr & ATTR_DIRECTORY ); |
224 | } | 224 | } |
225 | 225 | ||
@@ -234,7 +234,7 @@ static void showfileline(int line, int direntry, bool scroll, int *dirfilter) | |||
234 | #endif | 234 | #endif |
235 | 235 | ||
236 | /* if any file filter is on, strip the extension */ | 236 | /* if any file filter is on, strip the extension */ |
237 | if (*dirfilter != SHOW_ALL && | 237 | if (*dirfilter != SHOW_ALL && |
238 | !(dircache[direntry].attr & ATTR_DIRECTORY)) | 238 | !(dircache[direntry].attr & ATTR_DIRECTORY)) |
239 | { | 239 | { |
240 | char* dotpos = strrchr(name, '.'); | 240 | char* dotpos = strrchr(name, '.'); |
@@ -277,35 +277,35 @@ struct entry* load_and_sort_directory(char *dirname, int *dirfilter, | |||
277 | DIR *dir = opendir(dirname); | 277 | DIR *dir = opendir(dirname); |
278 | if(!dir) | 278 | if(!dir) |
279 | return NULL; /* not a directory */ | 279 | return NULL; /* not a directory */ |
280 | 280 | ||
281 | name_buffer_length = 0; | 281 | name_buffer_length = 0; |
282 | *buffer_full = false; | 282 | *buffer_full = false; |
283 | 283 | ||
284 | for ( i=0; i < max_files_in_dir; i++ ) { | 284 | for ( i=0; i < max_files_in_dir; i++ ) { |
285 | int len; | 285 | int len; |
286 | struct dirent *entry = readdir(dir); | 286 | struct dirent *entry = readdir(dir); |
287 | struct entry* dptr = &dircache[i]; | 287 | struct entry* dptr = &dircache[i]; |
288 | if (!entry) | 288 | if (!entry) |
289 | break; | 289 | break; |
290 | 290 | ||
291 | len = strlen(entry->d_name); | 291 | len = strlen(entry->d_name); |
292 | 292 | ||
293 | /* skip directories . and .. */ | 293 | /* skip directories . and .. */ |
294 | if ((entry->attribute & ATTR_DIRECTORY) && | 294 | if ((entry->attribute & ATTR_DIRECTORY) && |
295 | (((len == 1) && | 295 | (((len == 1) && |
296 | (!strncmp(entry->d_name, ".", 1))) || | 296 | (!strncmp(entry->d_name, ".", 1))) || |
297 | ((len == 2) && | 297 | ((len == 2) && |
298 | (!strncmp(entry->d_name, "..", 2))))) { | 298 | (!strncmp(entry->d_name, "..", 2))))) { |
299 | i--; | 299 | i--; |
300 | continue; | 300 | continue; |
301 | } | 301 | } |
302 | 302 | ||
303 | /* Skip FAT volume ID */ | 303 | /* Skip FAT volume ID */ |
304 | if (entry->attribute & ATTR_VOLUME_ID) { | 304 | if (entry->attribute & ATTR_VOLUME_ID) { |
305 | i--; | 305 | i--; |
306 | continue; | 306 | continue; |
307 | } | 307 | } |
308 | 308 | ||
309 | /* filter out dotfiles and hidden files */ | 309 | /* filter out dotfiles and hidden files */ |
310 | if (*dirfilter != SHOW_ALL && | 310 | if (*dirfilter != SHOW_ALL && |
311 | ((entry->d_name[0]=='.') || | 311 | ((entry->d_name[0]=='.') || |
@@ -313,11 +313,11 @@ struct entry* load_and_sort_directory(char *dirname, int *dirfilter, | |||
313 | i--; | 313 | i--; |
314 | continue; | 314 | continue; |
315 | } | 315 | } |
316 | 316 | ||
317 | dptr->attr = entry->attribute; | 317 | dptr->attr = entry->attribute; |
318 | 318 | ||
319 | /* check for known file types */ | 319 | /* check for known file types */ |
320 | if ( !(dptr->attr & ATTR_DIRECTORY) && (len > 4) ) | 320 | if ( !(dptr->attr & ATTR_DIRECTORY) && (len > 4) ) |
321 | { | 321 | { |
322 | unsigned j; | 322 | unsigned j; |
323 | for (j=0; j<sizeof(filetypes)/sizeof(*filetypes); j++) | 323 | for (j=0; j<sizeof(filetypes)/sizeof(*filetypes); j++) |
@@ -361,7 +361,7 @@ struct entry* load_and_sort_directory(char *dirname, int *dirfilter, | |||
361 | i--; | 361 | i--; |
362 | continue; | 362 | continue; |
363 | } | 363 | } |
364 | 364 | ||
365 | if (len > name_buffer_size - name_buffer_length - 1) { | 365 | if (len > name_buffer_size - name_buffer_length - 1) { |
366 | /* Tell the world that we ran out of buffer space */ | 366 | /* Tell the world that we ran out of buffer space */ |
367 | *buffer_full = true; | 367 | *buffer_full = true; |
@@ -514,8 +514,8 @@ static int showdir(char *path, int start, int *dirfilter) | |||
514 | int offset=0; | 514 | int offset=0; |
515 | if ( line_height > 8 ) | 515 | if ( line_height > 8 ) |
516 | offset = (line_height - 8) / 2; | 516 | offset = (line_height - 8) / 2; |
517 | lcd_bitmap(bitmap_icons_6x8[icon_type], | 517 | lcd_bitmap(bitmap_icons_6x8[icon_type], |
518 | CURSOR_X * 6 + CURSOR_WIDTH, | 518 | CURSOR_X * 6 + CURSOR_WIDTH, |
519 | MARGIN_Y+(i-start)*line_height + offset, | 519 | MARGIN_Y+(i-start)*line_height + offset, |
520 | 6, 8, true); | 520 | 6, 8, true); |
521 | #else | 521 | #else |
@@ -527,7 +527,7 @@ static int showdir(char *path, int start, int *dirfilter) | |||
527 | } | 527 | } |
528 | 528 | ||
529 | #ifdef HAVE_LCD_BITMAP | 529 | #ifdef HAVE_LCD_BITMAP |
530 | if (global_settings.scrollbar && (filesindir > tree_max_on_screen)) | 530 | if (global_settings.scrollbar && (filesindir > tree_max_on_screen)) |
531 | scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1, | 531 | scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1, |
532 | LCD_HEIGHT - SCROLLBAR_Y, filesindir, start, | 532 | LCD_HEIGHT - SCROLLBAR_Y, filesindir, start, |
533 | start + tree_max_on_screen, VERTICAL); | 533 | start + tree_max_on_screen, VERTICAL); |
@@ -539,7 +539,7 @@ static int showdir(char *path, int start, int *dirfilter) | |||
539 | static bool ask_resume(bool ask_once) | 539 | static bool ask_resume(bool ask_once) |
540 | { | 540 | { |
541 | bool stop = false; | 541 | bool stop = false; |
542 | 542 | ||
543 | #ifdef HAVE_LCD_CHARCELLS | 543 | #ifdef HAVE_LCD_CHARCELLS |
544 | lcd_double_height(false); | 544 | lcd_double_height(false); |
545 | #endif | 545 | #endif |
@@ -562,16 +562,20 @@ static bool ask_resume(bool ask_once) | |||
562 | while (!stop) { | 562 | while (!stop) { |
563 | switch (button_get(true)) { | 563 | switch (button_get(true)) { |
564 | case BUTTON_PLAY: | 564 | case BUTTON_PLAY: |
565 | #ifdef BUTTON_RC_PLAY | ||
565 | case BUTTON_RC_PLAY: | 566 | case BUTTON_RC_PLAY: |
567 | #endif | ||
566 | return true; | 568 | return true; |
567 | 569 | ||
570 | #ifdef BUTTON_ON | ||
568 | /* ignore the ON button, since it might | 571 | /* ignore the ON button, since it might |
569 | still be pressed since booting */ | 572 | still be pressed since booting */ |
570 | case BUTTON_ON: | 573 | case BUTTON_ON: |
571 | case BUTTON_ON | BUTTON_REL: | 574 | case BUTTON_ON | BUTTON_REL: |
572 | case BUTTON_ON | BUTTON_REPEAT: | 575 | case BUTTON_ON | BUTTON_REPEAT: |
573 | break; | 576 | break; |
574 | 577 | #endif | |
578 | |||
575 | case SYS_USB_CONNECTED: | 579 | case SYS_USB_CONNECTED: |
576 | usb_screen(); | 580 | usb_screen(); |
577 | stop = true; | 581 | stop = true; |
@@ -600,7 +604,7 @@ void resume_directory(char *dir) | |||
600 | &buffer_full)) | 604 | &buffer_full)) |
601 | return; | 605 | return; |
602 | lastdir[0] = 0; | 606 | lastdir[0] = 0; |
603 | 607 | ||
604 | build_playlist(0); | 608 | build_playlist(0); |
605 | } | 609 | } |
606 | 610 | ||
@@ -635,7 +639,7 @@ static void start_resume(bool ask_once) | |||
635 | 639 | ||
636 | if (!ask_resume(ask_once)) | 640 | if (!ask_resume(ask_once)) |
637 | return; | 641 | return; |
638 | 642 | ||
639 | if (playlist_resume() != -1) | 643 | if (playlist_resume() != -1) |
640 | { | 644 | { |
641 | playlist_start(global_settings.resume_index, | 645 | playlist_start(global_settings.resume_index, |
@@ -680,7 +684,7 @@ void set_current_file(char *path) | |||
680 | dirlevel = 0; | 684 | dirlevel = 0; |
681 | dirpos[dirlevel] = -1; | 685 | dirpos[dirlevel] = -1; |
682 | cursorpos[dirlevel] = 0; | 686 | cursorpos[dirlevel] = 0; |
683 | 687 | ||
684 | /* use '/' to calculate dirlevel */ | 688 | /* use '/' to calculate dirlevel */ |
685 | for (i=1; i<strlen(path)+1; i++) | 689 | for (i=1; i<strlen(path)+1; i++) |
686 | { | 690 | { |
@@ -711,9 +715,13 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, | |||
711 | while (!exit) { | 715 | while (!exit) { |
712 | switch (button_get(true)) { | 716 | switch (button_get(true)) { |
713 | case TREE_PREV: | 717 | case TREE_PREV: |
718 | #ifdef BUTTON_RC_LEFT | ||
714 | case BUTTON_RC_LEFT: | 719 | case BUTTON_RC_LEFT: |
720 | #endif | ||
721 | #ifdef BUTTON_ON | ||
715 | case BUTTON_ON | TREE_PREV: | 722 | case BUTTON_ON | TREE_PREV: |
716 | case BUTTON_ON | TREE_PREV | BUTTON_REPEAT: | 723 | case BUTTON_ON | TREE_PREV | BUTTON_REPEAT: |
724 | #endif | ||
717 | used = true; | 725 | used = true; |
718 | if ( dirstart ) { | 726 | if ( dirstart ) { |
719 | dirstart -= tree_max_on_screen; | 727 | dirstart -= tree_max_on_screen; |
@@ -723,15 +731,19 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, | |||
723 | else | 731 | else |
724 | dircursor = 0; | 732 | dircursor = 0; |
725 | break; | 733 | break; |
726 | 734 | ||
727 | case TREE_NEXT: | 735 | case TREE_NEXT: |
736 | #ifdef BUTTON_RC_RIGHT | ||
728 | case BUTTON_RC_RIGHT: | 737 | case BUTTON_RC_RIGHT: |
738 | #endif | ||
739 | #ifdef BUTTON_ON | ||
729 | case BUTTON_ON | TREE_NEXT: | 740 | case BUTTON_ON | TREE_NEXT: |
730 | case BUTTON_ON | TREE_NEXT | BUTTON_REPEAT: | 741 | case BUTTON_ON | TREE_NEXT | BUTTON_REPEAT: |
742 | #endif | ||
731 | used = true; | 743 | used = true; |
732 | if ( dirstart < numentries - tree_max_on_screen ) { | 744 | if ( dirstart < numentries - tree_max_on_screen ) { |
733 | dirstart += tree_max_on_screen; | 745 | dirstart += tree_max_on_screen; |
734 | if ( dirstart > | 746 | if ( dirstart > |
735 | numentries - tree_max_on_screen ) | 747 | numentries - tree_max_on_screen ) |
736 | dirstart = numentries - tree_max_on_screen; | 748 | dirstart = numentries - tree_max_on_screen; |
737 | } | 749 | } |
@@ -741,8 +753,13 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, | |||
741 | 753 | ||
742 | 754 | ||
743 | case BUTTON_PLAY: | 755 | case BUTTON_PLAY: |
756 | #ifdef BUTTON_RC_PLAY | ||
744 | case BUTTON_RC_PLAY: | 757 | case BUTTON_RC_PLAY: |
745 | case BUTTON_ON | BUTTON_PLAY: { | 758 | #endif |
759 | #ifdef BUTTON_ON | ||
760 | case BUTTON_ON | BUTTON_PLAY: | ||
761 | #endif | ||
762 | { | ||
746 | int onplay_result; | 763 | int onplay_result; |
747 | 764 | ||
748 | if (currdir[1]) | 765 | if (currdir[1]) |
@@ -768,12 +785,14 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen, | |||
768 | } | 785 | } |
769 | exit = true; | 786 | exit = true; |
770 | break; | 787 | break; |
771 | } | 788 | } |
789 | #ifdef BUTTON_ON | ||
772 | case BUTTON_ON | BUTTON_REL: | 790 | case BUTTON_ON | BUTTON_REL: |
773 | case BUTTON_ON | TREE_PREV | BUTTON_REL: | 791 | case BUTTON_ON | TREE_PREV | BUTTON_REL: |
774 | case BUTTON_ON | TREE_NEXT | BUTTON_REL: | 792 | case BUTTON_ON | TREE_NEXT | BUTTON_REL: |
775 | exit = true; | 793 | exit = true; |
776 | break; | 794 | break; |
795 | #endif | ||
777 | } | 796 | } |
778 | if ( used && !exit ) { | 797 | if ( used && !exit ) { |
779 | #ifdef HAVE_LCD_BITMAP | 798 | #ifdef HAVE_LCD_BITMAP |
@@ -834,15 +853,15 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
834 | start_resume(true); | 853 | start_resume(true); |
835 | 854 | ||
836 | numentries = showdir(currdir, dirstart, dirfilter); | 855 | numentries = showdir(currdir, dirstart, dirfilter); |
837 | if (numentries == -1) | 856 | if (numentries == -1) |
838 | return false; /* currdir is not a directory */ | 857 | return false; /* currdir is not a directory */ |
839 | 858 | ||
840 | if (*dirfilter > NUM_FILTER_MODES && numentries==0) | 859 | if (*dirfilter > NUM_FILTER_MODES && numentries==0) |
841 | { | 860 | { |
842 | splash(HZ*2, 0, true, str(LANG_NO_FILES)); | 861 | splash(HZ*2, 0, true, str(LANG_NO_FILES)); |
843 | return false; /* No files found for rockbox_browser() */ | 862 | return false; /* No files found for rockbox_browser() */ |
844 | } | 863 | } |
845 | 864 | ||
846 | update_all = true; | 865 | update_all = true; |
847 | 866 | ||
848 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); | 867 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); |
@@ -873,7 +892,9 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
873 | 892 | ||
874 | switch ( button ) { | 893 | switch ( button ) { |
875 | case TREE_EXIT: | 894 | case TREE_EXIT: |
895 | #ifdef BUTTON_RC_STOP | ||
876 | case BUTTON_RC_STOP: | 896 | case BUTTON_RC_STOP: |
897 | #endif | ||
877 | #ifdef HAVE_RECORDER_KEYPAD | 898 | #ifdef HAVE_RECORDER_KEYPAD |
878 | case BUTTON_LEFT | BUTTON_REPEAT: | 899 | case BUTTON_LEFT | BUTTON_REPEAT: |
879 | #endif | 900 | #endif |
@@ -918,7 +939,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
918 | #endif | 939 | #endif |
919 | settings_save(); | 940 | settings_save(); |
920 | break; | 941 | break; |
921 | 942 | ||
922 | #ifdef HAVE_RECORDER_KEYPAD | 943 | #ifdef HAVE_RECORDER_KEYPAD |
923 | case BUTTON_OFF | BUTTON_REPEAT: | 944 | case BUTTON_OFF | BUTTON_REPEAT: |
924 | #else | 945 | #else |
@@ -932,10 +953,12 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
932 | 953 | ||
933 | case TREE_ENTER: | 954 | case TREE_ENTER: |
934 | case TREE_ENTER | BUTTON_REPEAT: | 955 | case TREE_ENTER | BUTTON_REPEAT: |
956 | #ifdef BUTTON_RC_PLAY | ||
935 | case BUTTON_RC_PLAY: | 957 | case BUTTON_RC_PLAY: |
958 | #endif | ||
936 | #ifdef HAVE_RECORDER_KEYPAD | 959 | #ifdef HAVE_RECORDER_KEYPAD |
937 | case BUTTON_PLAY: | 960 | case BUTTON_PLAY: |
938 | case BUTTON_PLAY | BUTTON_REPEAT: | 961 | case BUTTON_PLAY | BUTTON_REPEAT: |
939 | #endif | 962 | #endif |
940 | if ( !numentries ) | 963 | if ( !numentries ) |
941 | break; | 964 | break; |
@@ -971,7 +994,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
971 | play = true; | 994 | play = true; |
972 | } | 995 | } |
973 | break; | 996 | break; |
974 | 997 | ||
975 | case TREE_ATTR_MPA: | 998 | case TREE_ATTR_MPA: |
976 | if (playlist_create(currdir, NULL) != -1) | 999 | if (playlist_create(currdir, NULL) != -1) |
977 | { | 1000 | { |
@@ -981,14 +1004,14 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
981 | { | 1004 | { |
982 | start_index = | 1005 | start_index = |
983 | playlist_shuffle(seed,start_index); | 1006 | playlist_shuffle(seed,start_index); |
984 | 1007 | ||
985 | /* when shuffling dir.: play all files | 1008 | /* when shuffling dir.: play all files |
986 | even if the file selected by user is | 1009 | even if the file selected by user is |
987 | not the first one */ | 1010 | not the first one */ |
988 | if (!global_settings.play_selected) | 1011 | if (!global_settings.play_selected) |
989 | start_index = 0; | 1012 | start_index = 0; |
990 | } | 1013 | } |
991 | 1014 | ||
992 | playlist_start(start_index, 0); | 1015 | playlist_start(start_index, 0); |
993 | play = true; | 1016 | play = true; |
994 | } | 1017 | } |
@@ -1015,7 +1038,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1015 | lcd_getstringsize("A", &fw, &fh); | 1038 | lcd_getstringsize("A", &fw, &fh); |
1016 | tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; | 1039 | tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; |
1017 | /* make sure cursor is on screen */ | 1040 | /* make sure cursor is on screen */ |
1018 | while ( dircursor > tree_max_on_screen ) | 1041 | while ( dircursor > tree_max_on_screen ) |
1019 | { | 1042 | { |
1020 | dircursor--; | 1043 | dircursor--; |
1021 | dirstart++; | 1044 | dirstart++; |
@@ -1043,7 +1066,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1043 | /* chip-8 game */ | 1066 | /* chip-8 game */ |
1044 | case TREE_ATTR_CH8: | 1067 | case TREE_ATTR_CH8: |
1045 | plugin_load("/.rockbox/rocks/chip8.rock",buf); | 1068 | plugin_load("/.rockbox/rocks/chip8.rock",buf); |
1046 | break; | 1069 | break; |
1047 | 1070 | ||
1048 | case TREE_ATTR_FONT: | 1071 | case TREE_ATTR_FONT: |
1049 | font_load(buf); | 1072 | font_load(buf); |
@@ -1070,7 +1093,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1070 | /* ucl flash file */ | 1093 | /* ucl flash file */ |
1071 | case TREE_ATTR_UCL: | 1094 | case TREE_ATTR_UCL: |
1072 | plugin_load("/.rockbox/rocks/rockbox_flash.rock",buf); | 1095 | plugin_load("/.rockbox/rocks/rockbox_flash.rock",buf); |
1073 | break; | 1096 | break; |
1074 | #endif | 1097 | #endif |
1075 | 1098 | ||
1076 | /* plugin file */ | 1099 | /* plugin file */ |
@@ -1109,7 +1132,9 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1109 | 1132 | ||
1110 | case TREE_PREV: | 1133 | case TREE_PREV: |
1111 | case TREE_PREV | BUTTON_REPEAT: | 1134 | case TREE_PREV | BUTTON_REPEAT: |
1135 | #ifdef BUTTON_RC_LEFT | ||
1112 | case BUTTON_RC_LEFT: | 1136 | case BUTTON_RC_LEFT: |
1137 | #endif | ||
1113 | if(filesindir) { | 1138 | if(filesindir) { |
1114 | if(dircursor) { | 1139 | if(dircursor) { |
1115 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); | 1140 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); |
@@ -1147,7 +1172,9 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1147 | 1172 | ||
1148 | case TREE_NEXT: | 1173 | case TREE_NEXT: |
1149 | case TREE_NEXT | BUTTON_REPEAT: | 1174 | case TREE_NEXT | BUTTON_REPEAT: |
1175 | #ifdef BUTTON_RC_RIGHT | ||
1150 | case BUTTON_RC_RIGHT: | 1176 | case BUTTON_RC_RIGHT: |
1177 | #endif | ||
1151 | if(filesindir) | 1178 | if(filesindir) |
1152 | { | 1179 | { |
1153 | if (dircursor + dirstart + 1 < numentries ) { | 1180 | if (dircursor + dirstart + 1 < numentries ) { |
@@ -1155,7 +1182,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1155 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); | 1182 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); |
1156 | dircursor++; | 1183 | dircursor++; |
1157 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); | 1184 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); |
1158 | } | 1185 | } |
1159 | else { | 1186 | else { |
1160 | dirstart++; | 1187 | dirstart++; |
1161 | numentries = showdir(currdir, dirstart, dirfilter); | 1188 | numentries = showdir(currdir, dirstart, dirfilter); |
@@ -1168,7 +1195,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1168 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); | 1195 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); |
1169 | dirstart = dircursor = 0; | 1196 | dirstart = dircursor = 0; |
1170 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); | 1197 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); |
1171 | } | 1198 | } |
1172 | else { | 1199 | else { |
1173 | dirstart = dircursor = 0; | 1200 | dirstart = dircursor = 0; |
1174 | numentries = showdir(currdir, dirstart, dirfilter); | 1201 | numentries = showdir(currdir, dirstart, dirfilter); |
@@ -1190,6 +1217,8 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1190 | } | 1217 | } |
1191 | break; | 1218 | break; |
1192 | 1219 | ||
1220 | #ifdef BUTTON_ON /* I bet the folks without ON-button want this to | ||
1221 | work on a different button */ | ||
1193 | case BUTTON_ON: | 1222 | case BUTTON_ON: |
1194 | if (handle_on(&dirstart, &dircursor, numentries, | 1223 | if (handle_on(&dirstart, &dircursor, numentries, |
1195 | tree_max_on_screen, dirfilter)) | 1224 | tree_max_on_screen, dirfilter)) |
@@ -1216,6 +1245,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1216 | } | 1245 | } |
1217 | } | 1246 | } |
1218 | break; | 1247 | break; |
1248 | #endif | ||
1219 | 1249 | ||
1220 | #ifdef HAVE_RECORDER_KEYPAD | 1250 | #ifdef HAVE_RECORDER_KEYPAD |
1221 | case BUTTON_F2: | 1251 | case BUTTON_F2: |
@@ -1254,7 +1284,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1254 | 1284 | ||
1255 | if ( button ) | 1285 | if ( button ) |
1256 | ata_spin(); | 1286 | ata_spin(); |
1257 | 1287 | ||
1258 | /* do we need to rescan dir? */ | 1288 | /* do we need to rescan dir? */ |
1259 | if (reload_dir || reload_root || | 1289 | if (reload_dir || reload_root || |
1260 | lastfilter != *dirfilter || | 1290 | lastfilter != *dirfilter || |
@@ -1298,7 +1328,7 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1298 | numentries = showdir(currdir, dirstart, dirfilter); | 1328 | numentries = showdir(currdir, dirstart, dirfilter); |
1299 | update_all = true; | 1329 | update_all = true; |
1300 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); | 1330 | put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); |
1301 | 1331 | ||
1302 | need_update = true; | 1332 | need_update = true; |
1303 | reload_dir = false; | 1333 | reload_dir = false; |
1304 | } | 1334 | } |
@@ -1340,15 +1370,15 @@ static bool add_dir(char* dirname, int fd) | |||
1340 | bool abort = false; | 1370 | bool abort = false; |
1341 | char buf[MAX_PATH/2]; /* saving a little stack... */ | 1371 | char buf[MAX_PATH/2]; /* saving a little stack... */ |
1342 | DIR* dir; | 1372 | DIR* dir; |
1343 | 1373 | ||
1344 | /* check for user abort */ | 1374 | /* check for user abort */ |
1345 | #ifdef HAVE_PLAYER_KEYPAD | 1375 | #ifdef BUTTON_STOP |
1346 | if (button_get(false) == BUTTON_STOP) | 1376 | if (button_get(false) == BUTTON_STOP) |
1347 | #else | 1377 | #else |
1348 | if (button_get(false) == BUTTON_OFF) | 1378 | if (button_get(false) == BUTTON_OFF) |
1349 | #endif | 1379 | #endif |
1350 | return true; | 1380 | return true; |
1351 | 1381 | ||
1352 | dir = opendir(dirname); | 1382 | dir = opendir(dirname); |
1353 | if(!dir) | 1383 | if(!dir) |
1354 | return true; | 1384 | return true; |
@@ -1431,7 +1461,7 @@ bool create_playlist(void) | |||
1431 | add_dir(currdir[1] ? currdir : "/", fd); | 1461 | add_dir(currdir[1] ? currdir : "/", fd); |
1432 | close(fd); | 1462 | close(fd); |
1433 | sleep(HZ); | 1463 | sleep(HZ); |
1434 | 1464 | ||
1435 | return true; | 1465 | return true; |
1436 | } | 1466 | } |
1437 | 1467 | ||
@@ -1465,7 +1495,7 @@ void tree_init(void) | |||
1465 | use it until the next reboot. */ | 1495 | use it until the next reboot. */ |
1466 | max_files_in_dir = global_settings.max_files_in_dir; | 1496 | max_files_in_dir = global_settings.max_files_in_dir; |
1467 | name_buffer_size = AVERAGE_FILENAME_LENGTH * max_files_in_dir; | 1497 | name_buffer_size = AVERAGE_FILENAME_LENGTH * max_files_in_dir; |
1468 | 1498 | ||
1469 | name_buffer = buffer_alloc(name_buffer_size); | 1499 | name_buffer = buffer_alloc(name_buffer_size); |
1470 | dircache = buffer_alloc(max_files_in_dir * sizeof(struct entry)); | 1500 | dircache = buffer_alloc(max_files_in_dir * sizeof(struct entry)); |
1471 | } | 1501 | } |