Qt/MappingWindow: update devices combo box when hotplugging devices

This commit is contained in:
Michael M 2018-07-05 14:17:47 -07:00
parent b689a195ff
commit ce98a9c71d
2 changed files with 8 additions and 1 deletions

View File

@ -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<void (QComboBox::*)(int)>(&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();

View File

@ -76,6 +76,7 @@ private:
void OnSaveProfilePressed();
void OnDefaultFieldsPressed();
void OnDeviceChanged(int index);
void OnGlobalDevicesChanged();
ControllerEmu::EmulatedController* m_controller = nullptr;