ioport tagged_list to unordered_map (nw)

This commit is contained in:
Miodrag Milanovic 2016-06-18 10:59:37 +02:00
parent cb9d158d57
commit d705e4a28d
10 changed files with 86 additions and 85 deletions

View File

@ -113,8 +113,8 @@ crosshair_manager::crosshair_manager(running_machine &machine)
m_auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT; m_auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT;
/* determine who needs crosshairs */ /* determine who needs crosshairs */
for (ioport_port &port : machine.ioport().ports()) for (auto &port : machine.ioport().ports())
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.crosshair_axis() != CROSSHAIR_AXIS_NONE) if (field.crosshair_axis() != CROSSHAIR_AXIS_NONE)
{ {
int player = field.player(); int player = field.player();

View File

@ -658,8 +658,8 @@ void ioport_list::append(device_t &device, std::string &errorbuf)
(*constructor)(device, *this, errorbuf); (*constructor)(device, *this, errorbuf);
// collapse fields and sort the list // collapse fields and sort the list
for (ioport_port &port : *this) for (auto &port : *this)
port.collapse_fields(errorbuf); port.second->collapse_fields(errorbuf);
} }
@ -1073,8 +1073,8 @@ void natural_keyboard::build_codes(ioport_manager &manager)
if (curshift == 0 || shift[curshift - 1] != nullptr) if (curshift == 0 || shift[curshift - 1] != nullptr)
// iterate over ports and fields // iterate over ports and fields
for (ioport_port &port : manager.ports()) for (auto &port : manager.ports())
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.type() == IPT_KEYBOARD) if (field.type() == IPT_KEYBOARD)
{ {
// fetch the code, ignoring 0 // fetch the code, ignoring 0
@ -2485,11 +2485,11 @@ time_t ioport_manager::initialize()
for (device_t &device : iter) for (device_t &device : iter)
{ {
int players = 0; int players = 0;
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
{ {
if (&port.device() == &device) if (&port.second->device() == &device)
{ {
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.type_class()==INPUT_CLASS_CONTROLLER) if (field.type_class()==INPUT_CLASS_CONTROLLER)
{ {
if (players < field.player() + 1) players = field.player() + 1; if (players < field.player() + 1) players = field.player() + 1;
@ -2501,8 +2501,8 @@ time_t ioport_manager::initialize()
} }
// allocate live structures to mirror the configuration // allocate live structures to mirror the configuration
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
port.init_live_state(); port.second->init_live_state();
// handle autoselection of devices // handle autoselection of devices
init_autoselect_devices(IPT_AD_STICK_X, IPT_AD_STICK_Y, IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE, "analog joystick"); init_autoselect_devices(IPT_AD_STICK_X, IPT_AD_STICK_Y, IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE, "analog joystick");
@ -2517,8 +2517,8 @@ time_t ioport_manager::initialize()
// look for 4-way diagonal joysticks and change the default map if we find any // look for 4-way diagonal joysticks and change the default map if we find any
const char *joystick_map_default = machine().options().joystick_map(); const char *joystick_map_default = machine().options().joystick_map();
if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0) if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0)
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.live().joystick != nullptr && field.rotated()) if (field.live().joystick != nullptr && field.rotated())
{ {
machine().input().set_global_joystick_map(joystick_map_4way_diagonal); machine().input().set_global_joystick_map(joystick_map_4way_diagonal);
@ -2537,8 +2537,8 @@ time_t ioport_manager::initialize()
m_has_bioses = false; m_has_bioses = false;
// scan the input port array to see what options we need to enable // scan the input port array to see what options we need to enable
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
if (field.type() == IPT_DIPSWITCH) if (field.type() == IPT_DIPSWITCH)
m_has_dips = true; m_has_dips = true;
@ -2627,8 +2627,8 @@ void ioport_manager::init_autoselect_devices(int type1, int type2, int type3, co
// only scan the list if we haven't already enabled this class of control // only scan the list if we haven't already enabled this class of control
if (!m_portlist.empty() && !machine().input().device_class(autoenable).enabled()) if (!m_portlist.empty() && !machine().input().device_class(autoenable).enabled())
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
// if this port type is in use, apply the autoselect criteria // if this port type is in use, apply the autoselect criteria
if ((type1 != 0 && field.type() == type1) || (type2 != 0 && field.type() == type2) || (type3 != 0 && field.type() == type3)) if ((type1 != 0 && field.type() == type1) || (type2 != 0 && field.type() == type2) || (type3 != 0 && field.type() == type3))
@ -2738,8 +2738,8 @@ bool ioport_manager::type_pressed(ioport_type type, int player)
bool ioport_manager::type_class_present(ioport_type_class inputclass) bool ioport_manager::type_class_present(ioport_type_class inputclass)
{ {
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.type_class() == inputclass) if (field.type_class() == inputclass)
return true; return true;
return false; return false;
@ -2754,8 +2754,8 @@ bool ioport_manager::type_class_present(ioport_type_class inputclass)
bool ioport_manager::has_keyboard() const bool ioport_manager::has_keyboard() const
{ {
// iterate over ports and fields // iterate over ports and fields
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
// if we are at init, check IPT_KEYBOARD // if we are at init, check IPT_KEYBOARD
if (!m_safe_to_read && field.type() == IPT_KEYBOARD) if (!m_safe_to_read && field.type() == IPT_KEYBOARD)
@ -2777,8 +2777,8 @@ bool ioport_manager::has_keyboard() const
int ioport_manager::count_players() const int ioport_manager::count_players() const
{ {
int max_player = 0; int max_player = 0;
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.type_class() == INPUT_CLASS_CONTROLLER && max_player <= field.player() + 1) if (field.type_class() == INPUT_CLASS_CONTROLLER && max_player <= field.player() + 1)
max_player = field.player() + 1; max_player = field.player() + 1;
@ -2795,8 +2795,8 @@ bool ioport_manager::crosshair_position(int player, float &x, float &y)
{ {
// read all the lightgun values // read all the lightgun values
bool gotx = false, goty = false; bool gotx = false, goty = false;
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.player() == player && field.crosshair_axis() != CROSSHAIR_AXIS_NONE && field.enabled()) if (field.player() == player && field.crosshair_axis() != CROSSHAIR_AXIS_NONE && field.enabled())
{ {
field.crosshair_position(x, y, gotx, goty); field.crosshair_position(x, y, gotx, goty);
@ -2863,23 +2863,23 @@ g_profiler.start(PROFILER_INPUT);
// compute default values for all the ports // compute default values for all the ports
// two passes to catch conditionals properly // two passes to catch conditionals properly
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
port.update_defvalue(true); port.second->update_defvalue(true);
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
port.update_defvalue(false); port.second->update_defvalue(false);
// loop over all input ports // loop over all input ports
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
{ {
port.frame_update(); port.second->frame_update();
// handle playback/record // handle playback/record
playback_port(port); playback_port(*port.second.get());
record_port(port); record_port(*port.second.get());
// call device line write handlers // call device line write handlers
ioport_value newvalue = port.read(); ioport_value newvalue = port.second->read();
for (dynamic_field &dynfield : port.live().writelist) for (dynamic_field &dynfield : port.second->live().writelist)
if (dynfield.field().type() != IPT_OUTPUT) if (dynfield.field().type() != IPT_OUTPUT)
dynfield.write(newvalue); dynfield.write(newvalue);
} }
@ -3045,9 +3045,9 @@ bool ioport_manager::load_game_config(xml_data_node *portnode, int type, int pla
ioport_value defvalue = xml_get_attribute_int(portnode, "defvalue", 0); ioport_value defvalue = xml_get_attribute_int(portnode, "defvalue", 0);
// find the port we want; if no tag, search them all // find the port we want; if no tag, search them all
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
if (tag == nullptr || strcmp(port.tag(), tag) == 0) if (tag == nullptr || strcmp(port.second->tag(), tag) == 0)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
// find the matching mask and defvalue // find the matching mask and defvalue
if (field.type() == type && field.player() == player && if (field.type() == type && field.player() == player &&
@ -3206,8 +3206,8 @@ void ioport_manager::save_default_inputs(xml_data_node *parentnode)
void ioport_manager::save_game_inputs(xml_data_node *parentnode) void ioport_manager::save_game_inputs(xml_data_node *parentnode)
{ {
// iterate over ports // iterate over ports
for (ioport_port &port : m_portlist) for (auto &port : m_portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (save_this_input_field_type(field.type())) if (save_this_input_field_type(field.type()))
{ {
// determine if we changed // determine if we changed
@ -3239,7 +3239,7 @@ void ioport_manager::save_game_inputs(xml_data_node *parentnode)
if (portnode != nullptr) if (portnode != nullptr)
{ {
// add the identifying information and attributes // add the identifying information and attributes
xml_set_attribute(portnode, "tag", port.tag()); xml_set_attribute(portnode, "tag", port.second->tag());
xml_set_attribute(portnode, "type", input_type_to_token(field.type(), field.player()).c_str()); xml_set_attribute(portnode, "type", input_type_to_token(field.type(), field.player()).c_str());
xml_set_attribute_int(portnode, "mask", field.mask()); xml_set_attribute_int(portnode, "mask", field.mask());
xml_set_attribute_int(portnode, "defvalue", field.defvalue() & field.mask()); xml_set_attribute_int(portnode, "defvalue", field.defvalue() & field.mask());
@ -3802,7 +3802,9 @@ void ioport_configurer::port_alloc(const char *tag)
std::string fulltag = m_owner.subtag(tag); std::string fulltag = m_owner.subtag(tag);
// add it to the list, and reset current field/setting // add it to the list, and reset current field/setting
m_curport = &m_portlist.append(fulltag.c_str(), *global_alloc(ioport_port(m_owner, fulltag.c_str()))); if (m_portlist.count(fulltag) != 0) throw add_exception(fulltag.c_str());
m_portlist.emplace(std::make_pair(fulltag, std::make_unique<ioport_port>(m_owner, fulltag.c_str())));
m_curport = m_portlist.find(fulltag)->second.get();
m_curfield = nullptr; m_curfield = nullptr;
m_cursetting = nullptr; m_cursetting = nullptr;
} }
@ -3819,7 +3821,7 @@ void ioport_configurer::port_modify(const char *tag)
std::string fulltag = m_owner.subtag(tag); std::string fulltag = m_owner.subtag(tag);
// find the existing port // find the existing port
m_curport = m_portlist.find(fulltag.c_str()); m_curport = m_portlist.find(fulltag.c_str())->second.get();
if (m_curport == nullptr) if (m_curport == nullptr)
throw emu_fatalerror("Requested to modify nonexistent port '%s'", fulltag.c_str()); throw emu_fatalerror("Requested to modify nonexistent port '%s'", fulltag.c_str());

View File

@ -1265,14 +1265,13 @@ struct ioport_field_live
// ======================> ioport_list // ======================> ioport_list
// class that holds a list of I/O ports // class that holds a list of I/O ports
class ioport_list : public tagged_list<ioport_port> class ioport_list : public std::unordered_map<std::string, std::unique_ptr<ioport_port>>
{ {
DISABLE_COPYING(ioport_list); DISABLE_COPYING(ioport_list);
public: public:
ioport_list() { } ioport_list() { }
using tagged_list<ioport_port>::append;
void append(device_t &device, std::string &errorbuf); void append(device_t &device, std::string &errorbuf);
}; };
@ -1515,7 +1514,7 @@ private:
void frame_update_callback(); void frame_update_callback();
void frame_update(); void frame_update();
ioport_port *port(const char *tag) const { return m_portlist.find(tag); } ioport_port *port(const char *tag) const { if (tag) { auto search = m_portlist.find(tag); if (search != m_portlist.end()) return search->second.get(); else return nullptr; } else return nullptr; }
void exit(); void exit();
input_seq_type token_to_seq_type(const char *string); input_seq_type token_to_seq_type(const char *string);

View File

@ -849,17 +849,17 @@ void validity_checker::validate_inputs()
osd_printf_error("I/O port error during construction:\n%s\n", errorbuf.c_str()); osd_printf_error("I/O port error during construction:\n%s\n", errorbuf.c_str());
// do a first pass over ports to add their names and find duplicates // do a first pass over ports to add their names and find duplicates
for (ioport_port &port : portlist) for (auto &port : portlist)
if (!port_map.insert(port.tag()).second) if (!port_map.insert(port.second->tag()).second)
osd_printf_error("Multiple I/O ports with the same tag '%s' defined\n", port.tag()); osd_printf_error("Multiple I/O ports with the same tag '%s' defined\n", port.second->tag());
// iterate over ports // iterate over ports
for (ioport_port &port : portlist) for (auto &port : portlist)
{ {
m_current_ioport = port.tag(); m_current_ioport = port.second->tag();
// iterate through the fields on this port // iterate through the fields on this port
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
// verify analog inputs // verify analog inputs
if (field.is_analog()) if (field.is_analog())

View File

@ -261,9 +261,9 @@ void info_xml_creator::output_one()
{ {
int nplayers = 0; int nplayers = 0;
bool new_kbd = false; bool new_kbd = false;
for (ioport_port &port : portlist) for (auto &port : portlist)
if (&port.device() == &device) if (&port.second->device() == &device)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.type() >= IPT_START && field.type() < IPT_ANALOG_LAST) if (field.type() >= IPT_START && field.type() < IPT_ANALOG_LAST)
{ {
if (field.type() == IPT_KEYBOARD) if (field.type() == IPT_KEYBOARD)
@ -366,8 +366,8 @@ void info_xml_creator::output_one_device(device_t &device, const char *devtag)
for (device_t &dev : device_iterator(device)) for (device_t &dev : device_iterator(device))
portlist.append(dev, errors); portlist.append(dev, errors);
// check if the device adds player inputs (other than dsw and configs) to the system // check if the device adds player inputs (other than dsw and configs) to the system
for (ioport_port &port : portlist) for (auto &port : portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.type() >= IPT_START1 && field.type() < IPT_UI_FIRST) if (field.type() >= IPT_START1 && field.type() < IPT_UI_FIRST)
{ {
has_input = TRUE; has_input = TRUE;
@ -891,11 +891,11 @@ void info_xml_creator::output_input(const ioport_list &portlist)
bool tilt = false; bool tilt = false;
// iterate over the ports // iterate over the ports
for (ioport_port &port : portlist) for (auto &port : portlist)
{ {
int ctrl_type = CTRL_DIGITAL_BUTTONS; int ctrl_type = CTRL_DIGITAL_BUTTONS;
bool ctrl_analog = FALSE; bool ctrl_analog = FALSE;
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
// track the highest player number // track the highest player number
if (nplayer < field.player() + 1) if (nplayer < field.player() + 1)
@ -1317,13 +1317,13 @@ void info_xml_creator::output_input(const ioport_list &portlist)
void info_xml_creator::output_switches(const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *innertag) void info_xml_creator::output_switches(const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *innertag)
{ {
// iterate looking for DIP switches // iterate looking for DIP switches
for (ioport_port &port : portlist) for (auto &port : portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.type() == type) if (field.type() == type)
{ {
std::ostringstream output; std::ostringstream output;
std::string newtag(port.tag()), oldtag(":"); std::string newtag(port.second->tag()), oldtag(":");
newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length()); newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length());
// output the switch name information // output the switch name information
@ -1351,10 +1351,10 @@ void info_xml_creator::output_switches(const ioport_list &portlist, const char *
void info_xml_creator::output_ports(const ioport_list &portlist) void info_xml_creator::output_ports(const ioport_list &portlist)
{ {
// cycle through ports // cycle through ports
for (ioport_port &port : portlist) for (auto &port : portlist)
{ {
fprintf(m_output,"\t\t<port tag=\"%s\">\n", xml_normalize_string(port.tag())); fprintf(m_output,"\t\t<port tag=\"%s\">\n", xml_normalize_string(port.second->tag()));
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
if(field.is_analog()) if(field.is_analog())
fprintf(m_output,"\t\t\t<analog mask=\"%u\"/>\n", field.mask()); fprintf(m_output,"\t\t\t<analog mask=\"%u\"/>\n", field.mask());
@ -1373,8 +1373,8 @@ void info_xml_creator::output_ports(const ioport_list &portlist)
void info_xml_creator::output_adjusters(const ioport_list &portlist) void info_xml_creator::output_adjusters(const ioport_list &portlist)
{ {
// iterate looking for Adjusters // iterate looking for Adjusters
for (ioport_port &port : portlist) for (auto &port : portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.type() == IPT_ADJUSTER) if (field.type() == IPT_ADJUSTER)
fprintf(m_output, "\t\t<adjuster name=\"%s\" default=\"%d\"/>\n", xml_normalize_string(field.name()), field.defvalue()); fprintf(m_output, "\t\t<adjuster name=\"%s\" default=\"%d\"/>\n", xml_normalize_string(field.name()), field.defvalue());
} }

View File

@ -644,8 +644,8 @@ luabridge::LuaRef lua_engine::l_ioport_get_ports(const ioport_manager *m)
lua_State *L = luaThis->m_lua_state; lua_State *L = luaThis->m_lua_state;
luabridge::LuaRef port_table = luabridge::LuaRef::newTable(L); luabridge::LuaRef port_table = luabridge::LuaRef::newTable(L);
for (ioport_port &port : im->ports()) { for (auto &port : im->ports()) {
port_table[port.tag()] = &port; port_table[port.second->tag()] = &port;
} }
return port_table; return port_table;
@ -1977,9 +1977,9 @@ void lua_engine::update_machine()
if (m_machine!=nullptr) if (m_machine!=nullptr)
{ {
// Create the ioport array // Create the ioport array
for (ioport_port &port : machine().ioport().ports()) for (auto &port : machine().ioport().ports())
{ {
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
if (field.type_class() != INPUT_CLASS_INTERNAL) if (field.type_class() != INPUT_CLASS_INTERNAL)
{ {

View File

@ -276,10 +276,10 @@ void menu_autofire::populate()
/* iterate over the input ports and add autofire toggle items */ /* iterate over the input ports and add autofire toggle items */
int menu_items = 0; int menu_items = 0;
for (ioport_port &port : machine().ioport().ports()) for (auto &port : machine().ioport().ports())
{ {
bool is_first_button = true; bool is_first_button = true;
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
if (field.type() >= IPT_BUTTON1 && field.type() <= IPT_BUTTON16) if (field.type() >= IPT_BUTTON1 && field.type() <= IPT_BUTTON16)
{ {

View File

@ -176,8 +176,8 @@ void menu_device_config::populate()
portlist.append(iptdev, errors); portlist.append(iptdev, errors);
// check if the device adds inputs to the system // check if the device adds inputs to the system
for (ioport_port &port : portlist) for (auto &port : portlist)
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
if (field.type() >= IPT_MAHJONG_FIRST && field.type() < IPT_MAHJONG_LAST) if (field.type() >= IPT_MAHJONG_FIRST && field.type() < IPT_MAHJONG_LAST)
input_mj++; input_mj++;

View File

@ -164,10 +164,10 @@ void menu_input_specific::populate()
suborder[SEQ_TYPE_INCREMENT] = 2; suborder[SEQ_TYPE_INCREMENT] = 2;
/* iterate over the input ports and add menu items */ /* iterate over the input ports and add menu items */
for (ioport_port &port : machine().ioport().ports()) for (auto &port : machine().ioport().ports())
{ {
port_count++; port_count++;
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
ioport_type_class type_class = field.type_class(); ioport_type_class type_class = field.type_class();
@ -548,8 +548,8 @@ void menu_settings::populate()
diplist_tailptr = &diplist; diplist_tailptr = &diplist;
/* loop over input ports and set up the current values */ /* loop over input ports and set up the current values */
for (ioport_port &port : machine().ioport().ports()) for (auto &port : machine().ioport().ports())
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.type() == type && field.enabled()) if (field.type() == type && field.enabled())
{ {
UINT32 flags = 0; UINT32 flags = 0;
@ -818,8 +818,8 @@ void menu_analog::populate()
bool first_entry = true; bool first_entry = true;
/* loop over input ports and add the items */ /* loop over input ports and add the items */
for (ioport_port &port : machine().ioport().ports()) for (auto &port : machine().ioport().ports())
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
if (field.is_analog() && field.enabled()) if (field.is_analog() && field.enabled())
{ {
ioport_field::user_settings settings; ioport_field::user_settings settings;

View File

@ -1657,9 +1657,9 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
// add analog adjusters // add analog adjusters
int slider_index = 0; int slider_index = 0;
for (ioport_port &port : machine.ioport().ports()) for (auto &port : machine.ioport().ports())
{ {
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
if (field.type() == IPT_ADJUSTER) if (field.type() == IPT_ADJUSTER)
{ {
@ -1763,9 +1763,9 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
#ifdef MAME_DEBUG #ifdef MAME_DEBUG
slider_index = 0; slider_index = 0;
// add crosshair adjusters // add crosshair adjusters
for (ioport_port &port : machine.ioport().ports()) for (auto &port : machine.ioport().ports())
{ {
for (ioport_field &field : port.fields()) for (ioport_field &field : port.second->fields())
{ {
if (field.crosshair_axis() != CROSSHAIR_AXIS_NONE && field.player() == 0) if (field.crosshair_axis() != CROSSHAIR_AXIS_NONE && field.player() == 0)
{ {