diff --git a/driver_menu.h b/driver_menu.h index 0010af386c..1f377d49d7 100644 --- a/driver_menu.h +++ b/driver_menu.h @@ -140,7 +140,6 @@ typedef struct menu_ctx_driver_backend unsigned (*shader_manager_get_type)(const struct gfx_shader *); int (*shader_manager_setting_toggle)(unsigned, unsigned); unsigned (*type_is)(unsigned); - int (*setting_toggle)(unsigned, unsigned, unsigned); void (*setting_set_label)(char *, size_t, unsigned *, unsigned,unsigned); void (*defer_decision_automatic)(void); void (*defer_decision_manual)(void); diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index e5eb91f2d2..4495f27fd1 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -1030,6 +1030,770 @@ static void menu_action_cancel(void) driver.menu->need_refresh = true; } +static int menu_common_core_setting_toggle(unsigned setting, unsigned action) +{ + unsigned index = setting - MENU_SETTINGS_CORE_OPTION_START; + + switch (action) + { + case MENU_ACTION_LEFT: + core_option_prev(g_extern.system.core_options, index); + break; + + case MENU_ACTION_RIGHT: + case MENU_ACTION_OK: + core_option_next(g_extern.system.core_options, index); + break; + + case MENU_ACTION_START: + core_option_set_default(g_extern.system.core_options, index); + break; + + default: + break; + } + + return 0; +} + +static void menu_common_defer_decision_automatic(void) +{ + if (driver.menu) + { + menu_flush_stack_type(MENU_SETTINGS); + driver.menu->msg_force = true; + } +} + +static void menu_common_defer_decision_manual(void) +{ + if (driver.menu) + menu_common_setting_push_current_menu(driver.menu->menu_stack, + g_settings.libretro_directory, "deferred_core_list", + MENU_SETTINGS_DEFERRED_CORE, driver.menu->selection_ptr, + MENU_ACTION_OK); +} + +static int menu_common_setting_set_perf(unsigned setting, unsigned action, + struct retro_perf_counter **counters, unsigned offset) +{ + if (counters[offset] && action == MENU_ACTION_START) + { + counters[offset]->total = 0; + counters[offset]->call_cnt = 0; + } + return 0; +} + +static void menu_common_setting_set_current_boolean(rarch_setting_t *setting, unsigned action) +{ + switch (action) + { + case MENU_ACTION_OK: + case MENU_ACTION_LEFT: + case MENU_ACTION_RIGHT: + *setting->value.boolean = !(*setting->value.boolean); + break; + case MENU_ACTION_START: + *setting->value.boolean = setting->default_value.boolean; + break; + } + + if (setting->change_handler) + setting->change_handler(setting); +} + +static void menu_common_setting_set_current_path_selection( + rarch_setting_t *setting, const char *start_path, unsigned type, + unsigned action) +{ + switch (action) + { + case MENU_ACTION_OK: + menu_common_setting_push_current_menu(driver.menu->menu_stack, + start_path, "path_list", type, + driver.menu->selection_ptr, action); + break; + case MENU_ACTION_START: + *setting->value.string = '\0'; + break; + } + + if (setting->change_handler) + setting->change_handler(setting); +} + +static void menu_common_setting_set_current_fraction(rarch_setting_t *setting, unsigned action) +{ + if (!strcmp(setting->name, "video_refresh_rate_auto")) + { + if (action == MENU_ACTION_START) + g_extern.measure_data.frame_time_samples_count = 0; + else if (action == MENU_ACTION_OK) + { + double refresh_rate, deviation = 0.0; + unsigned sample_points = 0; + + if (driver_monitor_fps_statistics(&refresh_rate, &deviation, &sample_points)) + { + driver_set_monitor_refresh_rate(refresh_rate); + // Incase refresh rate update forced non-block video. + rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); + } + } + } + else if (!strcmp(setting->name, "fastforward_ratio")) + { + bool clamp_value = false; + if (action == MENU_ACTION_START) + *setting->value.fraction = setting->default_value.fraction; + else if (action == MENU_ACTION_LEFT) + { + *setting->value.fraction -= setting->step; + if (*setting->value.fraction < 0.95f) // Avoid potential rounding errors when going from 1.1 to 1.0. + *setting->value.fraction = setting->default_value.fraction; + else + clamp_value = true; + } + else if (action == MENU_ACTION_RIGHT) + { + *setting->value.fraction += setting->step; + clamp_value = true; + } + if (clamp_value) + g_settings.fastforward_ratio = max(min(*setting->value.fraction, setting->max), 1.0f); + } + else + { + switch (action) + { + case MENU_ACTION_LEFT: + *setting->value.fraction = *setting->value.fraction - setting->step; + + if (setting->enforce_minrange) + { + if (*setting->value.fraction < setting->min) + *setting->value.fraction = setting->min; + } + break; + + case MENU_ACTION_RIGHT: + case MENU_ACTION_OK: + *setting->value.fraction = *setting->value.fraction + setting->step; + + if (setting->enforce_maxrange) + { + if (*setting->value.fraction > setting->max) + *setting->value.fraction = setting->max; + } + break; + + case MENU_ACTION_START: + *setting->value.fraction = setting->default_value.fraction; + break; + } + } + + if (setting->change_handler) + setting->change_handler(setting); +} + +static void menu_common_setting_set_current_unsigned_integer(rarch_setting_t *setting, unsigned action) +{ + if (!strcmp(setting->name, "netplay_tcp_udp_port")) + { + if (action == MENU_ACTION_OK) + menu_key_start_line(driver.menu, "TCP/UDP Port: ", setting->name, st_uint_callback); + else if (action == MENU_ACTION_START) + *setting->value.unsigned_integer = setting->default_value.unsigned_integer; + } + else + { + switch (action) + { + case MENU_ACTION_LEFT: + if (*setting->value.unsigned_integer != setting->min) + *setting->value.unsigned_integer = *setting->value.unsigned_integer - setting->step; + + if (setting->enforce_minrange) + { + if (*setting->value.unsigned_integer < setting->min) + *setting->value.unsigned_integer = setting->min; + } + break; + + case MENU_ACTION_RIGHT: + case MENU_ACTION_OK: + *setting->value.unsigned_integer = *setting->value.unsigned_integer + setting->step; + + if (setting->enforce_maxrange) + { + if (*setting->value.unsigned_integer > setting->max) + *setting->value.unsigned_integer = setting->max; + } + break; + + case MENU_ACTION_START: + *setting->value.unsigned_integer = setting->default_value.unsigned_integer; + break; + } + } + + if (setting->change_handler) + setting->change_handler(setting); +} + + +static void menu_common_setting_set_current_string_path(rarch_setting_t *setting, const char *dir, const char *path) +{ + fill_pathname_join(setting->value.string, dir, path, setting->size); + + if (setting->change_handler) + setting->change_handler(setting); +} + +void menu_common_setting_set_current_string(rarch_setting_t *setting, const char *str) +{ + strlcpy(setting->value.string, str, setting->size); + + if (setting->change_handler) + setting->change_handler(setting); +} + +static void handle_driver(unsigned id, char *driver, size_t sizeof_driver, + unsigned action) +{ + switch (action) + { + case MENU_ACTION_LEFT: + find_prev_driver(id, driver, sizeof_driver); + break; + case MENU_ACTION_RIGHT: + find_next_driver(id, driver, sizeof_driver); + break; + } +} + +static void handle_setting(rarch_setting_t *setting, + unsigned id, unsigned action) +{ + if (setting->type == ST_BOOL) + menu_common_setting_set_current_boolean(setting, action); + else if (setting->type == ST_UINT) + menu_common_setting_set_current_unsigned_integer(setting, action); + else if (setting->type == ST_FLOAT) + menu_common_setting_set_current_fraction(setting, action); + else if (setting->type == ST_DIR) + { + if (action == MENU_ACTION_START) + { + *setting->value.string = '\0'; + + if (setting->change_handler) + setting->change_handler(setting); + } + } + else if (setting->type == ST_PATH) + menu_common_setting_set_current_path_selection(setting, setting->default_value.string, id, action); + else if (setting->type == ST_STRING) + { + if (!strcmp(setting->name, "video_driver")) + handle_driver(RARCH_DRIVER_VIDEO, g_settings.video.driver, + sizeof(g_settings.video.driver), action); + else if (!strcmp(setting->name, "audio_driver")) + handle_driver(RARCH_DRIVER_AUDIO, g_settings.audio.driver, + sizeof(g_settings.audio.driver), action); + else if (!strcmp(setting->name, "audio_resampler_driver")) + { + if (action == MENU_ACTION_LEFT) + find_prev_resampler_driver(); + else if (action == MENU_ACTION_RIGHT) + find_next_resampler_driver(); + } + else if (!strcmp(setting->name, "input_driver")) + handle_driver(RARCH_DRIVER_INPUT, g_settings.input.driver, + sizeof(g_settings.input.driver), action); + else if (!strcmp(setting->name, "camera_driver")) + handle_driver(RARCH_DRIVER_CAMERA, g_settings.camera.driver, + sizeof(g_settings.camera.driver), action); + else if (!strcmp(setting->name, "location_driver")) + handle_driver(RARCH_DRIVER_LOCATION, g_settings.location.driver, + sizeof(g_settings.location.driver), action); + else if (!strcmp(setting->name, "menu_driver")) + handle_driver(RARCH_DRIVER_MENU, g_settings.menu.driver, + sizeof(g_settings.menu.driver), action); + } +} + +static int menu_common_setting_set(unsigned id, unsigned action) +{ + struct retro_perf_counter **counters; + unsigned port = driver.menu->current_pad; + rarch_setting_t *setting = (rarch_setting_t*)get_last_setting( + driver.menu->selection_buf, driver.menu->selection_ptr, + setting_data_get_list() + ); + + if (id >= MENU_SETTINGS_PERF_COUNTERS_BEGIN && id <= MENU_SETTINGS_PERF_COUNTERS_END) + { + counters = (struct retro_perf_counter**)perf_counters_rarch; + return menu_common_setting_set_perf(id, action, counters, id - MENU_SETTINGS_PERF_COUNTERS_BEGIN); + } + else if (id >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN && id <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END) + { + counters = (struct retro_perf_counter**)perf_counters_libretro; + return menu_common_setting_set_perf(id, action, counters, id - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN); + } + else if (id >= MENU_SETTINGS_BIND_BEGIN && id <= MENU_SETTINGS_BIND_ALL_LAST) + { + struct retro_keybind *bind = (struct retro_keybind*)&g_settings.input.binds[port][id - MENU_SETTINGS_BIND_BEGIN]; + + if (action == MENU_ACTION_OK) + { + driver.menu->binds.begin = id; + driver.menu->binds.last = id; + driver.menu->binds.target = bind; + driver.menu->binds.player = port; + file_list_push(driver.menu->menu_stack, "", "", + driver.menu->bind_mode_keyboard ? + MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND, + driver.menu->selection_ptr); + + if (driver.menu->bind_mode_keyboard) + { + driver.menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; + input_keyboard_wait_keys(driver.menu, menu_custom_bind_keyboard_cb); + } + else + { + menu_poll_bind_get_rested_axes(&driver.menu->binds); + menu_poll_bind_state(&driver.menu->binds); + } + } + else if (action == MENU_ACTION_START) + { + if (driver.menu->bind_mode_keyboard) + { + const struct retro_keybind *def_binds = port ? retro_keybinds_rest : retro_keybinds_1; + bind->key = def_binds[id - MENU_SETTINGS_BIND_BEGIN].key; + } + else + { + bind->joykey = NO_BTN; + bind->joyaxis = AXIS_NONE; + } + } + return 0; + } + else if (setting) + handle_setting(setting, id, action); + else + { + setting = (rarch_setting_t*)get_last_setting( + driver.menu->selection_buf, driver.menu->selection_ptr, + setting_data_get_mainmenu(true) + ); + + if (setting) + handle_setting(setting, id, action); + else + { + switch (id) + { + case MENU_SETTINGS_SAVESTATE_SAVE: + case MENU_SETTINGS_SAVESTATE_LOAD: + if (action == MENU_ACTION_OK) + { + if (id == MENU_SETTINGS_SAVESTATE_SAVE) + rarch_main_command(RARCH_CMD_SAVE_STATE); + else + rarch_main_command(RARCH_CMD_LOAD_STATE); + return -1; + } + else if (action == MENU_ACTION_START) + g_settings.state_slot = 0; + else if (action == MENU_ACTION_LEFT) + { + // Slot -1 is (auto) slot. + if (g_settings.state_slot >= 0) + g_settings.state_slot--; + } + else if (action == MENU_ACTION_RIGHT) + g_settings.state_slot++; + break; + case MENU_SETTINGS_DISK_INDEX: + { + int step = 0; + + if (action == MENU_ACTION_RIGHT || action == MENU_ACTION_OK) + step = 1; + else if (action == MENU_ACTION_LEFT) + step = -1; + + if (step) + { + const struct retro_disk_control_callback *control = (const struct retro_disk_control_callback*)&g_extern.system.disk_control; + unsigned num_disks = control->get_num_images(); + unsigned current = control->get_image_index(); + unsigned next_index = (current + num_disks + 1 + step) % (num_disks + 1); + rarch_disk_control_set_eject(true, false); + rarch_disk_control_set_index(next_index); + rarch_disk_control_set_eject(false, false); + } + + break; + } + // controllers + case MENU_SETTINGS_BIND_PLAYER: + if (action == MENU_ACTION_START) + driver.menu->current_pad = 0; + else if (action == MENU_ACTION_LEFT) + { + if (driver.menu->current_pad != 0) + driver.menu->current_pad--; + } + else if (action == MENU_ACTION_RIGHT) + { + if (driver.menu->current_pad < MAX_PLAYERS - 1) + driver.menu->current_pad++; + } + if (port != driver.menu->current_pad) + driver.menu->need_refresh = true; + port = driver.menu->current_pad; + break; + case MENU_SETTINGS_BIND_DEVICE: + { + int *p = &g_settings.input.joypad_map[port]; + if (action == MENU_ACTION_START) + *p = port; + else if (action == MENU_ACTION_LEFT) + (*p)--; + else if (action == MENU_ACTION_RIGHT) + (*p)++; + + if (*p < -1) + *p = -1; + else if (*p >= MAX_PLAYERS) + *p = MAX_PLAYERS - 1; + } + break; + case MENU_SETTINGS_BIND_ANALOG_MODE: + switch (action) + { + case MENU_ACTION_START: + g_settings.input.analog_dpad_mode[port] = 0; + break; + + case MENU_ACTION_OK: + case MENU_ACTION_RIGHT: + g_settings.input.analog_dpad_mode[port] = (g_settings.input.analog_dpad_mode[port] + 1) % ANALOG_DPAD_LAST; + break; + + case MENU_ACTION_LEFT: + g_settings.input.analog_dpad_mode[port] = (g_settings.input.analog_dpad_mode[port] + ANALOG_DPAD_LAST - 1) % ANALOG_DPAD_LAST; + break; + + default: + break; + } + break; + case MENU_SETTINGS_BIND_DEVICE_TYPE: + { + unsigned current_device, current_index, i, devices[128]; + const struct retro_controller_info *desc; + unsigned types = 0; + + devices[types++] = RETRO_DEVICE_NONE; + devices[types++] = RETRO_DEVICE_JOYPAD; + // Only push RETRO_DEVICE_ANALOG as default if we use an older core which doesn't use SET_CONTROLLER_INFO. + if (!g_extern.system.num_ports) + devices[types++] = RETRO_DEVICE_ANALOG; + + desc = port < g_extern.system.num_ports ? &g_extern.system.ports[port] : NULL; + if (desc) + { + for (i = 0; i < desc->num_types; i++) + { + unsigned id = desc->types[i].id; + if (types < ARRAY_SIZE(devices) && id != RETRO_DEVICE_NONE && id != RETRO_DEVICE_JOYPAD) + devices[types++] = id; + } + } + + current_device = g_settings.input.libretro_device[port]; + current_index = 0; + for (i = 0; i < types; i++) + { + if (current_device == devices[i]) + { + current_index = i; + break; + } + } + + bool updated = true; + switch (action) + { + case MENU_ACTION_START: + current_device = RETRO_DEVICE_JOYPAD; + break; + + case MENU_ACTION_LEFT: + current_device = devices[(current_index + types - 1) % types]; + break; + + case MENU_ACTION_RIGHT: + case MENU_ACTION_OK: + current_device = devices[(current_index + 1) % types]; + break; + + default: + updated = false; + } + + if (updated) + { + g_settings.input.libretro_device[port] = current_device; + pretro_set_controller_port_device(port, current_device); + } + + break; + } + case MENU_SETTINGS_CUSTOM_BIND_MODE: + if (action == MENU_ACTION_OK || action == MENU_ACTION_LEFT || action == MENU_ACTION_RIGHT) + driver.menu->bind_mode_keyboard = !driver.menu->bind_mode_keyboard; + break; + case MENU_SETTINGS_CUSTOM_BIND_ALL: + if (action == MENU_ACTION_OK) + { + driver.menu->binds.target = &g_settings.input.binds[port][0]; + driver.menu->binds.begin = MENU_SETTINGS_BIND_BEGIN; + driver.menu->binds.last = MENU_SETTINGS_BIND_LAST; + if (driver.menu->bind_mode_keyboard) + { + file_list_push(driver.menu->menu_stack, "", "", + MENU_SETTINGS_CUSTOM_BIND_KEYBOARD, + driver.menu->selection_ptr); + driver.menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; + input_keyboard_wait_keys(driver.menu, menu_custom_bind_keyboard_cb); + } + else + { + file_list_push(driver.menu->menu_stack, "", "", + MENU_SETTINGS_CUSTOM_BIND, + driver.menu->selection_ptr); + menu_poll_bind_get_rested_axes(&driver.menu->binds); + menu_poll_bind_state(&driver.menu->binds); + } + } + break; + case MENU_SETTINGS_CUSTOM_BIND_DEFAULT_ALL: + if (action == MENU_ACTION_OK) + { + unsigned i; + struct retro_keybind *target = (struct retro_keybind*)&g_settings.input.binds[port][0]; + const struct retro_keybind *def_binds = port ? retro_keybinds_rest : retro_keybinds_1; + + driver.menu->binds.begin = MENU_SETTINGS_BIND_BEGIN; + driver.menu->binds.last = MENU_SETTINGS_BIND_LAST; + + for (i = MENU_SETTINGS_BIND_BEGIN; i <= MENU_SETTINGS_BIND_LAST; i++, target++) + { + if (driver.menu->bind_mode_keyboard) + target->key = def_binds[i - MENU_SETTINGS_BIND_BEGIN].key; + else + { + target->joykey = NO_BTN; + target->joyaxis = AXIS_NONE; + } + } + } + break; +#if defined(GEKKO) + case MENU_SETTINGS_VIDEO_RESOLUTION: + if (action == MENU_ACTION_LEFT) + { + if (menu_current_gx_resolution > 0) + menu_current_gx_resolution--; + } + else if (action == MENU_ACTION_RIGHT) + { + if (menu_current_gx_resolution < GX_RESOLUTIONS_LAST - 1) + { +#ifdef HW_RVL + if ((menu_current_gx_resolution + 1) > GX_RESOLUTIONS_640_480) + if (CONF_GetVideo() != CONF_VIDEO_PAL) + return 0; +#endif + + menu_current_gx_resolution++; + } + } + else if (action == MENU_ACTION_OK) + { + if (driver.video_data) + gx_set_video_mode(driver.video_data, menu_gx_resolutions[menu_current_gx_resolution][0], + menu_gx_resolutions[menu_current_gx_resolution][1]); + } + break; +#elif defined(__CELLOS_LV2__) + case MENU_SETTINGS_VIDEO_RESOLUTION: + if (action == MENU_ACTION_LEFT) + { + if (g_extern.console.screen.resolutions.current.idx) + { + g_extern.console.screen.resolutions.current.idx--; + g_extern.console.screen.resolutions.current.id = + g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx]; + } + } + else if (action == MENU_ACTION_RIGHT) + { + if (g_extern.console.screen.resolutions.current.idx + 1 < + g_extern.console.screen.resolutions.count) + { + g_extern.console.screen.resolutions.current.idx++; + g_extern.console.screen.resolutions.current.id = + g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx]; + } + } + else if (action == MENU_ACTION_OK) + { + if (g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx] == CELL_VIDEO_OUT_RESOLUTION_576) + { + if (g_extern.console.screen.pal_enable) + g_extern.console.screen.pal60_enable = true; + } + else + { + g_extern.console.screen.pal_enable = false; + g_extern.console.screen.pal60_enable = false; + } + + rarch_main_command(RARCH_CMD_REINIT); + } +#endif + break; + case MENU_SETTINGS_SHADER_PASSES: + { + struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; + + switch (action) + { + case MENU_ACTION_START: + if (shader && shader->passes) + shader->passes = 0; + driver.menu->need_refresh = true; + break; + + case MENU_ACTION_LEFT: + if (shader && shader->passes) + shader->passes--; + driver.menu->need_refresh = true; + break; + + case MENU_ACTION_RIGHT: + case MENU_ACTION_OK: + if (shader && (shader->passes < GFX_MAX_SHADERS)) + shader->passes++; + driver.menu->need_refresh = true; + break; + + default: + break; + } + + if (driver.menu->need_refresh) + gfx_shader_resolve_parameters(NULL, driver.menu->shader); + } + break; + case MENU_SETTINGS_SHADER_APPLY: + { + struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; + unsigned type = RARCH_SHADER_NONE; + + if (!driver.video || !driver.video->set_shader || action != MENU_ACTION_OK) + return 0; + + RARCH_LOG("Applying shader ...\n"); + + if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_get_type) + type = driver.menu_ctx->backend->shader_manager_get_type(driver.menu->shader); + + if (shader->passes && type != RARCH_SHADER_NONE + && driver.menu_ctx && driver.menu_ctx->backend && + driver.menu_ctx->backend->shader_manager_save_preset) + driver.menu_ctx->backend->shader_manager_save_preset(NULL, true); + else + { + type = gfx_shader_parse_type("", DEFAULT_SHADER_TYPE); + if (type == RARCH_SHADER_NONE) + { +#if defined(HAVE_GLSL) + type = RARCH_SHADER_GLSL; +#elif defined(HAVE_CG) || defined(HAVE_HLSL) + type = RARCH_SHADER_CG; +#endif + } + if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_set_preset) + driver.menu_ctx->backend->shader_manager_set_preset(NULL, type, NULL); + } + break; + } +#ifdef HAVE_NETPLAY + case MENU_SETTINGS_NETPLAY_HOST_IP_ADDRESS: + if (action == MENU_ACTION_OK) + menu_key_start_line(driver.menu, "IP Address: ", "netplay_ip_address", st_string_callback); + else if (action == MENU_ACTION_START) + *g_extern.netplay_server = '\0'; + break; +#endif + case MENU_SETTINGS_DRIVER_AUDIO_DEVICE: + if (action == MENU_ACTION_OK) + menu_key_start_line(driver.menu, "Audio Device Name / IP: ", "audio_device", st_string_callback); + else if (action == MENU_ACTION_START) + *g_settings.audio.device = '\0'; + break; + case MENU_SETTINGS_NETPLAY_NICKNAME: + if (action == MENU_ACTION_OK) + menu_key_start_line(driver.menu, "Username: ", "netplay_nickname", st_string_callback); + else if (action == MENU_ACTION_START) + *g_settings.username = '\0'; + break; + case MENU_SETTINGS_SHADER_PRESET_SAVE: + if (action == MENU_ACTION_OK) + menu_key_start_line(driver.menu, "Preset Filename: ", "shader_preset_save", preset_filename_callback); + break; + default: + break; + } + } + } + + return 0; +} + +static int menu_common_setting_toggle(unsigned id, unsigned action, + unsigned menu_type) +{ + (void)menu_type; + + if ((id >= MENU_SETTINGS_SHADER_FILTER) && (id <= MENU_SETTINGS_SHADER_LAST)) + { + if (driver.menu_ctx && driver.menu_ctx->backend + && driver.menu_ctx->backend->shader_manager_setting_toggle) + return driver.menu_ctx->backend->shader_manager_setting_toggle(id, action); + return 0; + } + if ((id >= MENU_SETTINGS_CORE_OPTION_START)) + return menu_common_core_setting_toggle(id, action); + + if (driver.menu_ctx && driver.menu_ctx->backend) + return menu_common_setting_set(id, action); + + return 0; +} + static int menu_settings_iterate(unsigned action) { const char *path = NULL; @@ -1134,12 +1898,7 @@ static int menu_settings_iterate(unsigned action) } else { - int ret = 0; - - if (driver.menu_ctx && driver.menu_ctx->backend && - driver.menu_ctx->backend->setting_toggle) - ret = driver.menu_ctx->backend->setting_toggle(type, - action, menu_type); + int ret = menu_common_setting_toggle(type, action, menu_type); if (ret) return ret; @@ -1727,209 +2486,7 @@ static int menu_custom_bind_iterate_keyboard(void *data, unsigned action) return 0; } -static void menu_common_defer_decision_automatic(void) -{ - if (driver.menu) - { - menu_flush_stack_type(MENU_SETTINGS); - driver.menu->msg_force = true; - } -} -static void menu_common_defer_decision_manual(void) -{ - if (driver.menu) - menu_common_setting_push_current_menu(driver.menu->menu_stack, - g_settings.libretro_directory, "deferred_core_list", - MENU_SETTINGS_DEFERRED_CORE, driver.menu->selection_ptr, - MENU_ACTION_OK); -} - -static int menu_common_setting_set_perf(unsigned setting, unsigned action, - struct retro_perf_counter **counters, unsigned offset) -{ - if (counters[offset] && action == MENU_ACTION_START) - { - counters[offset]->total = 0; - counters[offset]->call_cnt = 0; - } - return 0; -} - -static void menu_common_setting_set_current_boolean(rarch_setting_t *setting, unsigned action) -{ - switch (action) - { - case MENU_ACTION_OK: - case MENU_ACTION_LEFT: - case MENU_ACTION_RIGHT: - *setting->value.boolean = !(*setting->value.boolean); - break; - case MENU_ACTION_START: - *setting->value.boolean = setting->default_value.boolean; - break; - } - - if (setting->change_handler) - setting->change_handler(setting); -} - -static void menu_common_setting_set_current_path_selection( - rarch_setting_t *setting, const char *start_path, unsigned type, - unsigned action) -{ - switch (action) - { - case MENU_ACTION_OK: - menu_common_setting_push_current_menu(driver.menu->menu_stack, - start_path, "path_list", type, - driver.menu->selection_ptr, action); - break; - case MENU_ACTION_START: - *setting->value.string = '\0'; - break; - } - - if (setting->change_handler) - setting->change_handler(setting); -} - -static void menu_common_setting_set_current_fraction(rarch_setting_t *setting, unsigned action) -{ - if (!strcmp(setting->name, "video_refresh_rate_auto")) - { - if (action == MENU_ACTION_START) - g_extern.measure_data.frame_time_samples_count = 0; - else if (action == MENU_ACTION_OK) - { - double refresh_rate, deviation = 0.0; - unsigned sample_points = 0; - - if (driver_monitor_fps_statistics(&refresh_rate, &deviation, &sample_points)) - { - driver_set_monitor_refresh_rate(refresh_rate); - // Incase refresh rate update forced non-block video. - rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); - } - } - } - else if (!strcmp(setting->name, "fastforward_ratio")) - { - bool clamp_value = false; - if (action == MENU_ACTION_START) - *setting->value.fraction = setting->default_value.fraction; - else if (action == MENU_ACTION_LEFT) - { - *setting->value.fraction -= setting->step; - if (*setting->value.fraction < 0.95f) // Avoid potential rounding errors when going from 1.1 to 1.0. - *setting->value.fraction = setting->default_value.fraction; - else - clamp_value = true; - } - else if (action == MENU_ACTION_RIGHT) - { - *setting->value.fraction += setting->step; - clamp_value = true; - } - if (clamp_value) - g_settings.fastforward_ratio = max(min(*setting->value.fraction, setting->max), 1.0f); - } - else - { - switch (action) - { - case MENU_ACTION_LEFT: - *setting->value.fraction = *setting->value.fraction - setting->step; - - if (setting->enforce_minrange) - { - if (*setting->value.fraction < setting->min) - *setting->value.fraction = setting->min; - } - break; - - case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: - *setting->value.fraction = *setting->value.fraction + setting->step; - - if (setting->enforce_maxrange) - { - if (*setting->value.fraction > setting->max) - *setting->value.fraction = setting->max; - } - break; - - case MENU_ACTION_START: - *setting->value.fraction = setting->default_value.fraction; - break; - } - } - - if (setting->change_handler) - setting->change_handler(setting); -} - -static void menu_common_setting_set_current_unsigned_integer(rarch_setting_t *setting, unsigned action) -{ - if (!strcmp(setting->name, "netplay_tcp_udp_port")) - { - if (action == MENU_ACTION_OK) - menu_key_start_line(driver.menu, "TCP/UDP Port: ", setting->name, st_uint_callback); - else if (action == MENU_ACTION_START) - *setting->value.unsigned_integer = setting->default_value.unsigned_integer; - } - else - { - switch (action) - { - case MENU_ACTION_LEFT: - if (*setting->value.unsigned_integer != setting->min) - *setting->value.unsigned_integer = *setting->value.unsigned_integer - setting->step; - - if (setting->enforce_minrange) - { - if (*setting->value.unsigned_integer < setting->min) - *setting->value.unsigned_integer = setting->min; - } - break; - - case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: - *setting->value.unsigned_integer = *setting->value.unsigned_integer + setting->step; - - if (setting->enforce_maxrange) - { - if (*setting->value.unsigned_integer > setting->max) - *setting->value.unsigned_integer = setting->max; - } - break; - - case MENU_ACTION_START: - *setting->value.unsigned_integer = setting->default_value.unsigned_integer; - break; - } - } - - if (setting->change_handler) - setting->change_handler(setting); -} - - -static void menu_common_setting_set_current_string_path(rarch_setting_t *setting, const char *dir, const char *path) -{ - fill_pathname_join(setting->value.string, dir, path, setting->size); - - if (setting->change_handler) - setting->change_handler(setting); -} - -void menu_common_setting_set_current_string(rarch_setting_t *setting, const char *str) -{ - strlcpy(setting->value.string, str, setting->size); - - if (setting->change_handler) - setting->change_handler(setting); -} static int menu_action_ok(const char *dir, unsigned menu_type) { @@ -2625,518 +3182,8 @@ static unsigned menu_common_shader_manager_get_type(const struct gfx_shader *sha return type; } -static void handle_driver(unsigned id, char *driver, size_t sizeof_driver, - unsigned action) -{ - switch (action) - { - case MENU_ACTION_LEFT: - find_prev_driver(id, driver, sizeof_driver); - break; - case MENU_ACTION_RIGHT: - find_next_driver(id, driver, sizeof_driver); - break; - } -} -static void handle_setting(rarch_setting_t *setting, - unsigned id, unsigned action) -{ - if (setting->type == ST_BOOL) - menu_common_setting_set_current_boolean(setting, action); - else if (setting->type == ST_UINT) - menu_common_setting_set_current_unsigned_integer(setting, action); - else if (setting->type == ST_FLOAT) - menu_common_setting_set_current_fraction(setting, action); - else if (setting->type == ST_DIR) - { - if (action == MENU_ACTION_START) - { - *setting->value.string = '\0'; - if (setting->change_handler) - setting->change_handler(setting); - } - } - else if (setting->type == ST_PATH) - menu_common_setting_set_current_path_selection(setting, setting->default_value.string, id, action); - else if (setting->type == ST_STRING) - { - if (!strcmp(setting->name, "video_driver")) - handle_driver(RARCH_DRIVER_VIDEO, g_settings.video.driver, - sizeof(g_settings.video.driver), action); - else if (!strcmp(setting->name, "audio_driver")) - handle_driver(RARCH_DRIVER_AUDIO, g_settings.audio.driver, - sizeof(g_settings.audio.driver), action); - else if (!strcmp(setting->name, "audio_resampler_driver")) - { - if (action == MENU_ACTION_LEFT) - find_prev_resampler_driver(); - else if (action == MENU_ACTION_RIGHT) - find_next_resampler_driver(); - } - else if (!strcmp(setting->name, "input_driver")) - handle_driver(RARCH_DRIVER_INPUT, g_settings.input.driver, - sizeof(g_settings.input.driver), action); - else if (!strcmp(setting->name, "camera_driver")) - handle_driver(RARCH_DRIVER_CAMERA, g_settings.camera.driver, - sizeof(g_settings.camera.driver), action); - else if (!strcmp(setting->name, "location_driver")) - handle_driver(RARCH_DRIVER_LOCATION, g_settings.location.driver, - sizeof(g_settings.location.driver), action); - else if (!strcmp(setting->name, "menu_driver")) - handle_driver(RARCH_DRIVER_MENU, g_settings.menu.driver, - sizeof(g_settings.menu.driver), action); - } -} - -static int menu_common_setting_set(unsigned id, unsigned action) -{ - struct retro_perf_counter **counters; - unsigned port = driver.menu->current_pad; - rarch_setting_t *setting = (rarch_setting_t*)get_last_setting( - driver.menu->selection_buf, driver.menu->selection_ptr, - setting_data_get_list() - ); - - if (id >= MENU_SETTINGS_PERF_COUNTERS_BEGIN && id <= MENU_SETTINGS_PERF_COUNTERS_END) - { - counters = (struct retro_perf_counter**)perf_counters_rarch; - return menu_common_setting_set_perf(id, action, counters, id - MENU_SETTINGS_PERF_COUNTERS_BEGIN); - } - else if (id >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN && id <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END) - { - counters = (struct retro_perf_counter**)perf_counters_libretro; - return menu_common_setting_set_perf(id, action, counters, id - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN); - } - else if (id >= MENU_SETTINGS_BIND_BEGIN && id <= MENU_SETTINGS_BIND_ALL_LAST) - { - struct retro_keybind *bind = (struct retro_keybind*)&g_settings.input.binds[port][id - MENU_SETTINGS_BIND_BEGIN]; - - if (action == MENU_ACTION_OK) - { - driver.menu->binds.begin = id; - driver.menu->binds.last = id; - driver.menu->binds.target = bind; - driver.menu->binds.player = port; - file_list_push(driver.menu->menu_stack, "", "", - driver.menu->bind_mode_keyboard ? - MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND, - driver.menu->selection_ptr); - - if (driver.menu->bind_mode_keyboard) - { - driver.menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; - input_keyboard_wait_keys(driver.menu, menu_custom_bind_keyboard_cb); - } - else - { - menu_poll_bind_get_rested_axes(&driver.menu->binds); - menu_poll_bind_state(&driver.menu->binds); - } - } - else if (action == MENU_ACTION_START) - { - if (driver.menu->bind_mode_keyboard) - { - const struct retro_keybind *def_binds = port ? retro_keybinds_rest : retro_keybinds_1; - bind->key = def_binds[id - MENU_SETTINGS_BIND_BEGIN].key; - } - else - { - bind->joykey = NO_BTN; - bind->joyaxis = AXIS_NONE; - } - } - return 0; - } - else if (setting) - handle_setting(setting, id, action); - else - { - setting = (rarch_setting_t*)get_last_setting( - driver.menu->selection_buf, driver.menu->selection_ptr, - setting_data_get_mainmenu(true) - ); - - if (setting) - handle_setting(setting, id, action); - else - { - switch (id) - { - case MENU_SETTINGS_SAVESTATE_SAVE: - case MENU_SETTINGS_SAVESTATE_LOAD: - if (action == MENU_ACTION_OK) - { - if (id == MENU_SETTINGS_SAVESTATE_SAVE) - rarch_main_command(RARCH_CMD_SAVE_STATE); - else - rarch_main_command(RARCH_CMD_LOAD_STATE); - return -1; - } - else if (action == MENU_ACTION_START) - g_settings.state_slot = 0; - else if (action == MENU_ACTION_LEFT) - { - // Slot -1 is (auto) slot. - if (g_settings.state_slot >= 0) - g_settings.state_slot--; - } - else if (action == MENU_ACTION_RIGHT) - g_settings.state_slot++; - break; - case MENU_SETTINGS_DISK_INDEX: - { - int step = 0; - - if (action == MENU_ACTION_RIGHT || action == MENU_ACTION_OK) - step = 1; - else if (action == MENU_ACTION_LEFT) - step = -1; - - if (step) - { - const struct retro_disk_control_callback *control = (const struct retro_disk_control_callback*)&g_extern.system.disk_control; - unsigned num_disks = control->get_num_images(); - unsigned current = control->get_image_index(); - unsigned next_index = (current + num_disks + 1 + step) % (num_disks + 1); - rarch_disk_control_set_eject(true, false); - rarch_disk_control_set_index(next_index); - rarch_disk_control_set_eject(false, false); - } - - break; - } - // controllers - case MENU_SETTINGS_BIND_PLAYER: - if (action == MENU_ACTION_START) - driver.menu->current_pad = 0; - else if (action == MENU_ACTION_LEFT) - { - if (driver.menu->current_pad != 0) - driver.menu->current_pad--; - } - else if (action == MENU_ACTION_RIGHT) - { - if (driver.menu->current_pad < MAX_PLAYERS - 1) - driver.menu->current_pad++; - } - if (port != driver.menu->current_pad) - driver.menu->need_refresh = true; - port = driver.menu->current_pad; - break; - case MENU_SETTINGS_BIND_DEVICE: - { - int *p = &g_settings.input.joypad_map[port]; - if (action == MENU_ACTION_START) - *p = port; - else if (action == MENU_ACTION_LEFT) - (*p)--; - else if (action == MENU_ACTION_RIGHT) - (*p)++; - - if (*p < -1) - *p = -1; - else if (*p >= MAX_PLAYERS) - *p = MAX_PLAYERS - 1; - } - break; - case MENU_SETTINGS_BIND_ANALOG_MODE: - switch (action) - { - case MENU_ACTION_START: - g_settings.input.analog_dpad_mode[port] = 0; - break; - - case MENU_ACTION_OK: - case MENU_ACTION_RIGHT: - g_settings.input.analog_dpad_mode[port] = (g_settings.input.analog_dpad_mode[port] + 1) % ANALOG_DPAD_LAST; - break; - - case MENU_ACTION_LEFT: - g_settings.input.analog_dpad_mode[port] = (g_settings.input.analog_dpad_mode[port] + ANALOG_DPAD_LAST - 1) % ANALOG_DPAD_LAST; - break; - - default: - break; - } - break; - case MENU_SETTINGS_BIND_DEVICE_TYPE: - { - unsigned current_device, current_index, i, devices[128]; - const struct retro_controller_info *desc; - unsigned types = 0; - - devices[types++] = RETRO_DEVICE_NONE; - devices[types++] = RETRO_DEVICE_JOYPAD; - // Only push RETRO_DEVICE_ANALOG as default if we use an older core which doesn't use SET_CONTROLLER_INFO. - if (!g_extern.system.num_ports) - devices[types++] = RETRO_DEVICE_ANALOG; - - desc = port < g_extern.system.num_ports ? &g_extern.system.ports[port] : NULL; - if (desc) - { - for (i = 0; i < desc->num_types; i++) - { - unsigned id = desc->types[i].id; - if (types < ARRAY_SIZE(devices) && id != RETRO_DEVICE_NONE && id != RETRO_DEVICE_JOYPAD) - devices[types++] = id; - } - } - - current_device = g_settings.input.libretro_device[port]; - current_index = 0; - for (i = 0; i < types; i++) - { - if (current_device == devices[i]) - { - current_index = i; - break; - } - } - - bool updated = true; - switch (action) - { - case MENU_ACTION_START: - current_device = RETRO_DEVICE_JOYPAD; - break; - - case MENU_ACTION_LEFT: - current_device = devices[(current_index + types - 1) % types]; - break; - - case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: - current_device = devices[(current_index + 1) % types]; - break; - - default: - updated = false; - } - - if (updated) - { - g_settings.input.libretro_device[port] = current_device; - pretro_set_controller_port_device(port, current_device); - } - - break; - } - case MENU_SETTINGS_CUSTOM_BIND_MODE: - if (action == MENU_ACTION_OK || action == MENU_ACTION_LEFT || action == MENU_ACTION_RIGHT) - driver.menu->bind_mode_keyboard = !driver.menu->bind_mode_keyboard; - break; - case MENU_SETTINGS_CUSTOM_BIND_ALL: - if (action == MENU_ACTION_OK) - { - driver.menu->binds.target = &g_settings.input.binds[port][0]; - driver.menu->binds.begin = MENU_SETTINGS_BIND_BEGIN; - driver.menu->binds.last = MENU_SETTINGS_BIND_LAST; - if (driver.menu->bind_mode_keyboard) - { - file_list_push(driver.menu->menu_stack, "", "", - MENU_SETTINGS_CUSTOM_BIND_KEYBOARD, - driver.menu->selection_ptr); - driver.menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; - input_keyboard_wait_keys(driver.menu, menu_custom_bind_keyboard_cb); - } - else - { - file_list_push(driver.menu->menu_stack, "", "", - MENU_SETTINGS_CUSTOM_BIND, - driver.menu->selection_ptr); - menu_poll_bind_get_rested_axes(&driver.menu->binds); - menu_poll_bind_state(&driver.menu->binds); - } - } - break; - case MENU_SETTINGS_CUSTOM_BIND_DEFAULT_ALL: - if (action == MENU_ACTION_OK) - { - unsigned i; - struct retro_keybind *target = (struct retro_keybind*)&g_settings.input.binds[port][0]; - const struct retro_keybind *def_binds = port ? retro_keybinds_rest : retro_keybinds_1; - - driver.menu->binds.begin = MENU_SETTINGS_BIND_BEGIN; - driver.menu->binds.last = MENU_SETTINGS_BIND_LAST; - - for (i = MENU_SETTINGS_BIND_BEGIN; i <= MENU_SETTINGS_BIND_LAST; i++, target++) - { - if (driver.menu->bind_mode_keyboard) - target->key = def_binds[i - MENU_SETTINGS_BIND_BEGIN].key; - else - { - target->joykey = NO_BTN; - target->joyaxis = AXIS_NONE; - } - } - } - break; -#if defined(GEKKO) - case MENU_SETTINGS_VIDEO_RESOLUTION: - if (action == MENU_ACTION_LEFT) - { - if (menu_current_gx_resolution > 0) - menu_current_gx_resolution--; - } - else if (action == MENU_ACTION_RIGHT) - { - if (menu_current_gx_resolution < GX_RESOLUTIONS_LAST - 1) - { -#ifdef HW_RVL - if ((menu_current_gx_resolution + 1) > GX_RESOLUTIONS_640_480) - if (CONF_GetVideo() != CONF_VIDEO_PAL) - return 0; -#endif - - menu_current_gx_resolution++; - } - } - else if (action == MENU_ACTION_OK) - { - if (driver.video_data) - gx_set_video_mode(driver.video_data, menu_gx_resolutions[menu_current_gx_resolution][0], - menu_gx_resolutions[menu_current_gx_resolution][1]); - } - break; -#elif defined(__CELLOS_LV2__) - case MENU_SETTINGS_VIDEO_RESOLUTION: - if (action == MENU_ACTION_LEFT) - { - if (g_extern.console.screen.resolutions.current.idx) - { - g_extern.console.screen.resolutions.current.idx--; - g_extern.console.screen.resolutions.current.id = - g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx]; - } - } - else if (action == MENU_ACTION_RIGHT) - { - if (g_extern.console.screen.resolutions.current.idx + 1 < - g_extern.console.screen.resolutions.count) - { - g_extern.console.screen.resolutions.current.idx++; - g_extern.console.screen.resolutions.current.id = - g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx]; - } - } - else if (action == MENU_ACTION_OK) - { - if (g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx] == CELL_VIDEO_OUT_RESOLUTION_576) - { - if (g_extern.console.screen.pal_enable) - g_extern.console.screen.pal60_enable = true; - } - else - { - g_extern.console.screen.pal_enable = false; - g_extern.console.screen.pal60_enable = false; - } - - rarch_main_command(RARCH_CMD_REINIT); - } -#endif - break; - case MENU_SETTINGS_SHADER_PASSES: - { - struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; - - switch (action) - { - case MENU_ACTION_START: - if (shader && shader->passes) - shader->passes = 0; - driver.menu->need_refresh = true; - break; - - case MENU_ACTION_LEFT: - if (shader && shader->passes) - shader->passes--; - driver.menu->need_refresh = true; - break; - - case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: - if (shader && (shader->passes < GFX_MAX_SHADERS)) - shader->passes++; - driver.menu->need_refresh = true; - break; - - default: - break; - } - - if (driver.menu->need_refresh) - gfx_shader_resolve_parameters(NULL, driver.menu->shader); - } - break; - case MENU_SETTINGS_SHADER_APPLY: - { - struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; - unsigned type = RARCH_SHADER_NONE; - - if (!driver.video || !driver.video->set_shader || action != MENU_ACTION_OK) - return 0; - - RARCH_LOG("Applying shader ...\n"); - - if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_get_type) - type = driver.menu_ctx->backend->shader_manager_get_type(driver.menu->shader); - - if (shader->passes && type != RARCH_SHADER_NONE - && driver.menu_ctx && driver.menu_ctx->backend && - driver.menu_ctx->backend->shader_manager_save_preset) - driver.menu_ctx->backend->shader_manager_save_preset(NULL, true); - else - { - type = gfx_shader_parse_type("", DEFAULT_SHADER_TYPE); - if (type == RARCH_SHADER_NONE) - { -#if defined(HAVE_GLSL) - type = RARCH_SHADER_GLSL; -#elif defined(HAVE_CG) || defined(HAVE_HLSL) - type = RARCH_SHADER_CG; -#endif - } - if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_set_preset) - driver.menu_ctx->backend->shader_manager_set_preset(NULL, type, NULL); - } - break; - } -#ifdef HAVE_NETPLAY - case MENU_SETTINGS_NETPLAY_HOST_IP_ADDRESS: - if (action == MENU_ACTION_OK) - menu_key_start_line(driver.menu, "IP Address: ", "netplay_ip_address", st_string_callback); - else if (action == MENU_ACTION_START) - *g_extern.netplay_server = '\0'; - break; -#endif - case MENU_SETTINGS_DRIVER_AUDIO_DEVICE: - if (action == MENU_ACTION_OK) - menu_key_start_line(driver.menu, "Audio Device Name / IP: ", "audio_device", st_string_callback); - else if (action == MENU_ACTION_START) - *g_settings.audio.device = '\0'; - break; - case MENU_SETTINGS_NETPLAY_NICKNAME: - if (action == MENU_ACTION_OK) - menu_key_start_line(driver.menu, "Username: ", "netplay_nickname", st_string_callback); - else if (action == MENU_ACTION_START) - *g_settings.username = '\0'; - break; - case MENU_SETTINGS_SHADER_PRESET_SAVE: - if (action == MENU_ACTION_OK) - menu_key_start_line(driver.menu, "Preset Filename: ", "shader_preset_save", preset_filename_callback); - break; - default: - break; - } - } - } - - return 0; -} static int menu_common_shader_manager_setting_toggle(unsigned id, unsigned action) { @@ -3288,52 +3335,7 @@ static int menu_common_shader_manager_setting_toggle(unsigned id, unsigned actio return 0; } -static int menu_common_core_setting_toggle(unsigned setting, unsigned action) -{ - unsigned index = setting - MENU_SETTINGS_CORE_OPTION_START; - switch (action) - { - case MENU_ACTION_LEFT: - core_option_prev(g_extern.system.core_options, index); - break; - - case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: - core_option_next(g_extern.system.core_options, index); - break; - - case MENU_ACTION_START: - core_option_set_default(g_extern.system.core_options, index); - break; - - default: - break; - } - - return 0; -} - -static int menu_common_setting_toggle(unsigned id, unsigned action, - unsigned menu_type) -{ - (void)menu_type; - - if ((id >= MENU_SETTINGS_SHADER_FILTER) && (id <= MENU_SETTINGS_SHADER_LAST)) - { - if (driver.menu_ctx && driver.menu_ctx->backend - && driver.menu_ctx->backend->shader_manager_setting_toggle) - return driver.menu_ctx->backend->shader_manager_setting_toggle(id, action); - return 0; - } - if ((id >= MENU_SETTINGS_CORE_OPTION_START)) - return menu_common_core_setting_toggle(id, action); - - if (driver.menu_ctx && driver.menu_ctx->backend) - return menu_common_setting_set(id, action); - - return 0; -} #ifdef GEKKO @@ -3688,7 +3690,6 @@ const menu_ctx_driver_backend_t menu_ctx_backend_common = { menu_common_shader_manager_get_type, menu_common_shader_manager_setting_toggle, menu_common_type_is, - menu_common_setting_toggle, menu_common_setting_set_label, menu_common_defer_decision_automatic, menu_common_defer_decision_manual,