Add config migration paths for the renamed joystick types

Fix backwards compatibility with old integer-based config joystick type selection
This commit is contained in:
Alexander Babikov
2021-12-21 02:36:37 +05:00
parent 9b427aada9
commit edc3d8ee21

View File

@@ -914,15 +914,30 @@ load_input_devices(void)
p = config_get_string(cat, "joystick_type", NULL);
if (p != NULL) {
if (!strcmp(p, "standard_2button"))
joystick_type = joystick_get_from_internal_name("2axis_2button");
else if (!strcmp(p, "standard_4button"))
joystick_type = joystick_get_from_internal_name("2axis_4button");
else if (!strcmp(p, "standard_6button"))
joystick_type = joystick_get_from_internal_name("2axis_6button");
else if (!strcmp(p, "standard_8button"))
joystick_type = joystick_get_from_internal_name("2axis_8button");
joystick_type = joystick_get_from_internal_name(p);
if (!joystick_type) {
/* Try to read an integer for backwards compatibility with old configs */
c = config_get_int(cat, "joystick_type", 8);
if ((c >= 0) && (c < 8))
/* "None" was type 8 instead of 0 previously, shift the number accordingly */
joystick_type = c + 1;
else
joystick_type = 0;
switch (c) {
case 0: case 1: case 2: case 3: /* 2-axis joysticks */
joystick_type = c + 1;
break;
case 4: case 5: case 6: case 7: /* other joysticks */
joystick_type = c + 3;
break;
default: /* "None" (8) or invalid value */
joystick_type = 0;
break;
}
}
} else
joystick_type = 0;