summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/mpeg_settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_settings.c')
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c106
1 files changed, 82 insertions, 24 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 964bad08bd..28062f4567 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -9,41 +9,87 @@ extern struct plugin_api* rb;
9struct mpeg_settings settings; 9struct mpeg_settings settings;
10static struct mpeg_settings old_settings; 10static struct mpeg_settings old_settings;
11 11
12#define SETTINGS_VERSION 1 12#define SETTINGS_VERSION 2
13#define SETTINGS_MIN_VERSION 1 13#define SETTINGS_MIN_VERSION 1
14#define SETTINGS_FILENAME "mpegplayer.cfg" 14#define SETTINGS_FILENAME "mpegplayer.cfg"
15 15
16static char* showfps_options[] = {"No", "Yes"};
17static char* limitfps_options[] = {"No", "Yes"};
18static char* skipframes_options[] = {"No", "Yes"};
19
20static struct configdata config[] = 16static struct configdata config[] =
21{ 17{
22 {TYPE_ENUM, 0, 2, &settings.showfps, "Show FPS", showfps_options, NULL}, 18 {TYPE_ENUM, 0, 2, &settings.showfps, "Show FPS",
23 {TYPE_ENUM, 0, 2, &settings.limitfps, "Limit FPS", limitfps_options, NULL}, 19 (char *[]){ "No", "Yes" }, NULL},
24 {TYPE_ENUM, 0, 2, &settings.skipframes, "Skip frames", skipframes_options, NULL}, 20 {TYPE_ENUM, 0, 2, &settings.limitfps, "Limit FPS",
21 (char *[]){ "No", "Yes" }, NULL},
22 {TYPE_ENUM, 0, 2, &settings.skipframes, "Skip frames",
23 (char *[]){ "No", "Yes" }, NULL},
24#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
25 {TYPE_INT, 0, INT_MAX, &settings.displayoptions, "Display options",
26 NULL, NULL},
27#endif
28};
29
30enum mpeg_menu_ids
31{
32 __MPEG_OPTION_START = -1,
33#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
34 MPEG_OPTION_DISPLAY_SETTINGS,
35#endif
36 MPEG_OPTION_DISPLAY_FPS,
37 MPEG_OPTION_LIMIT_FPS,
38 MPEG_OPTION_SKIP_FRAMES,
39 MPEG_OPTION_QUIT,
40};
41
42static const struct opt_items noyes[2] = {
43 { "No", -1 },
44 { "Yes", -1 },
25}; 45};
26 46
47#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
48static bool set_option_dithering(void)
49{
50 int val = (settings.displayoptions & LCD_YUV_DITHER) ? 1 : 0;
51 rb->set_option("Dithering", &val, INT, noyes, 2, NULL);
52 settings.displayoptions = (settings.displayoptions & ~LCD_YUV_DITHER)
53 | ((val != 0) ? LCD_YUV_DITHER : 0);
54 rb->lcd_yuv_set_options(settings.displayoptions);
55 return false;
56}
57
58static void display_options(void)
59{
60 static const struct menu_item items[] = {
61 { "Dithering", set_option_dithering },
62 };
63
64 int m = menu_init(rb, items, ARRAYLEN(items),
65 NULL, NULL, NULL, NULL);
66 menu_run(m);
67 menu_exit(m);
68}
69#endif /* #ifdef TOSHIBA_GIGABEAT_F */
70
27bool mpeg_menu(void) 71bool mpeg_menu(void)
28{ 72{
29 int m; 73 int m;
30 int result; 74 int result;
31 int menu_quit=0; 75 int menu_quit=0;
32 76
33 static const struct opt_items noyes[2] = {
34 { "No", -1 },
35 { "Yes", -1 },
36 };
37
38 static const struct menu_item items[] = { 77 static const struct menu_item items[] = {
39 { "Display FPS", NULL }, 78#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
40 { "Limit FPS", NULL }, 79 [MPEG_OPTION_DISPLAY_SETTINGS] =
41 { "Skip frames", NULL }, 80 { "Display Options", NULL },
42 { "Quit mpegplayer", NULL }, 81#endif
82 [MPEG_OPTION_DISPLAY_FPS] =
83 { "Display FPS", NULL },
84 [MPEG_OPTION_LIMIT_FPS] =
85 { "Limit FPS", NULL },
86 [MPEG_OPTION_SKIP_FRAMES] =
87 { "Skip frames", NULL },
88 [MPEG_OPTION_QUIT] =
89 { "Quit mpegplayer", NULL },
43 }; 90 };
44 91
45 m = menu_init(rb, items, sizeof(items) / sizeof(*items), 92 m = menu_init(rb, items, ARRAYLEN(items), NULL, NULL, NULL, NULL);
46 NULL, NULL, NULL, NULL);
47 93
48 rb->button_clear_queue(); 94 rb->button_clear_queue();
49 95
@@ -52,22 +98,28 @@ bool mpeg_menu(void)
52 98
53 switch(result) 99 switch(result)
54 { 100 {
55 case 0: /* Show FPS */ 101#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
102 case MPEG_OPTION_DISPLAY_SETTINGS:
103 display_options();
104 break;
105#endif
106 case MPEG_OPTION_DISPLAY_FPS:
56 rb->set_option("Display FPS",&settings.showfps,INT, 107 rb->set_option("Display FPS",&settings.showfps,INT,
57 noyes, 2, NULL); 108 noyes, 2, NULL);
58 break; 109 break;
59 case 1: /* Limit FPS */ 110 case MPEG_OPTION_LIMIT_FPS:
60 rb->set_option("Limit FPS",&settings.limitfps,INT, 111 rb->set_option("Limit FPS",&settings.limitfps,INT,
61 noyes, 2, NULL); 112 noyes, 2, NULL);
62 break; 113 break;
63 case 2: /* Skip frames */ 114 case MPEG_OPTION_SKIP_FRAMES:
64 rb->set_option("Skip frames",&settings.skipframes,INT, 115 rb->set_option("Skip frames",&settings.skipframes,INT,
65 noyes, 2, NULL); 116 noyes, 2, NULL);
66 break; 117 break;
118 case MPEG_OPTION_QUIT:
67 default: 119 default:
68 menu_quit=1; 120 menu_quit=1;
69 if (result == MENU_ATTACHED_USB) 121 if (result == MENU_ATTACHED_USB)
70 result = 3; 122 result = MPEG_OPTION_QUIT;
71 break; 123 break;
72 } 124 }
73 } 125 }
@@ -77,7 +129,7 @@ bool mpeg_menu(void)
77 rb->lcd_clear_display(); 129 rb->lcd_clear_display();
78 rb->lcd_update(); 130 rb->lcd_update();
79 131
80 return (result==3); 132 return (result==MPEG_OPTION_QUIT);
81} 133}
82 134
83 135
@@ -87,6 +139,9 @@ void init_settings(void)
87 settings.showfps = 0; /* Do not show FPS */ 139 settings.showfps = 0; /* Do not show FPS */
88 settings.limitfps = 1; /* Limit FPS */ 140 settings.limitfps = 1; /* Limit FPS */
89 settings.skipframes = 1; /* Skip frames */ 141 settings.skipframes = 1; /* Skip frames */
142#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
143 settings.displayoptions = 0; /* No visual effects */
144#endif
90 145
91 configfile_init(rb); 146 configfile_init(rb);
92 147
@@ -105,6 +160,9 @@ void init_settings(void)
105 /* Keep a copy of the saved version of the settings - so we can check if 160 /* Keep a copy of the saved version of the settings - so we can check if
106 the settings have changed when we quit */ 161 the settings have changed when we quit */
107 old_settings = settings; 162 old_settings = settings;
163#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
164 rb->lcd_yuv_set_options(settings.displayoptions);
165#endif
108} 166}
109 167
110void save_settings(void) 168void save_settings(void)