diff options
| author | 2022-02-05 02:31:55 -0500 | |
|---|---|---|
| committer | 2022-02-05 02:31:55 -0500 | |
| commit | 928380ebf991f55a763e92176b218f9ecacb94df (patch) | |
| tree | f493a50a570792a5d281493179913847271aeacc /src | |
| parent | Merge pull request #7848 from Morph1984/unused-core-include (diff) | |
| download | yuzu-928380ebf991f55a763e92176b218f9ecacb94df.tar.gz yuzu-928380ebf991f55a763e92176b218f9ecacb94df.tar.xz yuzu-928380ebf991f55a763e92176b218f9ecacb94df.zip | |
config: Support motion inputs
Motion inputs were not being read in by the config when yuzu-cmd boots
up. This adds support for those.
While we're at it, make a reference to the current player controls to
improve readability. Also updates the if statements in the Analog and
Button loops with curly braces to keep the style consistent.
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 8e9c7d211..ff616da70 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -66,6 +66,11 @@ static const std::array<int, Settings::NativeButton::NumButtons> default_buttons | |||
| 66 | SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_B, | 66 | SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_B, |
| 67 | }; | 67 | }; |
| 68 | 68 | ||
| 69 | static const std::array<int, Settings::NativeMotion::NumMotions> default_motions = { | ||
| 70 | SDL_SCANCODE_7, | ||
| 71 | SDL_SCANCODE_8, | ||
| 72 | }; | ||
| 73 | |||
| 69 | static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs{{ | 74 | static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs{{ |
| 70 | { | 75 | { |
| 71 | SDL_SCANCODE_UP, | 76 | SDL_SCANCODE_UP, |
| @@ -102,27 +107,42 @@ void Config::ReadSetting(const std::string& group, Settings::BasicSetting<Type>& | |||
| 102 | void Config::ReadValues() { | 107 | void Config::ReadValues() { |
| 103 | // Controls | 108 | // Controls |
| 104 | for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { | 109 | for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { |
| 110 | auto& player = Settings::values.players.GetValue()[p]; | ||
| 111 | |||
| 105 | const auto group = fmt::format("ControlsP{}", p); | 112 | const auto group = fmt::format("ControlsP{}", p); |
| 106 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | 113 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 107 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); | 114 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); |
| 108 | Settings::values.players.GetValue()[p].buttons[i] = | 115 | player.buttons[i] = |
| 109 | sdl2_config->Get(group, Settings::NativeButton::mapping[i], default_param); | 116 | sdl2_config->Get(group, Settings::NativeButton::mapping[i], default_param); |
| 110 | if (Settings::values.players.GetValue()[p].buttons[i].empty()) | 117 | if (player.buttons[i].empty()) { |
| 111 | Settings::values.players.GetValue()[p].buttons[i] = default_param; | 118 | player.buttons[i] = default_param; |
| 119 | } | ||
| 112 | } | 120 | } |
| 113 | 121 | ||
| 114 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { | 122 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { |
| 115 | std::string default_param = InputCommon::GenerateAnalogParamFromKeys( | 123 | std::string default_param = InputCommon::GenerateAnalogParamFromKeys( |
| 116 | default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], | 124 | default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], |
| 117 | default_analogs[i][3], default_analogs[i][4], 0.5f); | 125 | default_analogs[i][3], default_analogs[i][4], 0.5f); |
| 118 | Settings::values.players.GetValue()[p].analogs[i] = | 126 | player.analogs[i] = |
| 119 | sdl2_config->Get(group, Settings::NativeAnalog::mapping[i], default_param); | 127 | sdl2_config->Get(group, Settings::NativeAnalog::mapping[i], default_param); |
| 120 | if (Settings::values.players.GetValue()[p].analogs[i].empty()) | 128 | if (player.analogs[i].empty()) { |
| 121 | Settings::values.players.GetValue()[p].analogs[i] = default_param; | 129 | player.analogs[i] = default_param; |
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) { | ||
| 134 | const std::string default_param = | ||
| 135 | InputCommon::GenerateKeyboardParam(default_motions[i]); | ||
| 136 | auto& player_motions = player.motions[i]; | ||
| 137 | |||
| 138 | player_motions = | ||
| 139 | sdl2_config->Get(group, Settings::NativeMotion::mapping[i], default_param); | ||
| 140 | if (player_motions.empty()) { | ||
| 141 | player_motions = default_param; | ||
| 142 | } | ||
| 122 | } | 143 | } |
| 123 | 144 | ||
| 124 | Settings::values.players.GetValue()[p].connected = | 145 | player.connected = sdl2_config->GetBoolean(group, "connected", false); |
| 125 | sdl2_config->GetBoolean(group, "connected", false); | ||
| 126 | } | 146 | } |
| 127 | 147 | ||
| 128 | ReadSetting("ControlsGeneral", Settings::values.mouse_enabled); | 148 | ReadSetting("ControlsGeneral", Settings::values.mouse_enabled); |