Permalink
Browse files

Merge pull request #7219 from ligfx/mappingwindow_hotplug

 Qt/MappingWindow: update devices combo box when hotplugging devices
  • Loading branch information...
spycrab committed Jul 11, 2018
2 parents ea99cdd + ce98a9c commit c7ff1416064a303f835f544f70586f449371fd32
@@ -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();
@@ -76,6 +76,7 @@ class MappingWindow final : public QDialog
void OnSaveProfilePressed();
void OnDefaultFieldsPressed();
void OnDeviceChanged(int index);
void OnGlobalDevicesChanged();
ControllerEmu::EmulatedController* m_controller = nullptr;
@@ -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());
}
@@ -164,6 +164,7 @@ class Settings final : public QObject
void DebugFontChanged(QFont font);
void AutoUpdateTrackChanged(const QString& mode);
void AnalyticsToggled(bool enabled);
void DevicesChanged();
private:
bool m_batch = false;

0 comments on commit c7ff141

Please sign in to comment.