diff options
Diffstat (limited to 'src/emu/uiinput.cpp')
-rw-r--r-- | src/emu/uiinput.cpp | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/emu/uiinput.cpp b/src/emu/uiinput.cpp index 8d710ebcbfc..9707793b2a3 100644 --- a/src/emu/uiinput.cpp +++ b/src/emu/uiinput.cpp @@ -25,17 +25,18 @@ enum //************************************************************************** -// NETWORK MANAGER +// UI INPUT MANAGER //************************************************************************** //------------------------------------------------- -// network_manager - constructor +// ui_input_manager - constructor //------------------------------------------------- ui_input_manager::ui_input_manager(running_machine &machine) : m_machine(machine), m_current_mouse_target(nullptr), m_current_mouse_down(false), + m_current_mouse_field(nullptr), m_events_start(0), m_events_end(0) { @@ -68,6 +69,22 @@ void ui_input_manager::frame_update() if (!pressed || m_seqpressed[code] != SEQ_PRESSED_RESET) m_seqpressed[code] = pressed; } + + // perform mouse hit testing + ioport_field *mouse_field = m_current_mouse_down ? find_mouse_field() : nullptr; + if (m_current_mouse_field != mouse_field) + { + // clear the old field if there was one + if (m_current_mouse_field != nullptr) + m_current_mouse_field->set_value(0); + + // set the new field if it exists and isn't already being pressed + if (mouse_field != nullptr && !mouse_field->digital_value()) + mouse_field->set_value(1); + + // update internal state + m_current_mouse_field = mouse_field; + } } @@ -166,7 +183,7 @@ void ui_input_manager::reset() location of the mouse -------------------------------------------------*/ -render_target *ui_input_manager::find_mouse(INT32 *x, INT32 *y, bool *button) +render_target *ui_input_manager::find_mouse(INT32 *x, INT32 *y, bool *button) const { if (x != nullptr) *x = m_current_mouse_x; @@ -178,6 +195,29 @@ render_target *ui_input_manager::find_mouse(INT32 *x, INT32 *y, bool *button) } +/*------------------------------------------------- + find_mouse_field - retrieves the input field + the mouse is currently pointing at +-------------------------------------------------*/ + +ioport_field *ui_input_manager::find_mouse_field() const +{ + // map the point and determine what was hit + if (m_current_mouse_target != nullptr) + { + ioport_port *port = nullptr; + ioport_value mask; + float x, y; + if (m_current_mouse_target->map_point_input(m_current_mouse_x, m_current_mouse_y, port, mask, x, y)) + { + if (port != nullptr) + return port->field(mask); + } + } + return nullptr; +} + + /*************************************************************************** USER INTERFACE SEQUENCE READING |