From 55eb1c54ebe33faa8b1eb8c527d5644961ca78dc Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sun, 3 Feb 2019 20:12:50 -0500 Subject: [PATCH] FS#7704 - Talk support for plugins Original patch by Mario Lang Heavily updated by Igor Poretsky Further updated by myself This patch breaks binary API compatibility by placing the new functions where they make the most logical sense. IMO this is the better approach to take given the scope of the changes needed for talk support. Since binary API is changing, the patch also moves some other functions around to more logical locations. As well as voice support in plugins, this patch voice-enables several simple plugins. There will be follow-up patches for many plugins that build on this one. Change-Id: I18070c06e77e8a3c016c2eb6b6c5dbe6633b9b54 --- apps/lang/english.lang | 382 +++++++++++++++++++++++++++- apps/lang/lang.make | 2 + apps/plugin.c | 65 +++-- apps/plugin.h | 71 ++++-- apps/plugins/dice.c | 16 +- apps/plugins/fireworks.c | 52 ++-- apps/plugins/lib/playback_control.c | 16 +- apps/plugins/wavrecord.c | 22 +- apps/plugins/wormlet.c | 58 +++-- apps/talk.c | 3 - apps/talk.h | 6 +- tools/genlang | 23 +- 12 files changed, 583 insertions(+), 133 deletions(-) diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 265fcd6844..7a3b257429 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -1255,19 +1255,22 @@ id: LANG_DITHERING - desc: in the sound settings menu + desc: in the sound settings and some other menus user: core *: none swcodec: "Dithering" + lcd_bitmap: "Dithering" *: none swcodec: "Dithering" + lcd_bitmap: "Dithering" *: none swcodec: "Dithering" + lcd_bitmap: "Dithering" @@ -8259,7 +8262,7 @@ *: "Incompatible model" - *: "" + *: "Incompatible model" @@ -8273,7 +8276,7 @@ *: "Incompatible version" - *: "" + *: "Incompatible version" @@ -8287,7 +8290,7 @@ *: "Plugin returned error" - *: "" + *: "Plugin returned error" @@ -14051,3 +14054,374 @@ pitchscreen: "Time stretch" + + id: LANG_REMOTE_CONTROL + desc: Item for menus + user: core + + *: "Remote Control" + + + *: "Remote Control" + + + *: "Remote Control" + + + + id: LANG_NO_REM_CONTROL + desc: Item for menus + user: core + + *: "No Rem. Control" + + + *: "No Rem. Control" + + + *: "No Remote Control" + + + + id: LANG_OUT_OF_CONTROL + desc: Item for menus + user: core + + *: "Out of Control" + + + *: "Out of Control" + + + *: "Out of Control" + + + + id: LANG_2_KEY_CONTROL + desc: Item for menus + user: core + + *: "2 Key Control" + + + *: "2 Key Control" + + + *: "2 Key Control" + + + + id: LANG_4_KEY_CONTROL + desc: Item for menus + user: core + + *: "4 Key Control" + + + *: "4 Key Control" + + + *: "4 Key Control" + + + + id: LANG_PLAY_WORMLET + desc: For wormlet menu + user: core + + *: none + lcd_bitmap: "Play Wormlet!" + + + *: none + lcd_bitmap: "Play Wormlet!" + + + *: none + lcd_bitmap: "Play Wormlet!" + + + + id: LANG_NUMBER_OF_WORMS + desc: For wormlet menu + user: core + + *: none + lcd_bitmap: "Number of Worms" + + + *: none + lcd_bitmap: "Number of Worms" + + + *: none + lcd_bitmap: "Number of Worms" + + + + id: LANG_WORM_GROWTH_PER_FOOD + desc: For wormlet menu + user: core + + *: none + lcd_bitmap: "Worm Growth Per Food" + + + *: none + lcd_bitmap: "Worm Growth Per Food" + + + *: none + lcd_bitmap: "Worm Growth Per Food" + + + + id: LANG_WORM_SPEED + desc: For wormlet menu + user: core + + *: none + lcd_bitmap: "Worm Speed" + + + *: none + lcd_bitmap: "Worm Speed" + + + *: none + lcd_bitmap: "Worm Speed" + + + + id: LANG_ARGHS_PER_FOOD + desc: For wormlet menu + user: core + + *: none + lcd_bitmap: "Arghs Per Food" + + + *: none + lcd_bitmap: "Arghs Per Food" + + + *: none + lcd_bitmap: "Arghs Per Food" + + + + id: LANG_ARGH_SIZE + desc: For wormlet menu + user: core + + *: none + lcd_bitmap: "Argh Size" + + + *: none + lcd_bitmap: "Argh Size" + + + *: none + lcd_bitmap: "Argh Size" + + + + id: LANG_FOOD_SIZE + desc: For wormlet menu + user: core + + *: none + lcd_bitmap: "Food Size" + + + *: none + lcd_bitmap: "Food Size" + + + *: none + lcd_bitmap: "Food Size" + + + + id: LANG_NUMBER_OF_PLAYERS + desc: For game menus + user: core + + *: "Number of Players" + + + *: "Number of Players" + + + *: "Number of Players" + + + + id: LANG_CONTROL_STYLE + desc: In various menus + user: core + + *: "Control Style" + + + *: "Control Style" + + + *: "Control Style" + + + + id: LANG_REVERT_TO_DEFAULT_SETTINGS + desc: In various menus + user: core + + *: "Revert to Default Settings" + + + *: "Revert to Default Settings" + + + *: "Revert to Default Settings" + + + + id: LANG_MENU_QUIT + desc: in various menus + user: core + + *: "Quit" + + + *: "Quit" + + + *: "Quit" + + + + id: LANG_MENU_DISPLAY_OPTIONS + desc: in various menus + user: core + + *: "Display Options" + + + *: "Display Options" + + + *: "Display Options" + + + + id: LANG_PREVTRACK + desc: in playback control menu + user: core + + *: "Previous Track" + + + *: "Previous Track" + + + *: "Previous Track" + + + + id: LANG_PLAYPAUSE + desc: in playback control menu + user: core + + *: "Pause / Play" + + + *: "Pause / Play" + + + *: "Pause / Play" + + + + id: LANG_STOP_PLAYBACK + desc: in playback control menu + user: core + + *: "Stop Playback" + + + *: "Stop Playback" + + + *: "Stop Playback" + + + + id: LANG_NEXTTRACK + desc: in playback control menu + user: core + + *: "Next Track" + + + *: "Next Track" + + + *: "Next Track" + + + + id: LANG_CHANGE_VOLUME + desc: in playback control menu + user: core + + *: "Change Volume" + + + *: "Change Volume" + + + *: "Change Volume" + + + + id: LANG_CHANGE_SHUFFLE_MODE + desc: in playback control menu + user: core + + *: "Shuffle Mode" + + + *: "Shuffle Mode" + + + *: "Shuffle Mode" + + + + id: LANG_CHANGE_REPEAT_MODE + desc: in playback control menu + user: core + + *: "Change Repeat Mode" + + + *: "Change Repeat Mode" + + + *: "Change Repeat Mode" + + + + id: LANG_PLAYBACK_CONTROL + desc: in playback control menu + user: core + + *: "Playback Control" + + + *: "Playback Control" + + + *: "Playback Control" + + diff --git a/apps/lang/lang.make b/apps/lang/lang.make index cee2456b5d..ee01c5742a 100644 --- a/apps/lang/lang.make +++ b/apps/lang/lang.make @@ -42,6 +42,8 @@ $(BUILDDIR)/lang/lang.h: $(APPSDIR)/lang/$(LANGUAGE).lang $(BUILDDIR)/apps/featu perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(MODELNAME)$$feat $< $(BUILDDIR)/lang/lang_core.c: $(BUILDDIR)/lang/lang.h +$(BUILDDIR)/lang_enum.h: $(BUILDDIR)/lang/lang.h + # NOTE: for some weird reasons in GNU make, multi targets rules WITH patterns actually express # the fact that the two files are created as the result of one invocation of the rule $(BUILDDIR)/%.lng $(BUILDDIR)/%.vstrings: $(ROOTDIR)/%.lang $(BUILDDIR)/apps/genlang-features diff --git a/apps/plugin.c b/apps/plugin.c index 97ff7c8c43..7d4199a607 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -176,6 +176,10 @@ static void plugin_check_open_close__exit(void) #endif /* HAVE_PLUGIN_CHECK_OPEN_CLOSE */ static const struct plugin_api rockbox_api = { + rbversion, + &global_settings, + &global_status, + language_strings, /* lcd */ #ifdef HAVE_LCD_CONTRAST @@ -258,6 +262,7 @@ static const struct plugin_api rockbox_api = { bidi_l2v, #ifdef HAVE_LCD_BITMAP is_diacritic, + get_codepage_name, #endif font_get_bits, font_load, @@ -268,7 +273,6 @@ static const struct plugin_api rockbox_api = { screen_clear_area, gui_scrollbar_draw, #endif /* HAVE_LCD_BITMAP */ - get_codepage_name, backlight_on, backlight_off, @@ -334,14 +338,16 @@ static const struct plugin_api rockbox_api = { viewportmanager_theme_undo, viewport_set_fullscreen, #endif - + /* list */ gui_synclist_init, gui_synclist_set_nb_items, + gui_synclist_set_voice_callback, gui_synclist_set_icon_callback, gui_synclist_get_nb_items, gui_synclist_get_sel_pos, gui_synclist_draw, + gui_synclist_speak_item, gui_synclist_select_item, gui_synclist_add_item, gui_synclist_del_item, @@ -369,7 +375,7 @@ static const struct plugin_api rockbox_api = { touchscreen_set_mode, touchscreen_get_mode, #endif - + #ifdef HAVE_BUTTON_LIGHT buttonlight_set_timeout, buttonlight_off, @@ -421,6 +427,21 @@ static const struct plugin_api rockbox_api = { browse_context_init, rockbox_browse, + /* talking */ + talk_id, + talk_file, + talk_file_or_spell, + talk_dir_or_spell, + talk_number, + talk_value, + talk_spell, + talk_time, + talk_date, + talk_disable, + talk_shutup, + talk_force_shutup, + talk_force_enqueue_next, + /* kernel/ system */ #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE __div0, @@ -541,7 +562,7 @@ static const struct plugin_api rockbox_api = { utf8encode, utf8length, utf8seek, - + /* the buflib memory management library */ buflib_init, buflib_available, @@ -625,6 +646,7 @@ static const struct plugin_api rockbox_api = { mixer_set_frequency, mixer_get_frequency, + pcmbuf_fade, system_sound_play, keyclick_click, #endif /* CONFIG_CODEC == SWCODEC */ @@ -676,7 +698,12 @@ static const struct plugin_api rockbox_api = { #endif /* !SIMULATOR && CONFIG_CODEC != SWCODEC */ /* menu */ + root_menu_get_options, do_menu, + root_menu_set_default, + root_menu_write_to_cfg, + root_menu_load_from_cfg, + /* statusbars */ &statusbars, gui_syncstatusbar_draw, @@ -684,10 +711,12 @@ static const struct plugin_api rockbox_api = { /* options */ get_settings_list, find_setting, + settings_save, option_screen, set_option, set_bool_options, set_int, + set_int_ex, set_bool, #ifdef HAVE_LCD_COLOR set_color, @@ -731,17 +760,17 @@ static const struct plugin_api rockbox_api = { plugin_get_buffer, plugin_get_audio_buffer, /* defined in plugin.c */ plugin_release_audio_buffer, /* defined in plugin.c */ - plugin_tsr, /* defined in plugin.c */ + plugin_tsr, /* defined in plugin.c */ plugin_get_current_filename, +#ifdef PLUGIN_USE_IRAM + audio_hard_stop, +#endif #if defined(DEBUG) || defined(SIMULATOR) debugf, #endif #ifdef ROCKBOX_HAS_LOGF _logf, #endif - &global_settings, - &global_status, - talk_disable, #if CONFIG_CODEC == SWCODEC codec_thread_do_callback, codec_load_file, @@ -813,13 +842,6 @@ static const struct plugin_api rockbox_api = { semaphore_release, #endif - rbversion, - root_menu_get_options, - root_menu_set_default, - root_menu_write_to_cfg, - root_menu_load_from_cfg, - settings_save, - /* new stuff at the end, sort into place next time the API gets incompatible */ }; @@ -857,7 +879,7 @@ int plugin_load(const char* plugin, const void* parameter) p_hdr = lc_get_header(current_plugin_handle); hdr = p_hdr ? &p_hdr->lc_hdr : NULL; - + if (hdr == NULL || hdr->magic != PLUGIN_MAGIC @@ -869,14 +891,14 @@ int plugin_load(const char* plugin, const void* parameter) ) { lc_close(current_plugin_handle); - splash(HZ*2, str(LANG_PLUGIN_WRONG_MODEL)); + splash(HZ*2, ID2P(LANG_PLUGIN_WRONG_MODEL)); return -1; } if (hdr->api_version > PLUGIN_API_VERSION || hdr->api_version < PLUGIN_MIN_API_VERSION) { lc_close(current_plugin_handle); - splash(HZ*2, str(LANG_PLUGIN_WRONG_VERSION)); + splash(HZ*2, ID2P(LANG_PLUGIN_WRONG_VERSION)); return -1; } #if (CONFIG_PLATFORM & PLATFORM_NATIVE) @@ -901,18 +923,19 @@ int plugin_load(const char* plugin, const void* parameter) FOR_NB_SCREENS(i) viewportmanager_theme_enable(i, false, NULL); - + #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode(TOUCHSCREEN_BUTTON); #endif /* allow voice to back off if the plugin needs lots of memory */ - talk_buffer_set_policy(TALK_BUFFER_LOOSE); + if (!global_settings.talk_menu) + talk_buffer_set_policy(TALK_BUFFER_LOOSE); plugin_check_open_close__enter(); int rc = p_hdr->entry_point(parameter); - + tree_unlock_cache(tree_get_context()); pop_current_activity(); diff --git a/apps/plugin.h b/apps/plugin.h index 868c2a68e3..50f71914e9 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -71,6 +71,9 @@ void* plugin_get_buffer(size_t *buffer_size); #include "mp3_playback.h" #include "root_menu.h" #include "talk.h" +#ifdef PLUGIN +#include "lang_enum.h" +#endif #ifdef RB_PROFILE #include "profile.h" #endif @@ -160,12 +163,12 @@ void* plugin_get_buffer(size_t *buffer_size); #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 235 +#define PLUGIN_API_VERSION 236 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 235 +#define PLUGIN_MIN_API_VERSION 236 /* plugin return codes */ /* internal returns start at 0x100 to make exit(1..255) work */ @@ -186,9 +189,13 @@ enum plugin_status { version */ struct plugin_api { + /* let's put these at the top */ + const char *rbversion; + struct user_settings* global_settings; + struct system_status *global_status; + unsigned char **language_strings; /* lcd */ - #ifdef HAVE_LCD_CONTRAST void (*lcd_set_contrast)(int x); #endif @@ -284,6 +291,7 @@ struct plugin_api { unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation ); #ifdef HAVE_LCD_BITMAP bool (*is_diacritic)(const unsigned short char_code, bool *is_rtl); + const char* (*get_codepage_name)(int cp); #endif const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code ); int (*font_load)(const char *path); @@ -299,8 +307,6 @@ struct plugin_api { int min_shown, int max_shown, unsigned flags); #endif /* HAVE_LCD_BITMAP */ - const char* (*get_codepage_name)(int cp); - /* backlight */ /* The backlight_* functions must be present in the API regardless whether * HAVE_BACKLIGHT is defined or not. The reason is that the stock Ondio has @@ -370,7 +376,7 @@ struct plugin_api { int width, int height); #endif void (*viewport_set_defaults)(struct viewport *vp, - const enum screen_type screen); + const enum screen_type screen); #ifdef HAVE_LCD_BITMAP void (*viewportmanager_theme_enable)(enum screen_type screen, bool enable, struct viewport *viewport); @@ -384,11 +390,13 @@ struct plugin_api { bool scroll_all,int selected_size, struct viewport parent[NB_SCREENS]); void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items); + void (*gui_synclist_set_voice_callback)(struct gui_synclist * lists, list_speak_item voice_callback); void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, list_get_icon icon_callback); int (*gui_synclist_get_nb_items)(struct gui_synclist * lists); int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists); void (*gui_synclist_draw)(struct gui_synclist * lists); + void (*gui_synclist_speak_item)(struct gui_synclist * lists); void (*gui_synclist_select_item)(struct gui_synclist * lists, int item_number); void (*gui_synclist_add_item)(struct gui_synclist * lists); @@ -463,8 +471,6 @@ struct plugin_api { int (*filetype_get_attr)(const char* file); - - /* dir */ DIR * (*opendir)(const char *dirname); int (*closedir)(DIR *dirp); @@ -481,6 +487,24 @@ struct plugin_api { const char *root, const char *selected); int (*rockbox_browse)(struct browse_context *browse); + /* talking */ + int (*talk_id)(int32_t id, bool enqueue); + int (*talk_file)(const char *root, const char *dir, const char *file, + const char *ext, const long *prefix_ids, bool enqueue); + int (*talk_file_or_spell)(const char *dirname, const char* filename, + const long *prefix_ids, bool enqueue); + int (*talk_dir_or_spell)(const char* filename, + const long *prefix_ids, bool enqueue); + int (*talk_number)(long n, bool enqueue); + int (*talk_value)(long n, int unit, bool enqueue); + int (*talk_spell)(const char* spell, bool enqueue); + void (*talk_time)(const struct tm *tm, bool enqueue); + void (*talk_date)(const struct tm *tm, bool enqueue); + void (*talk_disable)(bool disable); + void (*talk_shutup)(void); + void (*talk_force_shutup)(void); + void (*talk_force_enqueue_next)(void); + /* kernel/ system */ #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE void (*__div0)(void); @@ -716,6 +740,7 @@ struct plugin_api { chan_buffer_hook_fn_type fn); void (*mixer_set_frequency)(unsigned int samplerate); unsigned int (*mixer_get_frequency)(void); + void (*pcmbuf_fade)(bool fade, bool in); void (*system_sound_play)(enum system_sound sound); void (*keyclick_click)(bool rawbutton, int action); #endif /* CONFIG_CODEC == SWCODC */ @@ -773,8 +798,12 @@ struct plugin_api { #endif /* menu */ + struct menu_table *(*root_menu_get_options)(int *nb_options); int (*do_menu)(const struct menu_item_ex *menu, int *start_selected, struct viewport parent[NB_SCREENS], bool hide_theme); + void (*root_menu_set_default)(void* setting, void* defaultval); + char* (*root_menu_write_to_cfg)(void* setting, char*buf, int buf_len); + void (*root_menu_load_from_cfg)(void* setting, char *value); /* scroll bar */ struct gui_syncstatusbar *statusbars; @@ -783,6 +812,7 @@ struct plugin_api { /* options */ const struct settings_list* (*get_settings_list)(int*count); const struct settings_list* (*find_setting)(const void* variable, int *id); + int (*settings_save)(void); bool (*option_screen)(const struct settings_list *setting, struct viewport parent[NB_SCREENS], bool use_temp_var, unsigned char* option_title); @@ -797,6 +827,11 @@ struct plugin_api { const int* variable, void (*function)(int), int step, int min, int max, const char* (*formatter)(char*, size_t, int, const char*) ); + bool (*set_int_ex)(const unsigned char* string, const char* unit, int voice_unit, + const int* variable, void (*function)(int), int step, + int min, int max, + const char* (*formatter)(char*, size_t, int, const char*) , + int32_t (*get_talk_id)(int, int)); bool (*set_bool)(const char* string, const bool* variable ); #ifdef HAVE_LCD_COLOR @@ -846,15 +881,15 @@ struct plugin_api { void (*plugin_release_audio_buffer)(void); void (*plugin_tsr)(bool (*exit_callback)(bool reenter)); char* (*plugin_get_current_filename)(void); +#ifdef PLUGIN_USE_IRAM + void (*audio_hard_stop)(void); +#endif #if defined(DEBUG) || defined(SIMULATOR) void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); #endif #ifdef ROCKBOX_HAS_LOGF void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); #endif - struct user_settings* global_settings; - struct system_status *global_status; - void (*talk_disable)(bool disable); #if CONFIG_CODEC == SWCODEC void (*codec_thread_do_callback)(void (*fn)(void), unsigned int *audio_thread_id); @@ -950,13 +985,6 @@ struct plugin_api { void (*semaphore_release)(struct semaphore *s); #endif - const char *rbversion; - struct menu_table *(*root_menu_get_options)(int *nb_options); - void (*root_menu_set_default)(void* setting, void* defaultval); - char* (*root_menu_write_to_cfg)(void* setting, char*buf, int buf_len); - void (*root_menu_load_from_cfg)(void* setting, char *value); - int (*settings_save)(void); - /* new stuff at the end, sort into place next time the API gets incompatible */ }; @@ -988,6 +1016,13 @@ extern unsigned char plugin_end_addr[]; #endif /* CONFIG_PLATFORM */ #endif /* PLUGIN */ +/* + * The str() macro/functions is how to access strings that might be + * translated. Use it like str(MACRO) and expect a string to be + * returned! + */ +#define str(x) language_strings[x] + int plugin_load(const char* plugin, const void* parameter); /* defined by the plugin */ diff --git a/apps/plugins/dice.c b/apps/plugins/dice.c index 098dd27c8b..622c58d71d 100644 --- a/apps/plugins/dice.c +++ b/apps/plugins/dice.c @@ -51,14 +51,14 @@ static struct dices dice; static int sides_index; static struct opt_items nb_sides_option[8] = { - { "3", -1 }, - { "4", -1 }, - { "6", -1 }, - { "8", -1 }, - { "10", -1 }, - { "12", -1 }, - { "20", -1 }, - { "100", -1 } + { "3", TALK_ID(3, UNIT_INT) }, + { "4", TALK_ID(4, UNIT_INT) }, + { "6", TALK_ID(6, UNIT_INT) }, + { "8", TALK_ID(8, UNIT_INT) }, + { "10", TALK_ID(10, UNIT_INT) }, + { "12", TALK_ID(12, UNIT_INT) }, + { "20", TALK_ID(20, UNIT_INT) }, + { "100", TALK_ID(100, UNIT_INT) } }; static int nb_sides_values[] = { 3, 4, 6, 8, 10, 12, 20, 100 }; static char *sides_conf[] = {"3", "4", "6", "8", "10", "12", "20", "100" }; diff --git a/apps/plugins/fireworks.c b/apps/plugins/fireworks.c index 54efaba6ca..d6ca6618cb 100644 --- a/apps/plugins/fireworks.c +++ b/apps/plugins/fireworks.c @@ -113,35 +113,35 @@ LCD_RGBPACK(19,10,26) }; #endif static const struct opt_items autofire_delay_settings[15] = { - { "Off", -1 }, - { "50ms", -1 }, - { "100ms", -1 }, - { "200ms", -1 }, - { "300ms", -1 }, - { "400ms", -1 }, - { "500ms", -1 }, - { "600ms", -1 }, - { "700ms", -1 }, - { "800ms", -1 }, - { "900ms", -1 }, - { "1s", -1 }, - { "2s", -1 }, - { "3s", -1 }, - { "4s", -1 } + { STR(LANG_OFF) }, + { "50ms", TALK_ID(50, UNIT_MS) }, + { "100ms", TALK_ID(100, UNIT_MS) }, + { "200ms", TALK_ID(200, UNIT_MS) }, + { "300ms", TALK_ID(300, UNIT_MS) }, + { "400ms", TALK_ID(400, UNIT_MS) }, + { "500ms", TALK_ID(500, UNIT_MS) }, + { "600ms", TALK_ID(600, UNIT_MS) }, + { "700ms", TALK_ID(700, UNIT_MS) }, + { "800ms", TALK_ID(800, UNIT_MS) }, + { "900ms", TALK_ID(900, UNIT_MS) }, + { "1s", TALK_ID(1, UNIT_SEC) }, + { "2s", TALK_ID(2, UNIT_SEC) }, + { "3s", TALK_ID(3, UNIT_SEC) }, + { "4s", TALK_ID(4, UNIT_SEC) } }; int autofire_delay_values[15] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400 }; static const struct opt_items particle_settings[8] = { - { "5", -1 }, - { "10", -1 }, - { "15", -1 }, - { "20", -1 }, - { "25", -1 }, - { "30", -1 }, - { "35", -1 }, - { "40", -1 }, + { "5", TALK_ID(5, UNIT_INT) }, + { "10", TALK_ID(10, UNIT_INT) }, + { "15", TALK_ID(15, UNIT_INT) }, + { "20", TALK_ID(20, UNIT_INT) }, + { "25", TALK_ID(25, UNIT_INT) }, + { "30", TALK_ID(30, UNIT_INT) }, + { "35", TALK_ID(35, UNIT_INT) }, + { "40", TALK_ID(40, UNIT_INT) }, }; int particle_values[8] = { @@ -163,7 +163,7 @@ int particle_life_values[9] = { 20, 30, 40, 50, 60, 70, 80, 90, 100 }; static const struct opt_items gravity_settings[4] = { - { "Off", -1 }, + { STR(LANG_OFF) }, { "Weak", -1 }, { "Moderate", -1 }, { "Strong", -1 }, @@ -185,8 +185,8 @@ int rocket_values[4] = { #else static const struct opt_items rocket_settings[2] = { - { "No", -1 }, - { "Yes", -1 }, + { STR(LANG_SET_BOOL_NO) }, + { STR(LANG_SET_BOOL_YES) }, }; int rocket_values[4] = { 1, 0 }; diff --git a/apps/plugins/lib/playback_control.c b/apps/plugins/lib/playback_control.c index 1be234f70f..363033b1f2 100644 --- a/apps/plugins/lib/playback_control.c +++ b/apps/plugins/lib/playback_control.c @@ -90,21 +90,21 @@ static bool repeat_mode(void) return false; } -MENUITEM_FUNCTION(prevtrack_item, 0, "Previous Track", +MENUITEM_FUNCTION(prevtrack_item, 0, ID2P(LANG_PREVTRACK), prevtrack, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(playpause_item, 0, "Pause / Play", +MENUITEM_FUNCTION(playpause_item, 0, ID2P(LANG_PLAYPAUSE), play, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(stop_item, 0, "Stop Playback", +MENUITEM_FUNCTION(stop_item, 0, ID2P(LANG_STOP_PLAYBACK), stop, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(nexttrack_item, 0, "Next Track", +MENUITEM_FUNCTION(nexttrack_item, 0, ID2P(LANG_NEXTTRACK), nexttrack, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(volume_item, 0, "Change Volume", +MENUITEM_FUNCTION(volume_item, 0, ID2P(LANG_CHANGE_VOLUME), volume, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(shuffle_item, 0, "Enable/Disable Shuffle", +MENUITEM_FUNCTION(shuffle_item, 0, ID2P(LANG_CHANGE_SHUFFLE_MODE), shuffle, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(repeat_mode_item, 0, "Change Repeat Mode", +MENUITEM_FUNCTION(repeat_mode_item, 0, ID2P(LANG_CHANGE_REPEAT_MODE), repeat_mode, NULL, NULL, Icon_NOICON); -MAKE_MENU(playback_control_menu, "Playback Control", NULL, Icon_NOICON, +MAKE_MENU(playback_control_menu, ID2P(LANG_PLAYBACK_CONTROL), NULL, Icon_NOICON, &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item, &volume_item, &shuffle_item, &repeat_mode_item); diff --git a/apps/plugins/wavrecord.c b/apps/plugins/wavrecord.c index f7467b5b5e..23751be041 100644 --- a/apps/plugins/wavrecord.c +++ b/apps/plugins/wavrecord.c @@ -3685,19 +3685,19 @@ static int recording_menu(void) bool done = false; static const struct opt_items freqs[9] = { - { "8000Hz", -1 }, - { "11025Hz", -1 }, - { "12000Hz", -1 }, - { "16000Hz", -1 }, - { "22050Hz", -1 }, - { "24000Hz", -1 }, - { "32000Hz", -1 }, - { "44100Hz", -1 }, - { "48000Hz", -1 }, + { "8000Hz", TALK_ID(8, UNIT_KHZ) }, + { "11025Hz", TALK_ID(11, UNIT_KHZ) }, + { "12000Hz", TALK_ID(12, UNIT_KHZ) }, + { "16000Hz", TALK_ID(16, UNIT_KHZ) }, + { "22050Hz", TALK_ID(22, UNIT_KHZ) }, + { "24000Hz", TALK_ID(24, UNIT_KHZ) }, + { "32000Hz", TALK_ID(32, UNIT_KHZ) }, + { "44100Hz", TALK_ID(44, UNIT_KHZ) }, + { "48000Hz", TALK_ID(48, UNIT_KHZ) }, }; static const struct opt_items chans[2] = { - { "Mono", -1 }, - { "Stereo", -1 }, + { STR(LANG_CHANNEL_MONO) }, + { STR(LANG_CHANNEL_STEREO) }, }; static const struct opt_items srcs[WAV_NUM_SRC] = { { "Line In", -1 }, diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c index 8c12862bdb..9adfc97b81 100644 --- a/apps/plugins/wormlet.c +++ b/apps/plugins/wormlet.c @@ -2499,39 +2499,41 @@ enum plugin_status plugin_start(const void* parameter) /* Setup screen */ static const struct opt_items noyes[2] = { - { "No", -1 }, - { "Yes", -1 }, + { STR(LANG_SET_BOOL_NO) }, + { STR(LANG_SET_BOOL_YES) }, }; static const struct opt_items remoteonly_option[1] = { - { "Remote Control", -1 } + { STR(LANG_REMOTE_CONTROL) } }; static const struct opt_items key24_option[2] = { - { "4 Key Control", -1 }, - { "2 Key Control", -1 } + { STR(LANG_4_KEY_CONTROL) }, + { STR(LANG_2_KEY_CONTROL) } }; #ifdef REMOTE static const struct opt_items remote_option[2] = { - { "Remote Control", -1 }, - { "No Rem. Control", -1 } + { STR(LANG_REMOTE_CONTROL) }, + { STR(LANG_NO_REM_CONTROL) } }; #else static const struct opt_items key2_option[1] = { - { "2 Key Control", -1 } + { STR(LANG_2_KEY_CONTROL) } }; #endif static const struct opt_items nokey_option[1] = { - { "Out of Control", -1 } + { STR(LANG_OUT_OF_CONTROL) } }; - MENUITEM_STRINGLIST(menu, "Wormlet Menu", NULL, "Play Wormlet!", - "Number of Worms", "Number of Players", "Control Style", - "Worm Growth Per Food","Worm Speed","Arghs Per Food", - "Argh Size","Food Size","Revert to Default Settings", - "Playback Control", "Quit"); + MENUITEM_STRINGLIST(menu, "Wormlet Menu", NULL, + ID2P(LANG_PLAY_WORMLET), ID2P(LANG_NUMBER_OF_WORMS), + ID2P(LANG_NUMBER_OF_PLAYERS), ID2P(LANG_CONTROL_STYLE), + ID2P(LANG_WORM_GROWTH_PER_FOOD), ID2P(LANG_WORM_SPEED), + ID2P(LANG_ARGHS_PER_FOOD), ID2P(LANG_ARGH_SIZE), + ID2P(LANG_FOOD_SIZE), ID2P(LANG_REVERT_TO_DEFAULT_SETTINGS), + ID2P(LANG_PLAYBACK_CONTROL), ID2P(LANG_MENU_QUIT)); rb->button_clear_queue(); @@ -2543,7 +2545,7 @@ enum plugin_status plugin_start(const void* parameter) launch_wormlet(); break; case 1: - rb->set_int("Number of Worms", "", UNIT_INT, &worm_count, NULL, + rb->set_int(rb->str(LANG_NUMBER_OF_WORMS), "", UNIT_INT, &worm_count, NULL, 1, 1, 3, NULL); if (worm_count < players) { worm_count = players; @@ -2551,10 +2553,10 @@ enum plugin_status plugin_start(const void* parameter) break; case 2: #ifdef MULTIPLAYER - rb->set_int("Number of Players", "", UNIT_INT, &players, NULL, + rb->set_int(rb->str(LANG_NUMBER_OF_PLAYERS), "", UNIT_INT, &players, NULL, 1, 0, 4, NULL); #else - rb->set_int("Number of Players", "", UNIT_INT, &players, NULL, + rb->set_int(rb->str(LANG_NUMBER_OF_PLAYERS), "", UNIT_INT, &players, NULL, 1, 0, 2, NULL); #endif if (players > worm_count) { @@ -2567,53 +2569,53 @@ enum plugin_status plugin_start(const void* parameter) case 3: switch(players) { case 0: - rb->set_option("Control Style",&use_remote,INT, + rb->set_option(rb->str(LANG_CONTROL_STYLE),&use_remote,INT, nokey_option, 1, NULL); break; case 1: - rb->set_option("Control Style",&use_remote,INT, + rb->set_option(rb->str(LANG_CONTROL_STYLE),&use_remote,INT, key24_option, 2, NULL); break; case 2: #ifdef REMOTE - rb->set_option("Control Style",&use_remote,INT, + rb->set_option(rb->str(LANG_CONTROL_STYLE),&use_remote,INT, remote_option, 2, NULL); #else - rb->set_option("Control Style",&use_remote,INT, + rb->set_option(rb->str(LANG_CONTROL_STYLE),&use_remote,INT, key2_option, 1, NULL); #endif break; case 3: - rb->set_option("Control Style",&use_remote,INT, + rb->set_option(rb->str(LANG_CONTROL_STYLE),&use_remote,INT, remoteonly_option, 1, NULL); break; } break; case 4: - rb->set_int("Worm Growth Per Food", "", UNIT_INT, &worm_food, + rb->set_int(rb->str(LANG_WORM_GROWTH_PER_FOOD), "", UNIT_INT, &worm_food, NULL, 1, 0, 15, NULL); break; case 5: new_setting = 20 - speed; - rb->set_int("Worm Speed", "", UNIT_INT, &new_setting, + rb->set_int(rb->str(LANG_WORM_SPEED), "", UNIT_INT, &new_setting, NULL, 1, 0, 20, NULL); speed = 20 - new_setting; break; case 6: - rb->set_int("Arghs Per Food", "", UNIT_INT, &arghs_per_food, + rb->set_int(rb->str(LANG_ARGHS_PER_FOOD), "", UNIT_INT, &arghs_per_food, NULL, 1, 0, 8, NULL); break; case 7: - rb->set_int("Argh Size", "", UNIT_INT, &argh_size, + rb->set_int(rb->str(LANG_ARGH_SIZE), "", UNIT_INT, &argh_size, NULL, 1, 2, 10, NULL); break; case 8: - rb->set_int("Food Size", "", UNIT_INT, &food_size, + rb->set_int(rb->str(LANG_FOOD_SIZE), "", UNIT_INT, &food_size, NULL, 1, 2, 10, NULL); break; case 9: new_setting = 0; - rb->set_option("Reset Settings?", &new_setting, INT, noyes , 2, NULL); + rb->set_option(rb->str(LANG_RESET), &new_setting, INT, noyes , 2, NULL); if (new_setting == 1) default_settings(); break; diff --git a/apps/talk.c b/apps/talk.c index de564c0ff0..aa79dd1b33 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -1540,7 +1540,6 @@ void talk_setting(const void *global_settings_variable) } -#if CONFIG_RTC void talk_date(const struct tm *tm, bool enqueue) { talk_id(LANG_MONTH_JANUARY + tm->tm_mon, enqueue); @@ -1595,8 +1594,6 @@ void talk_time(const struct tm *tm, bool enqueue) } } -#endif /* CONFIG_RTC */ - bool talk_get_debug_data(struct talk_debug_data *data) { char* p_lang = DEFAULT_VOICE_LANG; /* default */ diff --git a/apps/talk.h b/apps/talk.h index 3070efc61a..c298476b0c 100644 --- a/apps/talk.h +++ b/apps/talk.h @@ -107,11 +107,11 @@ int talk_file(const char *root, const char *dir, const char *file, /* play file's thumbnail or spell name */ int talk_file_or_spell(const char *dirname, const char* filename, const long *prefix_ids, bool enqueue); -#if CONFIG_CODEC == SWCODEC + /* play dir's thumbnail or spell name */ int talk_dir_or_spell(const char* filename, const long *prefix_ids, bool enqueue); -#endif + /* play thumbnails for each components of full path, or spell */ int talk_fullpath(const char* path, bool enqueue); int talk_number(long n, bool enqueue); /* say a number */ @@ -126,10 +126,8 @@ void talk_shutup(void); /* Interrupt voice, as when enqueue is false */ /* helper function for speaking fractional numbers */ void talk_fractional(char *tbuf, int value, int unit); -#if CONFIG_RTC void talk_time(const struct tm *tm, bool enqueue); void talk_date(const struct tm *tm, bool enqueue); -#endif /* CONFIG_RTC */ /* speaks hr, min, sec, ms; unit_idx is lowest or base unit of the time value */ int talk_time_intervals(long time, int unit_idx, bool enqueue); diff --git a/tools/genlang b/tools/genlang index ac49e594d3..d0b0f145ef 100755 --- a/tools/genlang +++ b/tools/genlang @@ -658,6 +658,20 @@ extern unsigned char *language_strings[]; /* this contains the concatenation of all strings, separated by \\0 chars */ extern const unsigned char core_language_builtin[]; +#include "${prefix}_enum.h" + +MOO + ; + + close(HFILE_CORE); + + open(HFILE_CORE, ">${prefix}_enum.h") || + die "couldn't create file ${prefix}_enum.h\n"; + + print HFILE_CORE <