summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2016-06-13 11:11:47 +0200
committerLéo Lam <leo@innovatetechnologi.es>2016-07-29 17:16:22 +0200
commit0d783f0869eaef163a318ab4d79744f592ed1cc5 (patch)
tree0bf286954d9c3d0c97d8b5ea279810cf69828259 /Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
parent2304d769149bfd758d7cf58c4f1735c1c57c8c69 (diff)
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.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp22
1 files changed, 22 insertions, 0 deletions
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
@@ -173,6 +173,28 @@ void ControllerInterface::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<void()> 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
//
// Gets the state of an input reference