mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-11 16:49:28 +02:00
GCPadWiiUConfigDialog: Update the adapter state dynamically
Update the GC adapter config GUI if the adapter is plugged or unplugged.
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
||||
|
||||
#include "InputCommon/GCAdapter.h"
|
||||
|
||||
@ -24,10 +25,43 @@ GCPadWiiUConfigDialog::GCPadWiiUConfigDialog(int port, QWidget* parent)
|
||||
ConnectWidgets();
|
||||
}
|
||||
|
||||
GCPadWiiUConfigDialog::~GCPadWiiUConfigDialog()
|
||||
{
|
||||
GCAdapter::SetAdapterCallback(nullptr);
|
||||
}
|
||||
|
||||
void GCPadWiiUConfigDialog::CreateLayout()
|
||||
{
|
||||
setWindowTitle(tr("GameCube Adapter for Wii U at Port %1").arg(m_port + 1));
|
||||
|
||||
m_layout = new QVBoxLayout();
|
||||
m_status_label = new QLabel();
|
||||
m_rumble = new QCheckBox(tr("Enable Rumble"));
|
||||
m_simulate_bongos = new QCheckBox(tr("Simulate DK Bongos"));
|
||||
m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
|
||||
UpdateAdapterStatus();
|
||||
|
||||
auto callback = [this] { QueueOnObject(this, &GCPadWiiUConfigDialog::UpdateAdapterStatus); };
|
||||
GCAdapter::SetAdapterCallback(callback);
|
||||
|
||||
m_layout->addWidget(m_status_label);
|
||||
m_layout->addWidget(m_rumble);
|
||||
m_layout->addWidget(m_simulate_bongos);
|
||||
m_layout->addWidget(m_button_box);
|
||||
|
||||
setLayout(m_layout);
|
||||
}
|
||||
|
||||
void GCPadWiiUConfigDialog::ConnectWidgets()
|
||||
{
|
||||
connect(m_rumble, &QCheckBox::toggled, this, &GCPadWiiUConfigDialog::SaveSettings);
|
||||
connect(m_simulate_bongos, &QCheckBox::toggled, this, &GCPadWiiUConfigDialog::SaveSettings);
|
||||
connect(m_button_box, &QDialogButtonBox::accepted, this, &GCPadWiiUConfigDialog::accept);
|
||||
}
|
||||
|
||||
void GCPadWiiUConfigDialog::UpdateAdapterStatus()
|
||||
{
|
||||
const char* error_message = nullptr;
|
||||
const bool detected = GCAdapter::IsDetected(&error_message);
|
||||
QString status_text;
|
||||
@ -45,31 +79,10 @@ void GCPadWiiUConfigDialog::CreateLayout()
|
||||
status_text = tr("No Adapter Detected");
|
||||
}
|
||||
|
||||
m_layout = new QVBoxLayout();
|
||||
m_status_label = new QLabel(status_text);
|
||||
m_rumble = new QCheckBox(tr("Enable Rumble"));
|
||||
m_simulate_bongos = new QCheckBox(tr("Simulate DK Bongos"));
|
||||
m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
m_status_label->setText(status_text);
|
||||
|
||||
m_layout->addWidget(m_status_label);
|
||||
m_layout->addWidget(m_rumble);
|
||||
m_layout->addWidget(m_simulate_bongos);
|
||||
m_layout->addWidget(m_button_box);
|
||||
|
||||
if (!detected)
|
||||
{
|
||||
m_rumble->setEnabled(false);
|
||||
m_simulate_bongos->setEnabled(false);
|
||||
}
|
||||
|
||||
setLayout(m_layout);
|
||||
}
|
||||
|
||||
void GCPadWiiUConfigDialog::ConnectWidgets()
|
||||
{
|
||||
connect(m_rumble, &QCheckBox::toggled, this, &GCPadWiiUConfigDialog::SaveSettings);
|
||||
connect(m_simulate_bongos, &QCheckBox::toggled, this, &GCPadWiiUConfigDialog::SaveSettings);
|
||||
connect(m_button_box, &QDialogButtonBox::accepted, this, &GCPadWiiUConfigDialog::accept);
|
||||
m_rumble->setEnabled(detected);
|
||||
m_simulate_bongos->setEnabled(detected);
|
||||
}
|
||||
|
||||
void GCPadWiiUConfigDialog::LoadSettings()
|
||||
|
Reference in New Issue
Block a user