summaryrefslogtreecommitdiff
path: root/controller_info.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-08-03 19:32:21 -0700
committerMichael Pavone <pavone@retrodev.com>2018-08-03 19:32:21 -0700
commit9a48ad9033ec167dd8eafa8e3e9e8173b1acf363 (patch)
tree4fde12f82a2661b23979c1f17aa889321d9b7a7a /controller_info.c
parent242137754a79f868401e2f6695ed3a6db3a94327 (diff)
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
Diffstat (limited to 'controller_info.c')
-rw-r--r--controller_info.c34
1 files changed, 34 insertions, 0 deletions
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;
+}
+