diff options
Diffstat (limited to 'src/osd/modules/input/input_winhybrid.cpp')
-rw-r--r-- | src/osd/modules/input/input_winhybrid.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/osd/modules/input/input_winhybrid.cpp b/src/osd/modules/input/input_winhybrid.cpp index ed6d88fd26b..4aad202ad4c 100644 --- a/src/osd/modules/input/input_winhybrid.cpp +++ b/src/osd/modules/input/input_winhybrid.cpp @@ -37,6 +37,8 @@ #include "input_xinput.h" #include "input_dinput.h" +namespace { + using namespace Microsoft::WRL; template<class TCom> @@ -46,8 +48,7 @@ private: std::vector<TCom*> m_entries; public: - ComArray(size_t capacity) - : m_entries(capacity, nullptr) + ComArray(size_t capacity) : m_entries(capacity, nullptr) { } @@ -76,12 +77,12 @@ public: void Release() { - for (int i = 0; i < m_entries.size(); i++) + for (auto &entry : m_entries) { - if (m_entries[i] != nullptr) + if (entry != nullptr) { - m_entries[i]->Release(); - m_entries[i] = nullptr; + entry->Release(); + entry = nullptr; } } } @@ -91,7 +92,7 @@ struct bstr_deleter { void operator () (BSTR bstr) const { - if (bstr != nullptr) + if (bstr) SysFreeString(bstr); } }; @@ -146,8 +147,8 @@ private: bool m_xinput_detect_failed; public: - winhybrid_joystick_module() - : wininput_module(OSD_JOYSTICKINPUT_PROVIDER, "winhybrid"), + winhybrid_joystick_module() : + wininput_module(OSD_JOYSTICKINPUT_PROVIDER, "winhybrid"), m_xinput_helper(nullptr), m_dinput_helper(nullptr), m_xinput_detect_failed(false) @@ -232,13 +233,13 @@ protected: if (result != 0) { m_xinput_detect_failed = true; - osd_printf_warning("XInput device detection failed. XInput won't be used. Error: 0x%X\n", static_cast<unsigned int>(result)); + osd_printf_warning("XInput device detection failed. XInput won't be used. Error: 0x%X\n", uint32_t(result)); } // Enumerate all the directinput joysticks and add them if they aren't xinput compatible result = m_dinput_helper->enum_attached_devices(DI8DEVCLASS_GAMECTRL, this, &machine); if (result != DI_OK) - fatalerror("DirectInput: Unable to enumerate keyboards (result=%08X)\n", static_cast<uint32_t>(result)); + fatalerror("DirectInput: Unable to enumerate game controllers (result=%08X)\n", uint32_t(result)); xinput_joystick_device *devinfo; @@ -254,7 +255,7 @@ protected: { // allocate and link in a new device devinfo = m_xinput_helper->create_xinput_device(machine, i, *this); - if (devinfo == nullptr) + if (!devinfo) continue; // Configure each gamepad to add buttons and Axes, etc. @@ -269,7 +270,7 @@ private: { int status = 0; - if (m_xinput_helper == nullptr) + if (!m_xinput_helper) { m_xinput_helper = std::make_shared<xinput_api_helper>(); status = m_xinput_helper->initialize(); @@ -280,9 +281,9 @@ private: } } - if (m_dinput_helper == nullptr) + if (!m_dinput_helper) { - m_dinput_helper = std::make_unique<dinput_api_helper>(DIRECTINPUT_VERSION); + m_dinput_helper = std::make_unique<dinput_api_helper>(); status = m_dinput_helper->initialize(); if (status != DI_OK) { @@ -441,8 +442,12 @@ private: } }; -#else +} // anonymous namespace + +#else // defined(OSD_WINDOWS) + MODULE_NOT_SUPPORTED(winhybrid_joystick_module, OSD_JOYSTICKINPUT_PROVIDER, "winhybrid") -#endif + +#endif // defined(OSD_WINDOWS) MODULE_DEFINITION(JOYSTICKINPUT_WINHYBRID, winhybrid_joystick_module) |