From ec2242db02a0d04167a41fd0539f1f8231965f3c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 26 Nov 2014 21:48:02 +0100 Subject: [PATCH] Implement other driver options too --- driver.c | 173 ++++++++++++++++++++++++++++++++++++++++++++++-- driver.h | 10 ++- settings_data.c | 16 +++-- 3 files changed, 188 insertions(+), 11 deletions(-) diff --git a/driver.c b/driver.c index 63f4081c38..b730803f8d 100644 --- a/driver.c +++ b/driver.c @@ -101,6 +101,34 @@ static const audio_driver_t *audio_drivers[] = { NULL, }; +const char* config_get_audio_driver_options(void) +{ + union string_list_elem_attr attr; + char *options = NULL; + int option_k = 0; + int options_len = 0; + struct string_list *options_l = NULL; + + attr.i = 0; + options_l = (struct string_list*)string_list_new(); + + for (option_k = 0; audio_drivers[option_k]; option_k++) + { + const char *opt = audio_drivers[option_k]->ident; + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + static const video_driver_t *video_drivers[] = { #ifdef HAVE_OPENGL &video_gl, @@ -142,6 +170,34 @@ static const video_driver_t *video_drivers[] = { NULL, }; +const char* config_get_video_driver_options(void) +{ + union string_list_elem_attr attr; + char *options = NULL; + int option_k = 0; + int options_len = 0; + struct string_list *options_l = NULL; + + attr.i = 0; + options_l = (struct string_list*)string_list_new(); + + for (option_k = 0; video_drivers[option_k]; option_k++) + { + const char *opt = video_drivers[option_k]->ident; + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + static const input_driver_t *input_drivers[] = { #ifdef __CELLOS_LV2__ &input_ps3, @@ -190,11 +246,6 @@ static const input_driver_t *input_drivers[] = { NULL, }; -/* JM: This is a very painful function to write, - * especially because we'll have to do it to all - * the drivers. - */ - const char* config_get_input_driver_options(void) { union string_list_elem_attr attr; @@ -231,6 +282,34 @@ static const input_osk_driver_t *osk_drivers[] = { NULL, }; +const char* config_get_osk_driver_options(void) +{ + union string_list_elem_attr attr; + char *options = NULL; + int option_k = 0; + int options_len = 0; + struct string_list *options_l = NULL; + + attr.i = 0; + options_l = (struct string_list*)string_list_new(); + + for (option_k = 0; osk_drivers[option_k]; option_k++) + { + const char *opt = osk_drivers[option_k]->ident; + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + static const camera_driver_t *camera_drivers[] = { #ifdef HAVE_V4L2 &camera_v4l2, @@ -248,6 +327,34 @@ static const camera_driver_t *camera_drivers[] = { NULL, }; +const char* config_get_camera_driver_options(void) +{ + union string_list_elem_attr attr; + char *options = NULL; + int option_k = 0; + int options_len = 0; + struct string_list *options_l = NULL; + + attr.i = 0; + options_l = (struct string_list*)string_list_new(); + + for (option_k = 0; camera_drivers[option_k]; option_k++) + { + const char *opt = camera_drivers[option_k]->ident; + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + static const location_driver_t *location_drivers[] = { #ifdef ANDROID &location_android, @@ -261,6 +368,34 @@ static const location_driver_t *location_drivers[] = { NULL, }; +const char* config_get_location_driver_options(void) +{ + union string_list_elem_attr attr; + char *options = NULL; + int option_k = 0; + int options_len = 0; + struct string_list *options_l = NULL; + + attr.i = 0; + options_l = (struct string_list*)string_list_new(); + + for (option_k = 0; location_drivers[option_k]; option_k++) + { + const char *opt = location_drivers[option_k]->ident; + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + #ifdef HAVE_MENU static const menu_ctx_driver_t *menu_ctx_drivers[] = { #ifdef IOS @@ -286,6 +421,34 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = { #endif NULL }; + +const char* config_get_menu_driver_options(void) +{ + union string_list_elem_attr attr; + char *options = NULL; + int option_k = 0; + int options_len = 0; + struct string_list *options_l = NULL; + + attr.i = 0; + options_l = (struct string_list*)string_list_new(); + + for (option_k = 0; menu_ctx_drivers[option_k]; option_k++) + { + const char *opt = menu_ctx_drivers[option_k]->ident; + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} #endif static const void *find_driver_nonempty(const char *label, int i, diff --git a/driver.h b/driver.h index 0b3871103c..1a165920ae 100644 --- a/driver.h +++ b/driver.h @@ -675,7 +675,15 @@ extern input_driver_t input_qnx; extern input_driver_t input_rwebinput; extern input_driver_t input_null; - const char* config_get_input_driver_options(void); +const char* config_get_input_driver_options(void); +const char* config_get_camera_driver_options(void); +const char* config_get_video_driver_options(void); +const char* config_get_audio_driver_options(void); +const char* config_get_osk_driver_options(void); +const char* config_get_location_driver_options(void); +#ifdef HAVE_MENU +const char* config_get_menu_driver_options(void); +#endif extern camera_driver_t camera_v4l2; extern camera_driver_t camera_android; diff --git a/settings_data.c b/settings_data.c index ddb2aca62a..993138bc40 100644 --- a/settings_data.c +++ b/settings_data.c @@ -2991,11 +2991,12 @@ static bool setting_data_append_list_driver_options( NULL); settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); - CONFIG_STRING( + CONFIG_STRING_OPTIONS( g_settings.video.driver, "video_driver", "Video Driver", config_get_default_video(), + config_get_video_driver_options(), group_info.name, subgroup_info.name, NULL, @@ -3012,11 +3013,13 @@ static bool setting_data_append_list_driver_options( NULL, NULL); settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); - CONFIG_STRING( + + CONFIG_STRING_OPTIONS( g_settings.audio.driver, "audio_driver", "Audio Driver", config_get_default_audio(), + config_get_audio_driver_options(), group_info.name, subgroup_info.name, NULL, @@ -3034,22 +3037,24 @@ static bool setting_data_append_list_driver_options( NULL); (*list)[list_info->index - 1].action_toggle = &setting_data_string_action_toggle_audio_resampler; - CONFIG_STRING( + CONFIG_STRING_OPTIONS( g_settings.camera.driver, "camera_driver", "Camera Driver", config_get_default_camera(), + config_get_camera_driver_options(), group_info.name, subgroup_info.name, NULL, NULL); settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); - CONFIG_STRING( + CONFIG_STRING_OPTIONS( g_settings.location.driver, "location_driver", "Location Driver", config_get_default_location(), + config_get_location_driver_options(), group_info.name, subgroup_info.name, NULL, @@ -3057,11 +3062,12 @@ static bool setting_data_append_list_driver_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); #ifdef HAVE_MENU - CONFIG_STRING( + CONFIG_STRING_OPTIONS( g_settings.menu.driver, "menu_driver", "Menu Driver", config_get_default_menu(), + config_get_menu_driver_options(), group_info.name, subgroup_info.name, NULL,