Implement other driver options too

This commit is contained in:
twinaphex 2014-11-26 21:48:02 +01:00
parent 195e0f2aa2
commit ec2242db02
3 changed files with 188 additions and 11 deletions

173
driver.c
View File

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

View File

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

View File

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