diff options
author | Vas Crabb <vas@vastheman.com> | 2019-11-20 02:54:59 +1100 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2019-11-20 02:54:59 +1100 |
commit | 228540e279df18da1dabec3819024c412ee7611e (patch) | |
tree | e4891f994d6ae51fff5daa9e146d4ef7f8a2984d | |
parent | bdaaa0a558be81c80d8ea23720d82c57fbd0bb38 (diff) |
restore code cleaning behaviour prior to ae2cc6853d935d3daeadd84b0b740af82ea9c41e - it's broken in some corner cases but the regressions are fixed
-rw-r--r-- | src/emu/input.cpp | 24 | ||||
-rw-r--r-- | src/frontend/mame/ui/inputmap.cpp | 7 |
2 files changed, 16 insertions, 15 deletions
diff --git a/src/emu/input.cpp b/src/emu/input.cpp index 0265b021e9a..1a5351c3c59 100644 --- a/src/emu/input.cpp +++ b/src/emu/input.cpp @@ -444,7 +444,6 @@ bool input_seq::is_valid() const for (auto code : m_code) { // invalid codes are never permitted - if (code == INPUT_CODE_INVALID) return false; @@ -1375,13 +1374,13 @@ void input_manager::seq_poll_start(input_item_class itemclass, const input_seq * bool input_manager::seq_poll() { - int curlen = m_poll_seq.length(); + const int curlen = m_poll_seq.length(); input_code lastcode = m_poll_seq[curlen - 1]; - // switch case: see if we have a new code to process input_code newcode; if (m_poll_seq_class == ITEM_CLASS_SWITCH) { + // switch case: see if we have a new code to process newcode = poll_switches(); if (newcode != INPUT_CODE_INVALID) { @@ -1399,10 +1398,9 @@ bool input_manager::seq_poll() } } } - - // absolute/relative case: see if we have an analog change of sufficient amount else { + // absolute/relative case: see if we have an analog change of sufficient amount bool has_or = false; if (lastcode == input_seq::or_code) { @@ -1470,6 +1468,8 @@ bool input_manager::seq_poll() input_seq input_manager::seq_clean(const input_seq &seq) const { + // make a copy of our sequence, removing any invalid bits + input_seq clean_codes; int clean_index = 0; for (int codenum = 0; seq[codenum] != input_seq::end_code; codenum++) { @@ -1477,17 +1477,19 @@ input_seq input_manager::seq_clean(const input_seq &seq) const input_code code = seq[codenum]; if (!code.internal() && code_name(code).empty()) { - while (clean_index > 0 && seq[clean_index - 1].internal()) + while (clean_index > 0 && clean_codes[clean_index - 1].internal()) + { + clean_codes.backspace(); clean_index--; + } } else if (clean_index > 0 || !code.internal()) + { + clean_codes += code; clean_index++; + } } - - input_seq cleaned_seq; - for (int i = 0; i < clean_index; i++) - cleaned_seq += seq[i]; - return cleaned_seq; + return clean_codes; } diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index 46ab0654320..16c91c5cb89 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -291,18 +291,17 @@ void menu_input::handle() // if we are polling, handle as a special case input_item_data *item = pollingitem; - // if UI_CANCEL is pressed, abort if (machine().ui_input().pressed(IPT_UI_CANCEL)) { + // if UI_CANCEL is pressed, abort pollingitem = nullptr; record_next = false; toggle_none_default(item->seq, starting_seq, *item->defseq); seqchangeditem = item; } - - // poll again; if finished, update the sequence - if (machine().input().seq_poll()) + else if (machine().input().seq_poll()) { + // poll again; if finished, update the sequence pollingitem = nullptr; record_next = true; item->seq = machine().input().seq_poll_final(); |