mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 02:00:41 +00:00
More code de-duplication
This commit is contained in:
parent
0116ea5ba5
commit
8b978bc674
@ -18,10 +18,9 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <string/string_list.h>
|
||||
|
||||
#include "input_keymaps.h"
|
||||
#include "../general.h"
|
||||
#include "../string_list_special.h"
|
||||
|
||||
static input_device_driver_t *joypad_drivers[] = {
|
||||
#ifdef __CELLOS_LV2__
|
||||
@ -107,39 +106,7 @@ const char *joypad_driver_find_ident(int idx)
|
||||
**/
|
||||
const char* config_get_joypad_driver_options(void)
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
unsigned i;
|
||||
char *options = NULL;
|
||||
int options_len = 0;
|
||||
struct string_list *options_l = string_list_new();
|
||||
|
||||
attr.i = 0;
|
||||
|
||||
if (!options_l)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; joypad_drivers[i]; i++)
|
||||
{
|
||||
const char *opt = joypad_drivers[i]->ident;
|
||||
options_len += strlen(opt) + 1;
|
||||
string_list_append(options_l, opt, attr);
|
||||
}
|
||||
|
||||
options = (char*)calloc(options_len, sizeof(char));
|
||||
|
||||
if (!options)
|
||||
{
|
||||
string_list_free(options_l);
|
||||
options_l = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
string_list_join_concat(options, options_len, options_l, "|");
|
||||
|
||||
string_list_free(options_l);
|
||||
options_l = NULL;
|
||||
|
||||
return options;
|
||||
return string_list_special_new(STRING_LIST_INPUT_JOYPAD_DRIVERS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "gfx/video_driver.h"
|
||||
#include "input/input_driver.h"
|
||||
#include "input/input_joypad_driver.h"
|
||||
#include "audio/audio_driver.h"
|
||||
|
||||
const char *string_list_special_new(enum string_list_type type)
|
||||
@ -47,6 +48,7 @@ const char *string_list_special_new(enum string_list_type type)
|
||||
{
|
||||
case STRING_LIST_MENU_DRIVERS:
|
||||
#ifdef HAVE_MENU
|
||||
#ifndef IS_JOYCONFIG
|
||||
for (i = 0; menu_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = menu_driver_find_ident(i);
|
||||
@ -55,6 +57,7 @@ const char *string_list_special_new(enum string_list_type type)
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case STRING_LIST_CAMERA_DRIVERS:
|
||||
#ifdef HAVE_CAMERA
|
||||
@ -68,6 +71,7 @@ const char *string_list_special_new(enum string_list_type type)
|
||||
break;
|
||||
#endif
|
||||
case STRING_LIST_AUDIO_DRIVERS:
|
||||
#ifndef IS_JOYCONFIG
|
||||
for (i = 0; audio_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = audio_driver_find_ident(i);
|
||||
@ -75,8 +79,10 @@ const char *string_list_special_new(enum string_list_type type)
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case STRING_LIST_VIDEO_DRIVERS:
|
||||
#ifndef IS_JOYCONFIG
|
||||
for (i = 0; video_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = video_driver_find_ident(i);
|
||||
@ -84,13 +90,25 @@ const char *string_list_special_new(enum string_list_type type)
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case STRING_LIST_INPUT_DRIVERS:
|
||||
#ifndef IS_JOYCONFIG
|
||||
for (i = 0; input_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = input_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case STRING_LIST_INPUT_JOYPAD_DRIVERS:
|
||||
for (i = 0; joypad_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = joypad_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
break;
|
||||
|
@ -23,7 +23,8 @@ enum string_list_type
|
||||
STRING_LIST_CAMERA_DRIVERS,
|
||||
STRING_LIST_AUDIO_DRIVERS,
|
||||
STRING_LIST_VIDEO_DRIVERS,
|
||||
STRING_LIST_INPUT_DRIVERS
|
||||
STRING_LIST_INPUT_DRIVERS,
|
||||
STRING_LIST_INPUT_JOYPAD_DRIVERS
|
||||
};
|
||||
|
||||
const char *string_list_special_new(enum string_list_type type);
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "../libretro-common/file/retro_file.c"
|
||||
#include "../libretro-common/file/retro_stat.c"
|
||||
|
||||
#include "../string_list_special.c"
|
||||
|
||||
#if defined(__linux) && !defined(ANDROID)
|
||||
#include "../input/drivers/linuxraw_input.c"
|
||||
#include "../input/drivers_joypad/linuxraw_joypad.c"
|
||||
|
Loading…
Reference in New Issue
Block a user