mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 00:39:53 +00:00
Move code over to input_driver.c
This commit is contained in:
parent
2b08ebb677
commit
3c69a941da
12
driver.h
12
driver.h
@ -83,6 +83,18 @@ typedef struct driver_ctx_info
|
|||||||
|
|
||||||
bool driver_ctl(enum driver_ctl_state state, void *data);
|
bool driver_ctl(enum driver_ctl_state state, void *data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* driver_find_index:
|
||||||
|
* @label : string of driver type to be found.
|
||||||
|
* @drv : identifier of driver to be found.
|
||||||
|
*
|
||||||
|
* Find index of the driver, based on @label.
|
||||||
|
*
|
||||||
|
* Returns: -1 if no driver based on @label and @drv found, otherwise
|
||||||
|
* index number of the driver found in the array.
|
||||||
|
**/
|
||||||
|
int driver_find_index(const char *label, const char *drv);
|
||||||
|
|
||||||
/* Sets audio and video drivers to nonblock state.
|
/* Sets audio and video drivers to nonblock state.
|
||||||
*
|
*
|
||||||
* If nonblock state is false, sets blocking state for both
|
* If nonblock state is false, sets blocking state for both
|
||||||
|
@ -2090,3 +2090,55 @@ void input_event_osk_append(
|
|||||||
word);
|
word);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *input_driver_init_wrap(input_driver_t *input, const char *name)
|
||||||
|
{
|
||||||
|
void *ret = NULL;
|
||||||
|
if (!input)
|
||||||
|
return NULL;
|
||||||
|
if ((ret = input->init(name)))
|
||||||
|
{
|
||||||
|
input_driver_init_joypads();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool input_driver_find_driver(
|
||||||
|
input_driver_state_t *input_driver_state,
|
||||||
|
settings_t *settings,
|
||||||
|
const char *prefix,
|
||||||
|
bool verbosity_enabled)
|
||||||
|
{
|
||||||
|
int i = (int)driver_find_index(
|
||||||
|
"input_driver",
|
||||||
|
settings->arrays.input_driver);
|
||||||
|
|
||||||
|
if (i >= 0)
|
||||||
|
{
|
||||||
|
input_driver_state->current_driver = (input_driver_t*)input_drivers[i];
|
||||||
|
RARCH_LOG("[Input]: Found %s: \"%s\".\n", prefix,
|
||||||
|
input_driver_state->current_driver->ident);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
input_driver_t *tmp = NULL;
|
||||||
|
if (verbosity_enabled)
|
||||||
|
{
|
||||||
|
unsigned d;
|
||||||
|
RARCH_ERR("Couldn't find any %s named \"%s\"\n", prefix,
|
||||||
|
settings->arrays.input_driver);
|
||||||
|
RARCH_LOG_OUTPUT("Available %ss are:\n", prefix);
|
||||||
|
for (d = 0; input_drivers[d]; d++)
|
||||||
|
RARCH_LOG_OUTPUT("\t%s\n", input_drivers[d]->ident);
|
||||||
|
RARCH_WARN("Going to default to first %s...\n", prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = (input_driver_t*)input_drivers[0];
|
||||||
|
if (!tmp)
|
||||||
|
return false;
|
||||||
|
input_driver_state->current_driver = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -723,6 +723,12 @@ bool input_driver_toggle_button_combo(
|
|||||||
retro_time_t current_time,
|
retro_time_t current_time,
|
||||||
input_bits_t* p_input);
|
input_bits_t* p_input);
|
||||||
|
|
||||||
|
bool input_driver_find_driver(
|
||||||
|
input_driver_state_t *input_driver_state,
|
||||||
|
settings_t *settings,
|
||||||
|
const char *prefix,
|
||||||
|
bool verbosity_enabled);
|
||||||
|
|
||||||
int16_t input_state_wrap(
|
int16_t input_state_wrap(
|
||||||
input_driver_t *current_input,
|
input_driver_t *current_input,
|
||||||
void *data,
|
void *data,
|
||||||
|
100
retroarch.c
100
retroarch.c
@ -453,17 +453,7 @@ void *video_driver_get_data(void)
|
|||||||
|
|
||||||
/* DRIVERS */
|
/* DRIVERS */
|
||||||
|
|
||||||
/**
|
int driver_find_index(const char *label, const char *drv)
|
||||||
* driver_find_index:
|
|
||||||
* @label : string of driver type to be found.
|
|
||||||
* @drv : identifier of driver to be found.
|
|
||||||
*
|
|
||||||
* Find index of the driver, based on @label.
|
|
||||||
*
|
|
||||||
* Returns: -1 if no driver based on @label and @drv found, otherwise
|
|
||||||
* index number of the driver found in the array.
|
|
||||||
**/
|
|
||||||
static int driver_find_index(const char *label, const char *drv)
|
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char str[256];
|
char str[256];
|
||||||
@ -20304,60 +20294,6 @@ void input_driver_init_joypads(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *input_driver_init_wrap(input_driver_t *input, const char *name)
|
|
||||||
{
|
|
||||||
void *ret = NULL;
|
|
||||||
if (!input)
|
|
||||||
return NULL;
|
|
||||||
if ((ret = input->init(name)))
|
|
||||||
{
|
|
||||||
input_driver_init_joypads();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool input_driver_find_driver(
|
|
||||||
struct rarch_state *p_rarch,
|
|
||||||
settings_t *settings,
|
|
||||||
const char *prefix,
|
|
||||||
bool verbosity_enabled)
|
|
||||||
{
|
|
||||||
int i = (int)driver_find_index(
|
|
||||||
"input_driver",
|
|
||||||
settings->arrays.input_driver);
|
|
||||||
|
|
||||||
if (i >= 0)
|
|
||||||
{
|
|
||||||
p_rarch->input_driver_state.current_driver = (input_driver_t*)input_drivers[i];
|
|
||||||
RARCH_LOG("[Input]: Found %s: \"%s\".\n", prefix,
|
|
||||||
p_rarch->input_driver_state.current_driver->ident);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (verbosity_enabled)
|
|
||||||
{
|
|
||||||
unsigned d;
|
|
||||||
RARCH_ERR("Couldn't find any %s named \"%s\"\n", prefix,
|
|
||||||
settings->arrays.input_driver);
|
|
||||||
RARCH_LOG_OUTPUT("Available %ss are:\n", prefix);
|
|
||||||
for (d = 0; input_drivers[d]; d++)
|
|
||||||
RARCH_LOG_OUTPUT("\t%s\n", input_drivers[d]->ident);
|
|
||||||
RARCH_WARN("Going to default to first %s...\n", prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
p_rarch->input_driver_state.current_driver = (input_driver_t*)input_drivers[0];
|
|
||||||
|
|
||||||
if (!p_rarch->input_driver_state.current_driver)
|
|
||||||
{
|
|
||||||
retroarch_fail(p_rarch, 1, "find_input_driver()");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_COMMAND
|
#ifdef HAVE_COMMAND
|
||||||
static void input_driver_init_command(struct rarch_state *p_rarch,
|
static void input_driver_init_command(struct rarch_state *p_rarch,
|
||||||
settings_t *settings)
|
settings_t *settings)
|
||||||
@ -22138,6 +22074,7 @@ static bool audio_driver_find_driver(struct rarch_state *p_rarch,
|
|||||||
audio_drivers[i];
|
audio_drivers[i];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const audio_driver_t *tmp = NULL;
|
||||||
if (verbosity_enabled)
|
if (verbosity_enabled)
|
||||||
{
|
{
|
||||||
unsigned d;
|
unsigned d;
|
||||||
@ -22152,11 +22089,11 @@ static bool audio_driver_find_driver(struct rarch_state *p_rarch,
|
|||||||
RARCH_WARN("Going to default to first %s...\n", prefix);
|
RARCH_WARN("Going to default to first %s...\n", prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_rarch->current_audio = (const audio_driver_t*)
|
tmp = (const audio_driver_t*)audio_drivers[0];
|
||||||
audio_drivers[0];
|
|
||||||
|
|
||||||
if (!p_rarch->current_audio)
|
if (!tmp)
|
||||||
retroarch_fail(p_rarch, 1, "audio_driver_find()");
|
return false;
|
||||||
|
p_rarch->current_audio = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -22222,8 +22159,9 @@ static bool audio_driver_init_internal(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_driver_find_driver(p_rarch, settings,
|
if (!(audio_driver_find_driver(p_rarch, settings,
|
||||||
"audio driver", verbosity_enabled);
|
"audio driver", verbosity_enabled)))
|
||||||
|
retroarch_fail(p_rarch, 1, "audio_driver_find()");
|
||||||
|
|
||||||
if (!p_rarch->current_audio || !p_rarch->current_audio->init)
|
if (!p_rarch->current_audio || !p_rarch->current_audio->init)
|
||||||
{
|
{
|
||||||
@ -24143,8 +24081,12 @@ static void video_driver_init_input(
|
|||||||
if (tmp)
|
if (tmp)
|
||||||
*input = tmp;
|
*input = tmp;
|
||||||
else
|
else
|
||||||
input_driver_find_driver(p_rarch, settings, "input driver",
|
{
|
||||||
verbosity_enabled);
|
if (!(input_driver_find_driver(
|
||||||
|
&p_rarch->input_driver_state, settings, "input driver",
|
||||||
|
verbosity_enabled)))
|
||||||
|
retroarch_fail(p_rarch, 1, "find_input_driver()");
|
||||||
|
}
|
||||||
|
|
||||||
/* This should never really happen as tmp (driver.input) is always
|
/* This should never really happen as tmp (driver.input) is always
|
||||||
* found before this in find_driver_input(), or we have aborted
|
* found before this in find_driver_input(), or we have aborted
|
||||||
@ -29982,12 +29924,16 @@ bool retroarch_main_init(int argc, char *argv[])
|
|||||||
* Attempts to find a default driver for
|
* Attempts to find a default driver for
|
||||||
* all driver types.
|
* all driver types.
|
||||||
*/
|
*/
|
||||||
audio_driver_find_driver(p_rarch, settings,
|
if (!(audio_driver_find_driver(p_rarch, settings,
|
||||||
"audio driver", verbosity_enabled);
|
"audio driver", verbosity_enabled)))
|
||||||
|
retroarch_fail(p_rarch, 1, "audio_driver_find()");
|
||||||
video_driver_find_driver(p_rarch, settings,
|
video_driver_find_driver(p_rarch, settings,
|
||||||
"video driver", verbosity_enabled);
|
"video driver", verbosity_enabled);
|
||||||
input_driver_find_driver(p_rarch, settings,
|
if (!input_driver_find_driver(
|
||||||
"input driver", verbosity_enabled);
|
&p_rarch->input_driver_state, settings,
|
||||||
|
"input driver", verbosity_enabled))
|
||||||
|
retroarch_fail(p_rarch, 1, "find_input_driver()");
|
||||||
|
|
||||||
camera_driver_find_driver(p_rarch, settings,
|
camera_driver_find_driver(p_rarch, settings,
|
||||||
"camera driver", verbosity_enabled);
|
"camera driver", verbosity_enabled);
|
||||||
bluetooth_driver_ctl(RARCH_BLUETOOTH_CTL_FIND_DRIVER, NULL);
|
bluetooth_driver_ctl(RARCH_BLUETOOTH_CTL_FIND_DRIVER, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user