emu/ioport.cpp: Changed config save/load behaviour for conditional fields.

* See GitHub #10937 for issues with current approach.
* Only save configuration for enabled fields.
* Apply loaded configuration to all matching fields.
This commit is contained in:
Vas Crabb 2023-03-01 03:22:48 +11:00
parent e629a85548
commit 678b56c7de

View File

@ -2460,6 +2460,7 @@ bool ioport_manager::load_controller_config(
// find the matching field
ioport_value const defvalue = portnode.get_attribute_int("defvalue", 0);
bool matched = false;
for (ioport_field &field : port->second->fields())
{
// find the matching mask and default value
@ -2521,13 +2522,16 @@ bool ioport_manager::load_controller_config(
#endif
}
// successfully applied
return true;
// only break out of the loop for unconditional inputs
if (field.condition().condition() == ioport_condition::ALWAYS)
return true;
else
matched = true;
}
}
// no matching field
return false;
// return whether any field matched
return matched;
}
@ -2598,7 +2602,10 @@ void ioport_manager::load_system_config(
else if (revstring && !strcmp(revstring, "no"))
field.live().analog->m_reverse = false;
}
break;
// only break out of the loop for unconditional inputs
if (field.condition().condition() == ioport_condition::ALWAYS)
break;
}
}
}
@ -2822,7 +2829,7 @@ void ioport_manager::save_game_inputs(util::xml::data_node &parentnode)
// iterate over ports
for (auto &port : m_portlist)
for (ioport_field const &field : port.second->fields())
if (save_this_input_field_type(field.type()))
if (save_this_input_field_type(field.type()) && field.enabled())
{
// determine if we changed
bool changed = false;