summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/InputConfig.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2019-01-10 09:02:38 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2019-01-10 18:32:16 -0600
commitb425f86121c8c9f3b4a510e522d03e432677dcea (patch)
treeec0a34d787c7962cdd61b1967d79c2bf2386c482 /Source/Core/InputCommon/InputConfig.cpp
parentc2afcb0f6bba761c248031ee715a1db3fd4dbe05 (diff)
ControllerInterface: Allow hotplug callbacks to be unregistered and don't reload the entire config from the ini file on hotplug, just update the control references. This should fix a crash on shutdown on Android.
Diffstat (limited to 'Source/Core/InputCommon/InputConfig.cpp')
-rw-r--r--Source/Core/InputCommon/InputConfig.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/InputConfig.cpp b/Source/Core/InputCommon/InputConfig.cpp
index dfc677d70a..65cfdef086 100644
--- a/Source/Core/InputCommon/InputConfig.cpp
+++ b/Source/Core/InputCommon/InputConfig.cpp
@@ -147,6 +147,21 @@ std::size_t InputConfig::GetControllerCount() const
return m_controllers.size();
}
+void InputConfig::RegisterHotplugCallback()
+{
+ // Update control references on all controllers
+ // as configured devices may have been added or removed.
+ m_hotplug_callback_handle = g_controller_interface.RegisterDevicesChangedCallback([this] {
+ for (auto& controller : m_controllers)
+ controller->UpdateReferences(g_controller_interface);
+ });
+}
+
+void InputConfig::UnregisterHotplugCallback()
+{
+ g_controller_interface.UnregisterDevicesChangedCallback(m_hotplug_callback_handle);
+}
+
bool InputConfig::IsControllerControlledByGamepadDevice(int index) const
{
if (static_cast<size_t>(index) >= m_controllers.size())