From 29595ce4f774cb81eb5fc4843bb7644d599f97f8 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Wed, 29 Dec 2021 09:51:42 +0500 Subject: [PATCH] Fix joystick type migration not working as intended Map legacy integer-based joystick type options directly --- src/config.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/config.c b/src/config.c index c37d0b18b..08326da71 100644 --- a/src/config.c +++ b/src/config.c @@ -927,21 +927,41 @@ load_input_devices(void) joystick_type = joystick_get_from_internal_name("2axis_8button"); else if (!strcmp(p, "ch_flighstick_pro")) joystick_type = joystick_get_from_internal_name("ch_flightstick_pro"); + else + joystick_type = joystick_get_from_internal_name(p); - 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); - 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; + if (!strcmp(p, "0")) /* workaround for config_get_int returning 0 on non-integer data */ + joystick_type = joystick_get_from_internal_name("2axis_2button"); + else { + c = config_get_int(cat, "joystick_type", 8); + switch (c) { + case 1: + joystick_type = joystick_get_from_internal_name("2axis_4button"); + break; + case 2: + joystick_type = joystick_get_from_internal_name("2axis_6button"); + break; + case 3: + joystick_type = joystick_get_from_internal_name("2axis_8button"); + break; + case 4: + joystick_type = joystick_get_from_internal_name("4axis_4button"); + break; + case 5: + joystick_type = joystick_get_from_internal_name("ch_flightstick_pro"); + break; + case 6: + joystick_type = joystick_get_from_internal_name("sidewinder_pad"); + break; + case 7: + joystick_type = joystick_get_from_internal_name("thrustmaster_fcs"); + break; + default: + joystick_type = 0; + break; + } } } } else