mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-26 06:18:32 +00:00
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.
This commit is contained in:
parent
2304d76914
commit
0d783f0869
6 changed files with 30 additions and 0 deletions
|
@ -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<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
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue