Merge pull request #1968 from lemondrops/bugfix/config_migration

Fixes to config file backwards compatibility
This commit is contained in:
Miran Grča
2021-12-29 16:26:47 +01:00
committed by GitHub
2 changed files with 40 additions and 15 deletions

View File

@@ -888,7 +888,10 @@ load_video(void)
} }
free_p = 1; free_p = 1;
} }
gfxcard = video_get_video_from_internal_name(p); if (!strcmp(p, "virge375_vbe20_pci")) /* migrate renamed cards */
gfxcard = video_get_video_from_internal_name("virge385_pci");
else
gfxcard = video_get_video_from_internal_name(p);
if (free_p) if (free_p)
free(p); free(p);
} }
@@ -914,7 +917,7 @@ load_input_devices(void)
p = config_get_string(cat, "joystick_type", NULL); p = config_get_string(cat, "joystick_type", NULL);
if (p != NULL) { if (p != NULL) {
if (!strcmp(p, "standard_2button")) if (!strcmp(p, "standard_2button")) /* migrate renamed types */
joystick_type = joystick_get_from_internal_name("2axis_2button"); joystick_type = joystick_get_from_internal_name("2axis_2button");
else if (!strcmp(p, "standard_4button")) else if (!strcmp(p, "standard_4button"))
joystick_type = joystick_get_from_internal_name("2axis_4button"); joystick_type = joystick_get_from_internal_name("2axis_4button");
@@ -922,21 +925,43 @@ load_input_devices(void)
joystick_type = joystick_get_from_internal_name("2axis_6button"); joystick_type = joystick_get_from_internal_name("2axis_6button");
else if (!strcmp(p, "standard_8button")) else if (!strcmp(p, "standard_8button"))
joystick_type = joystick_get_from_internal_name("2axis_8button"); 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) { if (!joystick_type) {
/* Try to read an integer for backwards compatibility with old configs */ /* Try to read an integer for backwards compatibility with old configs */
c = config_get_int(cat, "joystick_type", 8); if (!strcmp(p, "0")) /* workaround for config_get_int returning 0 on non-integer data */
switch (c) { joystick_type = joystick_get_from_internal_name("2axis_2button");
case 0: case 1: case 2: case 3: /* 2-axis joysticks */ else {
joystick_type = c + 1; c = config_get_int(cat, "joystick_type", 8);
break; switch (c) {
case 4: case 5: case 6: case 7: /* other joysticks */ case 1:
joystick_type = c + 3; joystick_type = joystick_get_from_internal_name("2axis_4button");
break; break;
default: /* "None" (8) or invalid value */ case 2:
joystick_type = 0; joystick_type = joystick_get_from_internal_name("2axis_6button");
break; 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 } else

View File

@@ -88,7 +88,7 @@ static const struct {
{ "3axis_2button", &joystick_3axis_2button }, { "3axis_2button", &joystick_3axis_2button },
{ "3axis_4button", &joystick_3axis_4button }, { "3axis_4button", &joystick_3axis_4button },
{ "4axis_4button", &joystick_4axis_4button }, { "4axis_4button", &joystick_4axis_4button },
{ "ch_flighstick_pro", &joystick_ch_flightstick_pro }, { "ch_flightstick_pro", &joystick_ch_flightstick_pro },
{ "sidewinder_pad", &joystick_sw_pad }, { "sidewinder_pad", &joystick_sw_pad },
{ "thrustmaster_fcs", &joystick_tm_fcs }, { "thrustmaster_fcs", &joystick_tm_fcs },
{ "", NULL } { "", NULL }