mirror of
https://github.com/holub/mame
synced 2025-04-25 01:40:16 +03:00
A couple of fixes
- Fix null-reference exception when mapping device to unused (null) controller index - Restrict device map to controller configs
This commit is contained in:
parent
0ed1ce5663
commit
32ea8266a3
@ -11,7 +11,8 @@ That's where the "mapdevice" configuration setting comes into the picture. This
|
||||
|
||||
Usage of mapdevice
|
||||
------------------
|
||||
The "mapdevice" xml element is specified under the input xml element in the configuration. It requires two attributes, "device" and "controller".
|
||||
The "mapdevice" xml element is specified under the input xml element in the controller configuration file. It requires two attributes, "device" and "controller".
|
||||
NOTE: This setting only take effect when added to the **ctrlr** config file.
|
||||
|
||||
The "device" attribute specifies the name of the device to match. It may also be a substring of the name. To see the list of available devices, enable verbose output and available devices will then be listed to the console at startup (more on this below).
|
||||
|
||||
@ -47,15 +48,7 @@ Listing Available Devices
|
||||
-------------------------
|
||||
How did we obtain the device names in the above example? Easy!
|
||||
|
||||
We simply set verbose to 1 in mame.ini:
|
||||
|
||||
| #
|
||||
| # CORE DEBUGGING OPTIONS
|
||||
| #
|
||||
| **verbose 1**
|
||||
|
|
||||
|
||||
Then, when MAME is started, it will list available devices to the console. For example:
|
||||
Run MAME with -v parameter to enable verbose output. It will then list available devices to the console. For example:
|
||||
|
||||
| Input: Adding Gun #0:
|
||||
| Input: Adding Gun #1:
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user