From e6728f5077492ff5bbf48890b263d1cbf972626a Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 31 Jul 2018 23:19:39 -0700 Subject: Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name --- controller_info.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'controller_info.c') diff --git a/controller_info.c b/controller_info.c index 12c90b3..c9ca1c7 100644 --- a/controller_info.c +++ b/controller_info.c @@ -2,6 +2,7 @@ #include "render_sdl.h" #include "controller_info.h" #include "config.h" +#include "util.h" typedef struct { char const *name; @@ -150,14 +151,19 @@ static void mappings_iter(char *key, tern_val val, uint8_t valtype, void *data) } char *mapping = tern_find_ptr(val.ptrval, "mapping"); if (mapping) { - SDL_GameControllerAddMapping(mapping); + const char *parts[] = {key, ",", mapping}; + char * full = alloc_concat_m(3, parts); + SDL_GameControllerAddMapping(full); + free(full); } } void controller_add_mappings(void) { load_ctype_config(); - tern_foreach(info_config, mappings_iter, NULL); + if (info_config) { + tern_foreach(info_config, mappings_iter, NULL); + } } void save_controller_info(int joystick, controller_info *info) -- cgit v1.2.3