mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-13 15:59:23 +01:00
ControllerInterface: HotplugCallbacks -> DevicesChangedCallbacks
This commit is contained in:
parent
7355b5f70d
commit
1ed7532af8
@ -37,7 +37,7 @@ void Initialize()
|
||||
s_config.CreateController<GCKeyboard>(i);
|
||||
}
|
||||
|
||||
g_controller_interface.RegisterHotplugCallback(LoadConfig);
|
||||
g_controller_interface.RegisterDevicesChangedCallback(LoadConfig);
|
||||
|
||||
// Load the saved controller config
|
||||
s_config.LoadConfig(true);
|
||||
|
@ -34,7 +34,7 @@ void Initialize()
|
||||
s_config.CreateController<GCPad>(i);
|
||||
}
|
||||
|
||||
g_controller_interface.RegisterHotplugCallback(LoadConfig);
|
||||
g_controller_interface.RegisterDevicesChangedCallback(LoadConfig);
|
||||
|
||||
// Load the saved controller config
|
||||
s_config.LoadConfig(true);
|
||||
|
@ -80,7 +80,7 @@ void Initialize(InitializeMode init_mode)
|
||||
s_config.CreateController<WiimoteEmu::Wiimote>(i);
|
||||
}
|
||||
|
||||
g_controller_interface.RegisterHotplugCallback(LoadConfig);
|
||||
g_controller_interface.RegisterDevicesChangedCallback(LoadConfig);
|
||||
|
||||
LoadConfig();
|
||||
|
||||
|
@ -213,7 +213,7 @@ void Initialize()
|
||||
if (s_config.ControllersNeedToBeCreated())
|
||||
s_config.CreateController<HotkeyManager>();
|
||||
|
||||
g_controller_interface.RegisterHotplugCallback(LoadConfig);
|
||||
g_controller_interface.RegisterDevicesChangedCallback(LoadConfig);
|
||||
|
||||
// load the saved controller config
|
||||
s_config.LoadConfig(true);
|
||||
|
@ -188,7 +188,7 @@ void ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device
|
||||
NOTICE_LOG(SERIALINTERFACE, "Added device: %s", device->GetQualifiedName().c_str());
|
||||
m_devices.emplace_back(std::move(device));
|
||||
}
|
||||
InvokeHotplugCallbacks();
|
||||
InvokeDevicesChangedCallbacks();
|
||||
}
|
||||
|
||||
void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::Device*)> callback)
|
||||
@ -205,7 +205,7 @@ void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::De
|
||||
});
|
||||
m_devices.erase(it, m_devices.end());
|
||||
}
|
||||
InvokeHotplugCallbacks();
|
||||
InvokeDevicesChangedCallbacks();
|
||||
}
|
||||
|
||||
//
|
||||
@ -225,23 +225,23 @@ void ControllerInterface::UpdateInput()
|
||||
}
|
||||
|
||||
//
|
||||
// RegisterHotplugCallback
|
||||
// RegisterDevicesChangedCallback
|
||||
//
|
||||
// Register a callback to be called from the input backends' hotplug thread
|
||||
// when there is a new device
|
||||
// Register a callback to be called when a device is added or removed (as from the input backends'
|
||||
// hotplug thread), or when devices are refreshed
|
||||
//
|
||||
void ControllerInterface::RegisterHotplugCallback(std::function<void()> callback)
|
||||
void ControllerInterface::RegisterDevicesChangedCallback(std::function<void()> callback)
|
||||
{
|
||||
m_hotplug_callbacks.emplace_back(std::move(callback));
|
||||
m_devices_changed_callbacks.emplace_back(std::move(callback));
|
||||
}
|
||||
|
||||
//
|
||||
// InvokeHotplugCallbacks
|
||||
// InvokeDevicesChangedCallbacks
|
||||
//
|
||||
// Invoke all callbacks that were registered
|
||||
//
|
||||
void ControllerInterface::InvokeHotplugCallbacks() const
|
||||
void ControllerInterface::InvokeDevicesChangedCallbacks() const
|
||||
{
|
||||
for (const auto& callback : m_hotplug_callbacks)
|
||||
for (const auto& callback : m_devices_changed_callbacks)
|
||||
callback();
|
||||
}
|
||||
|
@ -53,12 +53,11 @@ public:
|
||||
bool IsInit() const { return m_is_init; }
|
||||
void UpdateInput();
|
||||
|
||||
void RegisterHotplugCallback(std::function<void(void)> callback);
|
||||
void RegisterDevicesChangedCallback(std::function<void(void)> callback);
|
||||
void InvokeDevicesChangedCallbacks() const;
|
||||
|
||||
private:
|
||||
void InvokeHotplugCallbacks() const;
|
||||
|
||||
std::vector<std::function<void()>> m_hotplug_callbacks;
|
||||
std::vector<std::function<void()>> m_devices_changed_callbacks;
|
||||
bool m_is_init;
|
||||
void* m_hwnd;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user