layout: added "inputraw" parameter, for use with inputtag and inputmask. It sets the element state directly to the raw input data & mask. Example uses: 8 way joystick state, multi-bitmask dipswitch state. If you don't want it to respond to layout mouse clicks, add a dummy inputtag rect under it. (nw)

This commit is contained in:
hap 2019-03-23 11:50:36 +01:00
parent 842aa09d6a
commit 57cb0af3f0
2 changed files with 13 additions and 3 deletions

View File

@ -852,6 +852,7 @@ public:
std::string m_input_tag; // input tag of this item
ioport_port * m_input_port; // input port of this item
ioport_value m_input_mask; // input mask of this item
bool m_input_raw; // get raw data from input port
screen_device * m_screen; // pointer to screen
int m_orientation; // orientation of this item
render_bounds m_bounds; // bounds of the item

View File

@ -3283,6 +3283,7 @@ layout_view::item::item(
, m_input_tag(env.get_attribute_string(itemnode, "inputtag", ""))
, m_input_port(nullptr)
, m_input_mask(0)
, m_input_raw(false)
, m_screen(nullptr)
, m_orientation(orientation_add(env.parse_orientation(itemnode.get_child("orientation")), orientation))
, m_color(render_color_multiply(env.parse_color(itemnode.get_child("color")), color))
@ -3308,6 +3309,7 @@ layout_view::item::item(
if (index != -1)
m_screen = screen_device_iterator(env.machine().root_device()).byindex(index);
m_input_mask = env.get_attribute_int(itemnode, "inputmask", 0);
m_input_raw = env.get_attribute_int(itemnode, "inputraw", 0) == 1;
if (m_have_output && m_element)
m_output = m_element->default_state();
env.parse_bounds(itemnode.get_child("bounds"), m_rawbounds);
@ -3380,9 +3382,16 @@ int layout_view::item::state() const
// if configured to an input, fetch the input value
if (m_input_port)
{
ioport_field const *const field = m_input_port->field(m_input_mask);
if (field)
return ((m_input_port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0;
if (m_input_raw)
{
return m_input_port->read() & m_input_mask;
}
else
{
ioport_field const *const field = m_input_port->field(m_input_mask);
if (field)
return ((m_input_port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0;
}
}
}