From 9a48ad9033ec167dd8eafa8e3e9e8173b1acf363 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Fri, 3 Aug 2018 19:32:21 -0700 Subject: 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 --- controller_info.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'controller_info.c') diff --git a/controller_info.c b/controller_info.c index c9ca1c7..59934c3 100644 --- a/controller_info.c +++ b/controller_info.c @@ -261,3 +261,37 @@ const char *get_axis_label(controller_info *info, int axis) } } +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; +} + -- cgit v1.2.3