diff options
Diffstat (limited to 'src/frontend/mame/ui/inputmap.cpp')
-rw-r--r-- | src/frontend/mame/ui/inputmap.cpp | 95 |
1 files changed, 75 insertions, 20 deletions
diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index 5ddf7864adf..a651795ef6c 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -45,12 +45,11 @@ void menu_input_groups::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); } -void menu_input_groups::handle() +void menu_input_groups::handle(event const *ev) { // process the menu - const event *const menu_event = process(0); - if (menu_event && menu_event->iptkey == IPT_UI_SELECT) - menu::stack_push<menu_input_general>(ui(), container(), int(uintptr_t(menu_event->itemref) - 1)); + if (ev && (ev->iptkey == IPT_UI_SELECT)) + menu::stack_push<menu_input_general>(ui(), container(), int(uintptr_t(ev->itemref) - 1)); } @@ -243,6 +242,7 @@ void menu_input_specific::update_input(input_item_data &seqchangeditem) /*------------------------------------------------- menu_input - display a menu for inputs -------------------------------------------------*/ + menu_input::menu_input(mame_ui_manager &mui, render_container &container) : menu(mui, container) , data() @@ -254,12 +254,20 @@ menu_input::menu_input(mame_ui_manager &mui, render_container &container) , record_next(false) , modified_ticks(0) { + set_process_flags(PROCESS_LR_ALWAYS); } menu_input::~menu_input() { } +void menu_input::menu_activated() +{ + // scripts can change settings out from under us + reset(reset_options::REMEMBER_REF); +} + + /*------------------------------------------------- toggle_none_default - toggle between "NONE" and the default item @@ -329,13 +337,12 @@ void menu_input::custom_render(void *selectedref, float top, float bottom, float } } -void menu_input::handle() +void menu_input::handle(event const *ev) { input_item_data *seqchangeditem = nullptr; bool invalidate = false; // process the menu - const event *const menu_event = process(pollingitem ? PROCESS_NOKEYS : PROCESS_LR_ALWAYS); if (pollingitem) { // if we are polling, handle as a special case @@ -349,6 +356,7 @@ void menu_input::handle() { // if UI_CANCEL is pressed, abort pollingitem = nullptr; + set_process_flags(PROCESS_LR_ALWAYS); if (!seq_poll->modified() || modified_ticks == osd_ticks()) { // cancelled immediately - toggle between default and none @@ -366,6 +374,7 @@ void menu_input::handle() else if (seq_poll->poll()) // poll again; if finished, update the sequence { pollingitem = nullptr; + set_process_flags(PROCESS_LR_ALWAYS); if (seq_poll->valid()) { record_next = true; @@ -382,13 +391,15 @@ void menu_input::handle() seq_poll.reset(); } } - else if (menu_event && menu_event->itemref) + else if (ev && ev->itemref) { // otherwise, handle the events - input_item_data &item = *reinterpret_cast<input_item_data *>(menu_event->itemref); - switch (menu_event->iptkey) + input_item_data &item = *reinterpret_cast<input_item_data *>(ev->itemref); + input_item_data *newsel = &item; + switch (ev->iptkey) { case IPT_UI_SELECT: // an item was selected: begin polling + set_process_flags(PROCESS_NOKEYS); errormsg.clear(); erroritem = nullptr; modified_ticks = 0; @@ -415,14 +426,63 @@ void menu_input::handle() break; case IPT_UI_LEFT: // flip between set and append - case IPT_UI_RIGHT: // not very discoverable, but with the prompt it isn't opaque + case IPT_UI_RIGHT: // not very discoverable, but with the prompt it isn't completely opaque if (record_next || !item.seq.empty()) record_next = !record_next; break; + + case IPT_UI_PREV_GROUP: + { + auto current = std::distance(data.data(), &item); + bool found_break = false; + while (0 < current) + { + if (!found_break) + { + if (data[--current].owner != item.owner) + found_break = true; + } + else if (data[current].owner != data[current - 1].owner) + { + newsel = &data[current]; + set_selection(newsel); + set_top_line(selected_index() - 1); + break; + } + else + { + --current; + } + if (found_break && !current) + { + newsel = &data[current]; + set_selection(newsel); + set_top_line(selected_index() - 1); + break; + } + } + } + break; + + case IPT_UI_NEXT_GROUP: + { + auto current = std::distance(data.data(), &item); + while (data.size() > ++current) + { + if (data[current].owner != item.owner) + { + newsel = &data[current]; + set_selection(newsel); + set_top_line(selected_index() - 1); + break; + } + } + } + break; } // if the selection changed, reset the "record next" flag - if (&item != lastitem) + if (newsel != lastitem) { if (erroritem) { @@ -460,15 +520,14 @@ void menu_input::populate_sorted(float &customtop, float &custombottom) const char *nameformat[INPUT_TYPE_TOTAL] = { nullptr }; // create a mini lookup table for name format based on type - nameformat[INPUT_TYPE_DIGITAL] = "%s"; - nameformat[INPUT_TYPE_ANALOG] = "%s Analog"; - nameformat[INPUT_TYPE_ANALOG_INC] = "%s Analog Inc"; - nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec"; + nameformat[INPUT_TYPE_DIGITAL] = "%1$s"; + nameformat[INPUT_TYPE_ANALOG] = _("input-name", "%1$s Analog"); + nameformat[INPUT_TYPE_ANALOG_INC] = _("input-name", "%1$s Analog Inc"); + nameformat[INPUT_TYPE_ANALOG_DEC] = _("input-name", "%1$s Analog Dec"); // build the menu std::string text, subtext; const device_t *prev_owner = nullptr; - bool first_entry = true; for (input_item_data &item : data) { // generate the name of the item itself, based off the base name and the type @@ -476,10 +535,6 @@ void menu_input::populate_sorted(float &customtop, float &custombottom) if (item.owner && (item.owner != prev_owner)) { - if (first_entry) - first_entry = false; - else - item_append(menu_item_type::SEPARATOR); if (item.owner->owner()) item_append(string_format(_("%1$s [root%2$s]"), item.owner->type().fullname(), item.owner->tag()), FLAG_UI_HEADING | FLAG_DISABLE, nullptr); else |