From 7355b5f70d2bdf68c356873f2311025a81c7972a Mon Sep 17 00:00:00 2001 From: Michael M Date: Thu, 9 Nov 2017 12:14:21 -0800 Subject: ControllerInterface: invoke callbacks in AddDevice/RemoveDevice Some backends already cause this to happen, so make it consistent across systems. --- Source/Core/InputCommon/ControllerInterface/ControllerInterface.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.h') diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index 23afab7d67..eb94a8de67 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -54,9 +54,10 @@ public: void UpdateInput(); void RegisterHotplugCallback(std::function callback); - void InvokeHotplugCallbacks() const; private: + void InvokeHotplugCallbacks() const; + std::vector> m_hotplug_callbacks; bool m_is_init; void* m_hwnd; -- cgit v1.2.3 From 1ed7532af850691eea8d7eee502f59ed20a37694 Mon Sep 17 00:00:00 2001 From: Michael M Date: Sat, 4 Nov 2017 07:36:30 -0700 Subject: ControllerInterface: HotplugCallbacks -> DevicesChangedCallbacks --- Source/Core/InputCommon/ControllerInterface/ControllerInterface.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.h') diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index eb94a8de67..e70c135b3e 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -53,12 +53,11 @@ public: bool IsInit() const { return m_is_init; } void UpdateInput(); - void RegisterHotplugCallback(std::function callback); + void RegisterDevicesChangedCallback(std::function callback); + void InvokeDevicesChangedCallbacks() const; private: - void InvokeHotplugCallbacks() const; - - std::vector> m_hotplug_callbacks; + std::vector> m_devices_changed_callbacks; bool m_is_init; void* m_hwnd; }; -- cgit v1.2.3 From fd7cbd633edbac9e38592b9253a507410d7d6553 Mon Sep 17 00:00:00 2001 From: Michael M Date: Fri, 10 Nov 2017 12:29:25 -0800 Subject: ControllerInterface: add mutex around callbacks vector --- Source/Core/InputCommon/ControllerInterface/ControllerInterface.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.h') diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index e70c135b3e..b485cda31a 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -4,14 +4,11 @@ #pragma once -#include #include -#include -#include -#include +#include +#include #include -#include "Common/CommonTypes.h" #include "InputCommon/ControllerInterface/Device.h" // enable disable sources @@ -58,6 +55,7 @@ public: private: std::vector> m_devices_changed_callbacks; + mutable std::mutex m_callbacks_mutex; bool m_is_init; void* m_hwnd; }; -- cgit v1.2.3 From 8e6677be90d67a652eb4bcf7d0b76f548e254172 Mon Sep 17 00:00:00 2001 From: Michael M Date: Sat, 4 Nov 2017 07:37:03 -0700 Subject: ControllerInterface: don't call InvokeDevicesChangedCallbacks more than once when refreshing --- Source/Core/InputCommon/ControllerInterface/ControllerInterface.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.h') diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index b485cda31a..06fd7c544d 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include @@ -57,6 +58,7 @@ private: std::vector> m_devices_changed_callbacks; mutable std::mutex m_callbacks_mutex; bool m_is_init; + std::atomic m_is_populating_devices{false}; void* m_hwnd; }; -- cgit v1.2.3