diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2020-08-27 11:33:46 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2020-09-04 18:23:25 +0200 |
commit | 7299356f370a0981abed519e42343bb84cccb9c1 (patch) | |
tree | d5237a3b490d3d753b6a0833afb3bea58e2af81e /src/core/frontend | |
parent | applets/controller: Load configuration prior to setting up connections (diff) | |
download | yuzu-7299356f370a0981abed519e42343bb84cccb9c1.tar yuzu-7299356f370a0981abed519e42343bb84cccb9c1.tar.gz yuzu-7299356f370a0981abed519e42343bb84cccb9c1.tar.bz2 yuzu-7299356f370a0981abed519e42343bb84cccb9c1.tar.lz yuzu-7299356f370a0981abed519e42343bb84cccb9c1.tar.xz yuzu-7299356f370a0981abed519e42343bb84cccb9c1.tar.zst yuzu-7299356f370a0981abed519e42343bb84cccb9c1.zip |
Diffstat (limited to 'src/core/frontend')
-rw-r--r-- | src/core/frontend/applets/controller.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/core/frontend/applets/controller.cpp b/src/core/frontend/applets/controller.cpp index 0fbc7932c..34eacbb45 100644 --- a/src/core/frontend/applets/controller.cpp +++ b/src/core/frontend/applets/controller.cpp @@ -27,11 +27,44 @@ void DefaultControllerApplet::ReconfigureControllers(std::function<void()> callb auto& players = Settings::values.players; + const auto min_supported_players = parameters.enable_single_mode ? 1 : parameters.min_players; + + // Disconnect Handheld first. + npad.DisconnectNPadAtIndex(8); + // Deduce the best configuration based on the input parameters. - for (std::size_t index = 0; index < players.size(); ++index) { + for (std::size_t index = 0; index < players.size() - 2; ++index) { // First, disconnect all controllers regardless of the value of keep_controllers_connected. // This makes it easy to connect the desired controllers. npad.DisconnectNPadAtIndex(index); + + // Only connect the minimum number of required players. + if (index >= min_supported_players) { + continue; + } + + // Connect controllers based on the following priority list from highest to lowest priority: + // Pro Controller -> Dual Joycons -> Left Joycon -> Right Joycon -> Handheld + if (parameters.allow_pro_controller) { + npad.AddNewControllerAt( + npad.MapSettingsTypeToNPad(Settings::ControllerType::ProController), index); + } else if (parameters.allow_dual_joycons) { + npad.AddNewControllerAt( + npad.MapSettingsTypeToNPad(Settings::ControllerType::DualJoyconDetached), index); + } else if (parameters.allow_left_joycon) { + npad.AddNewControllerAt( + npad.MapSettingsTypeToNPad(Settings::ControllerType::LeftJoycon), index); + } else if (parameters.allow_right_joycon) { + npad.AddNewControllerAt( + npad.MapSettingsTypeToNPad(Settings::ControllerType::RightJoycon), index); + } else if (index == 0 && parameters.enable_single_mode && parameters.allow_handheld && + !Settings::values.use_docked_mode) { + // We should *never* reach here under any normal circumstances. + npad.AddNewControllerAt(npad.MapSettingsTypeToNPad(Settings::ControllerType::Handheld), + index); + } else { + UNREACHABLE_MSG("Unable to add a new controller based on the given parameters!"); + } } callback(); |