From 55eb1c54ebe33faa8b1eb8c527d5644961ca78dc Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sun, 3 Feb 2019 20:12:50 -0500 Subject: 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/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 +++++++++++++++++++------------------ 5 files changed, 83 insertions(+), 81 deletions(-) (limited to 'apps/plugins') 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; -- cgit v1.2.3