mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
More code deduplication
This commit is contained in:
parent
4a7595c7d2
commit
f6ed72b21c
@ -20,7 +20,9 @@
|
||||
|
||||
#include "input_keymaps.h"
|
||||
#include "../general.h"
|
||||
#ifndef IS_JOYCONFIG
|
||||
#include "../string_list_special.h"
|
||||
#endif
|
||||
|
||||
static input_device_driver_t *joypad_drivers[] = {
|
||||
#ifdef __CELLOS_LV2__
|
||||
@ -97,6 +99,7 @@ const char *joypad_driver_find_ident(int idx)
|
||||
return drv->ident;
|
||||
}
|
||||
|
||||
#ifndef IS_JOYCONFIG
|
||||
/**
|
||||
* config_get_joypad_driver_options:
|
||||
*
|
||||
@ -108,6 +111,7 @@ const char* config_get_joypad_driver_options(void)
|
||||
{
|
||||
return string_list_special_new(STRING_LIST_INPUT_JOYPAD_DRIVERS);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* input_joypad_init_driver:
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <string/string_list.h>
|
||||
|
||||
#include "../general.h"
|
||||
#include "../string_list_special.h"
|
||||
|
||||
static const location_driver_t *location_drivers[] = {
|
||||
#ifdef ANDROID
|
||||
@ -73,39 +73,7 @@ const char *location_driver_find_ident(int idx)
|
||||
**/
|
||||
const char* config_get_location_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; location_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = location_driver_find_ident(i);
|
||||
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_LOCATION_DRIVERS);
|
||||
}
|
||||
|
||||
void find_location_driver(void)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "../driver.h"
|
||||
#include "../general.h"
|
||||
#include "../msg_hash.h"
|
||||
#include "../string_list_special.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
@ -75,40 +76,7 @@ const void *record_driver_find_handle(int idx)
|
||||
**/
|
||||
const char* config_get_record_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; record_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = record_driver_find_ident(i);
|
||||
|
||||
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_RECORD_DRIVERS);
|
||||
}
|
||||
|
||||
void find_record_driver(void)
|
||||
|
@ -26,10 +26,15 @@
|
||||
#include "camera/camera_driver.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LOCATION
|
||||
#include "location/location_driver.h"
|
||||
#endif
|
||||
|
||||
#include "gfx/video_driver.h"
|
||||
#include "input/input_driver.h"
|
||||
#include "input/input_joypad_driver.h"
|
||||
#include "audio/audio_driver.h"
|
||||
#include "record/record_driver.h"
|
||||
|
||||
const char *string_list_special_new(enum string_list_type type)
|
||||
{
|
||||
@ -48,7 +53,6 @@ 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);
|
||||
@ -57,7 +61,6 @@ 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
|
||||
@ -69,9 +72,18 @@ const char *string_list_special_new(enum string_list_type type)
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case STRING_LIST_LOCATION_DRIVERS:
|
||||
#ifdef HAVE_LOCATION
|
||||
for (i = 0; location_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = location_driver_find_ident(i);
|
||||
options_len += strlen(opt) + 1;
|
||||
string_list_append(options_l, opt, attr);
|
||||
}
|
||||
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);
|
||||
@ -79,10 +91,8 @@ 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);
|
||||
@ -90,10 +100,8 @@ 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);
|
||||
@ -101,7 +109,6 @@ const char *string_list_special_new(enum string_list_type type)
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case STRING_LIST_INPUT_JOYPAD_DRIVERS:
|
||||
for (i = 0; joypad_driver_find_handle(i); i++)
|
||||
@ -112,6 +119,15 @@ const char *string_list_special_new(enum string_list_type type)
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
break;
|
||||
case STRING_LIST_RECORD_DRIVERS:
|
||||
for (i = 0; record_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = record_driver_find_ident(i);
|
||||
len += strlen(opt) + 1;
|
||||
|
||||
string_list_append(s, opt, attr);
|
||||
}
|
||||
break;
|
||||
case STRING_LIST_NONE:
|
||||
default:
|
||||
goto end;
|
||||
|
@ -21,9 +21,11 @@ enum string_list_type
|
||||
STRING_LIST_NONE = 0,
|
||||
STRING_LIST_MENU_DRIVERS,
|
||||
STRING_LIST_CAMERA_DRIVERS,
|
||||
STRING_LIST_LOCATION_DRIVERS,
|
||||
STRING_LIST_AUDIO_DRIVERS,
|
||||
STRING_LIST_VIDEO_DRIVERS,
|
||||
STRING_LIST_INPUT_DRIVERS,
|
||||
STRING_LIST_RECORD_DRIVERS,
|
||||
STRING_LIST_INPUT_JOYPAD_DRIVERS
|
||||
};
|
||||
|
||||
|
@ -24,8 +24,6 @@
|
||||
#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