void ui_menu_input_general::populate() { input_item_data *itemlist = NULL; int suborder[SEQ_TYPE_TOTAL]; astring tempstring; int sortorder = 1; /* create a mini lookup table for sort order based on sequence type */ suborder[SEQ_TYPE_STANDARD] = 0; suborder[SEQ_TYPE_DECREMENT] = 1; suborder[SEQ_TYPE_INCREMENT] = 2; /* iterate over the input ports and add menu items */ for (input_type_entry *entry = machine().ioport().first_type(); entry != NULL; entry = entry->next()) /* add if we match the group and we have a valid name */ if (entry->group() == group && entry->name() != NULL && entry->name()[0] != 0) { input_seq_type seqtype; /* loop over all sequence types */ sortorder++; for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++) { /* build an entry for the standard sequence */ input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); memset(item, 0, sizeof(*item)); item->ref = entry; if(pollingitem && pollingref == entry && pollingseq == seqtype) pollingitem = item; item->seqtype = seqtype; item->seq = machine().ioport().type_seq(entry->type(), entry->player(), seqtype); item->defseq = &entry->defseq(seqtype); item->sortorder = sortorder * 4 + suborder[seqtype]; item->type = ioport_manager::type_is_analog(entry->type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; item->name = entry->name(); item->owner_name = NULL; item->next = itemlist; itemlist = item; /* stop after one, unless we're analog */ if (item->type == INPUT_TYPE_DIGITAL) break; } } /* sort and populate the menu in a standard fashion */ populate_and_sort(itemlist); }
void ui_menu_input_specific::populate() { input_item_data *itemlist = NULL; int suborder[SEQ_TYPE_TOTAL]; int port_count = 0; /* create a mini lookup table for sort order based on sequence type */ suborder[SEQ_TYPE_STANDARD] = 0; suborder[SEQ_TYPE_DECREMENT] = 1; suborder[SEQ_TYPE_INCREMENT] = 2; /* iterate over the input ports and add menu items */ for (ioport_port *port = machine().ioport().first_port(); port != NULL; port = port->next()) { port_count++; for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) { const char *name = field->name(); /* add if we match the group and we have a valid name */ if (name != NULL && field->enabled() && ((field->type() == IPT_OTHER && field->name() != NULL) || machine().ioport().type_group(field->type(), field->player()) != IPG_INVALID)) { input_seq_type seqtype; UINT32 sortorder; /* determine the sorting order */ if (field->type() >= IPT_START1 && field->type() < IPT_ANALOG_LAST) { sortorder = (field->type() << 2) | (field->player() << 12); if (strcmp(field->device().tag(), ":")) sortorder |= (port_count & 0xfff) * 0x10000; } else sortorder = field->type() | 0xf000; /* loop over all sequence types */ for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++) { /* build an entry for the standard sequence */ input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); memset(item, 0, sizeof(*item)); item->ref = field; item->seqtype = seqtype; if(pollingitem && pollingref == field && pollingseq == seqtype) pollingitem = item; item->seq = field->seq(seqtype); item->defseq = &field->defseq(seqtype); item->sortorder = sortorder + suborder[seqtype]; item->type = field->is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; item->name = name; item->owner_name = field->device().tag(); item->next = itemlist; itemlist = item; /* stop after one, unless we're analog */ if (item->type == INPUT_TYPE_DIGITAL) break; } } } } /* sort and populate the menu in a standard fashion */ populate_and_sort(itemlist); }