summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ferrare <kevin@rockbox.org>2007-07-31 06:17:28 +0000
committerKevin Ferrare <kevin@rockbox.org>2007-07-31 06:17:28 +0000
commitf48d0ef7a23af5da9ddd6e8f5289e48f90c62ddd (patch)
tree68ca6c633db5f89f02ca3892f46a9d411be7c561
parent47bc31a174fff4981814186dd6dde3f729ae2d06 (diff)
downloadrockbox-f48d0ef7a23af5da9ddd6e8f5289e48f90c62ddd.tar.gz
rockbox-f48d0ef7a23af5da9ddd6e8f5289e48f90c62ddd.zip
Removed duplicated code for menu items definition, made the plugin use the action API
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14089 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/clock.c177
1 files changed, 42 insertions, 135 deletions
diff --git a/apps/plugins/clock.c b/apps/plugins/clock.c
index 8d0efeef43..c3df3ba472 100644
--- a/apps/plugins/clock.c
+++ b/apps/plugins/clock.c
@@ -94,6 +94,7 @@ Original release, featuring analog/digital modes and a few options.
94#include "xlcd.h" 94#include "xlcd.h"
95#include "oldmenuapi.h" 95#include "oldmenuapi.h"
96#include "fixedpoint.h" 96#include "fixedpoint.h"
97#include "pluginlib_actions.h"
97 98
98PLUGIN_HEADER 99PLUGIN_HEADER
99 100
@@ -168,66 +169,17 @@ PLUGIN_HEADER
168#define SMALLSEG_YOFS(x) (LCD_HEIGHT-x*SMALLSEG_HEIGHT)/2 169#define SMALLSEG_YOFS(x) (LCD_HEIGHT-x*SMALLSEG_HEIGHT)/2
169 170
170/* Keymaps */ 171/* Keymaps */
171#if (CONFIG_KEYPAD == RECORDER_PAD) 172const struct button_mapping* plugin_contexts[]={
172#define COUNTER_TOGGLE_BUTTON (BUTTON_ON|BUTTON_REL) 173 generic_actions,
173#define COUNTER_RESET_BUTTON (BUTTON_ON|BUTTON_REPEAT) 174 generic_directions
174#define MENU_BUTTON BUTTON_PLAY 175};
175#define ALT_MENU_BUTTON BUTTON_F1 176
176#define EXIT_BUTTON BUTTON_OFF 177#define ACTION_COUNTER_TOGGLE PLA_FIRE
177#define MODE_NEXT_BUTTON BUTTON_RIGHT 178#define ACTION_COUNTER_RESET PLA_FIRE_REPEAT
178#define MODE_PREV_BUTTON BUTTON_LEFT 179#define ACTION_MENU PLA_MENU
179#elif (CONFIG_KEYPAD == ARCHOS_AV300_PAD) 180#define ACTION_EXIT PLA_QUIT
180#define COUNTER_TOGGLE_BUTTON (BUTTON_ON|BUTTON_REL) 181#define ACTION_MODE_NEXT PLA_RIGHT
181#define COUNTER_RESET_BUTTON (BUTTON_ON|BUTTON_REPEAT) 182#define ACTION_MODE_PREV PLA_LEFT
182#define MENU_BUTTON BUTTON_SELECT
183#define ALT_MENU_BUTTON BUTTON_F1
184#define EXIT_BUTTON BUTTON_OFF
185#define MODE_NEXT_BUTTON BUTTON_RIGHT
186#define MODE_PREV_BUTTON BUTTON_LEFT
187#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD)
188#define COUNTER_TOGGLE_BUTTON (BUTTON_PLAY|BUTTON_REL)
189#define COUNTER_RESET_BUTTON (BUTTON_PLAY|BUTTON_REPEAT)
190#define MENU_BUTTON BUTTON_SELECT
191#define EXIT_BUTTON BUTTON_MENU
192#define MODE_NEXT_BUTTON BUTTON_RIGHT
193#define MODE_PREV_BUTTON BUTTON_LEFT
194#elif (CONFIG_KEYPAD == IRIVER_H300_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD)
195#define COUNTER_TOGGLE_BUTTON (BUTTON_ON|BUTTON_REL)
196#define COUNTER_RESET_BUTTON (BUTTON_ON|BUTTON_REPEAT)
197#define MENU_BUTTON BUTTON_SELECT
198#define EXIT_BUTTON BUTTON_OFF
199#define MODE_NEXT_BUTTON BUTTON_RIGHT
200#define MODE_PREV_BUTTON BUTTON_LEFT
201#define EXIT_RC_BUTTON BUTTON_RC_STOP
202#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
203#define COUNTER_TOGGLE_BUTTON (BUTTON_PLAY|BUTTON_REL)
204#define COUNTER_RESET_BUTTON (BUTTON_PLAY|BUTTON_REPEAT)
205#define MENU_BUTTON BUTTON_SELECT
206#define EXIT_BUTTON BUTTON_POWER
207#define MODE_NEXT_BUTTON BUTTON_RIGHT
208#define MODE_PREV_BUTTON BUTTON_LEFT
209#elif (CONFIG_KEYPAD == SANSA_E200_PAD)
210#define COUNTER_TOGGLE_BUTTON BUTTON_UP
211#define COUNTER_RESET_BUTTON BUTTON_DOWN
212#define MENU_BUTTON BUTTON_SELECT
213#define EXIT_BUTTON BUTTON_POWER
214#define MODE_NEXT_BUTTON BUTTON_RIGHT
215#define MODE_PREV_BUTTON BUTTON_LEFT
216#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
217#define COUNTER_TOGGLE_BUTTON (BUTTON_PLAY|BUTTON_REL)
218#define COUNTER_RESET_BUTTON (BUTTON_PLAY|BUTTON_REPEAT)
219#define MENU_BUTTON BUTTON_REW
220#define EXIT_BUTTON BUTTON_POWER
221#define MODE_NEXT_BUTTON BUTTON_RIGHT
222#define MODE_PREV_BUTTON BUTTON_LEFT
223#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
224#define COUNTER_TOGGLE_BUTTON (BUTTON_SELECT|BUTTON_REL)
225#define COUNTER_RESET_BUTTON (BUTTON_SELECT|BUTTON_REPEAT)
226#define MENU_BUTTON BUTTON_MENU
227#define EXIT_BUTTON BUTTON_A
228#define MODE_NEXT_BUTTON BUTTON_RIGHT
229#define MODE_PREV_BUTTON BUTTON_LEFT
230#endif
231 183
232/************ 184/************
233 * Prototypes 185 * Prototypes
@@ -349,14 +301,7 @@ static const struct opt_items noyes_text[2] = {
349 { "No", -1 }, 301 { "No", -1 },
350 { "Yes", -1 } 302 { "Yes", -1 }
351}; 303};
352static const struct opt_items saving_options_text[2] = { 304
353 { "No", -1 },
354 { "Yes", -1 }
355};
356static const struct opt_items show_counter_text[2] = {
357 { "No", -1 },
358 { "Yes", -1 }
359};
360static const struct opt_items backlight_settings_text[3] = { 305static const struct opt_items backlight_settings_text[3] = {
361 { "Always Off", -1 }, 306 { "Always Off", -1 },
362 { "Rockbox setting", -1 }, 307 { "Rockbox setting", -1 },
@@ -370,66 +315,27 @@ static const struct opt_items counting_direction_text[2] = {
370 {"Down", -1}, 315 {"Down", -1},
371 {"Up", -1} 316 {"Up", -1}
372}; 317};
373static const struct opt_items analog_date_text[3] = { 318static const struct opt_items date_format_text[] = {
374 { "No", -1 }, 319 { "No", -1 },
375 { "American format", -1 }, 320 { "American format", -1 },
376 { "European format", -1 } 321 { "European format", -1 }
377}; 322};
378static const struct opt_items analog_secondhand_text[2] = { 323
379 { "No", -1 },
380 { "Yes", -1 }
381};
382static const struct opt_items analog_time_text[3] = { 324static const struct opt_items analog_time_text[3] = {
383 { "No", -1 }, 325 { "No", -1 },
384 { "24-hour Format", -1 }, 326 { "24-hour Format", -1 },
385 { "12-hour Format", -1 } 327 { "12-hour Format", -1 }
386}; 328};
387static const struct opt_items digital_seconds_text[2] = { 329
388 { "No", -1 }, 330static const struct opt_items time_format_text[2] = {
389 { "Yes", -1 }
390};
391static const struct opt_items digital_date_text[3] = {
392 { "No", -1 },
393 { "American format", -1 },
394 { "European format", -1 }
395};
396static const struct opt_items digital_blinkcolon_text[2] = {
397 { "No", -1 },
398 { "Yes", -1 }
399};
400static const struct opt_items digital_format_text[2] = {
401 { "24-hour Format", -1 }, 331 { "24-hour Format", -1 },
402 { "12-hour Format", -1 } 332 { "12-hour Format", -1 }
403}; 333};
404static const struct opt_items fullscreen_border_text[2] = { 334
405 { "No", -1 },
406 { "Yes", -1 }
407};
408static const struct opt_items fullscreen_secondhand_text[2] = {
409 { "No", -1 },
410 { "Yes", -1 }
411};
412static const struct opt_items binary_mode_text[2] = { 335static const struct opt_items binary_mode_text[2] = {
413 { "Numbers", -1 }, 336 { "Numbers", -1 },
414 { "Dots", -1 } 337 { "Dots", -1 }
415}; 338};
416static const struct opt_items plain_date_text[3] = {
417 { "No", -1 },
418 { "American format", -1 },
419 { "European format", -1 }
420};
421static const struct opt_items plain_seconds_text[3] = {
422 { "No", -1 },
423 { "Yes", -1 }
424};
425static const struct opt_items plain_blinkcolon_text[2] = {
426 { "No", -1 },
427 { "Yes", -1 }
428};
429static const struct opt_items plain_format_text[3] = {
430 { "24-hour Format", -1 },
431 { "12-hour Format", -1 }
432};
433 339
434/***************************************** 340/*****************************************
435 * All settings, saved to default_filename 341 * All settings, saved to default_filename
@@ -1057,11 +963,11 @@ void analog_settings_menu(void)
1057 { 963 {
1058 case 0: 964 case 0:
1059 rb->set_option("Show Date", &settings.analog[analog_date], 965 rb->set_option("Show Date", &settings.analog[analog_date],
1060 INT, analog_date_text, 3, NULL); 966 INT, date_format_text, 3, NULL);
1061 break; 967 break;
1062 case 1: 968 case 1:
1063 rb->set_option("Show Second Hand", &settings.analog[analog_secondhand], 969 rb->set_option("Show Second Hand", &settings.analog[analog_secondhand],
1064 INT, analog_secondhand_text, 2, NULL); 970 INT, noyes_text, 2, NULL);
1065 break; 971 break;
1066 case 2: 972 case 2:
1067 rb->set_option("Show Time", &settings.analog[analog_time], 973 rb->set_option("Show Time", &settings.analog[analog_time],
@@ -1102,19 +1008,19 @@ void digital_settings_menu(void)
1102 { 1008 {
1103 case 0: 1009 case 0:
1104 rb->set_option("Show Seconds", &settings.digital[digital_seconds], 1010 rb->set_option("Show Seconds", &settings.digital[digital_seconds],
1105 INT, digital_seconds_text, 2, NULL); 1011 INT, noyes_text, 2, NULL);
1106 break; 1012 break;
1107 case 1: 1013 case 1:
1108 rb->set_option("Show Date", &settings.digital[digital_date], 1014 rb->set_option("Show Date", &settings.digital[digital_date],
1109 INT, digital_date_text, 3, NULL); 1015 INT, date_format_text, 3, NULL);
1110 break; 1016 break;
1111 case 2: 1017 case 2:
1112 rb->set_option("Blinking Colon", &settings.digital[digital_blinkcolon], 1018 rb->set_option("Blinking Colon", &settings.digital[digital_blinkcolon],
1113 INT, digital_blinkcolon_text, 2, NULL); 1019 INT, noyes_text, 2, NULL);
1114 break; 1020 break;
1115 case 3: 1021 case 3:
1116 rb->set_option("Time Format", &settings.digital[digital_format], 1022 rb->set_option("Time Format", &settings.digital[digital_format],
1117 INT, digital_format_text, 2, NULL); 1023 INT, time_format_text, 2, NULL);
1118 break; 1024 break;
1119 1025
1120 default: 1026 default:
@@ -1151,11 +1057,11 @@ void fullscreen_settings_menu(void)
1151 { 1057 {
1152 case 0: 1058 case 0:
1153 rb->set_option("Show Border", &settings.fullscreen[fullscreen_border], 1059 rb->set_option("Show Border", &settings.fullscreen[fullscreen_border],
1154 INT, fullscreen_border_text, 2, NULL); 1060 INT, noyes_text, 2, NULL);
1155 break; 1061 break;
1156 case 1: 1062 case 1:
1157 rb->set_option("Show Second Hand", &settings.fullscreen[fullscreen_secondhand], 1063 rb->set_option("Show Second Hand", &settings.fullscreen[fullscreen_secondhand],
1158 INT, fullscreen_secondhand_text, 2, NULL); 1064 INT, noyes_text, 2, NULL);
1159 break; 1065 break;
1160 1066
1161 default: 1067 default:
@@ -1229,19 +1135,19 @@ void plain_settings_menu(void)
1229 { 1135 {
1230 case 0: 1136 case 0:
1231 rb->set_option("Show Date", &settings.plain[plain_date], 1137 rb->set_option("Show Date", &settings.plain[plain_date],
1232 INT, plain_date_text, 3, NULL); 1138 INT, date_format_text, 3, NULL);
1233 break; 1139 break;
1234 case 1: 1140 case 1:
1235 rb->set_option("Show Seconds", &settings.plain[plain_seconds], 1141 rb->set_option("Show Seconds", &settings.plain[plain_seconds],
1236 INT, plain_seconds_text, 2, NULL); 1142 INT, noyes_text, 2, NULL);
1237 break; 1143 break;
1238 case 2: 1144 case 2:
1239 rb->set_option("Blinking Colon", &settings.plain[plain_blinkcolon], 1145 rb->set_option("Blinking Colon", &settings.plain[plain_blinkcolon],
1240 INT, plain_blinkcolon_text, 2, NULL); 1146 INT, noyes_text, 2, NULL);
1241 break; 1147 break;
1242 case 3: 1148 case 3:
1243 rb->set_option("Time Format", &settings.plain[plain_format], 1149 rb->set_option("Time Format", &settings.plain[plain_format],
1244 INT, plain_format_text, 2, NULL); 1150 INT, time_format_text, 2, NULL);
1245 break; 1151 break;
1246 1152
1247 default: 1153 default:
@@ -1323,7 +1229,7 @@ void general_settings(void)
1323 1229
1324 case 2: 1230 case 2:
1325 rb->set_option("Save On Exit", &settings.general[general_savesetting], 1231 rb->set_option("Save On Exit", &settings.general[general_savesetting],
1326 INT, saving_options_text, 2, NULL); 1232 INT, noyes_text, 2, NULL);
1327 1233
1328 /* if we no longer save on exit, we better save now to remember that */ 1234 /* if we no longer save on exit, we better save now to remember that */
1329 if(settings.general[general_savesetting] == 0) 1235 if(settings.general[general_savesetting] == 0)
@@ -1332,7 +1238,7 @@ void general_settings(void)
1332 1238
1333 case 3: 1239 case 3:
1334 rb->set_option("Show Counter", &settings.general[general_counter], 1240 rb->set_option("Show Counter", &settings.general[general_counter],
1335 INT, show_counter_text, 2, NULL); 1241 INT, noyes_text, 2, NULL);
1336 break; 1242 break;
1337 1243
1338 case 4: 1244 case 4:
@@ -1843,10 +1749,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1843 /************************* 1749 /*************************
1844 * Scan for button presses 1750 * Scan for button presses
1845 ************************/ 1751 ************************/
1846 button = rb->button_get_w_tmo(HZ/10); 1752 button = pluginlib_getaction(rb, HZ/10, plugin_contexts, 2);
1847 switch (button) 1753 switch (button)
1848 { 1754 {
1849 case COUNTER_TOGGLE_BUTTON: /* start/stop counter */ 1755 case ACTION_COUNTER_TOGGLE: /* start/stop counter */
1850 if(settings.general[general_counter]) 1756 if(settings.general[general_counter])
1851 { 1757 {
1852 if(!counter_btn_held) /* Ignore if the counter was reset */ 1758 if(!counter_btn_held) /* Ignore if the counter was reset */
@@ -1866,7 +1772,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1866 } 1772 }
1867 break; 1773 break;
1868 1774
1869 case COUNTER_RESET_BUTTON: /* reset counter */ 1775 case ACTION_COUNTER_RESET: /* reset counter */
1870 if(settings.general[general_counter]) 1776 if(settings.general[general_counter])
1871 { 1777 {
1872 counter_btn_held = true; /* Ignore the release event */ 1778 counter_btn_held = true; /* Ignore the release event */
@@ -1875,7 +1781,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1875 } 1781 }
1876 break; 1782 break;
1877 1783
1878 case MODE_NEXT_BUTTON: 1784 case ACTION_MODE_NEXT:
1879 if(settings.clock < CLOCK_MODES) 1785 if(settings.clock < CLOCK_MODES)
1880 settings.clock++; 1786 settings.clock++;
1881 else 1787 else
@@ -1884,7 +1790,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1884 set_digital_colors(); 1790 set_digital_colors();
1885 break; 1791 break;
1886 1792
1887 case MODE_PREV_BUTTON: 1793 case ACTION_MODE_PREV:
1888 if(settings.clock > 1) 1794 if(settings.clock > 1)
1889 settings.clock--; 1795 settings.clock--;
1890 else 1796 else
@@ -1893,13 +1799,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1893 set_digital_colors(); 1799 set_digital_colors();
1894 break; 1800 break;
1895 1801
1896 case MENU_BUTTON: /* main menu */ 1802 case ACTION_MENU: /* main menu */
1897#ifdef ALT_MENU_BUTTON
1898 case ALT_MENU_BUTTON:
1899#endif
1900 main_menu(); 1803 main_menu();
1901 break; 1804 break;
1902 1805
1806 case ACTION_EXIT: /* main menu */
1807 exit_clock=true;
1808 break;
1809
1903 default: 1810 default:
1904 if(rb->default_event_handler_ex(button, cleanup, NULL) 1811 if(rb->default_event_handler_ex(button, cleanup, NULL)
1905 == SYS_USB_CONNECTED) 1812 == SYS_USB_CONNECTED)