diff options
author | 2016-09-20 12:19:58 -0700 | |
---|---|---|
committer | 2016-09-20 12:19:58 -0700 | |
commit | 845b36dae268242ab4a103ceb39520efdfa89018 (patch) | |
tree | eca831bad8973be7ba3f449f16185619088c50a3 /src/osd/modules/input/input_rawinput.cpp | |
parent | 32ea8266a31080330a6fd84208997dc24b7368fc (diff) |
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.
Diffstat (limited to 'src/osd/modules/input/input_rawinput.cpp')
-rw-r--r-- | src/osd/modules/input/input_rawinput.cpp | 33 |
1 files changed, 14 insertions, 19 deletions
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<TDevice>(machine, utf8_name.c_str(), *this); + devinfo = devicelist()->create_device<TDevice>(machine, utf8_name.c_str(), utf8_id.c_str(), *this); // Add the handle devinfo->set_handle(rawinputdevice->hDevice); |