From 678b56c7de757449334474f85d1022d9325d9faf Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 1 Mar 2023 03:22:48 +1100 Subject: 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. --- src/emu/ioport.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index 892fad1a59c..73257338b17 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -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; -- cgit v1.2.3