diff --git a/configuration.c b/configuration.c index 7460c18efa..3bd4f6904f 100644 --- a/configuration.c +++ b/configuration.c @@ -1444,6 +1444,7 @@ static struct config_bool_setting *populate_settings_bool( SETTING_BOOL("core_updater_show_experimental_cores", &settings->bools.network_buildbot_show_experimental_cores, true, DEFAULT_NETWORK_BUILDBOT_SHOW_EXPERIMENTAL_CORES, false); SETTING_BOOL("core_updater_auto_backup", &settings->bools.core_updater_auto_backup, true, DEFAULT_CORE_UPDATER_AUTO_BACKUP, false); SETTING_BOOL("camera_allow", &settings->bools.camera_allow, true, false, false); + SETTING_BOOL("add_null_drivers", &settings->bools.add_null_drivers, true, false, false); SETTING_BOOL("discord_allow", &settings->bools.discord_enable, true, false, false); #if defined(VITA) SETTING_BOOL("input_backtouch_enable", &settings->bools.input_backtouch_enable, false, false, false); diff --git a/configuration.h b/configuration.h index c906a79b65..e09459bfa2 100644 --- a/configuration.h +++ b/configuration.h @@ -328,6 +328,7 @@ typedef struct settings bool driver_switch_enable; /* Misc. */ + bool add_null_drivers; bool discord_enable; bool threaded_data_runloop_enable; bool set_supports_no_game_enable; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index b2e48257e1..a2f64849e8 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -3110,6 +3110,10 @@ MSG_HASH( MENU_ENUM_LABEL_VIDEO_SHARED_CONTEXT, "video_shared_context" ) +MSG_HASH( + MENU_ENUM_LABEL_ADD_NULL_DRIVERS, + "ignore_null_drivers" + ) MSG_HASH( MENU_ENUM_LABEL_VIDEO_SMOOTH, "video_smooth" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 6da74bfc35..b02c2647d9 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -11160,7 +11160,14 @@ MSG_HASH( MSG_READ_ONLY, "Read-Only" ) - +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ADD_NULL_DRIVERS, + "Ignore null drivers" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_ADD_NULL_DRIVERS, + "Don't allow the user to set a driver to nothing. Can prevent the user from locking him/herself out of the program." + ) #ifdef HAVE_LAKKA_SWITCH MSG_HASH( MENU_ENUM_LABEL_VALUE_SWITCH_GPU_PROFILE, diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 1eb6876a9a..c8e13c7cab 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -111,6 +111,27 @@ static void menu_action_setting_disp_set_label_cheat_num_passes( snprintf(s, len, "%u", cheat_manager_get_buf_size()); } +static void menu_action_setting_disp_add_null_drivers( + file_list_t* list, + unsigned *w, unsigned type, unsigned i, + const char *label, + char *s, size_t len, + const char *path, + char *s2, size_t len2) +{ + settings_t *settings = config_get_ptr(); + bool add_null_drivers = settings->bools.add_null_drivers; + + *s = '\0'; + *w = 19; + strlcpy(s2, path, len2); + + if (add_null_drivers) + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF), len); + else + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON), len); +} + #ifdef HAVE_CHEEVOS static void menu_action_setting_disp_set_label_cheevos_entry( file_list_t* list, @@ -1535,6 +1556,9 @@ static int menu_cbs_init_bind_get_string_representation_compare_label( { switch (cbs->enum_idx) { + case MENU_ENUM_LABEL_ADD_NULL_DRIVERS: + BIND_ACTION_GET_VALUE(cbs, menu_action_setting_disp_add_null_drivers); + break; case MENU_ENUM_LABEL_VIDEO_DRIVER: case MENU_ENUM_LABEL_AUDIO_DRIVER: case MENU_ENUM_LABEL_INPUT_DRIVER: diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 44996c0229..986bc2d270 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -329,6 +329,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_audio_max_timing_skew, MENU_ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_pause_nonactive, MENU_ENUM_SUBLABEL_PAUSE_NONACTIVE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_disable_composition, MENU_ENUM_SUBLABEL_VIDEO_DISABLE_COMPOSITION) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_smooth, MENU_ENUM_SUBLABEL_VIDEO_SMOOTH) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_add_null_drivers, MENU_ENUM_SUBLABEL_ADD_NULL_DRIVERS) #ifdef HAVE_ODROIDGO2 DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_ctx_scaling, MENU_ENUM_SUBLABEL_VIDEO_RGA_SCALING) #else @@ -2920,6 +2921,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_VIDEO_CROP_OVERSCAN: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_crop_overscan); break; + case MENU_ENUM_LABEL_ADD_NULL_DRIVERS: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_add_null_drivers); + break; case MENU_ENUM_LABEL_VIDEO_SMOOTH: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_smooth); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 7863c65c05..63f24f9aaf 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7406,6 +7406,7 @@ unsigned menu_displaylist_build_list( { menu_displaylist_build_info_t build_list[] = { {MENU_ENUM_LABEL_SETTINGS_SHOW_DRIVERS, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_ADD_NULL_DRIVERS, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_SETTINGS_SHOW_VIDEO, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_SETTINGS_SHOW_AUDIO, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_SETTINGS_SHOW_INPUT, PARSE_ONLY_BOOL}, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 25de6c7eeb..fe79fee08a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -14957,6 +14957,21 @@ static bool setting_append_list( general_read_handler, SD_FLAG_NONE); + CONFIG_BOOL( + list, list_info, + &settings->bools.add_null_drivers, + MENU_ENUM_LABEL_ADD_NULL_DRIVERS, + MENU_ENUM_LABEL_VALUE_ADD_NULL_DRIVERS, + false, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + CONFIG_BOOL( list, list_info, &settings->bools.settings_show_video, diff --git a/msg_hash.h b/msg_hash.h index 1a59ca6978..cec0434c70 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -975,6 +975,7 @@ enum msg_hash_enums MENU_LABEL(SCREEN_ORIENTATION), MENU_LABEL(VIDEO_SCALE), MENU_LABEL(VIDEO_RECORD_THREADS), + MENU_LABEL(ADD_NULL_DRIVERS), MENU_LABEL(VIDEO_SMOOTH), MENU_LABEL(VIDEO_CTX_SCALING), #ifdef HAVE_ODROIDGO2 diff --git a/retroarch.c b/retroarch.c index 7c8e454c9a..430f0c4445 100644 --- a/retroarch.c +++ b/retroarch.c @@ -10094,8 +10094,10 @@ struct string_list *string_list_new_special(enum string_list_type type, unsigned i; core_info_list_t *core_info_list = NULL; const core_info_t *core_info = NULL; + struct rarch_state *p_rarch = &rarch_st; + settings_t *settings = p_rarch->configuration_settings; + bool add_null_entries = settings->bools.add_null_drivers; struct string_list *s = string_list_new(); - bool add_null_entries = true; if (!s || !len) goto error; @@ -10111,13 +10113,14 @@ struct string_list *string_list_new_special(enum string_list_type type, { if (menu_ctx_drivers[i]) { + bool add_null = add_null_entries; const char *opt = menu_ctx_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } } @@ -10126,13 +10129,14 @@ struct string_list *string_list_new_special(enum string_list_type type, case STRING_LIST_CAMERA_DRIVERS: for (i = 0; camera_drivers[i]; i++) { + bool add_null = add_null_entries; const char *opt = camera_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; @@ -10140,13 +10144,14 @@ struct string_list *string_list_new_special(enum string_list_type type, #ifdef HAVE_WIFI for (i = 0; wifi_drivers[i]; i++) { + bool add_null = add_null_entries; const char *opt = wifi_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; @@ -10154,65 +10159,70 @@ struct string_list *string_list_new_special(enum string_list_type type, case STRING_LIST_LOCATION_DRIVERS: for (i = 0; location_drivers[i]; i++) { + bool add_null = add_null_entries; const char *opt = location_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; case STRING_LIST_AUDIO_DRIVERS: for (i = 0; audio_drivers[i]; i++) { + bool add_null = add_null_entries; const char *opt = audio_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; case STRING_LIST_AUDIO_RESAMPLER_DRIVERS: for (i = 0; audio_resampler_driver_find_handle(i); i++) { + bool add_null = add_null_entries; const char *opt = audio_resampler_driver_find_ident(i); *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; case STRING_LIST_VIDEO_DRIVERS: for (i = 0; video_drivers[i]; i++) { + bool add_null = add_null_entries; const char *opt = video_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; case STRING_LIST_INPUT_DRIVERS: for (i = 0; input_drivers[i]; i++) { + bool add_null = add_null_entries; const char *opt = input_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; @@ -10220,13 +10230,14 @@ struct string_list *string_list_new_special(enum string_list_type type, #ifdef HAVE_HID for (i = 0; hid_drivers[i]; i++) { + bool add_null = add_null_entries; const char *opt = hid_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } #endif @@ -10234,39 +10245,42 @@ struct string_list *string_list_new_special(enum string_list_type type, case STRING_LIST_INPUT_JOYPAD_DRIVERS: for (i = 0; joypad_drivers[i]; i++) { + bool add_null = add_null_entries; const char *opt = joypad_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; case STRING_LIST_RECORD_DRIVERS: for (i = 0; record_drivers[i]; i++) { + bool add_null = add_null_entries; const char *opt = record_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; case STRING_LIST_MIDI_DRIVERS: for (i = 0; midi_driver_find_handle(i); i++) { + bool add_null = add_null_entries; const char *opt = midi_drivers[i]->ident; *len += strlen(opt) + 1; - if (!add_null_entries) - add_null_entries = (i == 0) || !string_is_equal(opt, "null"); + if (!add_null) + add_null = (i == 0) || !string_is_equal(opt, "null"); - if (add_null_entries) + if (add_null) string_list_append(s, opt, attr); } break; @@ -33445,7 +33459,8 @@ static void retroarch_deinit_drivers(struct rarch_state *p_rarch) bool driver_ctl(enum driver_ctl_state state, void *data) { struct rarch_state *p_rarch = &rarch_st; - bool add_null_entries = true; + settings_t *settings = p_rarch->configuration_settings; + bool add_null_entries = settings->bools.add_null_drivers; switch (state) {