summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/XInput
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2019-03-30 18:41:46 -0400
committerGitHub <noreply@github.com>2019-03-30 18:41:46 -0400
commit735a705e4dd9f535dc529e0a7eb0d96ba5982be9 (patch)
treef85eaff4a85ef81a6fdfd7ae078aedf6291d2772 /Source/Core/InputCommon/ControllerInterface/XInput
parent2dd564304efe8f0d341cf9ab9093f57f863639a0 (diff)
parenteadbdd6bc389cd89c3e3e57a31dabaeadf161865 (diff)
Merge pull request #7776 from jordan-woyak/wm_devicechange
Add hotplug support to DInput and XInput controller backends
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/XInput')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp7
-rw-r--r--Source/Core/InputCommon/ControllerInterface/XInput/XInput.h9
2 files changed, 12 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
index 8c518335a0..d6ecdb9d81 100644
--- a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
@@ -92,6 +92,8 @@ void PopulateDevices()
if (!hXInput)
return;
+ g_controller_interface.RemoveDevice([](const auto* dev) { return dev->GetSource() == "XInput"; });
+
XINPUT_CAPABILITIES caps;
for (int i = 0; i != 4; ++i)
if (ERROR_SUCCESS == PXInputGetCapabilities(i, 0, &caps))
@@ -192,6 +194,11 @@ void Device::UpdateMotors()
}
}
+std::optional<int> Device::GetPreferredId() const
+{
+ return m_index;
+}
+
// GET name/source/id
std::string Device::Button::GetName() const
diff --git a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h
index f2a81e3840..0b299e6324 100644
--- a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h
+++ b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h
@@ -92,8 +92,9 @@ public:
Device(const XINPUT_CAPABILITIES& capabilities, u8 index);
- std::string GetName() const override;
- std::string GetSource() const override;
+ std::string GetName() const final override;
+ std::string GetSource() const final override;
+ std::optional<int> GetPreferredId() const final override;
void UpdateMotors();
@@ -104,5 +105,5 @@ private:
const BYTE m_subtype;
const u8 m_index;
};
-}
-}
+} // namespace XInput
+} // namespace ciface