mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
(task_autodetect.c) Solve some threading errors
This commit is contained in:
parent
31aa1d6d19
commit
3a581ba8b0
@ -289,31 +289,11 @@ static bool input_autoconfigure_joypad_from_conf_internal(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool input_autoconfigure_joypad_init(autoconfig_params_t *params)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
if (!settings || !settings->input.autodetect_enable)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (i = 0; i < RARCH_BIND_LIST_END; i++)
|
|
||||||
{
|
|
||||||
settings->input.autoconf_binds[params->idx][i].joykey = NO_BTN;
|
|
||||||
settings->input.autoconf_binds[params->idx][i].joyaxis = AXIS_NONE;
|
|
||||||
settings->input.autoconf_binds[params->idx][i].joykey_label[0] = '\0';
|
|
||||||
settings->input.autoconf_binds[params->idx][i].joyaxis_label[0] = '\0';
|
|
||||||
}
|
|
||||||
settings->input.autoconfigured[params->idx] = false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void input_autoconfigure_connect_handler(retro_task_t *task)
|
static void input_autoconfigure_connect_handler(retro_task_t *task)
|
||||||
{
|
{
|
||||||
autoconfig_params_t *params = (autoconfig_params_t*)task->state;
|
autoconfig_params_t *params = (autoconfig_params_t*)task->state;
|
||||||
|
|
||||||
if (!params || !input_autoconfigure_joypad_init(params) || string_is_empty(params->name))
|
if (!params || string_is_empty(params->name))
|
||||||
{
|
{
|
||||||
free(params);
|
free(params);
|
||||||
task->finished = true;
|
task->finished = true;
|
||||||
@ -343,13 +323,10 @@ static void input_autoconfigure_connect_handler(retro_task_t *task)
|
|||||||
static void input_autoconfigure_disconnect_handler(retro_task_t *task)
|
static void input_autoconfigure_disconnect_handler(retro_task_t *task)
|
||||||
{
|
{
|
||||||
autoconfig_disconnect_t *params = (autoconfig_disconnect_t*)task->state;
|
autoconfig_disconnect_t *params = (autoconfig_disconnect_t*)task->state;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
task->title = strdup(params->msg);
|
task->title = strdup(params->msg);
|
||||||
task->finished = true;
|
task->finished = true;
|
||||||
|
|
||||||
settings->input.device_names[params->idx][0] = '\0';
|
|
||||||
|
|
||||||
RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_AUTODETECT), params->msg);
|
RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_AUTODETECT), params->msg);
|
||||||
|
|
||||||
free(params);
|
free(params);
|
||||||
@ -358,8 +335,9 @@ static void input_autoconfigure_disconnect_handler(retro_task_t *task)
|
|||||||
bool input_autoconfigure_disconnect(unsigned i, const char *ident)
|
bool input_autoconfigure_disconnect(unsigned i, const char *ident)
|
||||||
{
|
{
|
||||||
char msg[255];
|
char msg[255];
|
||||||
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
|
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
|
||||||
autoconfig_disconnect_t *state = (autoconfig_disconnect_t*)calloc(1, sizeof(*state));
|
autoconfig_disconnect_t *state = (autoconfig_disconnect_t*)calloc(1, sizeof(*state));
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
if (!state || !task)
|
if (!state || !task)
|
||||||
goto error;
|
goto error;
|
||||||
@ -374,6 +352,8 @@ bool input_autoconfigure_disconnect(unsigned i, const char *ident)
|
|||||||
|
|
||||||
strlcpy(state->msg, msg, sizeof(state->msg));
|
strlcpy(state->msg, msg, sizeof(state->msg));
|
||||||
|
|
||||||
|
settings->input.device_names[state->idx][0] = '\0';
|
||||||
|
|
||||||
task->state = state;
|
task->state = state;
|
||||||
task->handler = input_autoconfigure_disconnect_handler;
|
task->handler = input_autoconfigure_disconnect_handler;
|
||||||
|
|
||||||
@ -392,6 +372,7 @@ error:
|
|||||||
|
|
||||||
bool input_autoconfigure_connect(autoconfig_params_t *params)
|
bool input_autoconfigure_connect(autoconfig_params_t *params)
|
||||||
{
|
{
|
||||||
|
unsigned i;
|
||||||
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
|
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
|
||||||
autoconfig_params_t *state = (autoconfig_params_t*)calloc(1, sizeof(*state));
|
autoconfig_params_t *state = (autoconfig_params_t*)calloc(1, sizeof(*state));
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
@ -401,6 +382,15 @@ bool input_autoconfigure_connect(autoconfig_params_t *params)
|
|||||||
|
|
||||||
strlcpy(state->name, params->name, sizeof(state->name));
|
strlcpy(state->name, params->name, sizeof(state->name));
|
||||||
|
|
||||||
|
for (i = 0; i < RARCH_BIND_LIST_END; i++)
|
||||||
|
{
|
||||||
|
settings->input.autoconf_binds[params->idx][i].joykey = NO_BTN;
|
||||||
|
settings->input.autoconf_binds[params->idx][i].joyaxis = AXIS_NONE;
|
||||||
|
settings->input.autoconf_binds[params->idx][i].joykey_label[0] = '\0';
|
||||||
|
settings->input.autoconf_binds[params->idx][i].joyaxis_label[0] = '\0';
|
||||||
|
}
|
||||||
|
settings->input.autoconfigured[params->idx] = false;
|
||||||
|
|
||||||
state->idx = params->idx;
|
state->idx = params->idx;
|
||||||
state->vid = params->vid;
|
state->vid = params->vid;
|
||||||
state->pid = params->pid;
|
state->pid = params->pid;
|
||||||
|
Loading…
Reference in New Issue
Block a user