summaryrefslogtreecommitdiff
path: root/src/core/frontend/applets/controller.cpp
diff options
context:
space:
mode:
authorGravatar Morph2020-08-27 05:33:46 -0400
committerGravatar Morph2020-09-04 12:23:25 -0400
commit7299356f370a0981abed519e42343bb84cccb9c1 (patch)
treed5237a3b490d3d753b6a0833afb3bea58e2af81e /src/core/frontend/applets/controller.cpp
parentapplets/controller: Load configuration prior to setting up connections (diff)
downloadyuzu-7299356f370a0981abed519e42343bb84cccb9c1.tar.gz
yuzu-7299356f370a0981abed519e42343bb84cccb9c1.tar.xz
yuzu-7299356f370a0981abed519e42343bb84cccb9c1.zip
applets/controller: Implement fallback applet for the SDL frontend
Implement the fallback applet for the SDL frontend, connecting only the minimum amount of players required.
Diffstat (limited to 'src/core/frontend/applets/controller.cpp')
-rw-r--r--src/core/frontend/applets/controller.cpp35
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
27 27
28 auto& players = Settings::values.players; 28 auto& players = Settings::values.players;
29 29
30 const auto min_supported_players = parameters.enable_single_mode ? 1 : parameters.min_players;
31
32 // Disconnect Handheld first.
33 npad.DisconnectNPadAtIndex(8);
34
30 // Deduce the best configuration based on the input parameters. 35 // Deduce the best configuration based on the input parameters.
31 for (std::size_t index = 0; index < players.size(); ++index) { 36 for (std::size_t index = 0; index < players.size() - 2; ++index) {
32 // First, disconnect all controllers regardless of the value of keep_controllers_connected. 37 // First, disconnect all controllers regardless of the value of keep_controllers_connected.
33 // This makes it easy to connect the desired controllers. 38 // This makes it easy to connect the desired controllers.
34 npad.DisconnectNPadAtIndex(index); 39 npad.DisconnectNPadAtIndex(index);
40
41 // Only connect the minimum number of required players.
42 if (index >= min_supported_players) {
43 continue;
44 }
45
46 // Connect controllers based on the following priority list from highest to lowest priority:
47 // Pro Controller -> Dual Joycons -> Left Joycon -> Right Joycon -> Handheld
48 if (parameters.allow_pro_controller) {
49 npad.AddNewControllerAt(
50 npad.MapSettingsTypeToNPad(Settings::ControllerType::ProController), index);
51 } else if (parameters.allow_dual_joycons) {
52 npad.AddNewControllerAt(
53 npad.MapSettingsTypeToNPad(Settings::ControllerType::DualJoyconDetached), index);
54 } else if (parameters.allow_left_joycon) {
55 npad.AddNewControllerAt(
56 npad.MapSettingsTypeToNPad(Settings::ControllerType::LeftJoycon), index);
57 } else if (parameters.allow_right_joycon) {
58 npad.AddNewControllerAt(
59 npad.MapSettingsTypeToNPad(Settings::ControllerType::RightJoycon), index);
60 } else if (index == 0 && parameters.enable_single_mode && parameters.allow_handheld &&
61 !Settings::values.use_docked_mode) {
62 // We should *never* reach here under any normal circumstances.
63 npad.AddNewControllerAt(npad.MapSettingsTypeToNPad(Settings::ControllerType::Handheld),
64 index);
65 } else {
66 UNREACHABLE_MSG("Unable to add a new controller based on the given parameters!");
67 }
35 } 68 }
36 69
37 callback(); 70 callback();