diff controller_info.c @ 2624:6bd492b8172e

Update gamecontrollerdb.txt and tweak the entries and controller type heuristics so they work out of the box (at least on Win/Linux)
author Michael Pavone <pavone@retrodev.com>
date Sat, 22 Feb 2025 22:14:03 -0800
parents 639561060a28
children 36aa9ead0e62
line wrap: on
line diff
--- a/controller_info.c	Sat Feb 22 19:52:50 2025 -0800
+++ b/controller_info.c	Sat Feb 22 22:14:03 2025 -0800
@@ -30,7 +30,9 @@
 	{"Wii U", {.type = TYPE_NINTENDO, .subtype = SUBTYPE_WIIU}},
 	{"Nintendo Switch", {.type = TYPE_NINTENDO, .subtype = SUBTYPE_SWITCH}},
 	{"Saturn", {.type = TYPE_SEGA, .subtype = SUBTYPE_SATURN}},
-	{"8BitDo M30", {.type = TYPE_SEGA, .subtype = SUBTYPE_GENESIS, .variant = VARIANT_8BUTTON}}
+	{"8BitDo M30", {.type = TYPE_SEGA, .subtype = SUBTYPE_GENESIS, .variant = VARIANT_8BUTTON}},
+	{"Mini 3B Controller", {.type = TYPE_SEGA, .subtype = SUBTYPE_GENESIS, .variant = VARIANT_3BUTTON}},
+	{"Mini 6B Controller", {.type = TYPE_SEGA, .subtype = SUBTYPE_GENESIS, .variant = VARIANT_6B_BUMPERS}}
 };
 const uint32_t num_heuristics = sizeof(heuristics)/sizeof(*heuristics);
 
@@ -71,7 +73,6 @@
 	"6b bumpers",
 	"6b right",
 	"3button",
-	"6button",
 	"8button"
 };
 
@@ -140,13 +141,18 @@
 		char *variant = tern_find_ptr(info, "variant");
 		res.variant = VARIANT_NORMAL;
 		if (variant) {
-			for (int i = 0; i < VARIANT_NUM; i++)
+			int i;
+			for (i = 0; i < VARIANT_NUM; i++)
 			{
 				if (!strcmp(variant_names[i], variant)) {
 					res.variant = i;
 					break;
 				}
 			}
+			if (i == VARIANT_NUM && !strcmp("6button", variant)) {
+				//workaround for some bad saved configs caused by a silly bug
+				res.variant = VARIANT_8BUTTON;
+			}
 		}
 		res.name = control ? SDL_GameControllerName(control) : SDL_JoystickName(stick);
 		res.stick_deadzone = atoi(tern_find_ptr_default(info, "stick_deadzone", DEFAULT_DEADZONE_STR));