# HG changeset patch # User Michael Pavone # Date 1556934972 25200 # Node ID fc05f49075c28978e7026e007529aeee9339c62c # Parent bdca98187c9f852a33230e12621ba901b82233ac Reprocess bindings when SDL2 mappings, controller types or controller order change diff -r bdca98187c9f -r fc05f49075c2 controller_info.c --- a/controller_info.c Fri May 03 18:40:13 2019 -0700 +++ b/controller_info.c Fri May 03 18:56:12 2019 -0700 @@ -7,6 +7,7 @@ #include "config.h" #include "util.h" #include "blastem.h" +#include "bindings.h" typedef struct { char const *name; @@ -199,6 +200,7 @@ existing = tern_insert_ptr(existing, "variant", strdup(variant_names[info->variant])); info_config = tern_insert_node(info_config, guid_string, existing); persist_config_at(config, info_config, "controller_types.cfg"); + handle_joy_added(joystick); #endif } @@ -211,6 +213,11 @@ existing = tern_insert_ptr(existing, "mapping", mapping_string); info_config = tern_insert_node(info_config, guid_string, existing); persist_config_at(config, info_config, "controller_types.cfg"); + const char *parts[] = {guid_string, ",", mapping_string}; + char * full = alloc_concat_m(3, parts); + SDL_GameControllerAddMapping(full); + free(full); + handle_joy_added(joystick); #endif } diff -r bdca98187c9f -r fc05f49075c2 render_sdl.c --- a/render_sdl.c Fri May 03 18:40:13 2019 -0700 +++ b/render_sdl.c Fri May 03 18:56:12 2019 -0700 @@ -950,6 +950,11 @@ joysticks[desired_index] = tmp_joy; joystick_sdl_index[desired_index] = tmp_index; joystick_index_locked[desired_index] = 1; + //update bindings as the controllers being swapped may have different mappings + handle_joy_added(desired_index); + if (joysticks[joystick]) { + handle_joy_added(joystick); + } return desired_index; }