Merge pull request #7219 from ligfx/mappingwindow_hotplug

Qt/MappingWindow: update devices combo box when hotplugging devices
This commit is contained in:
spycrab 2018-07-11 10:58:26 +02:00 committed by GitHub
commit c7ff141606
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 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;

View File

@ -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());
}

View File

@ -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;