summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 8ff623f653..52cfb6ed48 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -1022,11 +1022,15 @@ bool set_bool_options(const char* string, bool* variable,
1022 return result; 1022 return result;
1023} 1023}
1024 1024
1025static void talk_unit(int unit, int value) 1025static void talk_unit(int unit, int value, long (*get_talk_id)(int value))
1026{ 1026{
1027 if (global_settings.talk_menu) 1027 if (global_settings.talk_menu)
1028 { 1028 {
1029 if (unit < UNIT_LAST) 1029 if (get_talk_id)
1030 {
1031 talk_id(get_talk_id(value),false);
1032 }
1033 else if (unit < UNIT_LAST)
1030 { /* use the available unit definition */ 1034 { /* use the available unit definition */
1031 talk_value(value, unit, false); 1035 talk_value(value, unit, false);
1032 } 1036 }
@@ -1046,7 +1050,8 @@ struct value_setting_data {
1046 int voice_unit; 1050 int voice_unit;
1047 const char * unit; 1051 const char * unit;
1048 void (*formatter)(char* dest, int dest_length, 1052 void (*formatter)(char* dest, int dest_length,
1049 int variable, const char* unit); 1053 int value, const char* unit);
1054 long (*get_talk_id)(int value);
1050 /* used for BOOL and "choice" settings */ 1055 /* used for BOOL and "choice" settings */
1051 struct opt_items* options; 1056 struct opt_items* options;
1052}; 1057};
@@ -1100,7 +1105,7 @@ static bool do_set_setting(const unsigned char* string, void *variable,
1100 if (global_settings.talk_menu) 1105 if (global_settings.talk_menu)
1101 { 1106 {
1102 if (cb_data->type == INT && !cb_data->options) 1107 if (cb_data->type == INT && !cb_data->options)
1103 talk_unit(cb_data->voice_unit, *(int*)variable); 1108 talk_unit(cb_data->voice_unit, *(int*)variable, cb_data->get_talk_id);
1104 else talk_id(cb_data->options[selected].voice_id, false); 1109 else talk_id(cb_data->options[selected].voice_id, false);
1105 } 1110 }
1106 1111
@@ -1121,7 +1126,7 @@ static bool do_set_setting(const unsigned char* string, void *variable,
1121 { 1126 {
1122 value = cb_data->max - 1127 value = cb_data->max -
1123 gui_synclist_get_sel_pos(&lists)*cb_data->step; 1128 gui_synclist_get_sel_pos(&lists)*cb_data->step;
1124 talk_unit(cb_data->voice_unit, value); 1129 talk_unit(cb_data->voice_unit, value, cb_data->get_talk_id);
1125 } 1130 }
1126 else 1131 else
1127 { 1132 {
@@ -1195,7 +1200,7 @@ static const char *unit_strings[] =
1195 [UNIT_KBIT] 1200 [UNIT_KBIT]
1196 = "kb/s", 1201 = "kb/s",
1197}; 1202};
1198bool set_int(const unsigned char* string, 1203bool set_int_ex(const unsigned char* string,
1199 const char* unit, 1204 const char* unit,
1200 int voice_unit, 1205 int voice_unit,
1201 int* variable, 1206 int* variable,
@@ -1203,11 +1208,12 @@ bool set_int(const unsigned char* string,
1203 int step, 1208 int step,
1204 int min, 1209 int min,
1205 int max, 1210 int max,
1206 void (*formatter)(char*, int, int, const char*) ) 1211 void (*formatter)(char*, int, int, const char*),
1212 long (*get_talk_id)(int))
1207{ 1213{
1208#if CONFIG_KEYPAD != PLAYER_PAD 1214#if CONFIG_KEYPAD != PLAYER_PAD
1209 struct value_setting_data data = { 1215 struct value_setting_data data = {
1210 INT,max, step, voice_unit,unit,formatter,NULL }; 1216 INT,max, step, voice_unit,unit,formatter,get_talk_id,NULL };
1211 if (unit == NULL) 1217 if (unit == NULL)
1212 data.unit = unit_strings[voice_unit]; 1218 data.unit = unit_strings[voice_unit];
1213 return do_set_setting(string,variable,(max-min)/step + 1, 1219 return do_set_setting(string,variable,(max-min)/step + 1,
@@ -1215,14 +1221,26 @@ bool set_int(const unsigned char* string,
1215#else 1221#else
1216 int count = (max-min)/step + 1; 1222 int count = (max-min)/step + 1;
1217 struct value_setting_data data = { 1223 struct value_setting_data data = {
1218 INT,min, -step, voice_unit,unit,formatter,NULL }; 1224 INT,min, -step, voice_unit,unit,formatter,get_talk_id,NULL };
1219 if (unit == NULL) 1225 if (unit == NULL)
1220 data.unit = unit_strings[voice_unit]; 1226 data.unit = unit_strings[voice_unit];
1221 return do_set_setting(string,variable,count, 1227 return do_set_setting(string,variable,count,
1222 count - ((max-*variable)/step), &data,function); 1228 count - ((max-*variable)/step), &data,function);
1223#endif 1229#endif
1224} 1230}
1225 1231bool set_int(const unsigned char* string,
1232 const char* unit,
1233 int voice_unit,
1234 int* variable,
1235 void (*function)(int),
1236 int step,
1237 int min,
1238 int max,
1239 void (*formatter)(char*, int, int, const char*) )
1240{
1241 return set_int_ex(string, unit, voice_unit, variable, function,
1242 step, min, max, formatter, NULL);
1243}
1226/* NOTE: the 'type' parameter specifies the actual type of the variable 1244/* NOTE: the 'type' parameter specifies the actual type of the variable
1227 that 'variable' points to. not the value within. Only variables with 1245 that 'variable' points to. not the value within. Only variables with
1228 type 'bool' should use parameter BOOL. 1246 type 'bool' should use parameter BOOL.
@@ -1234,7 +1252,7 @@ bool set_option(const char* string, void* variable, enum optiontype type,
1234 const struct opt_items* options, int numoptions, void (*function)(int)) 1252 const struct opt_items* options, int numoptions, void (*function)(int))
1235{ 1253{
1236 struct value_setting_data data = { 1254 struct value_setting_data data = {
1237 type,0, 0, 0,NULL,NULL,(struct opt_items*)options }; 1255 type,0, 0, 0,NULL,NULL,NULL,(struct opt_items*)options };
1238 int selected; 1256 int selected;
1239 if (type == BOOL) 1257 if (type == BOOL)
1240 selected = *(bool*)variable ? 1 : 0; 1258 selected = *(bool*)variable ? 1 : 0;