diff options
Diffstat (limited to 'src/osd/modules')
-rw-r--r-- | src/osd/modules/input/input_common.h | 15 | ||||
-rw-r--r-- | src/osd/modules/input/input_dinput.cpp | 16 | ||||
-rw-r--r-- | src/osd/modules/input/input_dinput.h | 13 | ||||
-rw-r--r-- | src/osd/modules/input/input_rawinput.cpp | 33 | ||||
-rw-r--r-- | src/osd/modules/input/input_sdl.cpp | 32 | ||||
-rw-r--r-- | src/osd/modules/input/input_win32.cpp | 18 | ||||
-rw-r--r-- | src/osd/modules/input/input_x11.cpp | 12 | ||||
-rw-r--r-- | src/osd/modules/input/input_xinput.cpp | 6 | ||||
-rw-r--r-- | src/osd/modules/input/input_xinput.h | 2 |
9 files changed, 74 insertions, 73 deletions
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 <typename TActual, typename... TArgs> - 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<TActual>(machine, name, module, std::forward<TArgs>(args)...); + auto devinfo = std::make_unique<TActual>(machine, name, id, module, std::forward<TArgs>(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<IDirectInputDevice> 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<TDevice>(machine, utf8_instance_name.c_str(), module); + TDevice* devinfo = module.devicelist()->create_device<TDevice>(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<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); 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<SDL_Event> { 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<sdl_keyboard_device>(machine, "System keyboard", *this); + devinfo = devicelist()->create_device<sdl_keyboard_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<sdl_mouse_device>(machine, "System mouse", *this); + devinfo = devicelist()->create_device<sdl_mouse_device>(machine, "System mouse", "System mouse", *this); // add the axes devinfo->device()->add_item("X", ITEM_ID_XAXIS, generic_axis_get_state<std::int32_t>, &devinfo->mouse.lX); @@ -890,16 +890,16 @@ private: { snprintf(tempname, ARRAY_LENGTH(tempname), "NC%d", index); m_sixaxis_mode - ? devicelist()->create_device<sdl_sixaxis_joystick_device>(machine, tempname, *this) - : devicelist()->create_device<sdl_joystick_device>(machine, tempname, *this); + ? devicelist()->create_device<sdl_sixaxis_joystick_device>(machine, tempname, tempname, *this) + : devicelist()->create_device<sdl_joystick_device>(machine, tempname, tempname, *this); } return nullptr; } return m_sixaxis_mode - ? devicelist()->create_device<sdl_sixaxis_joystick_device>(machine, devmap->map[index].name.c_str(), *this) - : devicelist()->create_device<sdl_joystick_device>(machine, devmap->map[index].name.c_str(), *this); + ? devicelist()->create_device<sdl_sixaxis_joystick_device>(machine, devmap->map[index].name.c_str(), devmap->map[index].name.c_str(), *this) + : devicelist()->create_device<sdl_joystick_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<KeyPressEventArgs> 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<win32_keyboard_device>(machine, "Win32 Keyboard 1", *this); + win32_keyboard_device *devinfo = devicelist()->create_device<win32_keyboard_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<win32_mouse_device>(machine, "Win32 Mouse 1", *this); + devinfo = devicelist()->create_device<win32_mouse_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<win32_lightgun_device>(machine, gun_names[gunnum], *this); + devinfo = devicelist()->create_device<win32_lightgun_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<XEvent> 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<x11_lightgun_device>(machine, tempname, *this); + devicelist()->create_device<x11_lightgun_device>(machine, tempname, tempname, *this); } return nullptr; } - return devicelist()->create_device<x11_lightgun_device>(machine, m_lightgun_map.map[index].name.c_str(), *this); + return devicelist()->create_device<x11_lightgun_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<xinput_joystick_device>(machine, device_name, module, shared_from_this()); + devinfo = module.devicelist()->create_device<xinput_joystick_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<xinput_api_helper> 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<xinput_api_helper> 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<xinput_api_helper> helper); + xinput_joystick_device(running_machine &machine, const char *name, const char *id, input_module &module, std::shared_ptr<xinput_api_helper> helper); void poll() override; void reset() override; |