mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02: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:
@ -6,9 +6,9 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/WindowSystemInfo.h"
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
@ -40,6 +40,8 @@
|
||||
class ControllerInterface : public ciface::Core::DeviceContainer
|
||||
{
|
||||
public:
|
||||
using HotplugCallbackHandle = std::list<std::function<void()>>::iterator;
|
||||
|
||||
ControllerInterface() : m_is_init(false) {}
|
||||
void Initialize(const WindowSystemInfo& wsi);
|
||||
void ChangeWindow(void* hwnd);
|
||||
@ -50,11 +52,12 @@ public:
|
||||
bool IsInit() const { return m_is_init; }
|
||||
void UpdateInput();
|
||||
|
||||
void RegisterDevicesChangedCallback(std::function<void(void)> callback);
|
||||
HotplugCallbackHandle RegisterDevicesChangedCallback(std::function<void(void)> callback);
|
||||
void UnregisterDevicesChangedCallback(const HotplugCallbackHandle& handle);
|
||||
void InvokeDevicesChangedCallbacks() const;
|
||||
|
||||
private:
|
||||
std::vector<std::function<void()>> m_devices_changed_callbacks;
|
||||
std::list<std::function<void()>> m_devices_changed_callbacks;
|
||||
mutable std::mutex m_callbacks_mutex;
|
||||
std::atomic<bool> m_is_init;
|
||||
std::atomic<bool> m_is_populating_devices{false};
|
||||
|
Reference in New Issue
Block a user