diff options
| author | 2023-02-26 09:20:02 -0500 | |
|---|---|---|
| committer | 2023-02-26 09:20:02 -0500 | |
| commit | c50a930bbb12184e9dee70000cec5588f2f56b0a (patch) | |
| tree | 242cb7de7a65be1337f61c4bcdd8dfca79b0ecfa /src/core/hid/emulated_controller.cpp | |
| parent | Merge pull request #9848 from german77/metroid_motion (diff) | |
| parent | yuzu: config: Remove player 8 and 9 from config file (diff) | |
| download | yuzu-c50a930bbb12184e9dee70000cec5588f2f56b0a.tar.gz yuzu-c50a930bbb12184e9dee70000cec5588f2f56b0a.tar.xz yuzu-c50a930bbb12184e9dee70000cec5588f2f56b0a.zip | |
Merge pull request #9824 from german77/burning-profiles
yuzu: config: Remove player 8 and 9 from config file
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 78 |
1 files changed, 66 insertions, 12 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index a29c9a6f8..9f0ceca49 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -82,7 +82,12 @@ Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleInde | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | void EmulatedController::ReloadFromSettings() { | 84 | void EmulatedController::ReloadFromSettings() { |
| 85 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 85 | if (npad_id_type == NpadIdType::Other) { |
| 86 | ReloadDebugPadFromSettings(); | ||
| 87 | return; | ||
| 88 | } | ||
| 89 | |||
| 90 | const auto player_index = NpadIdTypeToConfigIndex(npad_id_type); | ||
| 86 | const auto& player = Settings::values.players.GetValue()[player_index]; | 91 | const auto& player = Settings::values.players.GetValue()[player_index]; |
| 87 | 92 | ||
| 88 | for (std::size_t index = 0; index < player.buttons.size(); ++index) { | 93 | for (std::size_t index = 0; index < player.buttons.size(); ++index) { |
| @@ -111,13 +116,21 @@ void EmulatedController::ReloadFromSettings() { | |||
| 111 | 116 | ||
| 112 | ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs); | 117 | ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs); |
| 113 | 118 | ||
| 114 | // Other or debug controller should always be a pro controller | 119 | SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); |
| 115 | if (npad_id_type != NpadIdType::Other) { | 120 | original_npad_type = npad_type; |
| 116 | SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); | 121 | |
| 117 | original_npad_type = npad_type; | 122 | // Player 1 shares config with handheld. Disable controller when handheld is selected |
| 118 | } else { | 123 | if (npad_id_type == NpadIdType::Player1 && npad_type == NpadStyleIndex::Handheld) { |
| 119 | SetNpadStyleIndex(NpadStyleIndex::ProController); | 124 | Disconnect(); |
| 120 | original_npad_type = npad_type; | 125 | ReloadInput(); |
| 126 | return; | ||
| 127 | } | ||
| 128 | |||
| 129 | // Handheld shares config with player 1. Disable controller when handheld isn't selected | ||
| 130 | if (npad_id_type == NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) { | ||
| 131 | Disconnect(); | ||
| 132 | ReloadInput(); | ||
| 133 | return; | ||
| 121 | } | 134 | } |
| 122 | 135 | ||
| 123 | Disconnect(); | 136 | Disconnect(); |
| @@ -128,6 +141,33 @@ void EmulatedController::ReloadFromSettings() { | |||
| 128 | ReloadInput(); | 141 | ReloadInput(); |
| 129 | } | 142 | } |
| 130 | 143 | ||
| 144 | void EmulatedController::ReloadDebugPadFromSettings() { | ||
| 145 | for (std::size_t index = 0; index < Settings::values.debug_pad_buttons.size(); ++index) { | ||
| 146 | button_params[index] = Common::ParamPackage(Settings::values.debug_pad_buttons[index]); | ||
| 147 | } | ||
| 148 | for (std::size_t index = 0; index < Settings::values.debug_pad_analogs.size(); ++index) { | ||
| 149 | stick_params[index] = Common::ParamPackage(Settings::values.debug_pad_analogs[index]); | ||
| 150 | } | ||
| 151 | for (std::size_t index = 0; index < motion_params.size(); ++index) { | ||
| 152 | motion_params[index] = {}; | ||
| 153 | } | ||
| 154 | |||
| 155 | controller.color_values = {}; | ||
| 156 | controller.colors_state.fullkey = {}; | ||
| 157 | controller.colors_state.left = {}; | ||
| 158 | controller.colors_state.right = {}; | ||
| 159 | ring_params[0] = {}; | ||
| 160 | SetNpadStyleIndex(NpadStyleIndex::ProController); | ||
| 161 | original_npad_type = npad_type; | ||
| 162 | |||
| 163 | Disconnect(); | ||
| 164 | if (Settings::values.debug_pad_enabled) { | ||
| 165 | Connect(); | ||
| 166 | } | ||
| 167 | |||
| 168 | ReloadInput(); | ||
| 169 | } | ||
| 170 | |||
| 131 | void EmulatedController::LoadDevices() { | 171 | void EmulatedController::LoadDevices() { |
| 132 | // TODO(german77): Use more buttons to detect the correct device | 172 | // TODO(german77): Use more buttons to detect the correct device |
| 133 | const auto left_joycon = button_params[Settings::NativeButton::DRight]; | 173 | const auto left_joycon = button_params[Settings::NativeButton::DRight]; |
| @@ -560,9 +600,23 @@ bool EmulatedController::IsConfiguring() const { | |||
| 560 | } | 600 | } |
| 561 | 601 | ||
| 562 | void EmulatedController::SaveCurrentConfig() { | 602 | void EmulatedController::SaveCurrentConfig() { |
| 563 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 603 | // Other can't alter the config from here |
| 604 | if (npad_id_type == NpadIdType::Other) { | ||
| 605 | return; | ||
| 606 | } | ||
| 607 | |||
| 608 | const auto player_index = NpadIdTypeToConfigIndex(npad_id_type); | ||
| 564 | auto& player = Settings::values.players.GetValue()[player_index]; | 609 | auto& player = Settings::values.players.GetValue()[player_index]; |
| 565 | player.connected = is_connected; | 610 | |
| 611 | // Only save the connected status when handheld is connected | ||
| 612 | if (npad_id_type == NpadIdType::Handheld && npad_type == NpadStyleIndex::Handheld) { | ||
| 613 | player.connected = is_connected; | ||
| 614 | } | ||
| 615 | |||
| 616 | if (npad_id_type != NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) { | ||
| 617 | player.connected = is_connected; | ||
| 618 | } | ||
| 619 | |||
| 566 | player.controller_type = MapNPadToSettingsType(npad_type); | 620 | player.controller_type = MapNPadToSettingsType(npad_type); |
| 567 | for (std::size_t index = 0; index < player.buttons.size(); ++index) { | 621 | for (std::size_t index = 0; index < player.buttons.size(); ++index) { |
| 568 | player.buttons[index] = button_params[index].Serialize(); | 622 | player.buttons[index] = button_params[index].Serialize(); |
| @@ -1152,7 +1206,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v | |||
| 1152 | if (!output_devices[device_index]) { | 1206 | if (!output_devices[device_index]) { |
| 1153 | return false; | 1207 | return false; |
| 1154 | } | 1208 | } |
| 1155 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 1209 | const auto player_index = NpadIdTypeToConfigIndex(npad_id_type); |
| 1156 | const auto& player = Settings::values.players.GetValue()[player_index]; | 1210 | const auto& player = Settings::values.players.GetValue()[player_index]; |
| 1157 | const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; | 1211 | const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; |
| 1158 | 1212 | ||
| @@ -1178,7 +1232,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v | |||
| 1178 | } | 1232 | } |
| 1179 | 1233 | ||
| 1180 | bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { | 1234 | bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { |
| 1181 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | 1235 | const auto player_index = NpadIdTypeToConfigIndex(npad_id_type); |
| 1182 | const auto& player = Settings::values.players.GetValue()[player_index]; | 1236 | const auto& player = Settings::values.players.GetValue()[player_index]; |
| 1183 | 1237 | ||
| 1184 | if (!player.vibration_enabled) { | 1238 | if (!player.vibration_enabled) { |