summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/input/input_xinput.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-01-29 03:02:02 +1100
committer Vas Crabb <vas@vastheman.com>2023-01-29 03:16:14 +1100
commit68472d3d72ea4bbc545c0669348172b4e96c7b41 (patch)
treee34fca0f55c977624148d1c806ecc6c44a5edd11 /src/osd/modules/input/input_xinput.cpp
parent01fcb2e0decf670a4cdee3d37b6f7ebde9b8f02b (diff)
Various input and OSD refactoring:
osd: Supply OSD object to modules on initialisation. Encapsulated some event handling in the OSD objects rather than leaving it in free functions. Put various stuff in namespaces. osd/modules/input: Enabled dinput, xinput and winhybrid modules for Windows SDL builds, and enabled background input for dinput and xinput (and by extension winhybrid) modules. Also fixed some COM and X11 resource leaks. osd/modules/input/input_sdl.cpp: Flipped SDL mouse button order to match Windows, and exposed vertical and horizontal scroll as Z and rZ axes. Moved SDL UI event handling out of input devices into OSD object. osd/modules/input_rawinput.cpp: Changed lightgun Z axis token so it's correctly identified as a relative axis (it maps to the scroll wheel equivalent). osd: Added an option to choose the network provider module. Mostly useful if you build with both TUN/TAP and pcap support included, or if you want to disable emulated networking completely. emu/input.cpp: Use a better strategy for assembling input code names that uses fewer temporary strings and doesn't require use of the non-Unicode-aware space trimming function (fixes MT08552). osd/modules/input_dinput.cpp: Improved polling logic. osd: Made various parts of the input code less dependent on concrete emu objects, and reduced inappropriately passing around the machine object. Made input modules less dependent on OSD implementation. Encapsulated some stuff and got rid of some vestigial newui and SDL1 support code. Cleaned up some interfaces. Moved OSD options classes to their own files. Prepare to remove main.h from emu.h - it's mostly used to get the application name, which the vast majority of emulated devices don't need to do.
Diffstat (limited to 'src/osd/modules/input/input_xinput.cpp')
-rw-r--r--src/osd/modules/input/input_xinput.cpp264
1 files changed, 125 insertions, 139 deletions
diff --git a/src/osd/modules/input/input_xinput.cpp b/src/osd/modules/input/input_xinput.cpp
index d996424c643..5cdc3fd29a2 100644
--- a/src/osd/modules/input/input_xinput.cpp
+++ b/src/osd/modules/input/input_xinput.cpp
@@ -1,5 +1,5 @@
// license:BSD-3-Clause
-// copyright-holders:Brad Hughes
+// copyright-holders:Brad Hughes, Vas Crabb
//============================================================
//
// input_xinput.cpp - XInput API input support for Windows
@@ -176,14 +176,19 @@ LSX 15 C
#include "modules/osdmodule.h"
-#if defined(OSD_WINDOWS)
+#if defined(OSD_WINDOWS) || defined(SDLMAME_WIN32)
+#include "input_xinput.h"
+
+#include "modules/lib/osdobj_common.h"
+
+// emu
#include "emu.h"
-#include "input_xinput.h"
+// lib/util
+#include "util/coretmpl.h"
-// standard windows headers
-#include <windows.h>
+#include "eminline.h"
#include <algorithm>
#include <cstdint>
@@ -191,6 +196,9 @@ LSX 15 C
#include <tuple>
#include <utility>
+// standard windows headers
+#include <windows.h>
+
#define XINPUT_LIBRARIES { "xinput1_4.dll", "xinput9_1_0.dll" }
@@ -201,6 +209,9 @@ namespace osd {
namespace {
+using util::BIT;
+
+
char const *const AXIS_NAMES_GAMEPAD[]{
"LSX",
"LSY",
@@ -325,18 +336,14 @@ char const *const BUTTON_NAMES_KEYBOARD[]{
class xinput_device_base : public device_info
{
-public:
- virtual void configure() = 0;
-
protected:
xinput_device_base(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper);
+ xinput_api_helper const &helper);
// capabilities
BYTE device_type() const { return m_capabilities.Type; }
@@ -370,19 +377,18 @@ private:
XINPUT_STATE m_xinput_state;
bool m_reset;
- std::shared_ptr<xinput_api_helper> m_xinput_helper;
+ xinput_api_helper const &m_xinput_helper;
};
xinput_device_base::xinput_device_base(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper) :
- device_info(machine, std::move(name), std::move(id), DEVICE_CLASS_JOYSTICK, module),
+ xinput_api_helper const &helper) :
+ device_info(std::move(name), std::move(id), module),
m_player_index(player),
m_capabilities(caps),
m_xinput_state{ 0 },
@@ -522,7 +528,7 @@ bool xinput_device_base::read_state()
{
// save previous packet number and try to read peripheral state
DWORD const prevpacket = m_xinput_state.dwPacketNumber;
- HRESULT const result = m_xinput_helper->xinput_get_state(m_player_index, &m_xinput_state);
+ HRESULT const result = m_xinput_helper.xinput_get_state(m_player_index, &m_xinput_state);
// only update if it succeeded and the packed number changed
if (FAILED(result))
@@ -593,18 +599,16 @@ class xinput_joystick_device : public xinput_device_base
{
public:
xinput_joystick_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper);
+ xinput_api_helper const &helper);
virtual void poll() override;
virtual void reset() override;
-
- virtual void configure() override;
+ virtual void configure(input_device &device) override;
private:
static inline constexpr USHORT SWITCH_BITS[] =
@@ -677,14 +681,13 @@ private:
xinput_joystick_device::xinput_joystick_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper) :
- xinput_device_base(machine, std::move(name), std::move(id), module, player, caps, helper)
+ xinput_api_helper const &helper) :
+ xinput_device_base(std::move(name), std::move(id), module, player, caps, helper)
{
std::fill(std::begin(m_switches), std::end(m_switches), 0);
std::fill(std::begin(m_axes), std::end(m_axes), 0);
@@ -735,7 +738,7 @@ void xinput_joystick_device::reset()
}
-void xinput_joystick_device::configure()
+void xinput_joystick_device::configure(input_device &device)
{
// TODO: proper support for dance mat controllers
@@ -789,7 +792,7 @@ void xinput_joystick_device::configure()
{
if (axis_caps[i])
{
- device()->add_item(
+ device.add_item(
axis_names[i],
axis_ids[i],
generic_axis_get_state<s32>,
@@ -811,7 +814,7 @@ void xinput_joystick_device::configure()
{
if (hat_caps[i])
{
- device()->add_item(
+ device.add_item(
hat_names[i],
input_item_id(ITEM_ID_HAT1UP + i), // matches up/down/left/right order
generic_button_get_state<u8>,
@@ -837,7 +840,7 @@ void xinput_joystick_device::configure()
auto const [offset, supported] = button_caps[i];
if (supported)
{
- device()->add_item(
+ device.add_item(
button_names[i],
button_id++,
generic_button_get_state<u8>,
@@ -848,7 +851,7 @@ void xinput_joystick_device::configure()
// add start/back
if (has_button(XINPUT_GAMEPAD_START))
{
- device()->add_item(
+ device.add_item(
"Start",
ITEM_ID_START,
generic_button_get_state<u8>,
@@ -856,7 +859,7 @@ void xinput_joystick_device::configure()
}
if (has_button(XINPUT_GAMEPAD_BACK))
{
- device()->add_item(
+ device.add_item(
"Back",
ITEM_ID_SELECT,
generic_button_get_state<u8>,
@@ -870,7 +873,7 @@ void xinput_joystick_device::configure()
{
if (i ? has_trigger_right() : has_trigger_left())
{
- device()->add_item(
+ device.add_item(
axis_names[4 + i],
axis_ids[4 + i],
generic_axis_get_state<s32>,
@@ -890,18 +893,16 @@ class xinput_guitar_device : public xinput_device_base
{
public:
xinput_guitar_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper);
+ xinput_api_helper const &helper);
virtual void poll() override;
virtual void reset() override;
-
- virtual void configure() override;
+ virtual void configure(input_device &device) override;
private:
static inline constexpr USHORT SWITCH_BITS[] =
@@ -965,14 +966,13 @@ private:
xinput_guitar_device::xinput_guitar_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper) :
- xinput_device_base(machine, std::move(name), std::move(id), module, player, caps, helper)
+ xinput_api_helper const &helper) :
+ xinput_device_base(std::move(name), std::move(id), module, player, caps, helper)
{
std::fill(std::begin(m_switches), std::end(m_switches), 0);
std::fill(std::begin(m_axes), std::end(m_axes), 0);
@@ -1012,7 +1012,7 @@ void xinput_guitar_device::reset()
}
-void xinput_guitar_device::configure()
+void xinput_guitar_device::configure(input_device &device)
{
// TODO: does subtype 0x06 indicate digital neck orientation sensor or lack of three-axis accelerometer?
@@ -1030,7 +1030,7 @@ void xinput_guitar_device::configure()
auto const [item, name, supported] = axis_caps[i];
if (supported)
{
- device()->add_item(
+ device.add_item(
name,
item,
generic_axis_get_state<s32>,
@@ -1043,7 +1043,7 @@ void xinput_guitar_device::configure()
{
if (has_button(SWITCH_BITS[SWITCH_DPAD_UP + i]))
{
- device()->add_item(
+ device.add_item(
HAT_NAMES_GUITAR[i],
input_item_id(ITEM_ID_HAT1UP + i), // matches up/down/left/right order
generic_button_get_state<u8>,
@@ -1057,7 +1057,7 @@ void xinput_guitar_device::configure()
{
if (has_button(SWITCH_BITS[i]))
{
- device()->add_item(
+ device.add_item(
BUTTON_NAMES_GUITAR[i],
button_id++,
generic_button_get_state<u8>,
@@ -1068,7 +1068,7 @@ void xinput_guitar_device::configure()
// add start/back
if (has_button(XINPUT_GAMEPAD_START))
{
- device()->add_item(
+ device.add_item(
"Start",
ITEM_ID_START,
generic_button_get_state<u8>,
@@ -1076,7 +1076,7 @@ void xinput_guitar_device::configure()
}
if (has_button(XINPUT_GAMEPAD_BACK))
{
- device()->add_item(
+ device.add_item(
"Back",
ITEM_ID_SELECT,
generic_button_get_state<u8>,
@@ -1094,18 +1094,16 @@ class xinput_drumkit_device : public xinput_device_base
{
public:
xinput_drumkit_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper);
+ xinput_api_helper const &helper);
virtual void poll() override;
virtual void reset() override;
-
- virtual void configure() override;
+ virtual void configure(input_device &device) override;
private:
static inline constexpr USHORT SWITCH_BITS[] =
@@ -1166,14 +1164,13 @@ private:
xinput_drumkit_device::xinput_drumkit_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper) :
- xinput_device_base(machine, std::move(name), std::move(id), module, player, caps, helper)
+ xinput_api_helper const &helper) :
+ xinput_device_base(std::move(name), std::move(id), module, player, caps, helper)
{
std::fill(std::begin(m_switches), std::end(m_switches), 0);
std::fill(std::begin(m_axes), std::end(m_axes), 0);
@@ -1208,7 +1205,7 @@ void xinput_drumkit_device::reset()
}
-void xinput_drumkit_device::configure()
+void xinput_drumkit_device::configure(input_device &device)
{
// add axes
std::tuple<input_item_id, char const *, bool> const axis_caps[]{
@@ -1223,7 +1220,7 @@ void xinput_drumkit_device::configure()
auto const [item, name, supported] = axis_caps[i];
if (supported)
{
- device()->add_item(
+ device.add_item(
name,
item,
generic_axis_get_state<s32>,
@@ -1236,7 +1233,7 @@ void xinput_drumkit_device::configure()
{
if (has_button(SWITCH_BITS[SWITCH_DPAD_UP + i]))
{
- device()->add_item(
+ device.add_item(
HAT_NAMES_GAMEPAD[i],
input_item_id(ITEM_ID_HAT1UP + i), // matches up/down/left/right order
generic_button_get_state<u8>,
@@ -1250,7 +1247,7 @@ void xinput_drumkit_device::configure()
{
if (has_button(SWITCH_BITS[i]))
{
- device()->add_item(
+ device.add_item(
BUTTON_NAMES_DRUMKIT[i],
button_id++,
generic_button_get_state<u8>,
@@ -1261,7 +1258,7 @@ void xinput_drumkit_device::configure()
// add start/back
if (has_button(XINPUT_GAMEPAD_START))
{
- device()->add_item(
+ device.add_item(
"Start",
ITEM_ID_START,
generic_button_get_state<u8>,
@@ -1269,7 +1266,7 @@ void xinput_drumkit_device::configure()
}
if (has_button(XINPUT_GAMEPAD_BACK))
{
- device()->add_item(
+ device.add_item(
"Back",
ITEM_ID_SELECT,
generic_button_get_state<u8>,
@@ -1287,18 +1284,16 @@ class xinput_turntable_device : public xinput_device_base
{
public:
xinput_turntable_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper);
+ xinput_api_helper const &helper);
virtual void poll() override;
virtual void reset() override;
-
- virtual void configure() override;
+ virtual void configure(input_device &device) override;
private:
static inline constexpr USHORT SWITCH_BITS[] =
@@ -1361,14 +1356,13 @@ private:
xinput_turntable_device::xinput_turntable_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper) :
- xinput_device_base(machine, std::move(name), std::move(id), module, player, caps, helper),
+ xinput_api_helper const &helper) :
+ xinput_device_base(std::move(name), std::move(id), module, player, caps, helper),
m_prev_effect(0)
{
std::fill(std::begin(m_switches), std::end(m_switches), 0);
@@ -1423,20 +1417,20 @@ void xinput_turntable_device::reset()
}
-void xinput_turntable_device::configure()
+void xinput_turntable_device::configure(input_device &device)
{
// add axes
- device()->add_item(
+ device.add_item(
"Turntable",
ITEM_ID_ADD_RELATIVE1,
generic_axis_get_state<s32>,
&m_axes[AXIS_TURNTABLE]);
- device()->add_item(
+ device.add_item(
"Effect",
ITEM_ID_ADD_RELATIVE2,
generic_axis_get_state<s32>,
&m_axes[AXIS_EFFECT]);
- device()->add_item(
+ device.add_item(
"Crossfade",
ITEM_ID_XAXIS,
generic_axis_get_state<s32>,
@@ -1447,7 +1441,7 @@ void xinput_turntable_device::configure()
{
if (has_button(SWITCH_BITS[SWITCH_DPAD_UP + i]))
{
- device()->add_item(
+ device.add_item(
HAT_NAMES_GAMEPAD[i],
input_item_id(ITEM_ID_HAT1UP + i), // matches up/down/left/right order
generic_button_get_state<u8>,
@@ -1461,24 +1455,24 @@ void xinput_turntable_device::configure()
{
if (has_button(SWITCH_BITS[i]))
{
- device()->add_item(
+ device.add_item(
BUTTON_NAMES_KEYBOARD[i],
button_id++,
generic_button_get_state<u8>,
&m_switches[SWITCH_A + i]);
}
}
- device()->add_item(
+ device.add_item(
"Green",
button_id++,
generic_button_get_state<u8>,
&m_switches[SWITCH_GREEN]);
- device()->add_item(
+ device.add_item(
"Red",
button_id++,
generic_button_get_state<u8>,
&m_switches[SWITCH_RED]);
- device()->add_item(
+ device.add_item(
"Blue",
button_id++,
generic_button_get_state<u8>,
@@ -1487,7 +1481,7 @@ void xinput_turntable_device::configure()
// add start/back
if (has_button(XINPUT_GAMEPAD_START))
{
- device()->add_item(
+ device.add_item(
"Start",
ITEM_ID_START,
generic_button_get_state<u8>,
@@ -1495,7 +1489,7 @@ void xinput_turntable_device::configure()
}
if (has_button(XINPUT_GAMEPAD_BACK))
{
- device()->add_item(
+ device.add_item(
"Back",
ITEM_ID_SELECT,
generic_button_get_state<u8>,
@@ -1513,18 +1507,16 @@ class xinput_keyboard_device : public xinput_device_base
{
public:
xinput_keyboard_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper);
+ xinput_api_helper const &helper);
virtual void poll() override;
virtual void reset() override;
-
- virtual void configure() override;
+ virtual void configure(input_device &device) override;
private:
static inline constexpr USHORT SWITCH_BITS[] =
@@ -1584,14 +1576,13 @@ private:
xinput_keyboard_device::xinput_keyboard_device(
- running_machine &machine,
std::string &&name,
std::string &&id,
input_module &module,
u32 player,
XINPUT_CAPABILITIES const &caps,
- std::shared_ptr<xinput_api_helper> const &helper) :
- xinput_device_base(machine, std::move(name), std::move(id), module, player, caps, helper)
+ xinput_api_helper const &helper) :
+ xinput_device_base(std::move(name), std::move(id), module, player, caps, helper)
{
std::fill(std::begin(m_switches), std::end(m_switches), 0);
std::fill(std::begin(m_axes), std::end(m_axes), 0);
@@ -1634,15 +1625,15 @@ void xinput_keyboard_device::reset()
}
-void xinput_keyboard_device::configure()
+void xinput_keyboard_device::configure(input_device &device)
{
// add axes
- device()->add_item(
+ device.add_item(
"Velocity",
ITEM_ID_SLIDER1,
generic_axis_get_state<s32>,
&m_axes[AXIS_VELOCITY]);
- device()->add_item(
+ device.add_item(
"Pedal",
ITEM_ID_SLIDER2,
generic_axis_get_state<s32>,
@@ -1653,7 +1644,7 @@ void xinput_keyboard_device::configure()
{
if (has_button(SWITCH_BITS[SWITCH_DPAD_UP + i]))
{
- device()->add_item(
+ device.add_item(
HAT_NAMES_GAMEPAD[i],
input_item_id(ITEM_ID_HAT1UP + i), // matches up/down/left/right order
generic_button_get_state<u8>,
@@ -1667,7 +1658,7 @@ void xinput_keyboard_device::configure()
{
if (has_button(SWITCH_BITS[i]))
{
- device()->add_item(
+ device.add_item(
BUTTON_NAMES_KEYBOARD[i],
button_id++,
generic_button_get_state<u8>,
@@ -1680,7 +1671,7 @@ void xinput_keyboard_device::configure()
"C %d", "C# %d", "D %d", "D# %d", "E %d", "F %d", "F# %d", "G %d", "G# %d", "A %d", "A# %d", "B %d" };
for (unsigned i = 0; (SWITCH_C3 - SWITCH_C1) >= i; ++i)
{
- device()->add_item(
+ device.add_item(
util::string_format(key_formats[i % 12], (i / 12) + 1),
(ITEM_ID_BUTTON32 >= button_id) ? button_id++ : ITEM_ID_OTHER_SWITCH,
generic_button_get_state<u8>,
@@ -1690,7 +1681,7 @@ void xinput_keyboard_device::configure()
// add start/back
if (has_button(XINPUT_GAMEPAD_START))
{
- device()->add_item(
+ device.add_item(
"Start",
ITEM_ID_START,
generic_button_get_state<u8>,
@@ -1698,7 +1689,7 @@ void xinput_keyboard_device::configure()
}
if (has_button(XINPUT_GAMEPAD_BACK))
{
- device()->add_item(
+ device.add_item(
"Back",
ITEM_ID_SELECT,
generic_button_get_state<u8>,
@@ -1712,22 +1703,24 @@ void xinput_keyboard_device::configure()
// XInput joystick module
//============================================================
-class xinput_joystick_module : public wininput_module
+class xinput_joystick_module : public input_module_impl<device_info, osd_common_t>
{
public:
- xinput_joystick_module() : wininput_module(OSD_JOYSTICKINPUT_PROVIDER, "xinput")
+ xinput_joystick_module() : input_module_impl<device_info, osd_common_t>(OSD_JOYSTICKINPUT_PROVIDER, "xinput")
{
}
- int init(const osd_options &options) override
+ virtual int init(osd_interface &osd, const osd_options &options) override
{
+ int status;
+
// Call the base
- int status = wininput_module::init(options);
+ status = input_module_impl<device_info, osd_common_t>::init(osd, options);
if (status != 0)
return status;
// Create and initialize our helper
- m_xinput_helper = std::make_shared<xinput_api_helper>();
+ m_xinput_helper = std::make_unique<xinput_api_helper>();
status = m_xinput_helper->initialize();
if (status != 0)
{
@@ -1738,22 +1731,29 @@ public:
return 0;
}
-protected:
virtual void input_init(running_machine &machine) override
{
+ input_module_impl<device_info, osd_common_t>::input_init(machine);
+
// Loop through each gamepad to determine if they are connected
for (UINT i = 0; i < XUSER_MAX_COUNT; i++)
{
- XINPUT_STATE state{ 0 };
-
// allocate and link in a new device
- if (m_xinput_helper->xinput_get_state(i, &state) == ERROR_SUCCESS)
- m_xinput_helper->create_xinput_device(machine, i, *this);
+ auto devinfo = m_xinput_helper->create_xinput_device(i, *this);
+ if (devinfo)
+ add_device(DEVICE_CLASS_JOYSTICK, std::move(devinfo));
}
}
+ virtual void exit() override
+ {
+ input_module_impl<device_info, osd_common_t>::exit();
+
+ m_xinput_helper.reset();
+ }
+
private:
- std::shared_ptr<xinput_api_helper> m_xinput_helper;
+ std::unique_ptr<xinput_api_helper> m_xinput_helper;
};
} // anonymous namespace
@@ -1781,9 +1781,14 @@ int xinput_api_helper::initialize()
// create_xinput_device
//============================================================
-device_info *xinput_api_helper::create_xinput_device(running_machine &machine, UINT index, wininput_module &module)
+std::unique_ptr<device_info> xinput_api_helper::create_xinput_device(
+ UINT index,
+ input_module_base &module)
{
// If we can't get the capabilities skip this device
+ XINPUT_STATE state{ 0 };
+ if (xinput_get_state(index, &state) != ERROR_SUCCESS)
+ return nullptr;
XINPUT_CAPABILITIES caps{ 0 };
if (FAILED(xinput_get_capabilities(index, 0, &caps)))
return nullptr;
@@ -1791,8 +1796,7 @@ device_info *xinput_api_helper::create_xinput_device(running_machine &machine, U
char device_name[16];
snprintf(device_name, sizeof(device_name), "XInput Player %u", index + 1);
- // allocate the device object
- xinput_device_base *devinfo;
+ // allocate specialised device objects
switch (caps.Type)
{
case XINPUT_DEVTYPE_GAMEPAD:
@@ -1801,81 +1805,63 @@ device_info *xinput_api_helper::create_xinput_device(running_machine &machine, U
case XINPUT_DEVSUBTYPE_GUITAR:
case XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE:
case XINPUT_DEVSUBTYPE_GUITAR_BASS:
- devinfo = &module.devicelist().create_device<xinput_guitar_device>(
- machine,
+ return std::make_unique<xinput_guitar_device>(
device_name,
device_name,
module,
index,
caps,
- shared_from_this());
+ *this);
break;
case XINPUT_DEVSUBTYPE_DRUM_KIT:
- devinfo = &module.devicelist().create_device<xinput_drumkit_device>(
- machine,
+ return std::make_unique<xinput_drumkit_device>(
device_name,
device_name,
module,
index,
caps,
- shared_from_this());
+ *this);
break;
case 0x0f:
- devinfo = &module.devicelist().create_device<xinput_keyboard_device>(
- machine,
+ return std::make_unique<xinput_keyboard_device>(
device_name,
device_name,
module,
index,
caps,
- shared_from_this());
+ *this);
break;
case 0x17:
- devinfo = &module.devicelist().create_device<xinput_turntable_device>(
- machine,
+ return std::make_unique<xinput_turntable_device>(
device_name,
device_name,
module,
index,
caps,
- shared_from_this());
+ *this);
break;
- default:
- devinfo = &module.devicelist().create_device<xinput_joystick_device>(
- machine,
- device_name,
- device_name,
- module,
- index,
- caps,
- shared_from_this());
}
break;
- default:
- devinfo = &module.devicelist().create_device<xinput_joystick_device>(
- machine,
- device_name,
- device_name,
- module,
- index,
- caps,
- shared_from_this());
}
- // configure each controller to add buttons, axes, etc.
- devinfo->configure();
-
- return devinfo;
+ // create default general-purpose device
+ return std::make_unique<xinput_joystick_device>(
+ device_name,
+ device_name,
+ module,
+ index,
+ caps,
+ *this);
}
} // namespace osd
-#else // defined(OSD_WINDOWS)
+#else // defined(OSD_WINDOWS) || defined(SDLMAME_WIN32)
#include "input_module.h"
-namespace osd { MODULE_NOT_SUPPORTED(xinput_joystick_module, OSD_JOYSTICKINPUT_PROVIDER, "xinput") }
+namespace osd { namespace { MODULE_NOT_SUPPORTED(xinput_joystick_module, OSD_JOYSTICKINPUT_PROVIDER, "xinput") } }
-#endif // defined(OSD_WINDOWS)
+#endif // defined(OSD_WINDOWS) || defined(SDLMAME_WIN32)
MODULE_DEFINITION(JOYSTICKINPUT_XINPUT, osd::xinput_joystick_module)