summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/input/input_rawinput.cpp
diff options
context:
space:
mode:
author Tomer Verona <tverona@hotmail.com>2016-09-20 12:19:58 -0700
committer Tomer Verona <tverona@hotmail.com>2016-09-20 12:19:58 -0700
commit845b36dae268242ab4a103ceb39520efdfa89018 (patch)
treeeca831bad8973be7ba3f449f16185619088c50a3 /src/osd/modules/input/input_rawinput.cpp
parent32ea8266a31080330a6fd84208997dc24b7368fc (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.cpp33
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);