diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index c65de1fe56..15f6d7f8f2 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -570,10 +570,13 @@ static void render_text(rgui_handle_t *rgui) strlcpy(type_str, "...", sizeof(type_str)); break; case RGUI_SETTINGS_BIND_DEVICE: - strlcpy(type_str, g_settings.input.device_names[port], sizeof(type_str)); + { + int map = g_settings.input.joypad_map[port]; + strlcpy(type_str, g_settings.input.device_names[map], sizeof(type_str)); break; + } case RGUI_SETTINGS_BIND_DPAD_EMULATION: - switch(g_settings.input.dpad_emulation[port]) + switch (g_settings.input.dpad_emulation[port]) { case ANALOG_DPAD_NONE: strlcpy(type_str, "None", sizeof(type_str)); diff --git a/input/linuxraw_joypad.c b/input/linuxraw_joypad.c index dbb80a9aa6..a2f86ab451 100644 --- a/input/linuxraw_joypad.c +++ b/input/linuxraw_joypad.c @@ -35,7 +35,7 @@ struct linuxraw_joypad bool buttons[NUM_BUTTONS]; int16_t axes[NUM_AXES]; - char ident[256]; + char *ident; }; static struct linuxraw_joypad g_pads[MAX_PLAYERS]; @@ -79,7 +79,7 @@ static void linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p *pad->ident = '\0'; if (pad->fd >= 0) { - if (ioctl(pad->fd, JSIOCGNAME(sizeof(pad->ident)), pad->ident) >= 0) + if (ioctl(pad->fd, JSIOCGNAME(sizeof(g_settings.input.device_names[0])), pad->ident) >= 0) RARCH_LOG("[Joypad]: Found pad: %s on %s.\n", pad->ident, path); else RARCH_ERR("[Joypad]: Didn't find ident of %s.\n", path); @@ -122,8 +122,10 @@ static void handle_plugged_pad(void) { RARCH_LOG("[Joypad]: Joypad %s disconnected.\n", g_pads[index].ident); close(g_pads[index].fd); - memset(&g_pads[index], 0, sizeof(g_pads[index])); + memset(g_pads[index].buttons, 0, sizeof(g_pads[index].buttons)); + memset(g_pads[index].axes, 0, sizeof(g_pads[index].axes)); g_pads[index].fd = -1; + *g_pads[index].ident = '\0'; } } // Sometimes, device will be created before acess to it is established. @@ -174,6 +176,7 @@ static bool linuxraw_joypad_init(void) { struct linuxraw_joypad *pad = &g_pads[i]; pad->fd = -1; + pad->ident = g_settings.input.device_names[i]; char path[PATH_MAX]; snprintf(path, sizeof(path), "/dev/input/js%u", i); @@ -181,6 +184,7 @@ static bool linuxraw_joypad_init(void) linuxraw_joypad_init_pad(path, pad); if (pad->fd >= 0) poll_pad(pad); + } g_notify = inotify_init();