From 2bd18d5fea66bedcde02da1b2c17d83c4640a782 Mon Sep 17 00:00:00 2001 From: Tomer Verona Date: Mon, 12 Sep 2016 18:35:36 -0700 Subject: [PATCH 1/4] Support for configuring device to conrtoller id This change adds support for configuring device to conrtoller id. This allows for stable controller ids even if USB devices are plugged / unplugged, system is rebooted, etc. See documentation for additional context. --- docs/source/advanced/devicemap.rst | 81 ++++++++++++++++++ docs/source/advanced/index.rst | 3 +- src/emu/input.cpp | 103 +++++++++++++++++++++++ src/emu/input.h | 8 ++ src/emu/ioport.cpp | 18 ++++ src/osd/modules/input/input_rawinput.cpp | 12 ++- 6 files changed, 222 insertions(+), 3 deletions(-) create mode 100644 docs/source/advanced/devicemap.rst diff --git a/docs/source/advanced/devicemap.rst b/docs/source/advanced/devicemap.rst new file mode 100644 index 00000000000..2b52ef00c78 --- /dev/null +++ b/docs/source/advanced/devicemap.rst @@ -0,0 +1,81 @@ +Stable Controller IDs +=============================== + +By default, the mapping between devices and controller IDs is not stable. For instance, a gamepad controller may be assigned to "Joy 1" initially, but after a reboot, it may get re-assigned to "Joy 3". + +The reason is that MAME enumerates attached devices and assigns controller IDs based on the enumeration order. Factors that can cause controller IDs to change include plugging / unplugging USB devices, changing ports / hubs and even system reboots. + +It is quite cumbersome to ensure that controller IDs are always correct. + +That's where the "mapdevice" configuration setting comes into the picture. This setting allows you to map a device name to a controller ID, ensuring that the specified device always maps to the same controller ID in MAME. + +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 "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). + +The "controller" attribute specifies the MAME controller ID. It is made up of a controller class (i.e. "JOYCODE", "GUNCODE", "MOUSECODE") and controller index. For example: "JOYCODE_1". + +Example +------- +Here's an example: + +| +| +| +| **** +| **** +| **** +| **** +| +| +| +| JOYCODE_1_YAXIS_UP_SWITCH OR KEYCODE_8PAD +| +| +| ... +| + +In the above example, we have four device mappings specified: + +The first two mapdevice entries map player 1 and 2 lightguns to Gun 1 and Gun 2, respectively. We use a substring of the full raw device names to match each devices. Note that, since this is XML, we needed to escape the '&' in the name using '&'. + +The last two mapdevices entries map player 1 and player 2 gamepad controllers to Joy 1 and Joy 2, respectively. In this case, these are XInput devices. + +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: + +| Input: Adding Gun #0: +| Input: Adding Gun #1: +| Input: Adding Gun #2: HID-compliant mouse (\\?\HID#VID_045E&PID_0053#7&18297dcb&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Input: Adding Gun #3: HID-compliant mouse (\\?\HID#IrDeviceV2&Col08#2&2818a073&0&0007#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Input: Adding Gun #4: HID-compliant mouse (\\?\HID#VID_D209&PID_1602&MI_02#8&389ab7f3&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Input: Adding Gun #5: HID-compliant mouse (\\?\HID#VID_D209&PID_1601&MI_02#9&375eebb1&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Input: Adding Gun #6: HID-compliant mouse (\\?\HID#VID_1241&PID_1111#8&198f3adc&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Skipping DirectInput for XInput compatible joystick Controller (XBOX 360 For Windows). +| Input: Adding Joy #0: ATRAK Device #1 +| Skipping DirectInput for XInput compatible joystick Controller (XBOX 360 For Windows). +| Input: Adding Joy #1: ATRAK Device #2 +| Input: Adding Joy #2: XInput Player 1 +| Input: Adding Joy #3: XInput Player 2 +| + +Furthermore, when devices are mapped using mapdevice, you'll see that in the verbose logging too, such as: + +| Mapped device 'HID-compliant mouse (\\?\HID#VID_D209&PID_1601&MI_02#9&375eebb1&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd})' to Gun #0 +| Mapped device 'HID-compliant mouse (\\?\HID#VID_D209&PID_1602&MI_02#8&389ab7f3&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd})' to Gun #1 +| Mapped device 'XInput Player 1' to Joy #0 +| Mapped device 'XInput Player 2' to Joy #1 +| diff --git a/docs/source/advanced/index.rst b/docs/source/advanced/index.rst index d40a328fe2f..8ce1dfee49c 100644 --- a/docs/source/advanced/index.rst +++ b/docs/source/advanced/index.rst @@ -9,4 +9,5 @@ Advanced configuration shiftertoggle bgfx hlsl - glsl \ No newline at end of file + glsl + devicemap \ No newline at end of file diff --git a/src/emu/input.cpp b/src/emu/input.cpp index bbae55fcd34..560e9271797 100644 --- a/src/emu/input.cpp +++ b/src/emu/input.cpp @@ -941,6 +941,21 @@ void input_device::apply_steadykey() const } } +//------------------------------------------------- +// match_device_name - match device name via +// substring search +//------------------------------------------------- + +bool input_device::match_device_name(const char *devicename) +{ + std::string devicenameupper(devicename); + std::string nameupper(m_name); + + strmakeupper(devicenameupper); + strmakeupper(nameupper); + + return std::string::npos == nameupper.find(devicenameupper) ? false : true; +} //************************************************************************** @@ -1019,6 +1034,29 @@ input_item_class input_class::standard_item_class(input_item_id itemid) } +//------------------------------------------------- +// remap_device_index - remaps device index by +// mapping oldindex to newindex +//------------------------------------------------- + +void input_class::remap_device_index(int oldindex, int newindex) +{ + assert(oldindex >= 0 && oldindex < DEVICE_INDEX_MAXIMUM); + assert(newindex >= 0 && newindex < DEVICE_INDEX_MAXIMUM); + + // swap indexes in m_device array + m_device[oldindex].swap(m_device[newindex]); + + // update device indexes + m_device[oldindex]->set_devindex(oldindex); + m_device[newindex]->set_devindex(newindex); + + // update the maximum index found, since newindex may + // exceed current m_maxindex + m_maxindex = std::max(m_maxindex, newindex); +} + + //------------------------------------------------- // frame_callback - per-frame callback for various // bookkeeping @@ -2058,6 +2096,71 @@ void input_manager::seq_from_tokens(input_seq &seq, const char *string) } } +//------------------------------------------------- +// map_device_to_controller - map device to +// controller based on device map table +//------------------------------------------------- + +bool input_manager::map_device_to_controller(const devicemap_table_type *devicemap_table) +{ + if (nullptr == devicemap_table) + return true; + + for (devicemap_table_type::const_iterator it = devicemap_table->begin(); it != devicemap_table->end(); it++) + { + const char *devicename = it->first.c_str(); + const char *controllername = it->second.c_str(); + + // tokenize the controller name into device class and index (i.e. controller name should be of the form "GUNCODE_1") + std::string token[2]; + int numtokens; + const char *_token = controllername; + for (numtokens = 0; numtokens < ARRAY_LENGTH(token); ) + { + // make a token up to the next underscore + char *score = (char *)strchr(_token, '_'); + token[numtokens++].assign(_token, (score == nullptr) ? strlen(_token) : (score - _token)); + + // if we hit the end, we're done, else advance our pointer + if (score == nullptr) + break; + _token = score + 1; + } + if (2 != numtokens) + return false; + + // first token should be the devclass + input_device_class devclass = input_device_class((*devclass_token_table)[strmakeupper(token[0]).c_str()]); + if (devclass == ~input_device_class(0)) + return false; + + // second token should be the devindex + int devindex = 0; + if (1 != sscanf(token[1].c_str(), "%d", &devindex)) + return false; + devindex--; + + if (devindex >= DEVICE_INDEX_MAXIMUM) + return false; + + // enumerate through devices and look for a match + input_class *input_devclass = m_class[devclass]; + for (int devnum = 0; devnum <= input_devclass->maxindex(); devnum++) + { + input_device *device = input_devclass->device(devnum); + if (device != nullptr && device->match_device_name(devicename)) + { + // remap devindex + input_devclass->remap_device_index(device->devindex(), devindex); + osd_printf_info("Mapped device '%s' to %s #%d\n", device->name(), (*devclass_string_table)[input_devclass->devclass()], devindex); + break; + } + } + } + + return true; +} + //------------------------------------------------- // set_global_joystick_map - set the joystick map diff --git a/src/emu/input.h b/src/emu/input.h index d7012c1f779..1c4276fef3d 100644 --- a/src/emu/input.h +++ b/src/emu/input.h @@ -352,6 +352,8 @@ class input_manager; // callback for getting the value of an item on a device typedef INT32 (*item_get_state_func)(void *device_internal, void *item_internal); +// controller alias table typedef +typedef std::map devicemap_table_type; // ======================> joystick_map @@ -562,6 +564,9 @@ public: bool steadykey_enabled() const { return m_steadykey_enabled; } bool lightgun_reload_button() const { return m_lightgun_reload_button; } + // setters + void set_devindex(int devindex) { m_devindex = devindex; } + // item management input_item_id add_item(const char *name, input_item_id itemid, item_get_state_func getstate, void *internal = nullptr); void set_joystick_map(const joystick_map &map) { m_joymap = map; } @@ -569,6 +574,7 @@ public: // helpers INT32 apply_deadzone_and_saturation(INT32 value) const; void apply_steadykey() const; + bool match_device_name(const char * devicename); private: // internal state @@ -616,6 +622,7 @@ public: // misc helpers input_item_class standard_item_class(input_item_id itemid); + void remap_device_index(int oldindex, int newindex); private: // internal helpers @@ -679,6 +686,7 @@ public: // misc bool set_global_joystick_map(const char *mapstring); + bool map_device_to_controller(const devicemap_table_type *devicemap_table = nullptr); private: // internal helpers diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index 44e758b5752..00dbedb8de8 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -2904,6 +2904,24 @@ 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 = std::make_unique(); + for (xml_data_node *mapdevice_node = xml_get_sibling(parentnode->child, "mapdevice"); mapdevice_node != nullptr; mapdevice_node = xml_get_sibling(mapdevice_node->next, "mapdevice")) + { + 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()); + } + // iterate over all the port nodes for (xml_data_node *portnode = xml_get_sibling(parentnode->child, "port"); portnode; portnode = xml_get_sibling(portnode->next, "port")) { diff --git a/src/osd/modules/input/input_rawinput.cpp b/src/osd/modules/input/input_rawinput.cpp index ee6dbf4a511..44fba696e2c 100644 --- a/src/osd/modules/input/input_rawinput.cpp +++ b/src/osd/modules/input/input_rawinput.cpp @@ -572,8 +572,16 @@ protected: // improve the name and then allocate a device std::wstring name = rawinput_device_improve_name(tname.get()); - // convert name to utf8 - std::string utf8_name = utf8_from_wstring(name.c_str()); + // convert name to utf8. Preserve raw name as well (if different than improved name) to allow mapping of device to controller. + std::string utf8_name; + if (0 == name.compare(tname.get())) + { + utf8_name = utf8_from_wstring(name.c_str()); + } + else + { + utf8_name = util::string_format("%s (%s)", utf8_from_wstring(name.c_str()), utf8_from_wstring(tname.get())); + } devinfo = devicelist()->create_device(machine, utf8_name.c_str(), *this); From 0ed1ce56639faf0b4545ef75fc28e10746f17728 Mon Sep 17 00:00:00 2001 From: Tomer Verona Date: Wed, 14 Sep 2016 17:53:34 -0700 Subject: [PATCH 2/4] Tweak info message --- docs/source/advanced/devicemap.rst | 8 ++++---- src/emu/input.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/advanced/devicemap.rst b/docs/source/advanced/devicemap.rst index 2b52ef00c78..be49b7d0091 100644 --- a/docs/source/advanced/devicemap.rst +++ b/docs/source/advanced/devicemap.rst @@ -74,8 +74,8 @@ Then, when MAME is started, it will list available devices to the console. For e Furthermore, when devices are mapped using mapdevice, you'll see that in the verbose logging too, such as: -| Mapped device 'HID-compliant mouse (\\?\HID#VID_D209&PID_1601&MI_02#9&375eebb1&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd})' to Gun #0 -| Mapped device 'HID-compliant mouse (\\?\HID#VID_D209&PID_1602&MI_02#8&389ab7f3&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd})' to Gun #1 -| Mapped device 'XInput Player 1' to Joy #0 -| Mapped device 'XInput Player 2' to Joy #1 +| Input: Remapped Gun #0: HID-compliant mouse (\\?\HID#VID_D209&PID_1601&MI_02#9&375eebb1&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Input: Remapped Gun #1: HID-compliant mouse (\\?\HID#VID_D209&PID_1602&MI_02#8&389ab7f3&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Input: Remapped Joy #0: XInput Player 1 +| Input: Remapped Joy #1: XInput Player 2 | diff --git a/src/emu/input.cpp b/src/emu/input.cpp index 560e9271797..cb63a33e05a 100644 --- a/src/emu/input.cpp +++ b/src/emu/input.cpp @@ -2152,7 +2152,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("Mapped device '%s' to %s #%d\n", device->name(), (*devclass_string_table)[input_devclass->devclass()], devindex); + osd_printf_info("Input: Remapped %s #%d: %s\n", (*devclass_string_table)[input_devclass->devclass()], devindex, device->name()); break; } } From 32ea8266a31080330a6fd84208997dc24b7368fc Mon Sep 17 00:00:00 2001 From: Tomer Verona Date: Tue, 20 Sep 2016 01:24:36 -0700 Subject: [PATCH 3/4] A couple of fixes - Fix null-reference exception when mapping device to unused (null) controller index - Restrict device map to controller configs --- docs/source/advanced/devicemap.rst | 13 +++---------- src/emu/input.cpp | 9 ++++++--- src/emu/ioport.cpp | 27 +++++++++++++++------------ 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/docs/source/advanced/devicemap.rst b/docs/source/advanced/devicemap.rst index be49b7d0091..d834f57aebf 100644 --- a/docs/source/advanced/devicemap.rst +++ b/docs/source/advanced/devicemap.rst @@ -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: 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 = std::make_unique(); - 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 = std::make_unique(); + 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 From 845b36dae268242ab4a103ceb39520efdfa89018 Mon Sep 17 00:00:00 2001 From: Tomer Verona Date: Tue, 20 Sep 2016 12:19:58 -0700 Subject: [PATCH 4/4] Adding id() property to input_device This change adds id() property to input_device, which represents the unique device id. This allows the osd layer when creating a device to pass a friendly display name along with a unique identifier. Currently the device id is only used to map a physical controller device to controller id, but can be used more generally in the future. For raw input devices, we use the full raw input name as the device id. For all other devices, we fall back to device name as the device id. The "uniqueness" of the device id is not currently enforced in code. --- docs/source/advanced/devicemap.rst | 38 ++++++++++++----------- src/emu/input.cpp | 39 ++++++++++++++---------- src/emu/input.h | 10 +++--- src/osd/modules/input/input_common.h | 15 +++++---- src/osd/modules/input/input_dinput.cpp | 16 +++++----- src/osd/modules/input/input_dinput.h | 13 +++++--- src/osd/modules/input/input_rawinput.cpp | 33 +++++++++----------- src/osd/modules/input/input_sdl.cpp | 32 +++++++++---------- src/osd/modules/input/input_win32.cpp | 18 +++++------ src/osd/modules/input/input_x11.cpp | 12 ++++---- src/osd/modules/input/input_xinput.cpp | 6 ++-- src/osd/modules/input/input_xinput.h | 2 +- 12 files changed, 123 insertions(+), 111 deletions(-) diff --git a/docs/source/advanced/devicemap.rst b/docs/source/advanced/devicemap.rst index d834f57aebf..d1888090a93 100644 --- a/docs/source/advanced/devicemap.rst +++ b/docs/source/advanced/devicemap.rst @@ -7,14 +7,14 @@ The reason is that MAME enumerates attached devices and assigns controller IDs b It is quite cumbersome to ensure that controller IDs are always correct. -That's where the "mapdevice" configuration setting comes into the picture. This setting allows you to map a device name to a controller ID, ensuring that the specified device always maps to the same controller ID in MAME. +That's where the "mapdevice" configuration setting comes into the picture. This setting allows you to map a device id to a controller ID, ensuring that the specified device always maps to the same controller ID in MAME. Usage of mapdevice ------------------ 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). +The "device" attribute specifies the id of the device to match. It may also be a substring of the id. 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). The "controller" attribute specifies the MAME controller ID. It is made up of a controller class (i.e. "JOYCODE", "GUNCODE", "MOUSECODE") and controller index. For example: "JOYCODE_1". @@ -40,35 +40,37 @@ Here's an example: In the above example, we have four device mappings specified: -The first two mapdevice entries map player 1 and 2 lightguns to Gun 1 and Gun 2, respectively. We use a substring of the full raw device names to match each devices. Note that, since this is XML, we needed to escape the '&' in the name using '&'. +The first two mapdevice entries map player 1 and 2 lightguns to Gun 1 and Gun 2, respectively. We use a substring of the full raw device names to match each devices. Note that, since this is XML, we needed to escape the '&' using '&'. The last two mapdevices entries map player 1 and player 2 gamepad controllers to Joy 1 and Joy 2, respectively. In this case, these are XInput devices. Listing Available Devices ------------------------- -How did we obtain the device names in the above example? Easy! +How did we obtain the device id's in the above example? Easy! -Run MAME with -v parameter to enable verbose output. It will then list available devices to the console. For example: +Run MAME with -v parameter to enable verbose output. It will then list available devices include the corresponding "device id" to the console. + +Here an example: | Input: Adding Gun #0: | Input: Adding Gun #1: -| Input: Adding Gun #2: HID-compliant mouse (\\?\HID#VID_045E&PID_0053#7&18297dcb&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) -| Input: Adding Gun #3: HID-compliant mouse (\\?\HID#IrDeviceV2&Col08#2&2818a073&0&0007#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) -| Input: Adding Gun #4: HID-compliant mouse (\\?\HID#VID_D209&PID_1602&MI_02#8&389ab7f3&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) -| Input: Adding Gun #5: HID-compliant mouse (\\?\HID#VID_D209&PID_1601&MI_02#9&375eebb1&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) -| Input: Adding Gun #6: HID-compliant mouse (\\?\HID#VID_1241&PID_1111#8&198f3adc&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Input: Adding Gun #2: HID-compliant mouse (**device id: \\?\HID#VID_045E&PID_0053#7&18297dcb&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}**) +| Input: Adding Gun #3: HID-compliant mouse (**device id: \\?\HID#IrDeviceV2&Col08#2&2818a073&0&0007#{378de44c-56ef-11d1-bc8c-00a0c91405dd}**) +| Input: Adding Gun #4: HID-compliant mouse (**device id: \\?\HID#VID_D209&PID_1602&MI_02#8&389ab7f3&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}**) +| Input: Adding Gun #5: HID-compliant mouse (**device id: \\?\HID#VID_D209&PID_1601&MI_02#9&375eebb1&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}**) +| Input: Adding Gun #6: HID-compliant mouse (**device id: \\?\HID#VID_1241&PID_1111#8&198f3adc&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}**) | Skipping DirectInput for XInput compatible joystick Controller (XBOX 360 For Windows). -| Input: Adding Joy #0: ATRAK Device #1 +| Input: Adding Joy #0: ATRAK Device #1 (**device id: ATRAK Device #1**) | Skipping DirectInput for XInput compatible joystick Controller (XBOX 360 For Windows). -| Input: Adding Joy #1: ATRAK Device #2 -| Input: Adding Joy #2: XInput Player 1 -| Input: Adding Joy #3: XInput Player 2 +| Input: Adding Joy #1: ATRAK Device #2 (**device id: ATRAK Device #2**) +| Input: Adding Joy #2: XInput Player 1 (**device id: XInput Player 1**) +| Input: Adding Joy #3: XInput Player 2 (**device id: XInput Player 2**) | Furthermore, when devices are mapped using mapdevice, you'll see that in the verbose logging too, such as: -| Input: Remapped Gun #0: HID-compliant mouse (\\?\HID#VID_D209&PID_1601&MI_02#9&375eebb1&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) -| Input: Remapped Gun #1: HID-compliant mouse (\\?\HID#VID_D209&PID_1602&MI_02#8&389ab7f3&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) -| Input: Remapped Joy #0: XInput Player 1 -| Input: Remapped Joy #1: XInput Player 2 +| Input: Remapped Gun #0: HID-compliant mouse (device id: \\?\HID#VID_D209&PID_1601&MI_02#9&375eebb1&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Input: Remapped Gun #1: HID-compliant mouse (device id: \\?\HID#VID_D209&PID_1602&MI_02#8&389ab7f3&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}) +| Input: Remapped Joy #0: XInput Player 1 (device id: XInput Player 1) +| Input: Remapped Joy #1: XInput Player 2 (device id: XInput Player 2) | diff --git a/src/emu/input.cpp b/src/emu/input.cpp index 2a65ff4c688..4c8aad97307 100644 --- a/src/emu/input.cpp +++ b/src/emu/input.cpp @@ -794,9 +794,10 @@ void input_seq::replace(input_code oldcode, input_code newcode) // input_device - constructor //------------------------------------------------- -input_device::input_device(input_class &_class, int devindex, const char *name, void *internal) +input_device::input_device(input_class &_class, int devindex, const char *name, const char *id, void *internal) : m_class(_class), m_name(name), + m_id(id), m_devindex(devindex), m_maxitem(input_item_id(0)), m_internal(internal), @@ -942,19 +943,19 @@ void input_device::apply_steadykey() const } //------------------------------------------------- -// match_device_name - match device name via +// match_device_id - match device id via // substring search //------------------------------------------------- -bool input_device::match_device_name(const char *devicename) +bool input_device::match_device_id(const char *deviceid) { - std::string devicenameupper(devicename); - std::string nameupper(m_name); + std::string deviceidupper(deviceid); + std::string idupper(m_id); - strmakeupper(devicenameupper); - strmakeupper(nameupper); + strmakeupper(deviceidupper); + strmakeupper(idupper); - return std::string::npos == nameupper.find(devicenameupper) ? false : true; + return std::string::npos == idupper.find(deviceidupper) ? false : true; } @@ -983,7 +984,7 @@ input_class::input_class(input_manager &manager, input_device_class devclass, bo // add_device - add a new input device //------------------------------------------------- -input_device *input_class::add_device(const char *name, void *internal) +input_device *input_class::add_device(const char *name, const char *id, void *internal) { // find the next empty index int devindex; @@ -992,23 +993,28 @@ input_device *input_class::add_device(const char *name, void *internal) break; // call through - return add_device(devindex, name, internal); + return add_device(devindex, name, id, internal); } -input_device *input_class::add_device(int devindex, const char *name, void *internal) +input_device *input_class::add_device(int devindex, const char *name, const char *id, void *internal) { assert_always(machine().phase() == MACHINE_PHASE_INIT, "Can only call input_class::add_device at init time!"); assert(name != nullptr); + assert(id != nullptr); assert(devindex >= 0 && devindex < DEVICE_INDEX_MAXIMUM); assert(m_device[devindex] == nullptr); // allocate a new device - m_device[devindex] = std::make_unique(*this, devindex, name, internal); + m_device[devindex] = std::make_unique(*this, devindex, name, id, internal); // update the maximum index found m_maxindex = std::max(m_maxindex, devindex); - osd_printf_verbose("Input: Adding %s #%d: %s\n", (*devclass_string_table)[m_devclass], devindex, name); + if (0 == strlen(id)) + osd_printf_verbose("Input: Adding %s #%d: %s\n", (*devclass_string_table)[m_devclass], devindex, name); + else + osd_printf_verbose("Input: Adding %s #%d: %s (device id: %s)\n", (*devclass_string_table)[m_devclass], devindex, name, id); + return m_device[devindex].get(); } @@ -2111,7 +2117,7 @@ bool input_manager::map_device_to_controller(const devicemap_table_type *devicem for (devicemap_table_type::const_iterator it = devicemap_table->begin(); it != devicemap_table->end(); it++) { - const char *devicename = it->first.c_str(); + const char *deviceid = it->first.c_str(); const char *controllername = it->second.c_str(); // tokenize the controller name into device class and index (i.e. controller name should be of the form "GUNCODE_1") @@ -2151,11 +2157,12 @@ bool input_manager::map_device_to_controller(const devicemap_table_type *devicem for (int devnum = 0; devnum <= input_devclass->maxindex(); devnum++) { input_device *device = input_devclass->device(devnum); - if (device != nullptr && device->match_device_name(devicename)) + if (device != nullptr && device->match_device_id(deviceid)) { // remap devindex input_devclass->remap_device_index(device->devindex(), devindex); - osd_printf_verbose("Input: Remapped %s #%d: %s\n", (*devclass_string_table)[input_devclass->devclass()], devindex, device->name()); + osd_printf_verbose("Input: Remapped %s #%d: %s (device id: %s)\n", (*devclass_string_table)[input_devclass->devclass()], devindex, device->name(), device->id()); + break; } } diff --git a/src/emu/input.h b/src/emu/input.h index 1c4276fef3d..dff829f5d54 100644 --- a/src/emu/input.h +++ b/src/emu/input.h @@ -549,13 +549,14 @@ class input_device public: // construction/destruction - input_device(input_class &_class, int _devindex, const char *_name, void *_internal); + input_device(input_class &_class, int _devindex, const char *_name, const char *_id, void *_internal); // getters input_class &device_class() const { return m_class; } input_manager &manager() const; running_machine &machine() const; input_device_class devclass() const; const char *name() const { return m_name.c_str(); } + const char *id() const { return m_id.c_str(); } int devindex() const { return m_devindex; } input_device_item *item(input_item_id index) const { return m_item[index].get(); } input_item_id maxitem() const { return m_maxitem; } @@ -574,12 +575,13 @@ public: // helpers INT32 apply_deadzone_and_saturation(INT32 value) const; void apply_steadykey() const; - bool match_device_name(const char * devicename); + bool match_device_id(const char * deviceid); private: // internal state input_class & m_class; // reference to our class std::string m_name; // string name of device + std::string m_id; // id of device int m_devindex; // device index of this device std::unique_ptr m_item[ITEM_ID_ABSOLUTE_MAXIMUM+1]; // array of pointers to items input_item_id m_maxitem; // maximum item index @@ -617,8 +619,8 @@ public: void set_multi(bool multi = true) { m_multi = multi; } // device management - input_device *add_device(const char *name, void *internal = nullptr); - input_device *add_device(int devindex, const char *name, void *internal = nullptr); + input_device *add_device(const char *name, const char *id, void *internal = nullptr); + input_device *add_device(int devindex, const char *name, const char *id, void *internal = nullptr); // misc helpers input_item_class standard_item_class(input_item_id itemid); diff --git a/src/osd/modules/input/input_common.h b/src/osd/modules/input/input_common.h index 43c77f16b06..f59ee472758 100644 --- a/src/osd/modules/input/input_common.h +++ b/src/osd/modules/input/input_common.h @@ -202,6 +202,7 @@ class device_info private: std::string m_name; + std::string m_id; input_device * m_device; running_machine & m_machine; input_module & m_module; @@ -209,8 +210,9 @@ private: public: // Constructor - device_info(running_machine &machine, const char *name, input_device_class deviceclass, input_module &module) + device_info(running_machine &machine, const char *name, const char *id, input_device_class deviceclass, input_module &module) : m_name(name), + m_id(id), m_device(nullptr), m_machine(machine), m_module(module), @@ -224,6 +226,7 @@ public: // Getters running_machine & machine() const { return m_machine; } const char * name() const { return m_name.c_str(); } + const char * id() const { return m_id.c_str(); } input_device * device() const { return m_device; } input_module & module() const { return m_module; } input_device_class deviceclass() const { return m_deviceclass; } @@ -251,8 +254,8 @@ protected: virtual void process_event(TEvent &ev) = 0; public: - event_based_device(running_machine &machine, const char *name, input_device_class deviceclass, input_module &module) - : device_info(machine, name, deviceclass, module) + event_based_device(running_machine &machine, const char *name, const char *id, input_device_class deviceclass, input_module &module) + : device_info(machine, name, id, deviceclass, module) { } @@ -327,13 +330,13 @@ public: } template - TActual* create_device(running_machine &machine, const char *name, input_module &module, TArgs&&... args) + TActual* create_device(running_machine &machine, const char *name, const char *id, input_module &module, TArgs&&... args) { // allocate the device object - auto devinfo = std::make_unique(machine, name, module, std::forward(args)...); + auto devinfo = std::make_unique(machine, name, id, module, std::forward(args)...); // Add the device to the machine - devinfo->m_device = machine.input().device_class(devinfo->deviceclass()).add_device(devinfo->name(), devinfo.get()); + devinfo->m_device = machine.input().device_class(devinfo->deviceclass()).add_device(devinfo->name(), devinfo->id(), devinfo.get()); // append us to the list m_list.push_back(std::move(devinfo)); diff --git a/src/osd/modules/input/input_dinput.cpp b/src/osd/modules/input/input_dinput.cpp index 01e920f2953..b17cf3a61a3 100644 --- a/src/osd/modules/input/input_dinput.cpp +++ b/src/osd/modules/input/input_dinput.cpp @@ -68,8 +68,8 @@ static HRESULT dinput_set_dword_property(ComPtr device, REFG // dinput_device - base directinput device //============================================================ -dinput_device::dinput_device(running_machine &machine, const char *name, input_device_class deviceclass, input_module &module) - : device_info(machine, name, deviceclass, module), +dinput_device::dinput_device(running_machine &machine, const char *name, const char *id, input_device_class deviceclass, input_module &module) + : device_info(machine, name, id, deviceclass, module), dinput({nullptr}) { } @@ -110,8 +110,8 @@ HRESULT dinput_device::poll_dinput(LPVOID pState) const // dinput_keyboard_device - directinput keyboard device //============================================================ -dinput_keyboard_device::dinput_keyboard_device(running_machine &machine, const char *name, input_module &module) - : dinput_device(machine, name, DEVICE_CLASS_KEYBOARD, module), +dinput_keyboard_device::dinput_keyboard_device(running_machine &machine, const char *name, const char *id, input_module &module) + : dinput_device(machine, name, id, DEVICE_CLASS_KEYBOARD, module), keyboard({{0}}) { } @@ -328,8 +328,8 @@ public: }; -dinput_mouse_device::dinput_mouse_device(running_machine &machine, const char *name, input_module &module) - : dinput_device(machine, name, DEVICE_CLASS_MOUSE, module), +dinput_mouse_device::dinput_mouse_device(running_machine &machine, const char *name, const char *id, input_module &module) + : dinput_device(machine, name, id, DEVICE_CLASS_MOUSE, module), mouse({0}) { } @@ -427,8 +427,8 @@ public: } }; -dinput_joystick_device::dinput_joystick_device(running_machine &machine, const char *name, input_module &module) - : dinput_device(machine, name, DEVICE_CLASS_JOYSTICK, module), +dinput_joystick_device::dinput_joystick_device(running_machine &machine, const char *name, const char *id, input_module &module) + : dinput_device(machine, name, id, DEVICE_CLASS_JOYSTICK, module), joystick({{0}}) { } diff --git a/src/osd/modules/input/input_dinput.h b/src/osd/modules/input/input_dinput.h index d7142c35480..db640490dc6 100644 --- a/src/osd/modules/input/input_dinput.h +++ b/src/osd/modules/input/input_dinput.h @@ -81,8 +81,11 @@ public: // convert instance name to utf8 std::string utf8_instance_name = utf8_from_tstring(instance->tszInstanceName); + // set device id to name + std::string utf8_instance_id = utf8_instance_name; + // allocate memory for the device object - TDevice* devinfo = module.devicelist()->create_device(machine, utf8_instance_name.c_str(), module); + TDevice* devinfo = module.devicelist()->create_device(machine, utf8_instance_name.c_str(), utf8_instance_id.c_str(), module); // attempt to create a device result = m_dinput->CreateDevice(instance->guidInstance, devinfo->dinput.device.GetAddressOf(), nullptr); @@ -137,7 +140,7 @@ class dinput_device : public device_info public: dinput_api_state dinput; - dinput_device(running_machine &machine, const char *name, input_device_class deviceclass, input_module &module); + dinput_device(running_machine &machine, const char *name, const char *id, input_device_class deviceclass, input_module &module); virtual ~dinput_device(); protected: @@ -152,7 +155,7 @@ private: public: keyboard_state keyboard; - dinput_keyboard_device(running_machine &machine, const char *name, input_module &module); + dinput_keyboard_device(running_machine &machine, const char *name, const char *id, input_module &module); void poll() override; void reset() override; @@ -164,7 +167,7 @@ public: mouse_state mouse; public: - dinput_mouse_device(running_machine &machine, const char *name, input_module &module); + dinput_mouse_device(running_machine &machine, const char *name, const char *id, input_module &module); void poll() override; void reset() override; }; @@ -182,7 +185,7 @@ class dinput_joystick_device : public dinput_device public: dinput_joystick_state joystick; public: - dinput_joystick_device(running_machine &machine, const char *name, input_module &module); + dinput_joystick_device(running_machine &machine, const char *name, const char *id, input_module &module); void reset() override; void poll() override; int configure(); diff --git a/src/osd/modules/input/input_rawinput.cpp b/src/osd/modules/input/input_rawinput.cpp index 44fba696e2c..f9d111f2f8e 100644 --- a/src/osd/modules/input/input_rawinput.cpp +++ b/src/osd/modules/input/input_rawinput.cpp @@ -289,8 +289,8 @@ private: HANDLE m_handle; public: - rawinput_device(running_machine& machine, const char* name, input_device_class deviceclass, input_module& module) - : event_based_device(machine, name, deviceclass, module), + rawinput_device(running_machine& machine, const char *name, const char *id, input_device_class deviceclass, input_module& module) + : event_based_device(machine, name, id, deviceclass, module), m_handle(nullptr) { } @@ -308,8 +308,8 @@ class rawinput_keyboard_device : public rawinput_device public: keyboard_state keyboard; - rawinput_keyboard_device(running_machine& machine, const char* name, input_module& module) - : rawinput_device(machine, name, DEVICE_CLASS_KEYBOARD, module), + rawinput_keyboard_device(running_machine& machine, const char *name, const char *id, input_module& module) + : rawinput_device(machine, name, id, DEVICE_CLASS_KEYBOARD, module), keyboard({{0}}) { } @@ -344,8 +344,8 @@ private: public: mouse_state mouse; - rawinput_mouse_device(running_machine& machine, const char* name, input_module& module) - : rawinput_device(machine, name, DEVICE_CLASS_MOUSE, module), + rawinput_mouse_device(running_machine& machine, const char *name, const char *id, input_module& module) + : rawinput_device(machine, name, id, DEVICE_CLASS_MOUSE, module), mouse({0}) { } @@ -404,8 +404,8 @@ private: public: mouse_state lightgun; - rawinput_lightgun_device(running_machine& machine, const char* name, input_module& module) - : rawinput_device(machine, name, DEVICE_CLASS_LIGHTGUN, module), + rawinput_lightgun_device(running_machine& machine, const char *name, const char *id, input_module& module) + : rawinput_device(machine, name, id, DEVICE_CLASS_LIGHTGUN, module), lightgun({0}) { } @@ -572,18 +572,13 @@ protected: // improve the name and then allocate a device std::wstring name = rawinput_device_improve_name(tname.get()); - // convert name to utf8. Preserve raw name as well (if different than improved name) to allow mapping of device to controller. - std::string utf8_name; - if (0 == name.compare(tname.get())) - { - utf8_name = utf8_from_wstring(name.c_str()); - } - else - { - utf8_name = util::string_format("%s (%s)", utf8_from_wstring(name.c_str()), utf8_from_wstring(tname.get())); - } + // convert name to utf8 + std::string utf8_name = utf8_from_wstring(name.c_str()); + + // set device id to raw input name + std::string utf8_id = utf8_from_wstring(tname.get()); - devinfo = devicelist()->create_device(machine, utf8_name.c_str(), *this); + devinfo = devicelist()->create_device(machine, utf8_name.c_str(), utf8_id.c_str(), *this); // Add the handle devinfo->set_handle(rawinputdevice->hDevice); diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index b234efee7c4..9a8180b7088 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -110,8 +110,8 @@ static int lookup_sdl_code(const char *scode) class sdl_device : public event_based_device { public: - sdl_device(running_machine &machine, const char* name, input_device_class devclass, input_module &module) - : event_based_device(machine, name, devclass, module) + sdl_device(running_machine &machine, const char *name, const char *id, input_device_class devclass, input_module &module) + : event_based_device(machine, name, id, devclass, module) { } @@ -132,8 +132,8 @@ class sdl_keyboard_device : public sdl_device public: keyboard_state keyboard; - sdl_keyboard_device(running_machine &machine, const char* name, input_module &module) - : sdl_device(machine, name, DEVICE_CLASS_KEYBOARD, module), + sdl_keyboard_device(running_machine &machine, const char *name, const char *id, input_module &module) + : sdl_device(machine, name, id, DEVICE_CLASS_KEYBOARD, module), keyboard({{0}}) { } @@ -201,8 +201,8 @@ private: public: mouse_state mouse; - sdl_mouse_device(running_machine &machine, const char* name, input_module &module) - : sdl_device(machine, name, DEVICE_CLASS_MOUSE, module), + sdl_mouse_device(running_machine &machine, const char *name, const char *id, input_module &module) + : sdl_device(machine, name, id, DEVICE_CLASS_MOUSE, module), last_x(0), last_y(0), mouse({0}) @@ -338,8 +338,8 @@ public: sdl_joystick_state joystick; sdl_api_state sdl_state; - sdl_joystick_device(running_machine &machine, const char *name, input_module &module) - : sdl_device(machine, name, DEVICE_CLASS_JOYSTICK, module), + sdl_joystick_device(running_machine &machine, const char *name, const char *id, input_module &module) + : sdl_device(machine, name, id, DEVICE_CLASS_JOYSTICK, module), joystick({{0}}), sdl_state({ nullptr }) { @@ -419,8 +419,8 @@ public: class sdl_sixaxis_joystick_device : public sdl_joystick_device { public: - sdl_sixaxis_joystick_device(running_machine &machine, const char *name, input_module &module) - : sdl_joystick_device(machine, name, module) + sdl_sixaxis_joystick_device(running_machine &machine, const char *name, const char *id, input_module &module) + : sdl_joystick_device(machine, name, id, module) { } @@ -536,7 +536,7 @@ public: osd_printf_verbose("Keyboard: Start initialization\n"); // SDL only has 1 keyboard add it now - devinfo = devicelist()->create_device(machine, "System keyboard", *this); + devinfo = devicelist()->create_device(machine, "System keyboard", "System keyboard", *this); // populate it for (int keynum = 0; local_table[keynum].mame_key != ITEM_ID_INVALID; keynum++) @@ -672,7 +672,7 @@ public: osd_printf_verbose("Mouse: Start initialization\n"); // SDL currently only supports one mouse - devinfo = devicelist()->create_device(machine, "System mouse", *this); + devinfo = devicelist()->create_device(machine, "System mouse", "System mouse", *this); // add the axes devinfo->device()->add_item("X", ITEM_ID_XAXIS, generic_axis_get_state, &devinfo->mouse.lX); @@ -890,16 +890,16 @@ private: { snprintf(tempname, ARRAY_LENGTH(tempname), "NC%d", index); m_sixaxis_mode - ? devicelist()->create_device(machine, tempname, *this) - : devicelist()->create_device(machine, tempname, *this); + ? devicelist()->create_device(machine, tempname, tempname, *this) + : devicelist()->create_device(machine, tempname, tempname, *this); } return nullptr; } return m_sixaxis_mode - ? devicelist()->create_device(machine, devmap->map[index].name.c_str(), *this) - : devicelist()->create_device(machine, devmap->map[index].name.c_str(), *this); + ? devicelist()->create_device(machine, devmap->map[index].name.c_str(), devmap->map[index].name.c_str(), *this) + : devicelist()->create_device(machine, devmap->map[index].name.c_str(), devmap->map[index].name.c_str(), *this); } }; diff --git a/src/osd/modules/input/input_win32.cpp b/src/osd/modules/input/input_win32.cpp index 78e162f296b..ccae2be2861 100644 --- a/src/osd/modules/input/input_win32.cpp +++ b/src/osd/modules/input/input_win32.cpp @@ -38,8 +38,8 @@ class win32_keyboard_device : public event_based_device public: keyboard_state keyboard; - win32_keyboard_device(running_machine& machine, const char *name, input_module &module) - : event_based_device(machine, name, DEVICE_CLASS_KEYBOARD, module), + win32_keyboard_device(running_machine& machine, const char *name, const char *id, input_module &module) + : event_based_device(machine, name, id, DEVICE_CLASS_KEYBOARD, module), keyboard({{0}}) { } @@ -73,7 +73,7 @@ public: virtual void input_init(running_machine &machine) override { // Add a single win32 keyboard device that we'll monitor using Win32 - win32_keyboard_device *devinfo = devicelist()->create_device(machine, "Win32 Keyboard 1", *this); + win32_keyboard_device *devinfo = devicelist()->create_device(machine, "Win32 Keyboard 1", "Win32 Keyboard 1", *this); keyboard_trans_table &table = keyboard_trans_table::instance(); @@ -133,8 +133,8 @@ public: mouse_state mouse; win32_mouse_state win32_mouse; - win32_mouse_device(running_machine& machine, const char *name, input_module &module) - : event_based_device(machine, name, DEVICE_CLASS_MOUSE, module), + win32_mouse_device(running_machine& machine, const char *name, const char *id, input_module &module) + : event_based_device(machine, name, id, DEVICE_CLASS_MOUSE, module), mouse({0}), win32_mouse({{0}}) { @@ -206,7 +206,7 @@ public: return; // allocate a device - devinfo = devicelist()->create_device(machine, "Win32 Mouse 1", *this); + devinfo = devicelist()->create_device(machine, "Win32 Mouse 1", "Win32 Mouse 1", *this); if (devinfo == nullptr) return; @@ -261,8 +261,8 @@ private: public: mouse_state mouse; - win32_lightgun_device(running_machine& machine, const char *name, input_module &module) - : event_based_device(machine, name, DEVICE_CLASS_LIGHTGUN, module), + win32_lightgun_device(running_machine& machine, const char *name, const char *id, input_module &module) + : event_based_device(machine, name, id, DEVICE_CLASS_LIGHTGUN, module), m_lightgun_shared_axis_mode(FALSE), m_gun_index(0), mouse({0}) @@ -393,7 +393,7 @@ public: int axisnum, butnum; // allocate a device - devinfo = devicelist()->create_device(machine, gun_names[gunnum], *this); + devinfo = devicelist()->create_device(machine, gun_names[gunnum], gun_names[gunnum], *this); if (devinfo == nullptr) break; diff --git a/src/osd/modules/input/input_x11.cpp b/src/osd/modules/input/input_x11.cpp index f13a94358ab..312f3c5f0c8 100644 --- a/src/osd/modules/input/input_x11.cpp +++ b/src/osd/modules/input/input_x11.cpp @@ -338,8 +338,8 @@ class x11_input_device : public event_based_device public: x11_api_state x11_state; - x11_input_device(running_machine &machine, const char* name, input_device_class devclass, input_module &module) - : event_based_device(machine, name, devclass, module), + x11_input_device(running_machine &machine, const char *name, const char *id, input_device_class devclass, input_module &module) + : event_based_device(machine, name, id, devclass, module), x11_state({0}) { } @@ -354,8 +354,8 @@ class x11_lightgun_device : public x11_input_device public: lightgun_state lightgun; - x11_lightgun_device(running_machine &machine, const char* name, input_module &module) - : x11_input_device(machine, name, DEVICE_CLASS_LIGHTGUN, module), + x11_lightgun_device(running_machine &machine, const char *name, const char *id, input_module &module) + : x11_input_device(machine, name, id, DEVICE_CLASS_LIGHTGUN, module), lightgun({0}) { } @@ -533,13 +533,13 @@ private: if (m_lightgun_map.initialized) { snprintf(tempname, ARRAY_LENGTH(tempname), "NC%d", index); - devicelist()->create_device(machine, tempname, *this); + devicelist()->create_device(machine, tempname, tempname, *this); } return nullptr; } - return devicelist()->create_device(machine, m_lightgun_map.map[index].name.c_str(), *this); + return devicelist()->create_device(machine, m_lightgun_map.map[index].name.c_str(), m_lightgun_map.map[index].name.c_str(), *this); } void add_lightgun_buttons(XAnyClassPtr first_info_class, int num_classes, x11_lightgun_device *devinfo) const diff --git a/src/osd/modules/input/input_xinput.cpp b/src/osd/modules/input/input_xinput.cpp index ba25e4e1cd9..8baf1fd6cdd 100644 --- a/src/osd/modules/input/input_xinput.cpp +++ b/src/osd/modules/input/input_xinput.cpp @@ -74,7 +74,7 @@ xinput_joystick_device * xinput_api_helper::create_xinput_device(running_machine snprintf(device_name, sizeof(device_name), "XInput Player %u", index + 1); // allocate the device object - devinfo = module.devicelist()->create_device(machine, device_name, module, shared_from_this()); + devinfo = module.devicelist()->create_device(machine, device_name, device_name, module, shared_from_this()); // Set the player ID devinfo->xinput_state.player_index = index; @@ -89,8 +89,8 @@ xinput_joystick_device * xinput_api_helper::create_xinput_device(running_machine // xinput_joystick_device //============================================================ -xinput_joystick_device::xinput_joystick_device(running_machine &machine, const char *name, input_module &module, std::shared_ptr helper) - : device_info(machine, name, DEVICE_CLASS_JOYSTICK, module), +xinput_joystick_device::xinput_joystick_device(running_machine &machine, const char *name, char const *id, input_module &module, std::shared_ptr helper) + : device_info(machine, name, id, DEVICE_CLASS_JOYSTICK, module), gamepad({{0}}), xinput_state({0}), m_xinput_helper(helper), diff --git a/src/osd/modules/input/input_xinput.h b/src/osd/modules/input/input_xinput.h index 4dddc3069fd..68b5bbeca27 100644 --- a/src/osd/modules/input/input_xinput.h +++ b/src/osd/modules/input/input_xinput.h @@ -135,7 +135,7 @@ private: bool m_configured; public: - xinput_joystick_device(running_machine &machine, const char *name, input_module &module, std::shared_ptr helper); + xinput_joystick_device(running_machine &machine, const char *name, const char *id, input_module &module, std::shared_ptr helper); void poll() override; void reset() override;