diff options
author | tim lindner <tlindner@macmess.org> | 2020-06-12 05:44:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 14:44:27 +0200 |
commit | e0715320f7657ba7b3a9b90290848e39abf10b63 (patch) | |
tree | 5f1dfc5f456e0c00116d65c6ea92528ed74a6623 | |
parent | b2e3faace62651a944ccf0e4c29873257af003e2 (diff) |
Setting analog inputs don't work in LUA (#6812)
* fixed set_value for analog inputs.
-rw-r--r-- | src/emu/ioport.cpp | 29 | ||||
-rw-r--r-- | src/emu/ioport.h | 7 |
2 files changed, 32 insertions, 4 deletions
diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index 09bea86931e..06766134370 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -652,7 +652,10 @@ ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value def void ioport_field::set_value(ioport_value value) { - m_digital_value = value != 0; + if (is_analog()) + live().analog->set_value(s32(value)); + else + m_digital_value = value != 0; } @@ -3234,6 +3237,7 @@ analog_field::analog_field(ioport_field &field) m_accum(0), m_previous(0), m_previousanalog(0), + m_prog_analog_value(0), m_minimum(INPUT_ABSOLUTE_MIN), m_maximum(INPUT_ABSOLUTE_MAX), m_center(0), @@ -3248,7 +3252,8 @@ analog_field::analog_field(ioport_field &field) m_autocenter(false), m_single_scale(false), m_interpolate(false), - m_lastdigital(false) + m_lastdigital(false), + m_was_written(false) { // compute the shift amount and number of bits for (ioport_value mask = field.mask(); !(mask & 1); mask >>= 1) @@ -3488,6 +3493,17 @@ s32 analog_field::apply_settings(s32 value) const //------------------------------------------------- +// set_value - take a new value to be used +// at next frame update +//------------------------------------------------- + +void analog_field::set_value(s32 value) +{ + m_was_written = true; + m_prog_analog_value = value; +} + +//------------------------------------------------- // frame_update - update the internals of a // single analog field periodically //------------------------------------------------- @@ -3504,7 +3520,14 @@ void analog_field::frame_update(running_machine &machine) // get the new raw analog value and its type input_item_class itemclass; s32 rawvalue = machine.input().seq_axis_value(m_field.seq(SEQ_TYPE_STANDARD), itemclass); - + + // use programmatically set value if avaiable + if (m_was_written) + { + m_was_written = false; + rawvalue = m_prog_analog_value; + } + // if we got an absolute input, it overrides everything else if (itemclass == ITEM_CLASS_ABSOLUTE) { diff --git a/src/emu/ioport.h b/src/emu/ioport.h index 82834584815..aa0a04bfca8 100644 --- a/src/emu/ioport.h +++ b/src/emu/ioport.h @@ -1266,7 +1266,10 @@ public: void read(ioport_value &value); float crosshair_read(); void frame_update(running_machine &machine); - + + // setters + void set_value(s32 value); + private: // helpers s32 apply_min_max(s32 value) const; @@ -1294,6 +1297,7 @@ private: s32 m_accum; // accumulated value (including relative adjustments) s32 m_previous; // previous adjusted value s32 m_previousanalog; // previous analog value + s32 m_prog_analog_value; // programmatically set analog value // parameters for modifying live values s32 m_minimum; // minimum adjusted value @@ -1315,6 +1319,7 @@ private: bool m_single_scale; // scale joystick differently if default is between min/max bool m_interpolate; // should we do linear interpolation for mid-frame reads? bool m_lastdigital; // was the last modification caused by a digital form? + bool m_was_written; // was the last modification caused programmatically? }; |