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.

This commit is contained in:
Jordan Woyak
2019-01-10 09:02:38 -06:00
parent c2afcb0f6b
commit b425f86121
10 changed files with 62 additions and 16 deletions

View File

@ -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())