mirror of
https://github.com/libretro/RetroArch
synced 2025-03-06 04:13:52 +00:00
Make joypad driver configurable.
This commit is contained in:
parent
aea523c418
commit
b323640d7c
@ -216,6 +216,7 @@ struct settings
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char driver[32];
|
char driver[32];
|
||||||
|
char joypad_driver[32];
|
||||||
struct retro_keybind binds[MAX_PLAYERS][RARCH_BIND_LIST_END];
|
struct retro_keybind binds[MAX_PLAYERS][RARCH_BIND_LIST_END];
|
||||||
|
|
||||||
// Set by autoconfiguration in joypad_autoconfig_dir. Does not override main binds.
|
// Set by autoconfiguration in joypad_autoconfig_dir. Does not override main binds.
|
||||||
|
@ -126,7 +126,7 @@ static void *dinput_init(void)
|
|||||||
IDirectInputDevice8_Acquire(di->mouse);
|
IDirectInputDevice8_Acquire(di->mouse);
|
||||||
|
|
||||||
input_init_keyboard_lut(rarch_key_map_dinput);
|
input_init_keyboard_lut(rarch_key_map_dinput);
|
||||||
di->joypad = input_joypad_init_first();
|
di->joypad = input_joypad_init_driver(g_settings.input.joypad_driver);
|
||||||
|
|
||||||
return di;
|
return di;
|
||||||
|
|
||||||
|
@ -54,11 +54,14 @@ static const rarch_joypad_driver_t *joypad_drivers[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
const rarch_joypad_driver_t *input_joypad_find_driver(const char *ident)
|
const rarch_joypad_driver_t *input_joypad_init_driver(const char *ident)
|
||||||
{
|
{
|
||||||
|
if (!ident || !*ident)
|
||||||
|
return input_joypad_init_first();
|
||||||
|
|
||||||
for (unsigned i = 0; joypad_drivers[i]; i++)
|
for (unsigned i = 0; joypad_drivers[i]; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(ident, joypad_drivers[i]->ident) == 0)
|
if (strcmp(ident, joypad_drivers[i]->ident) == 0 && joypad_drivers[i]->init())
|
||||||
{
|
{
|
||||||
RARCH_LOG("Found joypad driver: \"%s\".\n", joypad_drivers[i]->ident);
|
RARCH_LOG("Found joypad driver: \"%s\".\n", joypad_drivers[i]->ident);
|
||||||
return joypad_drivers[i];
|
return joypad_drivers[i];
|
||||||
|
@ -71,7 +71,8 @@ typedef struct rarch_joypad_driver
|
|||||||
const char *ident;
|
const char *ident;
|
||||||
} rarch_joypad_driver_t;
|
} rarch_joypad_driver_t;
|
||||||
|
|
||||||
const rarch_joypad_driver_t *input_joypad_find_driver(const char *ident);
|
// If ident points to NULL or a zero-length string, equivalent to calling input_joypad_init_first().
|
||||||
|
const rarch_joypad_driver_t *input_joypad_init_driver(const char *ident);
|
||||||
const rarch_joypad_driver_t *input_joypad_init_first(void);
|
const rarch_joypad_driver_t *input_joypad_init_first(void);
|
||||||
|
|
||||||
bool input_joypad_pressed(const rarch_joypad_driver_t *driver,
|
bool input_joypad_pressed(const rarch_joypad_driver_t *driver,
|
||||||
|
@ -226,7 +226,7 @@ static void *linuxraw_input_init(void)
|
|||||||
|
|
||||||
atexit(linuxraw_resetKbmd);
|
atexit(linuxraw_resetKbmd);
|
||||||
|
|
||||||
linuxraw->joypad = input_joypad_init_first();
|
linuxraw->joypad = input_joypad_init_driver(g_settings.input.joypad_driver);
|
||||||
init_lut();
|
init_lut();
|
||||||
|
|
||||||
driver.stdin_claimed = true; // We need to disable use of stdin command interface if stdin is supposed to be used for input.
|
driver.stdin_claimed = true; // We need to disable use of stdin command interface if stdin is supposed to be used for input.
|
||||||
|
@ -40,7 +40,7 @@ static void *sdl_input_init(void)
|
|||||||
if (!sdl)
|
if (!sdl)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
sdl->joypad = input_joypad_init_first();
|
sdl->joypad = input_joypad_init_driver(g_settings.input.joypad_driver);
|
||||||
return sdl;
|
return sdl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ static void *x_input_init(void)
|
|||||||
x11->display = (Display*)driver.video_display;
|
x11->display = (Display*)driver.video_display;
|
||||||
x11->win = (Window)driver.video_window;
|
x11->win = (Window)driver.video_window;
|
||||||
|
|
||||||
x11->joypad = input_joypad_init_first();
|
x11->joypad = input_joypad_init_driver(g_settings.input.joypad_driver);
|
||||||
input_init_keyboard_lut(rarch_key_map_x11);
|
input_init_keyboard_lut(rarch_key_map_x11);
|
||||||
|
|
||||||
return x11;
|
return x11;
|
||||||
|
@ -184,6 +184,9 @@
|
|||||||
# Input driver. Depending on video driver, it might force a different input driver.
|
# Input driver. Depending on video driver, it might force a different input driver.
|
||||||
# input_driver = sdl
|
# input_driver = sdl
|
||||||
|
|
||||||
|
# Joypad driver. (Valid: linuxraw, sdl, dinput)
|
||||||
|
# input_joypad_driver =
|
||||||
|
|
||||||
# Defines axis threshold. Possible values are [0.0, 1.0]
|
# Defines axis threshold. Possible values are [0.0, 1.0]
|
||||||
# input_axis_threshold = 0.5
|
# input_axis_threshold = 0.5
|
||||||
|
|
||||||
|
@ -619,6 +619,7 @@ bool config_load_file(const char *path)
|
|||||||
CONFIG_GET_STRING(audio.driver, "audio_driver");
|
CONFIG_GET_STRING(audio.driver, "audio_driver");
|
||||||
CONFIG_GET_PATH(audio.dsp_plugin, "audio_dsp_plugin");
|
CONFIG_GET_PATH(audio.dsp_plugin, "audio_dsp_plugin");
|
||||||
CONFIG_GET_STRING(input.driver, "input_driver");
|
CONFIG_GET_STRING(input.driver, "input_driver");
|
||||||
|
CONFIG_GET_STRING(input.joypad_driver, "input_joypad_driver");
|
||||||
|
|
||||||
if (!*g_settings.libretro)
|
if (!*g_settings.libretro)
|
||||||
CONFIG_GET_PATH(libretro, "libretro_path");
|
CONFIG_GET_PATH(libretro, "libretro_path");
|
||||||
|
@ -39,6 +39,7 @@ static int g_timeout = 0;
|
|||||||
static char *g_in_path = NULL;
|
static char *g_in_path = NULL;
|
||||||
static char *g_out_path = NULL;
|
static char *g_out_path = NULL;
|
||||||
static char *g_auto_path = NULL;
|
static char *g_auto_path = NULL;
|
||||||
|
static char *g_driver = NULL;
|
||||||
static unsigned g_meta_level = 0;
|
static unsigned g_meta_level = 0;
|
||||||
|
|
||||||
static void print_help(void)
|
static void print_help(void)
|
||||||
@ -58,6 +59,7 @@ static void print_help(void)
|
|||||||
puts("\tThese configurations are for player 1 only.");
|
puts("\tThese configurations are for player 1 only.");
|
||||||
puts("-m/--misc: Same as --allmisc, but exposes a smaller subset of misc binds which are deemed most useful for regular use.");
|
puts("-m/--misc: Same as --allmisc, but exposes a smaller subset of misc binds which are deemed most useful for regular use.");
|
||||||
puts("-t/--timeout: Adds a timeout of N seconds to each bind. If timed out, the bind will not be used.");
|
puts("-t/--timeout: Adds a timeout of N seconds to each bind. If timed out, the bind will not be used.");
|
||||||
|
puts("-d/--driver: Uses a specific joypad driver.");
|
||||||
puts("-h/--help: This help.");
|
puts("-h/--help: This help.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ static void poll_joypad(const rarch_joypad_driver_t *driver,
|
|||||||
|
|
||||||
static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, int joypad)
|
static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, int joypad)
|
||||||
{
|
{
|
||||||
const rarch_joypad_driver_t *driver = input_joypad_init_first();
|
const rarch_joypad_driver_t *driver = input_joypad_init_driver(g_driver);
|
||||||
if (!driver)
|
if (!driver)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Cannot find any valid input driver.\n");
|
fprintf(stderr, "Cannot find any valid input driver.\n");
|
||||||
@ -313,7 +315,7 @@ out:
|
|||||||
|
|
||||||
static void parse_input(int argc, char *argv[])
|
static void parse_input(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char optstring[] = "i:o:a:p:j:t:hmM";
|
char optstring[] = "i:o:a:p:j:t:hmMd:";
|
||||||
struct option opts[] = {
|
struct option opts[] = {
|
||||||
{ "input", 1, NULL, 'i' },
|
{ "input", 1, NULL, 'i' },
|
||||||
{ "output", 1, NULL, 'o' },
|
{ "output", 1, NULL, 'o' },
|
||||||
@ -324,6 +326,7 @@ static void parse_input(int argc, char *argv[])
|
|||||||
{ "misc", 0, NULL, 'm' },
|
{ "misc", 0, NULL, 'm' },
|
||||||
{ "allmisc", 0, NULL, 'M' },
|
{ "allmisc", 0, NULL, 'M' },
|
||||||
{ "timeout", 1, NULL, 't' },
|
{ "timeout", 1, NULL, 't' },
|
||||||
|
{ "driver", 1, NULL, 'd' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -348,6 +351,10 @@ static void parse_input(int argc, char *argv[])
|
|||||||
g_timeout = strtol(optarg, NULL, 0);
|
g_timeout = strtol(optarg, NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
g_driver = strdup(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
g_out_path = strdup(optarg);
|
g_out_path = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user