Move more settings callbacks over to settings_data.c

This commit is contained in:
twinaphex 2014-10-15 06:46:00 +02:00
parent ec002b5f5c
commit 459e4fa0d2
3 changed files with 77 additions and 48 deletions

View File

@ -77,39 +77,6 @@ int menu_action_setting_fraction(
return 0;
}
static void menu_action_setting_driver(
rarch_setting_t *setting, unsigned action)
{
if (!strcmp(setting->name, "audio_resampler_driver"))
{
switch (action)
{
case MENU_ACTION_LEFT:
find_prev_resampler_driver();
break;
case MENU_ACTION_RIGHT:
find_next_resampler_driver();
break;
}
}
else if (setting->flags & SD_FLAG_IS_DRIVER)
{
const char *label = setting->name;
char *drv = (char*)setting->value.string;
size_t sizeof_driver = setting->size;
switch (action)
{
case MENU_ACTION_LEFT:
find_prev_driver(label, drv, sizeof_driver);
break;
case MENU_ACTION_RIGHT:
find_next_driver(label, drv, sizeof_driver);
break;
}
}
}
int menu_action_setting_set_current_string(
rarch_setting_t *setting, const char *str)
{
@ -225,21 +192,8 @@ int menu_action_handle_setting(rarch_setting_t *setting,
if (setting->type == ST_STRING)
{
if (setting->flags & SD_FLAG_ALLOW_INPUT)
{
switch (action)
{
case MENU_ACTION_OK:
menu_key_start_line(driver.menu, setting->short_description,
setting->name, st_string_callback);
break;
case MENU_ACTION_START:
*setting->value.string = '\0';
break;
}
}
else
menu_action_setting_driver(setting, action);
if (setting->action_toggle)
setting->action_toggle(setting, action);
}
return 0;

View File

@ -2378,13 +2378,85 @@ static void general_write_handler(void *data)
#define MAX_GAMMA_SETTING 1
#endif
static int setting_data_string_action_toggle_driver(void *data,
unsigned action)
{
rarch_setting_t *setting = (rarch_setting_t*)data;
if (!setting)
return -1;
switch (action)
{
case MENU_ACTION_LEFT:
find_prev_driver(setting->name, setting->value.string, setting->size);
break;
case MENU_ACTION_RIGHT:
find_next_driver(setting->name, setting->value.string, setting->size);
break;
}
return 0;
}
static int setting_data_string_action_toggle_allow_input(void *data,
unsigned action)
{
rarch_setting_t *setting = (rarch_setting_t*)data;
if (!setting || !driver.menu)
return -1;
switch (action)
{
case MENU_ACTION_OK:
menu_key_start_line(driver.menu, setting->short_description,
setting->name, st_string_callback);
break;
case MENU_ACTION_START:
*setting->value.string = '\0';
break;
}
return 0;
}
static int setting_data_string_action_toggle_audio_resampler(void *data,
unsigned action)
{
rarch_setting_t *setting = (rarch_setting_t*)data;
if (!setting)
return -1;
switch (action)
{
case MENU_ACTION_LEFT:
find_prev_resampler_driver();
break;
case MENU_ACTION_RIGHT:
find_next_resampler_driver();
break;
}
return 0;
}
static void setting_data_add_special_callbacks(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
unsigned values)
{
/* Action OK. */
if (values & SD_FLAG_ALLOW_INPUT)
(*list)[list_info->index - 1].action_ok = setting_data_uint_action_ok_linefeed;
/* Action Toggle. */
if (values & SD_FLAG_ALLOW_INPUT)
(*list)[list_info->index - 1].action_toggle = setting_data_string_action_toggle_allow_input;
else if (values & SD_FLAG_IS_DRIVER)
(*list)[list_info->index - 1].action_toggle = setting_data_string_action_toggle_driver;
}
static void settings_data_list_current_add_flags(
@ -2760,6 +2832,7 @@ static bool setting_data_append_list_driver_options(
subgroup_info.name,
NULL,
NULL);
(*list)[list_info->index - 1].action_toggle = &setting_data_string_action_toggle_audio_resampler;
CONFIG_STRING(
g_settings.camera.driver,

View File

@ -81,6 +81,7 @@ enum setting_list_flags
#define SL_FLAG_ALL_SETTINGS (SL_FLAG_ALL - SL_FLAG_MAIN_MENU)
typedef void (*change_handler_t)(void *data);
typedef int (*action_toggle_handler_t)(void *data, unsigned action);
typedef int (*action_ok_handler_t)(void *data, unsigned action);
typedef struct rarch_setting_info
@ -116,6 +117,7 @@ typedef struct rarch_setting
change_handler_t change_handler;
change_handler_t deferred_handler;
change_handler_t read_handler;
action_toggle_handler_t action_toggle;
action_ok_handler_t action_ok;
union