mirror of
https://github.com/holub/mame
synced 2025-04-24 01:11:11 +03:00
Service mode DIP switch adjustments
- Changed how input sequences are assigned to service mode DIP switches. The frontend now assigns them the default sequence for the non-toggle service mode/test switch (not necessarily the F2 key, the previously hardcoded default) unless the machine happens to have one of those as well (as is somewhat common with gambling games). - All DIP and configuration switches are automatically defined as toggle fields to make assigning input codes to them easier.
This commit is contained in:
parent
2b13832d36
commit
e624a3cd38
@ -634,6 +634,8 @@ ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value def
|
||||
if (device().subtag(def->tag) == fulltag && def->mask == m_mask)
|
||||
m_defvalue = def->defvalue & m_mask;
|
||||
}
|
||||
|
||||
m_flags |= FIELD_FLAG_TOGGLE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -706,6 +708,24 @@ const input_seq &ioport_field::defseq(input_seq_type seqtype) const
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// set_defseq - dynamically alter the default
|
||||
// input sequence for the given input field
|
||||
//-------------------------------------------------
|
||||
|
||||
void ioport_field::set_defseq(input_seq_type seqtype, const input_seq &newseq)
|
||||
{
|
||||
const bool was_changed = seq(seqtype) != defseq(seqtype);
|
||||
|
||||
// set the new sequence
|
||||
m_seq[seqtype] = newseq;
|
||||
|
||||
// also update live state unless previously customized
|
||||
if (m_live != nullptr && !was_changed)
|
||||
m_live->seq[seqtype] = newseq;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// type_class - return the type class for this
|
||||
// field
|
||||
@ -3112,13 +3132,6 @@ ioport_configurer& ioport_configurer::onoff_alloc(const char *name, ioport_value
|
||||
// allocate a field normally
|
||||
field_alloc(IPT_DIPSWITCH, defval, mask, name);
|
||||
|
||||
// special case service mode
|
||||
if (name == DEF_STR(Service_Mode))
|
||||
{
|
||||
field_set_toggle();
|
||||
m_curfield->m_seq[SEQ_TYPE_STANDARD].set(KEYCODE_F2);
|
||||
}
|
||||
|
||||
// expand the diplocation
|
||||
if (diplocation != nullptr)
|
||||
field_set_diplocation(diplocation);
|
||||
|
@ -1058,6 +1058,8 @@ public:
|
||||
const input_seq &seq(input_seq_type seqtype = SEQ_TYPE_STANDARD) const;
|
||||
const input_seq &defseq(input_seq_type seqtype = SEQ_TYPE_STANDARD) const;
|
||||
const input_seq &defseq_unresolved(input_seq_type seqtype = SEQ_TYPE_STANDARD) const { return m_seq[seqtype]; }
|
||||
void set_defseq(const input_seq &newseq) { set_defseq(SEQ_TYPE_STANDARD, newseq); }
|
||||
void set_defseq(input_seq_type seqtype, const input_seq &newseq);
|
||||
bool has_dynamic_read() const { return !m_read.isnull(); }
|
||||
bool has_dynamic_write() const { return !m_write.isnull(); }
|
||||
|
||||
|
@ -30,6 +30,7 @@ machine_info::machine_info(running_machine &machine)
|
||||
m_has_dips = false;
|
||||
m_has_bioses = false;
|
||||
m_has_keyboard = false;
|
||||
m_has_test_switch = false;
|
||||
|
||||
// scan the input port array to see what options we need to enable
|
||||
for (auto &port : machine.ioport().ports())
|
||||
@ -43,6 +44,8 @@ machine_info::machine_info(running_machine &machine)
|
||||
m_has_analog = true;
|
||||
if (field.type() == IPT_KEYBOARD)
|
||||
m_has_keyboard = true;
|
||||
if (field.type() == IPT_SERVICE)
|
||||
m_has_test_switch = true;
|
||||
}
|
||||
|
||||
for (device_t &device : device_iterator(machine.root_device()))
|
||||
@ -51,6 +54,24 @@ machine_info::machine_info(running_machine &machine)
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// find_dipname - look up DIP switch by name
|
||||
//-------------------------------------------------
|
||||
|
||||
ioport_field *machine_info::find_dipname(const char *name) const
|
||||
{
|
||||
if (!m_has_dips)
|
||||
return nullptr;
|
||||
|
||||
for (auto &port : m_machine.ioport().ports())
|
||||
for (ioport_field &field : port.second->fields())
|
||||
if (field.type() == IPT_DIPSWITCH && strcmp(field.name(), name) == 0)
|
||||
return &field;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
TEXT GENERATORS
|
||||
***************************************************************************/
|
||||
|
@ -29,6 +29,9 @@ public:
|
||||
bool has_dips() const { return m_has_dips; }
|
||||
bool has_bioses() const { return m_has_bioses; }
|
||||
bool has_keyboard() const { return m_has_keyboard; }
|
||||
bool has_test_switch() const { return m_has_test_switch; }
|
||||
|
||||
ioport_field *find_dipname(const char *name) const;
|
||||
|
||||
// text generators
|
||||
std::string warnings_string();
|
||||
@ -46,6 +49,7 @@ private:
|
||||
bool m_has_dips;
|
||||
bool m_has_bioses;
|
||||
bool m_has_keyboard;
|
||||
bool m_has_test_switch;
|
||||
};
|
||||
|
||||
class menu_game_info : public menu
|
||||
|
@ -256,6 +256,13 @@ void mame_ui_manager::initialize(running_machine &machine)
|
||||
{
|
||||
slider_current = nullptr;
|
||||
}
|
||||
|
||||
if (!m_machine_info->has_test_switch())
|
||||
{
|
||||
ioport_field *service_mode_sw = m_machine_info->find_dipname(ioport_configurer::string_from_token(DEF_STR(Service_Mode)));
|
||||
if (service_mode_sw != nullptr)
|
||||
service_mode_sw->set_defseq(machine.ioport().type_seq(IPT_SERVICE));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user