diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2025-11-06 20:06:53 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-06 20:06:53 -0600 |
| commit | 5650be68425960131225bcd3ea5a8dfc85074148 (patch) | |
| tree | df7ba26cd8dc7a3bfb914264ad713aaad0d08679 /Source/Core/InputCommon/ControllerInterface/ControllerInterface.h | |
| parent | 852b7d85b2eac31da239f4d6c0e0d5a7f2bb8a30 (diff) | |
| parent | ca6d8e1f0b1b17096a9e09c61e8d7e1eb97ab06f (diff) | |
Merge pull request #14069 from jordan-woyak/ciface-hookable-event
InputCommon: Make ControllerInterface RegisterDevicesChangedCallback use Common::HookableEvent.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.h')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index e5712f0a4f..806c6b4b2a 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -5,12 +5,13 @@ #include <atomic> #include <functional> -#include <list> #include <memory> #include <mutex> +#include "Common/HookableEvent.h" #include "Common/Matrix.h" #include "Common/WindowSystemInfo.h" + #include "InputCommon/ControllerInterface/CoreDevice.h" #include "InputCommon/ControllerInterface/InputBackend.h" @@ -64,8 +65,6 @@ enum class InputChannel class ControllerInterface : public ciface::Core::DeviceContainer { public: - using HotplugCallbackHandle = std::list<std::function<void()>>::iterator; - enum class WindowChangeReason { // Application is shutting down @@ -115,9 +114,9 @@ public: bool IsMouseCenteringRequested() const; - HotplugCallbackHandle RegisterDevicesChangedCallback(std::function<void(void)> callback); - void UnregisterDevicesChangedCallback(const HotplugCallbackHandle& handle); - void InvokeDevicesChangedCallbacks() const; + [[nodiscard]] Common::EventHook + RegisterDevicesChangedCallback(std::string_view name, + Common::HookableEvent<>::CallbackType callback); static void SetCurrentInputChannel(ciface::InputChannel); static ciface::InputChannel GetCurrentInputChannel(); @@ -127,9 +126,11 @@ public: private: void ClearDevices(); - std::list<std::function<void()>> m_devices_changed_callbacks; + void InvokeDevicesChangedCallbacks(); + + Common::HookableEvent<> m_devices_changed_event{"Devices Changed"}; + mutable std::recursive_mutex m_devices_population_mutex; - mutable std::mutex m_callbacks_mutex; std::atomic<bool> m_is_init; // This is now always protected by m_devices_population_mutex, so // it doesn't really need to be a counter or atomic anymore (it could be a raw bool), |
