Mercurial > repos > blastem
changeset 1861:fc05f49075c2
Reprocess bindings when SDL2 mappings, controller types or controller order change
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 03 May 2019 18:56:12 -0700 |
parents | bdca98187c9f |
children | e07fc3d473b2 |
files | controller_info.c render_sdl.c |
diffstat | 2 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 }
--- 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; }