Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
1603:c0727712d529 | 1604:68b05322d971 |
---|---|
1 #include <string.h> | 1 #include <string.h> |
2 #include "render_sdl.h" | 2 #include "render_sdl.h" |
3 #include "controller_info.h" | 3 #include "controller_info.h" |
4 #include "config.h" | 4 #include "config.h" |
5 #include "util.h" | |
5 | 6 |
6 typedef struct { | 7 typedef struct { |
7 char const *name; | 8 char const *name; |
8 controller_info info; | 9 controller_info info; |
9 } heuristic; | 10 } heuristic; |
148 if (valtype != TVAL_NODE) { | 149 if (valtype != TVAL_NODE) { |
149 return; | 150 return; |
150 } | 151 } |
151 char *mapping = tern_find_ptr(val.ptrval, "mapping"); | 152 char *mapping = tern_find_ptr(val.ptrval, "mapping"); |
152 if (mapping) { | 153 if (mapping) { |
153 SDL_GameControllerAddMapping(mapping); | 154 const char *parts[] = {key, ",", mapping}; |
155 char * full = alloc_concat_m(3, parts); | |
156 SDL_GameControllerAddMapping(full); | |
157 free(full); | |
154 } | 158 } |
155 } | 159 } |
156 | 160 |
157 void controller_add_mappings(void) | 161 void controller_add_mappings(void) |
158 { | 162 { |
159 load_ctype_config(); | 163 load_ctype_config(); |
160 tern_foreach(info_config, mappings_iter, NULL); | 164 if (info_config) { |
165 tern_foreach(info_config, mappings_iter, NULL); | |
166 } | |
161 } | 167 } |
162 | 168 |
163 void save_controller_info(int joystick, controller_info *info) | 169 void save_controller_info(int joystick, controller_info *info) |
164 { | 170 { |
165 char guid_string[33]; | 171 char guid_string[33]; |