DolphinQt: Add "Poll Rate" display to GCAdapter config window. The window now refreshes every 500ms. SetAdapterCallback is no longer used.
This commit is contained in:
@@ -6,10 +6,10 @@
|
|||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QTimer>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
|
||||||
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
||||||
|
|
||||||
#include "InputCommon/GCAdapter.h"
|
#include "InputCommon/GCAdapter.h"
|
||||||
@@ -23,27 +23,25 @@ GCPadWiiUConfigDialog::GCPadWiiUConfigDialog(int port, QWidget* parent)
|
|||||||
ConnectWidgets();
|
ConnectWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
GCPadWiiUConfigDialog::~GCPadWiiUConfigDialog()
|
|
||||||
{
|
|
||||||
GCAdapter::SetAdapterCallback(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GCPadWiiUConfigDialog::CreateLayout()
|
void GCPadWiiUConfigDialog::CreateLayout()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("GameCube Controller Adapter at Port %1").arg(m_port + 1));
|
setWindowTitle(tr("GameCube Controller Adapter at Port %1").arg(m_port + 1));
|
||||||
|
|
||||||
m_layout = new QVBoxLayout();
|
m_layout = new QVBoxLayout();
|
||||||
m_status_label = new QLabel();
|
m_status_label = new QLabel();
|
||||||
|
m_poll_rate_label = new QLabel;
|
||||||
m_rumble = new QCheckBox(tr("Enable Rumble"));
|
m_rumble = new QCheckBox(tr("Enable Rumble"));
|
||||||
m_simulate_bongos = new QCheckBox(tr("Simulate DK Bongos"));
|
m_simulate_bongos = new QCheckBox(tr("Simulate DK Bongos"));
|
||||||
m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||||
|
|
||||||
UpdateAdapterStatus();
|
UpdateAdapterStatus();
|
||||||
|
|
||||||
auto callback = [this] { QueueOnObject(this, &GCPadWiiUConfigDialog::UpdateAdapterStatus); };
|
auto* const timer = new QTimer{this};
|
||||||
GCAdapter::SetAdapterCallback(callback);
|
connect(timer, &QTimer::timeout, this, &GCPadWiiUConfigDialog::UpdateAdapterStatus);
|
||||||
|
timer->start(std::chrono::milliseconds{500});
|
||||||
|
|
||||||
m_layout->addWidget(m_status_label);
|
m_layout->addWidget(m_status_label);
|
||||||
|
m_layout->addWidget(m_poll_rate_label);
|
||||||
m_layout->addWidget(m_rumble);
|
m_layout->addWidget(m_rumble);
|
||||||
m_layout->addWidget(m_simulate_bongos);
|
m_layout->addWidget(m_simulate_bongos);
|
||||||
m_layout->addWidget(m_button_box);
|
m_layout->addWidget(m_button_box);
|
||||||
@@ -79,6 +77,12 @@ void GCPadWiiUConfigDialog::UpdateAdapterStatus()
|
|||||||
|
|
||||||
m_status_label->setText(status_text);
|
m_status_label->setText(status_text);
|
||||||
|
|
||||||
|
const auto poll_rate = GCAdapter::GetCurrentPollRate();
|
||||||
|
if (poll_rate != 0)
|
||||||
|
m_poll_rate_label->setText(tr("Poll Rate: %1 Hz").arg(poll_rate, 0, 'f', 2));
|
||||||
|
else
|
||||||
|
m_poll_rate_label->clear();
|
||||||
|
|
||||||
m_rumble->setEnabled(detected);
|
m_rumble->setEnabled(detected);
|
||||||
m_simulate_bongos->setEnabled(detected);
|
m_simulate_bongos->setEnabled(detected);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class GCPadWiiUConfigDialog final : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit GCPadWiiUConfigDialog(int port, QWidget* parent = nullptr);
|
explicit GCPadWiiUConfigDialog(int port, QWidget* parent = nullptr);
|
||||||
~GCPadWiiUConfigDialog() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
@@ -31,6 +30,7 @@ private:
|
|||||||
|
|
||||||
QVBoxLayout* m_layout;
|
QVBoxLayout* m_layout;
|
||||||
QLabel* m_status_label;
|
QLabel* m_status_label;
|
||||||
|
QLabel* m_poll_rate_label;
|
||||||
QDialogButtonBox* m_button_box;
|
QDialogButtonBox* m_button_box;
|
||||||
|
|
||||||
// Checkboxes
|
// Checkboxes
|
||||||
|
|||||||
Reference in New Issue
Block a user