diff controller_info.c @ 1604:68b05322d971

Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name
author Michael Pavone <pavone@retrodev.com>
date Tue, 31 Jul 2018 23:19:39 -0700
parents c0727712d529
children 419a0a133b5c
line wrap: on
line diff
--- 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)