applets/controller: Load configuration prior to setting up connections
This avoids unintentionally changing the states of elements while loading them in.
This commit is contained in:
parent
aeec0f8a38
commit
72b2f5d34f
|
@ -171,7 +171,18 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
|
||||||
ui->checkboxPlayer7Connected, ui->checkboxPlayer8Connected,
|
ui->checkboxPlayer7Connected, ui->checkboxPlayer8Connected,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Setup/load everything prior to setting up connections.
|
||||||
|
// This avoids unintentionally changing the states of elements while loading them in.
|
||||||
|
SetSupportedControllers();
|
||||||
|
DisableUnsupportedPlayers();
|
||||||
|
LoadConfiguration();
|
||||||
|
|
||||||
for (std::size_t i = 0; i < NUM_PLAYERS; ++i) {
|
for (std::size_t i = 0; i < NUM_PLAYERS; ++i) {
|
||||||
|
SetExplainText(i);
|
||||||
|
UpdateControllerIcon(i);
|
||||||
|
UpdateLEDPattern(i);
|
||||||
|
UpdateBorderColor(i);
|
||||||
|
|
||||||
connect(player_groupboxes[i], &QGroupBox::toggled, [this, i](bool checked) {
|
connect(player_groupboxes[i], &QGroupBox::toggled, [this, i](bool checked) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
for (std::size_t index = 0; index <= i; ++index) {
|
for (std::size_t index = 0; index <= i; ++index) {
|
||||||
|
@ -208,8 +219,6 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
|
||||||
Settings::ControllerType::Handheld);
|
Settings::ControllerType::Handheld);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SetExplainText(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(ui->inputConfigButton, &QPushButton::clicked, this,
|
connect(ui->inputConfigButton, &QPushButton::clicked, this,
|
||||||
|
@ -218,10 +227,6 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this,
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this,
|
||||||
&QtControllerSelectorDialog::ApplyConfiguration);
|
&QtControllerSelectorDialog::ApplyConfiguration);
|
||||||
|
|
||||||
SetSupportedControllers();
|
|
||||||
DisableUnsupportedPlayers();
|
|
||||||
LoadConfiguration();
|
|
||||||
|
|
||||||
// If keep_controllers_connected is false, forcefully disconnect all controllers
|
// If keep_controllers_connected is false, forcefully disconnect all controllers
|
||||||
if (!parameters.keep_controllers_connected) {
|
if (!parameters.keep_controllers_connected) {
|
||||||
for (auto player : player_groupboxes) {
|
for (auto player : player_groupboxes) {
|
||||||
|
@ -249,6 +254,21 @@ void QtControllerSelectorDialog::ApplyConfiguration() {
|
||||||
Settings::values.vibration_enabled = ui->vibrationGroup->isChecked();
|
Settings::values.vibration_enabled = ui->vibrationGroup->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtControllerSelectorDialog::LoadConfiguration() {
|
||||||
|
for (std::size_t index = 0; index < NUM_PLAYERS; ++index) {
|
||||||
|
const auto connected = Settings::values.players[index].connected ||
|
||||||
|
(index == 0 && Settings::values.players[8].connected);
|
||||||
|
player_groupboxes[index]->setChecked(connected);
|
||||||
|
connected_controller_checkboxes[index]->setChecked(connected);
|
||||||
|
emulated_controllers[index]->setCurrentIndex(
|
||||||
|
GetIndexFromControllerType(Settings::values.players[index].controller_type));
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateDockedState(Settings::values.players[8].connected);
|
||||||
|
|
||||||
|
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void QtControllerSelectorDialog::CallConfigureInputDialog() {
|
void QtControllerSelectorDialog::CallConfigureInputDialog() {
|
||||||
const auto max_supported_players = parameters.enable_single_mode ? 1 : parameters.max_players;
|
const auto max_supported_players = parameters.enable_single_mode ? 1 : parameters.max_players;
|
||||||
|
|
||||||
|
@ -557,20 +577,6 @@ void QtControllerSelectorDialog::DisableUnsupportedPlayers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtControllerSelectorDialog::LoadConfiguration() {
|
|
||||||
for (std::size_t index = 0; index < NUM_PLAYERS; ++index) {
|
|
||||||
const auto connected = Settings::values.players[index].connected ||
|
|
||||||
(index == 0 && Settings::values.players[8].connected);
|
|
||||||
player_groupboxes[index]->setChecked(connected);
|
|
||||||
emulated_controllers[index]->setCurrentIndex(
|
|
||||||
GetIndexFromControllerType(Settings::values.players[index].controller_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateDockedState(Settings::values.players[8].connected);
|
|
||||||
|
|
||||||
ui->vibrationGroup->setChecked(Settings::values.vibration_enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
QtControllerSelector::QtControllerSelector(GMainWindow& parent) {
|
QtControllerSelector::QtControllerSelector(GMainWindow& parent) {
|
||||||
connect(this, &QtControllerSelector::MainWindowReconfigureControllers, &parent,
|
connect(this, &QtControllerSelector::MainWindowReconfigureControllers, &parent,
|
||||||
&GMainWindow::ControllerSelectorReconfigureControllers, Qt::QueuedConnection);
|
&GMainWindow::ControllerSelectorReconfigureControllers, Qt::QueuedConnection);
|
||||||
|
|
|
@ -37,6 +37,9 @@ private:
|
||||||
// Applies the current configuration.
|
// Applies the current configuration.
|
||||||
void ApplyConfiguration();
|
void ApplyConfiguration();
|
||||||
|
|
||||||
|
// Loads the current input configuration into the frontend applet.
|
||||||
|
void LoadConfiguration();
|
||||||
|
|
||||||
// Initializes the "Configure Input" Dialog.
|
// Initializes the "Configure Input" Dialog.
|
||||||
void CallConfigureInputDialog();
|
void CallConfigureInputDialog();
|
||||||
|
|
||||||
|
@ -68,9 +71,6 @@ private:
|
||||||
// Disables and disconnects unsupported players based on the given parameters.
|
// Disables and disconnects unsupported players based on the given parameters.
|
||||||
void DisableUnsupportedPlayers();
|
void DisableUnsupportedPlayers();
|
||||||
|
|
||||||
// Loads the current input configuration into the frontend applet.
|
|
||||||
void LoadConfiguration();
|
|
||||||
|
|
||||||
std::unique_ptr<Ui::QtControllerSelectorDialog> ui;
|
std::unique_ptr<Ui::QtControllerSelectorDialog> ui;
|
||||||
|
|
||||||
// Parameters sent in from the backend HLE applet.
|
// Parameters sent in from the backend HLE applet.
|
||||||
|
|
Loading…
Reference in New Issue