summaryrefslogtreecommitdiff
path: root/controller_info.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-11-30 00:35:05 -0800
committerMichael Pavone <pavone@retrodev.com>2018-11-30 00:35:05 -0800
commit8bbaa2d21379e777584ed1367bdcc60c575bdece (patch)
treeeb6ac4e61e74c0ab4fb7de1675d63c9eb2f2fa17 /controller_info.c
parentf001120e88e9e148e46677c731754cdcf1e1b6fd (diff)
Added code for actually saving new controller bindings to an appropriate key in the config file
Diffstat (limited to 'controller_info.c')
-rw-r--r--controller_info.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/controller_info.c b/controller_info.c
index 59934c3..a34265e 100644
--- a/controller_info.c
+++ b/controller_info.c
@@ -41,6 +41,19 @@ static const char *subtype_names[] = {
"genesis",
"saturn"
};
+static const char *subtype_human_names[] = {
+ "unknown",
+ "Xbos",
+ "Xbox 360",
+ "Xbox One",
+ "PS2",
+ "PS3",
+ "PS4",
+ "Wii-U",
+ "Switch",
+ "Genesis",
+ "Saturn"
+};
static const char *variant_names[] = {
"normal",
"6b bumpers",
@@ -295,3 +308,27 @@ char *make_controller_type_key(controller_info *info)
return ret;
}
+char *make_human_readable_type_name(controller_info *info)
+{
+ const char *base = subtype_human_names[info->subtype];
+ char *prefix;
+ if (info->variant == VARIANT_NORMAL) {
+ prefix = "Normal ";
+ } else {
+ static const char *parts[] = {"6 button (", NULL, "/", NULL, ") "};
+ if (info->variant == VARIANT_6B_BUMPERS) {
+ parts[1] = get_button_label(info, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
+ parts[3] = get_button_label(info, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
+ } else {
+ parts[1] = get_button_label(info, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
+ parts[3] = get_axis_label(info, SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
+ }
+ prefix = alloc_concat_m(5, parts);
+ }
+ char *ret = alloc_concat(prefix, base);
+ if (info->variant != VARIANT_NORMAL) {
+ free(prefix);
+ }
+ return ret;
+}
+