From edc3d8ee21c23d6fe11c38f991fc4f6130006f61 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Tue, 21 Dec 2021 02:36:37 +0500 Subject: [PATCH] Add config migration paths for the renamed joystick types Fix backwards compatibility with old integer-based config joystick type selection --- src/config.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index 50c0e5c9c..bda66d417 100644 --- a/src/config.c +++ b/src/config.c @@ -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;