From 0d783f0869eaef163a318ab4d79744f592ed1cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 13 Jun 2016 11:11:47 +0200 Subject: ControllerInterface: Add a way to register callbacks This adds RegisterHotplugCallback() to register a callback which will be invoked by the input backends' hotplug threads when there is a new device, so that Core (GCKeyboard, GCPad, Wiimote, Hotkey) can reload the configuration without adding a dependency to Core from InputCommon. --- .../ControllerInterface/ControllerInterface.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 700d390b92..cc80b7b234 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -172,6 +172,28 @@ void ControllerInterface::UpdateInput() d->UpdateInput(); } +// +// RegisterHotplugCallback +// +// Register a callback to be called from the input backends' hotplug thread +// when there is a new device +// +void ControllerInterface::RegisterHotplugCallback(std::function callback) +{ + m_hotplug_callbacks.emplace_back(std::move(callback)); +} + +// +// InvokeHotplugCallbacks +// +// Invoke all callbacks that were registered +// +void ControllerInterface::InvokeHotplugCallbacks() const +{ + for (const auto& callback : m_hotplug_callbacks) + callback(); +} + // // InputReference :: State // -- cgit v1.2.3