Add 'Ignore null drivers' setting

This commit is contained in:
twinaphex 2020-06-27 03:00:28 +02:00
parent e0c442c99a
commit f16f3d2968
10 changed files with 112 additions and 39 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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"

View File

@ -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,

View File

@ -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:

View File

@ -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;

View File

@ -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},

View File

@ -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,

View File

@ -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

View File

@ -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)
{