Mercurial > repos > blastem
comparison controller_info.c @ 2218:58774a77f2e0
Fix crash when rebinding a controller
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 01 Sep 2022 22:37:25 -0700 |
parents | a8af8d898a7c |
children | dd9d43c67986 |
comparison
equal
deleted
inserted
replaced
2217:8483c685cf03 | 2218:58774a77f2e0 |
---|---|
212 { | 212 { |
213 #ifndef USE_FBDEV | 213 #ifndef USE_FBDEV |
214 char guid_string[33]; | 214 char guid_string[33]; |
215 SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(render_get_joystick(joystick)), guid_string, sizeof(guid_string)); | 215 SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(render_get_joystick(joystick)), guid_string, sizeof(guid_string)); |
216 tern_node *existing = tern_find_node(info_config, guid_string); | 216 tern_node *existing = tern_find_node(info_config, guid_string); |
217 existing = tern_insert_ptr(existing, "mapping", mapping_string); | 217 existing = tern_insert_ptr(existing, "mapping", strdup(mapping_string)); |
218 info_config = tern_insert_node(info_config, guid_string, existing); | 218 info_config = tern_insert_node(info_config, guid_string, existing); |
219 persist_config_at(config, info_config, "controller_types.cfg"); | 219 persist_config_at(config, info_config, "controller_types.cfg"); |
220 const char *parts[] = {guid_string, ",", mapping_string}; | 220 const char *parts[] = {guid_string, ",", mapping_string}; |
221 char * full = alloc_concat_m(3, parts); | 221 char * full = alloc_concat_m(3, parts); |
222 SDL_GameControllerAddMapping(full); | 222 SDL_GameControllerAddMapping(full); |