summaryrefslogtreecommitdiff
path: root/apps/wps-display.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-09-06 13:43:26 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-09-06 13:43:26 +0000
commitff73f0dcbf49ddac923a1eae9b8e0e2d34c613a8 (patch)
tree6ed4830f2134137d31b263a86c4c9891c76bec48 /apps/wps-display.c
parentfbaf503d0d5506d4b4867e3b9bd468bb1bae381b (diff)
downloadrockbox-ff73f0dcbf49ddac923a1eae9b8e0e2d34c613a8.tar.gz
rockbox-ff73f0dcbf49ddac923a1eae9b8e0e2d34c613a8.zip
Changed WPS enum conditional functionality, displaying the last part in the list if the tag has no value. Also added enum support for battery (5 steps) and volume (10 steps).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7476 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/wps-display.c')
-rw-r--r--apps/wps-display.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c
index 9cb9e9601f..1aa21b72f5 100644
--- a/apps/wps-display.c
+++ b/apps/wps-display.c
@@ -617,7 +617,10 @@ static char* get_tag(struct mp3entry* cid3,
617 return buf; 617 return buf;
618 618
619 case 'c': /* File Codec */ 619 case 'c': /* File Codec */
620 *intval = id3->codectype; 620 if(id3->codectype == AFMT_UNKNOWN)
621 *intval = AFMT_NUM_CODECS;
622 else
623 *intval = id3->codectype;
621 return id3_get_codec(id3); 624 return id3_get_codec(id3);
622 } 625 }
623 break; 626 break;
@@ -697,6 +700,7 @@ static char* get_tag(struct mp3entry* cid3,
697 case 'v': /* volume */ 700 case 'v': /* volume */
698 *flags |= WPS_REFRESH_DYNAMIC; 701 *flags |= WPS_REFRESH_DYNAMIC;
699 snprintf(buf, buf_size, "%d%%", global_settings.volume); 702 snprintf(buf, buf_size, "%d%%", global_settings.volume);
703 *intval = global_settings.volume / 10 + 1;
700 return buf; 704 return buf;
701 705
702 } 706 }
@@ -752,9 +756,15 @@ static char* get_tag(struct mp3entry* cid3,
752 { 756 {
753 int l = battery_level(); 757 int l = battery_level();
754 if (l > -1) 758 if (l > -1)
759 {
755 snprintf(buf, buf_size, "%d%%", l); 760 snprintf(buf, buf_size, "%d%%", l);
761 *intval = l / 20 + 1;
762 }
756 else 763 else
764 {
765 *intval = 6;
757 return "?%"; 766 return "?%";
767 }
758 return buf; 768 return buf;
759 } 769 }
760 770
@@ -857,6 +867,7 @@ static const char* skip_conditional(const char* fmt, int num)
857{ 867{
858 int level = 1; 868 int level = 1;
859 int count = num; 869 int count = num;
870 const char *last_alternative = NULL;
860 871
861 while (*fmt) 872 while (*fmt)
862 { 873 {
@@ -867,6 +878,7 @@ static const char* skip_conditional(const char* fmt, int num)
867 878
868 case '|': 879 case '|':
869 if(1 == level) { 880 if(1 == level) {
881 last_alternative = fmt;
870 if(num) { 882 if(num) {
871 count--; 883 count--;
872 if(count == 0) 884 if(count == 0)
@@ -879,10 +891,18 @@ static const char* skip_conditional(const char* fmt, int num)
879 case '>': 891 case '>':
880 if (0 == --level) 892 if (0 == --level)
881 { 893 {
882 if (num) 894 /* We're just skipping to the end */
883 fmt--; 895 if(num == 0)
884 896 return fmt;
885 return fmt; 897
898 /* If we are parsing an enum, we'll return the selected
899 item. If there weren't enough items in the enum, we'll
900 return the last one found. */
901 if(count && last_alternative)
902 {
903 return last_alternative;
904 }
905 return fmt - 1;
886 } 906 }
887 continue; 907 continue;
888 908
@@ -1069,9 +1089,10 @@ static void format_display(char* buf,
1069 if ('<' == *fmt) 1089 if ('<' == *fmt)
1070 fmt++; 1090 fmt++;
1071 1091
1072 /* No value, so skip to else part */ 1092 /* No value, so skip to else part, using a sufficiently high
1093 value to "hit" the last part of the conditional */
1073 if ((!value) || (!strlen(value))) 1094 if ((!value) || (!strlen(value)))
1074 fmt = skip_conditional(fmt, 1); 1095 fmt = skip_conditional(fmt, 1000);
1075 else 1096 else
1076 if(intval > 1) /* enum */ 1097 if(intval > 1) /* enum */
1077 fmt = skip_conditional(fmt, intval - 1); 1098 fmt = skip_conditional(fmt, intval - 1);