summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Tomer Verona <tverona@hotmail.com>2016-09-20 01:24:36 -0700
committer Tomer Verona <tverona@hotmail.com>2016-09-20 01:24:36 -0700
commit32ea8266a31080330a6fd84208997dc24b7368fc (patch)
treea213335cdd8ec6ae03373b7c320b2a624cd7569f /src
parent0ed1ce56639faf0b4545ef75fc28e10746f17728 (diff)
A couple of fixes
- Fix null-reference exception when mapping device to unused (null) controller index - Restrict device map to controller configs
Diffstat (limited to 'src')
-rw-r--r--src/emu/input.cpp9
-rw-r--r--src/emu/ioport.cpp27
2 files changed, 21 insertions, 15 deletions
diff --git a/src/emu/input.cpp b/src/emu/input.cpp
index cb63a33e05a..2a65ff4c688 100644
--- a/src/emu/input.cpp
+++ b/src/emu/input.cpp
@@ -1048,8 +1048,11 @@ void input_class::remap_device_index(int oldindex, int newindex)
m_device[oldindex].swap(m_device[newindex]);
// update device indexes
- m_device[oldindex]->set_devindex(oldindex);
- m_device[newindex]->set_devindex(newindex);
+ if (nullptr != m_device[oldindex].get())
+ m_device[oldindex]->set_devindex(oldindex);
+
+ if (nullptr != m_device[newindex].get())
+ m_device[newindex]->set_devindex(newindex);
// update the maximum index found, since newindex may
// exceed current m_maxindex
@@ -2152,7 +2155,7 @@ bool input_manager::map_device_to_controller(const devicemap_table_type *devicem
{
// remap devindex
input_devclass->remap_device_index(device->devindex(), devindex);
- osd_printf_info("Input: Remapped %s #%d: %s\n", (*devclass_string_table)[input_devclass->devclass()], devindex, device->name());
+ osd_printf_verbose("Input: Remapped %s #%d: %s\n", (*devclass_string_table)[input_devclass->devclass()], devindex, device->name());
break;
}
}
diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp
index 00dbedb8de8..bf6a4cd52c4 100644
--- a/src/emu/ioport.cpp
+++ b/src/emu/ioport.cpp
@@ -2904,22 +2904,25 @@ void ioport_manager::load_config(config_type cfg_type, xml_data_node *parentnode
if (cfg_type == config_type::CONFIG_TYPE_CONTROLLER)
load_remap_table(parentnode);
- // load device map table, if any
- std::unique_ptr<devicemap_table_type> devicemap_table = std::make_unique<devicemap_table_type>();
- for (xml_data_node *mapdevice_node = xml_get_sibling(parentnode->child, "mapdevice"); mapdevice_node != nullptr; mapdevice_node = xml_get_sibling(mapdevice_node->next, "mapdevice"))
+ // load device map table for controller configs only
+ if (cfg_type == config_type::CONFIG_TYPE_CONTROLLER)
{
- const char *devicename = xml_get_attribute_string(mapdevice_node, "device", nullptr);
- const char *controllername = xml_get_attribute_string(mapdevice_node, "controller", nullptr);
- if (devicename != nullptr && controllername != nullptr)
+ std::unique_ptr<devicemap_table_type> devicemap_table = std::make_unique<devicemap_table_type>();
+ for (xml_data_node *mapdevice_node = xml_get_sibling(parentnode->child, "mapdevice"); mapdevice_node != nullptr; mapdevice_node = xml_get_sibling(mapdevice_node->next, "mapdevice"))
{
- devicemap_table->insert(std::make_pair(std::string(devicename), std::string(controllername)));
+ const char *devicename = xml_get_attribute_string(mapdevice_node, "device", nullptr);
+ const char *controllername = xml_get_attribute_string(mapdevice_node, "controller", nullptr);
+ if (devicename != nullptr && controllername != nullptr)
+ {
+ devicemap_table->insert(std::make_pair(std::string(devicename), std::string(controllername)));
+ }
}
- }
- // map device to controller if we have a device map
- if (!devicemap_table->empty())
- {
- machine().input().map_device_to_controller(devicemap_table.get());
+ // map device to controller if we have a device map
+ if (!devicemap_table->empty())
+ {
+ machine().input().map_device_to_controller(devicemap_table.get());
+ }
}
// iterate over all the port nodes