mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-28 23:38:49 +00:00
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:
parent
c2afcb0f6b
commit
b425f86121
10 changed files with 62 additions and 16 deletions
|
@ -249,10 +249,20 @@ void ControllerInterface::UpdateInput()
|
|||
|
||||
// Register a callback to be called when a device is added or removed (as from the input backends'
|
||||
// hotplug thread), or when devices are refreshed
|
||||
void ControllerInterface::RegisterDevicesChangedCallback(std::function<void()> callback)
|
||||
// Returns a handle for later removing the callback.
|
||||
ControllerInterface::HotplugCallbackHandle
|
||||
ControllerInterface::RegisterDevicesChangedCallback(std::function<void()> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_callbacks_mutex);
|
||||
m_devices_changed_callbacks.emplace_back(std::move(callback));
|
||||
return std::prev(m_devices_changed_callbacks.end());
|
||||
}
|
||||
|
||||
// Unregister a device callback.
|
||||
void ControllerInterface::UnregisterDevicesChangedCallback(const HotplugCallbackHandle& handle)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_callbacks_mutex);
|
||||
m_devices_changed_callbacks.erase(handle);
|
||||
}
|
||||
|
||||
// Invoke all callbacks that were registered
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue