Qt: Fix vibration motor binding not showing some devices

This commit is contained in:
Stenzek 2025-03-06 17:03:29 +10:00
parent c3ce0eece2
commit 160f1ea8a0
No known key found for this signature in database
2 changed files with 12 additions and 10 deletions

View File

@ -2218,7 +2218,7 @@ void InputDeviceListModel::enumerateDevices()
}
QMetaObject::invokeMethod(this, "resetLists", Qt::QueuedConnection, Q_ARG(const DeviceList&, new_devices),
Q_ARG(const QStringList&, m_vibration_motors));
Q_ARG(const QStringList&, new_motors));
}
void InputDeviceListModel::resetLists(const DeviceList& devices, const QStringList& motors)

View File

@ -2167,30 +2167,32 @@ void InputManager::UpdateInputSourceState(const SettingsInterface& si, std::uniq
InputSourceType type, std::unique_ptr<InputSource> (*factory_function)())
{
const bool enabled = IsInputSourceEnabled(si, type);
std::unique_ptr<InputSource>& source = s_input_sources[static_cast<u32>(type)];
if (enabled)
{
if (s_input_sources[static_cast<u32>(type)])
if (source)
{
s_input_sources[static_cast<u32>(type)]->UpdateSettings(si, settings_lock);
source->UpdateSettings(si, settings_lock);
}
else
{
std::unique_ptr<InputSource> source(factory_function());
if (!source->Initialize(si, settings_lock))
source = factory_function();
if (!source || !source->Initialize(si, settings_lock))
{
ERROR_LOG("Source '{}' failed to initialize.", InputSourceToString(type));
if (source)
source->Shutdown();
source.reset();
return;
}
s_input_sources[static_cast<u32>(type)] = std::move(source);
}
}
else
{
if (s_input_sources[static_cast<u32>(type)])
if (source)
{
s_input_sources[static_cast<u32>(type)]->Shutdown();
s_input_sources[static_cast<u32>(type)].reset();
source->Shutdown();
source.reset();
}
}
}