mirror of
https://github.com/holub/mame
synced 2025-04-28 11:11:48 +03:00
Hardcoded toggled inputs (eg. simulated hi-lo gearshift-lock in racing games) can now be manually turned off or on by the user. [hap]
For example, to disable the toggle on the shifter in outrun, open /cfg/outrun.cfg and add toggle="no" to the port tag, like so: <port tag=":SERVICE" type="P1_BUTTON1" mask="16" defvalue="0" toggle="no">
This commit is contained in:
parent
ace93fb887
commit
d0406ad5e0
@ -245,6 +245,7 @@ struct ioport_field_live
|
|||||||
ioport_value value; // current value of this port
|
ioport_value value; // current value of this port
|
||||||
UINT8 impulse; // counter for impulse controls
|
UINT8 impulse; // counter for impulse controls
|
||||||
bool last; // were we pressed last time?
|
bool last; // were we pressed last time?
|
||||||
|
bool toggle; // current toggle setting
|
||||||
digital_joystick::direction_t joydir; // digital joystick direction index
|
digital_joystick::direction_t joydir; // digital joystick direction index
|
||||||
astring name; // overridden name
|
astring name; // overridden name
|
||||||
};
|
};
|
||||||
@ -1813,6 +1814,12 @@ void ioport_field::get_user_settings(user_settings &settings)
|
|||||||
settings.centerdelta = m_live->analog->centerdelta();
|
settings.centerdelta = m_live->analog->centerdelta();
|
||||||
settings.reverse = m_live->analog->reverse();
|
settings.reverse = m_live->analog->reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// non-analog settings
|
||||||
|
else
|
||||||
|
{
|
||||||
|
settings.toggle = m_live->toggle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1845,6 +1852,12 @@ void ioport_field::set_user_settings(const user_settings &settings)
|
|||||||
m_live->analog->m_centerdelta = settings.centerdelta;
|
m_live->analog->m_centerdelta = settings.centerdelta;
|
||||||
m_live->analog->m_reverse = settings.reverse;
|
m_live->analog->m_reverse = settings.reverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// non-analog settings
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_live->toggle = settings.toggle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2036,12 +2049,12 @@ void ioport_field::frame_update(ioport_value &result, bool mouse_down)
|
|||||||
// if this is a switch-down event, handle impulse and toggle
|
// if this is a switch-down event, handle impulse and toggle
|
||||||
if (changed && curstate)
|
if (changed && curstate)
|
||||||
{
|
{
|
||||||
// impluse controls: reset the impulse counter
|
// impulse controls: reset the impulse counter
|
||||||
if (effective_impulse != 0 && m_live->impulse == 0)
|
if (effective_impulse != 0 && m_live->impulse == 0)
|
||||||
m_live->impulse = effective_impulse;
|
m_live->impulse = effective_impulse;
|
||||||
|
|
||||||
// toggle controls: flip the toggle state or advance to the next setting
|
// toggle controls: flip the toggle state or advance to the next setting
|
||||||
if (toggle())
|
if (m_live->toggle)
|
||||||
{
|
{
|
||||||
if (m_settinglist.count() == 0)
|
if (m_settinglist.count() == 0)
|
||||||
m_live->value ^= m_mask;
|
m_live->value ^= m_mask;
|
||||||
@ -2060,7 +2073,7 @@ void ioport_field::frame_update(ioport_value &result, bool mouse_down)
|
|||||||
|
|
||||||
// for toggle switches, the current value is folded into the port's default value
|
// for toggle switches, the current value is folded into the port's default value
|
||||||
// so we always return FALSE here
|
// so we always return FALSE here
|
||||||
if (toggle())
|
if (m_live->toggle)
|
||||||
curstate = false;
|
curstate = false;
|
||||||
|
|
||||||
// additional logic to restrict digital joysticks
|
// additional logic to restrict digital joysticks
|
||||||
@ -2262,6 +2275,7 @@ ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog)
|
|||||||
value(field.defvalue()),
|
value(field.defvalue()),
|
||||||
impulse(0),
|
impulse(0),
|
||||||
last(0),
|
last(0),
|
||||||
|
toggle(field.toggle()),
|
||||||
joydir(digital_joystick::JOYDIR_COUNT)
|
joydir(digital_joystick::JOYDIR_COUNT)
|
||||||
{
|
{
|
||||||
// fill in the basic values
|
// fill in the basic values
|
||||||
@ -3187,11 +3201,20 @@ bool ioport_manager::load_game_config(xml_data_node *portnode, int type, int pla
|
|||||||
if (newseq[seqtype][0] != INPUT_CODE_INVALID)
|
if (newseq[seqtype][0] != INPUT_CODE_INVALID)
|
||||||
field->live().seq[seqtype] = newseq[seqtype];
|
field->live().seq[seqtype] = newseq[seqtype];
|
||||||
|
|
||||||
// for non-analog fields, fetch the value
|
// fetch configurable attributes
|
||||||
|
// for non-analog fields
|
||||||
if (field->live().analog == NULL)
|
if (field->live().analog == NULL)
|
||||||
|
{
|
||||||
|
// fetch the value
|
||||||
field->live().value = xml_get_attribute_int(portnode, "value", field->defvalue());
|
field->live().value = xml_get_attribute_int(portnode, "value", field->defvalue());
|
||||||
|
|
||||||
// for analog fields, fetch configurable analog attributes
|
// fetch yes/no for toggle setting
|
||||||
|
const char *togstring = xml_get_attribute_string(portnode, "toggle", NULL);
|
||||||
|
if (togstring != NULL)
|
||||||
|
field->live().toggle = (strcmp(togstring, "yes") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for analog fields
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// get base attributes
|
// get base attributes
|
||||||
@ -3338,7 +3361,10 @@ void ioport_manager::save_game_inputs(xml_data_node *parentnode)
|
|||||||
|
|
||||||
// non-analog changes
|
// non-analog changes
|
||||||
if (!field->is_analog())
|
if (!field->is_analog())
|
||||||
|
{
|
||||||
changed |= ((field->live().value & field->mask()) != (field->defvalue() & field->mask()));
|
changed |= ((field->live().value & field->mask()) != (field->defvalue() & field->mask()));
|
||||||
|
changed |= (field->live().toggle != field->toggle());
|
||||||
|
}
|
||||||
|
|
||||||
// analog changes
|
// analog changes
|
||||||
else
|
else
|
||||||
@ -3373,6 +3399,8 @@ void ioport_manager::save_game_inputs(xml_data_node *parentnode)
|
|||||||
{
|
{
|
||||||
if ((field->live().value & field->mask()) != (field->defvalue() & field->mask()))
|
if ((field->live().value & field->mask()) != (field->defvalue() & field->mask()))
|
||||||
xml_set_attribute_int(portnode, "value", field->live().value & field->mask());
|
xml_set_attribute_int(portnode, "value", field->live().value & field->mask());
|
||||||
|
if (field->live().toggle != field->toggle())
|
||||||
|
xml_set_attribute(portnode, "toggle", field->live().toggle ? "yes" : "no");
|
||||||
}
|
}
|
||||||
|
|
||||||
// write out analog changes
|
// write out analog changes
|
||||||
|
@ -1078,6 +1078,7 @@ public:
|
|||||||
INT32 delta; // for analog controls
|
INT32 delta; // for analog controls
|
||||||
INT32 centerdelta; // for analog controls
|
INT32 centerdelta; // for analog controls
|
||||||
bool reverse; // for analog controls
|
bool reverse; // for analog controls
|
||||||
|
bool toggle; // for non-analog controls
|
||||||
};
|
};
|
||||||
void get_user_settings(user_settings &settings);
|
void get_user_settings(user_settings &settings);
|
||||||
void set_user_settings(const user_settings &settings);
|
void set_user_settings(const user_settings &settings);
|
||||||
|
Loading…
Reference in New Issue
Block a user