summaryrefslogtreecommitdiffstats
path: root/src/core/hid/emulated_controller.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2023-02-27 07:18:25 +0100
committerGitHub <noreply@github.com>2023-02-27 07:18:25 +0100
commit2b4ba9032920c408527985a493467063cf405a2e (patch)
tree0be3e8dfec5f9df92c38e3bba7b632751ad57379 /src/core/hid/emulated_controller.cpp
parentMerge pull request #9849 from ameerj/async-astc (diff)
parentRevert "yuzu: config: Remove player 8 and 9 from config file" (diff)
downloadyuzu-2b4ba9032920c408527985a493467063cf405a2e.tar
yuzu-2b4ba9032920c408527985a493467063cf405a2e.tar.gz
yuzu-2b4ba9032920c408527985a493467063cf405a2e.tar.bz2
yuzu-2b4ba9032920c408527985a493467063cf405a2e.tar.lz
yuzu-2b4ba9032920c408527985a493467063cf405a2e.tar.xz
yuzu-2b4ba9032920c408527985a493467063cf405a2e.tar.zst
yuzu-2b4ba9032920c408527985a493467063cf405a2e.zip
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
-rw-r--r--src/core/hid/emulated_controller.cpp78
1 files changed, 12 insertions, 66 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 9f0ceca49..a29c9a6f8 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -82,12 +82,7 @@ Settings::ControllerType EmulatedController::MapNPadToSettingsType(NpadStyleInde
}
void EmulatedController::ReloadFromSettings() {
- if (npad_id_type == NpadIdType::Other) {
- ReloadDebugPadFromSettings();
- return;
- }
-
- const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
+ const auto player_index = NpadIdTypeToIndex(npad_id_type);
const auto& player = Settings::values.players.GetValue()[player_index];
for (std::size_t index = 0; index < player.buttons.size(); ++index) {
@@ -116,21 +111,13 @@ void EmulatedController::ReloadFromSettings() {
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
- SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
- original_npad_type = npad_type;
-
- // Player 1 shares config with handheld. Disable controller when handheld is selected
- if (npad_id_type == NpadIdType::Player1 && npad_type == NpadStyleIndex::Handheld) {
- Disconnect();
- ReloadInput();
- return;
- }
-
- // Handheld shares config with player 1. Disable controller when handheld isn't selected
- if (npad_id_type == NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) {
- Disconnect();
- ReloadInput();
- return;
+ // Other or debug controller should always be a pro controller
+ if (npad_id_type != NpadIdType::Other) {
+ SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
+ original_npad_type = npad_type;
+ } else {
+ SetNpadStyleIndex(NpadStyleIndex::ProController);
+ original_npad_type = npad_type;
}
Disconnect();
@@ -141,33 +128,6 @@ void EmulatedController::ReloadFromSettings() {
ReloadInput();
}
-void EmulatedController::ReloadDebugPadFromSettings() {
- for (std::size_t index = 0; index < Settings::values.debug_pad_buttons.size(); ++index) {
- button_params[index] = Common::ParamPackage(Settings::values.debug_pad_buttons[index]);
- }
- for (std::size_t index = 0; index < Settings::values.debug_pad_analogs.size(); ++index) {
- stick_params[index] = Common::ParamPackage(Settings::values.debug_pad_analogs[index]);
- }
- for (std::size_t index = 0; index < motion_params.size(); ++index) {
- motion_params[index] = {};
- }
-
- controller.color_values = {};
- controller.colors_state.fullkey = {};
- controller.colors_state.left = {};
- controller.colors_state.right = {};
- ring_params[0] = {};
- SetNpadStyleIndex(NpadStyleIndex::ProController);
- original_npad_type = npad_type;
-
- Disconnect();
- if (Settings::values.debug_pad_enabled) {
- Connect();
- }
-
- ReloadInput();
-}
-
void EmulatedController::LoadDevices() {
// TODO(german77): Use more buttons to detect the correct device
const auto left_joycon = button_params[Settings::NativeButton::DRight];
@@ -600,23 +560,9 @@ bool EmulatedController::IsConfiguring() const {
}
void EmulatedController::SaveCurrentConfig() {
- // Other can't alter the config from here
- if (npad_id_type == NpadIdType::Other) {
- return;
- }
-
- const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
+ const auto player_index = NpadIdTypeToIndex(npad_id_type);
auto& player = Settings::values.players.GetValue()[player_index];
-
- // Only save the connected status when handheld is connected
- if (npad_id_type == NpadIdType::Handheld && npad_type == NpadStyleIndex::Handheld) {
- player.connected = is_connected;
- }
-
- if (npad_id_type != NpadIdType::Handheld && npad_type != NpadStyleIndex::Handheld) {
- player.connected = is_connected;
- }
-
+ player.connected = is_connected;
player.controller_type = MapNPadToSettingsType(npad_type);
for (std::size_t index = 0; index < player.buttons.size(); ++index) {
player.buttons[index] = button_params[index].Serialize();
@@ -1206,7 +1152,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
if (!output_devices[device_index]) {
return false;
}
- const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
+ const auto player_index = NpadIdTypeToIndex(npad_id_type);
const auto& player = Settings::values.players.GetValue()[player_index];
const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f;
@@ -1232,7 +1178,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
}
bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {
- const auto player_index = NpadIdTypeToConfigIndex(npad_id_type);
+ const auto player_index = NpadIdTypeToIndex(npad_id_type);
const auto& player = Settings::values.players.GetValue()[player_index];
if (!player.vibration_enabled) {