# HG changeset patch # User Michael Pavone # Date 1533104379 25200 # Node ID 68b05322d971311ae627bf7c8c107fc831b835a7 # Parent c0727712d5299a88011af0aab2cb054451e18bc7 Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name diff -r c0727712d529 -r 68b05322d971 controller_info.c --- a/controller_info.c Tue Jul 31 23:08:52 2018 -0700 +++ b/controller_info.c Tue Jul 31 23:19:39 2018 -0700 @@ -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 @@ } 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) diff -r c0727712d529 -r 68b05322d971 nuklear_ui/blastem_nuklear.c --- a/nuklear_ui/blastem_nuklear.c Tue Jul 31 23:08:52 2018 -0700 +++ b/nuklear_ui/blastem_nuklear.c Tue Jul 31 23:19:39 2018 -0700 @@ -839,10 +839,14 @@ const char *name = SDL_JoystickName(joy); size_t namesz = strlen(name); mapping_string = malloc(512 + namesz); - SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joy), mapping_string, 33); - mapping_string[32] = ','; - memcpy(mapping_string + 33, name, namesz); - mapping_pos = 33+namesz; + for (mapping_pos = 0; mapping_pos < namesz; mapping_pos++) + { + char c = name[mapping_pos]; + if (c == ',' || c == '\n' || c == '\r') { + c = ' '; + } + mapping_string[mapping_pos] = c; + } push_view(view_controller_mappings); }