summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
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/ControllerInterface/ControllerInterface.h
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/ControllerInterface/ControllerInterface.h')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
index 0d712e5245..7330172421 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
@@ -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};