Mercurial > repos > blastem
diff controller_info.c @ 1931:374a5ae694e8 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 18 Apr 2020 11:42:53 -0700 |
parents | fc05f49075c2 |
children | 8a64d86cc362 |
line wrap: on
line diff
--- a/controller_info.c Thu Apr 18 22:06:47 2019 -0700 +++ b/controller_info.c Sat Apr 18 11:42:53 2020 -0700 @@ -6,6 +6,8 @@ #include "controller_info.h" #include "config.h" #include "util.h" +#include "blastem.h" +#include "bindings.h" typedef struct { char const *name; @@ -66,7 +68,7 @@ static void load_ctype_config(void) { if (!loaded) { - info_config = load_overrideable_config("controller_types.cfg", "controller_types.cfg"); + info_config = load_overrideable_config("controller_types.cfg", "controller_types.cfg", NULL); loaded = 1; } } @@ -194,10 +196,11 @@ char guid_string[33]; SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(render_get_joystick(joystick)), guid_string, sizeof(guid_string)); tern_node *existing = tern_find_node(info_config, guid_string); - existing = tern_insert_ptr(existing, "subtype", (void *)subtype_names[info->subtype]); - existing = tern_insert_ptr(existing, "variant", (void *)variant_names[info->variant]); + existing = tern_insert_ptr(existing, "subtype", strdup(subtype_names[info->subtype])); + existing = tern_insert_ptr(existing, "variant", strdup(variant_names[info->variant])); info_config = tern_insert_node(info_config, guid_string, existing); - persist_config_at(info_config, "controller_types.cfg"); + persist_config_at(config, info_config, "controller_types.cfg"); + handle_joy_added(joystick); #endif } @@ -209,7 +212,12 @@ tern_node *existing = tern_find_node(info_config, guid_string); existing = tern_insert_ptr(existing, "mapping", mapping_string); info_config = tern_insert_node(info_config, guid_string, existing); - persist_config_at(info_config, "controller_types.cfg"); + 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 }