diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp index 48e5a5f0f2..1b6f629c1c 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp @@ -136,6 +136,8 @@ void MappingWindow::CreateMainLayout() void MappingWindow::ConnectWidgets() { + connect(&Settings::Instance(), &Settings::DevicesChanged, this, + &MappingWindow::OnGlobalDevicesChanged); connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(m_devices_refresh, &QPushButton::clicked, this, &MappingWindow::RefreshDevices); connect(m_devices_combo, static_cast(&QComboBox::currentIndexChanged), @@ -242,11 +244,15 @@ bool MappingWindow::IsMappingAllDevices() const } void MappingWindow::RefreshDevices() +{ + Core::RunAsCPUThread([&] { g_controller_interface.RefreshDevices(); }); +} + +void MappingWindow::OnGlobalDevicesChanged() { m_devices_combo->clear(); Core::RunAsCPUThread([&] { - g_controller_interface.RefreshDevices(); m_controller->UpdateReferences(g_controller_interface); const auto default_device = m_controller->GetDefaultDevice().ToString(); diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h index c0a9f47af2..0432286e01 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h @@ -76,6 +76,7 @@ private: void OnSaveProfilePressed(); void OnDefaultFieldsPressed(); void OnDeviceChanged(int index); + void OnGlobalDevicesChanged(); ControllerEmu::EmulatedController* m_controller = nullptr; diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index 7db5017a32..c1dce6b29d 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -25,6 +25,7 @@ #include "DolphinQt/GameList/GameListModel.h" #include "DolphinQt/QtUtils/QueueOnObject.h" +#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/InputConfig.h" Settings::Settings() @@ -37,6 +38,9 @@ Settings::Settings() Config::AddConfigChangedCallback( [this] { QueueOnObject(this, [this] { emit ConfigChanged(); }); }); + g_controller_interface.RegisterDevicesChangedCallback( + [this] { QueueOnObject(this, [this] { emit DevicesChanged(); }); }); + SetCurrentUserStyle(GetCurrentUserStyle()); } diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h index 8636d21bdb..68303530fa 100644 --- a/Source/Core/DolphinQt/Settings.h +++ b/Source/Core/DolphinQt/Settings.h @@ -164,6 +164,7 @@ signals: void DebugFontChanged(QFont font); void AutoUpdateTrackChanged(const QString& mode); void AnalyticsToggled(bool enabled); + void DevicesChanged(); private: bool m_batch = false;