Mercurial > repos > blastem
diff controller_info.c @ 1608:419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 03 Aug 2018 19:32:21 -0700 |
parents | 68b05322d971 |
children | 84ef1eb2c96a |
line wrap: on
line diff
--- a/controller_info.c Thu Aug 02 19:06:57 2018 -0700 +++ b/controller_info.c Fri Aug 03 19:32:21 2018 -0700 @@ -261,3 +261,37 @@ } } +char *make_controller_type_key(controller_info *info) +{ + const char *subtype; + if (info->subtype == SUBTYPE_UNKNOWN) { + switch(info->type) + { + case TYPE_XBOX: + subtype = subtype_names[SUBTYPE_X360]; + break; + case TYPE_PSX: + subtype = subtype_names[SUBTYPE_PS4]; + break; + case TYPE_NINTENDO: + subtype = subtype_names[SUBTYPE_SWITCH]; + break; + default: + subtype = "unknown"; + } + } else { + subtype = subtype_names[info->subtype]; + } + const char *variant = variant_names[info->variant]; + const char *parts[] = {subtype, "_", variant}; + char *ret = alloc_concat_m(3, parts); + for (char *cur = ret; *cur; cur++) + { + if (*cur == ' ') + { + *cur = '_'; + } + } + return ret; +} +