diff options
| -rw-r--r-- | src/yuzu/applets/controller.cpp | 29 | ||||
| -rw-r--r-- | src/yuzu/applets/controller.h | 8 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 1 |
3 files changed, 24 insertions, 14 deletions
diff --git a/src/yuzu/applets/controller.cpp b/src/yuzu/applets/controller.cpp index c6fa3e4f6..ee770f315 100644 --- a/src/yuzu/applets/controller.cpp +++ b/src/yuzu/applets/controller.cpp | |||
| @@ -229,6 +229,13 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( | |||
| 229 | connect(ui->buttonBox, &QDialogButtonBox::accepted, this, | 229 | connect(ui->buttonBox, &QDialogButtonBox::accepted, this, |
| 230 | &QtControllerSelectorDialog::ApplyConfiguration); | 230 | &QtControllerSelectorDialog::ApplyConfiguration); |
| 231 | 231 | ||
| 232 | // Enhancement: Check if the parameters have already been met before disconnecting controllers. | ||
| 233 | // If all the parameters are met AND only allows a single player, | ||
| 234 | // stop the constructor here as we do not need to continue. | ||
| 235 | if (CheckIfParametersMet() && parameters.enable_single_mode) { | ||
| 236 | return; | ||
| 237 | } | ||
| 238 | |||
| 232 | // If keep_controllers_connected is false, forcefully disconnect all controllers | 239 | // If keep_controllers_connected is false, forcefully disconnect all controllers |
| 233 | if (!parameters.keep_controllers_connected) { | 240 | if (!parameters.keep_controllers_connected) { |
| 234 | for (auto player : player_groupboxes) { | 241 | for (auto player : player_groupboxes) { |
| @@ -236,13 +243,18 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( | |||
| 236 | } | 243 | } |
| 237 | } | 244 | } |
| 238 | 245 | ||
| 239 | CheckIfParametersMet(); | ||
| 240 | |||
| 241 | resize(0, 0); | 246 | resize(0, 0); |
| 242 | } | 247 | } |
| 243 | 248 | ||
| 244 | QtControllerSelectorDialog::~QtControllerSelectorDialog() = default; | 249 | QtControllerSelectorDialog::~QtControllerSelectorDialog() = default; |
| 245 | 250 | ||
| 251 | int QtControllerSelectorDialog::exec() { | ||
| 252 | if (parameters_met && parameters.enable_single_mode) { | ||
| 253 | return QDialog::Accepted; | ||
| 254 | } | ||
| 255 | return QDialog::exec(); | ||
| 256 | } | ||
| 257 | |||
| 246 | void QtControllerSelectorDialog::ApplyConfiguration() { | 258 | void QtControllerSelectorDialog::ApplyConfiguration() { |
| 247 | // Update the controller state once more, just to be sure they are properly applied. | 259 | // Update the controller state once more, just to be sure they are properly applied. |
| 248 | for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { | 260 | for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { |
| @@ -287,7 +299,7 @@ void QtControllerSelectorDialog::CallConfigureInputDialog() { | |||
| 287 | CheckIfParametersMet(); | 299 | CheckIfParametersMet(); |
| 288 | } | 300 | } |
| 289 | 301 | ||
| 290 | void QtControllerSelectorDialog::CheckIfParametersMet() { | 302 | bool QtControllerSelectorDialog::CheckIfParametersMet() { |
| 291 | // Here, we check and validate the current configuration against all applicable parameters. | 303 | // Here, we check and validate the current configuration against all applicable parameters. |
| 292 | const auto num_connected_players = static_cast<int>( | 304 | const auto num_connected_players = static_cast<int>( |
| 293 | std::count_if(player_groupboxes.begin(), player_groupboxes.end(), | 305 | std::count_if(player_groupboxes.begin(), player_groupboxes.end(), |
| @@ -301,7 +313,7 @@ void QtControllerSelectorDialog::CheckIfParametersMet() { | |||
| 301 | num_connected_players > max_supported_players) { | 313 | num_connected_players > max_supported_players) { |
| 302 | parameters_met = false; | 314 | parameters_met = false; |
| 303 | ui->buttonBox->setEnabled(parameters_met); | 315 | ui->buttonBox->setEnabled(parameters_met); |
| 304 | return; | 316 | return parameters_met; |
| 305 | } | 317 | } |
| 306 | 318 | ||
| 307 | // Next, check against all connected controllers. | 319 | // Next, check against all connected controllers. |
| @@ -326,14 +338,9 @@ void QtControllerSelectorDialog::CheckIfParametersMet() { | |||
| 326 | return true; | 338 | return true; |
| 327 | }(); | 339 | }(); |
| 328 | 340 | ||
| 329 | if (!all_controllers_compatible) { | 341 | parameters_met = all_controllers_compatible; |
| 330 | parameters_met = false; | ||
| 331 | ui->buttonBox->setEnabled(parameters_met); | ||
| 332 | return; | ||
| 333 | } | ||
| 334 | |||
| 335 | parameters_met = true; | ||
| 336 | ui->buttonBox->setEnabled(parameters_met); | 342 | ui->buttonBox->setEnabled(parameters_met); |
| 343 | return parameters_met; | ||
| 337 | } | 344 | } |
| 338 | 345 | ||
| 339 | void QtControllerSelectorDialog::SetSupportedControllers() { | 346 | void QtControllerSelectorDialog::SetSupportedControllers() { |
diff --git a/src/yuzu/applets/controller.h b/src/yuzu/applets/controller.h index 729ecc831..8fefecf05 100644 --- a/src/yuzu/applets/controller.h +++ b/src/yuzu/applets/controller.h | |||
| @@ -33,6 +33,8 @@ public: | |||
| 33 | InputCommon::InputSubsystem* input_subsystem_); | 33 | InputCommon::InputSubsystem* input_subsystem_); |
| 34 | ~QtControllerSelectorDialog() override; | 34 | ~QtControllerSelectorDialog() override; |
| 35 | 35 | ||
| 36 | int exec() override; | ||
| 37 | |||
| 36 | private: | 38 | private: |
| 37 | // Applies the current configuration. | 39 | // Applies the current configuration. |
| 38 | void ApplyConfiguration(); | 40 | void ApplyConfiguration(); |
| @@ -43,9 +45,9 @@ private: | |||
| 43 | // Initializes the "Configure Input" Dialog. | 45 | // Initializes the "Configure Input" Dialog. |
| 44 | void CallConfigureInputDialog(); | 46 | void CallConfigureInputDialog(); |
| 45 | 47 | ||
| 46 | // Checks the current configuration against the given parameters and | 48 | // Checks the current configuration against the given parameters. |
| 47 | // sets the value of parameters_met. | 49 | // This sets and returns the value of parameters_met. |
| 48 | void CheckIfParametersMet(); | 50 | bool CheckIfParametersMet(); |
| 49 | 51 | ||
| 50 | // Sets the controller icons for "Supported Controller Types". | 52 | // Sets the controller icons for "Supported Controller Types". |
| 51 | void SetSupportedControllers(); | 53 | void SetSupportedControllers(); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 4ff7fd92f..5f9f416ea 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -288,6 +288,7 @@ GMainWindow::~GMainWindow() { | |||
| 288 | void GMainWindow::ControllerSelectorReconfigureControllers( | 288 | void GMainWindow::ControllerSelectorReconfigureControllers( |
| 289 | const Core::Frontend::ControllerParameters& parameters) { | 289 | const Core::Frontend::ControllerParameters& parameters) { |
| 290 | QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get()); | 290 | QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get()); |
| 291 | |||
| 291 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | | 292 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | |
| 292 | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); | 293 | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); |
| 293 | dialog.setWindowModality(Qt::WindowModal); | 294 | dialog.setWindowModality(Qt::WindowModal); |