Don't spam OSD messages for autoconfigure.

This commit is contained in:
Themaister 2013-04-26 15:02:18 +02:00
parent cca7fce89c
commit f06f6e544e
3 changed files with 18 additions and 7 deletions

View File

@ -220,6 +220,7 @@ struct settings
// Set by autoconfiguration in joypad_autoconfig_dir. Does not override main binds.
struct retro_keybind autoconf_binds[MAX_PLAYERS][RARCH_BIND_LIST_END];
bool autoconfigured[MAX_PLAYERS];
float axis_threshold;
int joypad_map[MAX_PLAYERS];

View File

@ -809,11 +809,16 @@ void input_config_autoconfigure_joypad(unsigned index, const char *name, const c
if (!g_settings.input.autodetect_enable)
return;
// This will be the case if input driver is reinit. No reason to spam autoconfigure messages
// every time (fine in log).
bool block_osd_spam = g_settings.input.autoconfigured[index] && name;
for (unsigned i = 0; i < RARCH_BIND_LIST_END; i++)
{
g_settings.input.autoconf_binds[index][i].joykey = NO_BTN;
g_settings.input.autoconf_binds[index][i].joyaxis = AXIS_NONE;
}
g_settings.input.autoconfigured[index] = false;
if (!name)
return;
@ -840,13 +845,15 @@ void input_config_autoconfigure_joypad(unsigned index, const char *name, const c
if (!strcmp(ident, name) && !strcmp(driver, input_driver))
{
g_settings.input.autoconfigured[index] = true;
input_autoconfigure_joypad_conf(conf, g_settings.input.autoconf_binds[index]);
char msg[512];
snprintf(msg, sizeof(msg), "Joypad port #%u (%s) configured.",
index, name);
msg_queue_push(g_extern.msg_queue, msg, 0, 60);
if (!block_osd_spam)
msg_queue_push(g_extern.msg_queue, msg, 0, 60);
RARCH_LOG("%s\n", msg);
config_file_free(conf);

View File

@ -68,15 +68,15 @@ static void poll_pad(struct linuxraw_joypad *pad)
}
}
static void linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *pad)
static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *pad)
{
if (pad->fd >= 0)
return;
return false;
// Device can have just been created, but not made accessible (yet).
// IN_ATTRIB will signal when permissions change.
if (access(path, R_OK) < 0)
return;
return false;
pad->fd = open(path, O_RDONLY | O_NONBLOCK);
@ -106,9 +106,13 @@ static void linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p
event.events = EPOLLIN;
event.data.ptr = pad;
epoll_ctl(g_epoll, EPOLL_CTL_ADD, pad->fd, &event);
return true;
}
else
{
RARCH_ERR("[Joypad]: Failed to open pad %s (error: %s).\n", path, strerror(errno));
return false;
}
}
static void handle_plugged_pad(void)
@ -164,10 +168,10 @@ static void handle_plugged_pad(void)
{
char path[PATH_MAX];
snprintf(path, sizeof(path), "/dev/input/%s", event->name);
linuxraw_joypad_init_pad(path, &g_pads[index]);
bool ret = linuxraw_joypad_init_pad(path, &g_pads[index]);
#ifndef IS_JOYCONFIG
if (*g_pads[index].ident)
if (*g_pads[index].ident && ret)
input_config_autoconfigure_joypad(index, g_pads[index].ident, "linuxraw");
#endif
}
@ -220,7 +224,6 @@ static bool linuxraw_joypad_init(void)
linuxraw_joypad_init_pad(path, pad);
if (pad->fd >= 0)
poll_pad(pad);
}
g_notify = inotify_init();