From f06f6e544ec56cb5d741c7ded5b41ef48d898b3d Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 26 Apr 2013 15:02:18 +0200 Subject: [PATCH] Don't spam OSD messages for autoconfigure. --- general.h | 1 + input/input_common.c | 9 ++++++++- input/linuxraw_joypad.c | 15 +++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/general.h b/general.h index 76eac149a7..82aac61198 100644 --- a/general.h +++ b/general.h @@ -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]; diff --git a/input/input_common.c b/input/input_common.c index 4cb3a5b327..1b060e6819 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -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); diff --git a/input/linuxraw_joypad.c b/input/linuxraw_joypad.c index 33c64083a9..6144340f64 100644 --- a/input/linuxraw_joypad.c +++ b/input/linuxraw_joypad.c @@ -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();