From 24116490ca13581b2c48895dfd336e4a8c553554 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 18 Jul 2014 03:31:04 +0200 Subject: [PATCH] (Menu) Refactor more settings --- frontend/menu/backend/menu_common_backend.c | 45 +++++++-------------- settings_data.c | 6 +-- 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 14b87f9473..af2b9931d8 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -241,9 +241,11 @@ static void menu_common_entries_init(void *data, unsigned menu_type) #if defined(__CELLOS_LV2__) file_list_push(menu->selection_buf, "PAL60 Mode", MENU_SETTINGS_VIDEO_PAL60, 0); #endif -#ifndef HAVE_SHADER_MANAGER - file_list_push(menu->selection_buf, "Default Filter", MENU_SETTINGS_VIDEO_FILTER, 0); -#endif + if ((current_setting = setting_data_find_setting(setting_data, "video_smooth"))) + { + *current_setting->value.boolean = g_settings.video.smooth; + file_list_push(menu->selection_buf, current_setting->short_description, MENU_SETTINGS_VIDEO_FILTER, 0); + } #ifdef HW_RVL file_list_push(menu->selection_buf, "VI Trap filtering", MENU_SETTINGS_VIDEO_SOFT_FILTER, 0); #endif @@ -539,7 +541,11 @@ static void menu_common_entries_init(void *data, unsigned menu_type) file_list_push(menu->selection_buf, "Device", MENU_SETTINGS_BIND_DEVICE, 0); file_list_push(menu->selection_buf, "Device Type", MENU_SETTINGS_BIND_DEVICE_TYPE, 0); file_list_push(menu->selection_buf, "Analog D-pad Mode", MENU_SETTINGS_BIND_ANALOG_MODE, 0); - file_list_push(menu->selection_buf, "Input Axis Threshold", MENU_SETTINGS_INPUT_AXIS_THRESHOLD, 0); + if ((current_setting = setting_data_find_setting(setting_data, "input_axis_threshold"))) + { + *current_setting->value.fraction = g_settings.input.axis_threshold; + file_list_push(menu->selection_buf, current_setting->short_description, MENU_SETTINGS_INPUT_AXIS_THRESHOLD, 0); + } file_list_push(menu->selection_buf, "Autodetect Enable", MENU_SETTINGS_DEVICE_AUTODETECT_ENABLE, 0); file_list_push(menu->selection_buf, "Bind Mode", MENU_SETTINGS_CUSTOM_BIND_MODE, 0); @@ -4150,24 +4156,8 @@ static int menu_common_setting_set(unsigned setting, unsigned action) } break; case MENU_SETTINGS_INPUT_AXIS_THRESHOLD: - switch (action) - { - case MENU_ACTION_START: - g_settings.input.axis_threshold = 0.5; - break; - - case MENU_ACTION_OK: - case MENU_ACTION_RIGHT: - g_settings.input.axis_threshold += 0.01; - break; - case MENU_ACTION_LEFT: - g_settings.input.axis_threshold -= 0.01; - break; - - default: - break; - } - g_settings.input.axis_threshold = max(min(g_settings.input.axis_threshold, 0.95f), 0.05f); + if ((current_setting = setting_data_find_setting(setting_data, "input_axis_threshold"))) + menu_common_setting_set_current_fraction(current_setting, 0.01, action, false, false); break; case MENU_SETTINGS_BIND_DEVICE_TYPE: { @@ -4358,17 +4348,10 @@ static int menu_common_setting_set(unsigned setting, unsigned action) if ((current_setting = setting_data_find_setting(setting_data, "video_rotation"))) menu_common_setting_set_current_unsigned_integer(current_setting, 1, action, true, true); break; - case MENU_SETTINGS_VIDEO_FILTER: - if (action == MENU_ACTION_START) - g_settings.video.smooth = video_smooth; - else - g_settings.video.smooth = !g_settings.video.smooth; - - if (driver.video_data && driver.video_poke && driver.video_poke->set_filtering) - driver.video_poke->set_filtering(driver.video_data, 1, g_settings.video.smooth); + if ((current_setting = setting_data_find_setting(setting_data, "video_smooth"))) + menu_common_setting_set_current_boolean(current_setting, action); break; - case MENU_SETTINGS_DRIVER_VIDEO: if (action == MENU_ACTION_LEFT) find_prev_video_driver(); diff --git a/settings_data.c b/settings_data.c index 5b6b5158b6..ad8a744c2a 100644 --- a/settings_data.c +++ b/settings_data.c @@ -558,7 +558,7 @@ static void general_change_handler(const void *data) else if (!strcmp(setting->name, "input_duty_cycle")) g_settings.input.turbo_duty_cycle = *setting->value.unsigned_integer; else if (!strcmp(setting->name, "input_axis_threshold")) - g_settings.input.axis_threshold = *setting->value.fraction; + g_settings.input.axis_threshold = max(min(*setting->value.fraction, 0.95f), 0.05f); else if (!strcmp(setting->name, "savestate_auto_save")) g_settings.savestate_auto_save = *setting->value.boolean; else if (!strcmp(setting->name, "savestate_auto_load")) @@ -908,7 +908,7 @@ rarch_setting_t* setting_data_get_list(void) CONFIG_UINT(g_extern.console.screen.viewports.custom_vp.width, "custom_viewport_width", "Custom Viewport Width", 0, GROUP_NAME, SUBGROUP_NAME, NULL) CONFIG_UINT(g_extern.console.screen.viewports.custom_vp.height, "custom_viewport_height", "Custom Viewport Height", 0, GROUP_NAME, SUBGROUP_NAME, NULL) - CONFIG_BOOL(g_settings.video.smooth, "video_smooth", "Use bilinear filtering", video_smooth, GROUP_NAME, SUBGROUP_NAME, general_change_handler) + CONFIG_BOOL(g_settings.video.smooth, "video_smooth", "Use Bilinear Filtering", video_smooth, GROUP_NAME, SUBGROUP_NAME, general_change_handler) CONFIG_UINT(g_settings.video.rotation, "video_rotation", "Rotation", 0, GROUP_NAME, SUBGROUP_NAME, general_change_handler) WITH_RANGE(0, 3) END_SUB_GROUP() @@ -1001,7 +1001,7 @@ rarch_setting_t* setting_data_get_list(void) END_SUB_GROUP() START_SUB_GROUP("Turbo/Deadzone") - CONFIG_FLOAT(g_settings.input.axis_threshold, "input_axis_threshold", "Axis Deadzone", axis_threshold, GROUP_NAME, SUBGROUP_NAME, general_change_handler) + CONFIG_FLOAT(g_settings.input.axis_threshold, "input_axis_threshold", "Input Axis Threshold", axis_threshold, GROUP_NAME, SUBGROUP_NAME, general_change_handler) CONFIG_UINT(g_settings.input.turbo_period, "input_turbo_period", "Turbo Period", turbo_period, GROUP_NAME, SUBGROUP_NAME, general_change_handler) CONFIG_UINT(g_settings.input.turbo_duty_cycle, "input_duty_cycle", "Duty Cycle", turbo_duty_cycle, GROUP_NAME, SUBGROUP_NAME, general_change_handler) END_SUB_GROUP()