diff options
| author | MaranBr <maranbr@outlook.com> | 2025-10-17 22:24:38 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2025-10-17 22:24:38 +0200 |
| commit | 9c7ed0f59dd41ec0bbbfbc81678209ae60a36016 (patch) | |
| tree | 61c74b7fd9422b5c3cb9058ba77ce0869661ec38 /src/hid_core/frontend | |
| parent | de46b8e81753ecb491265b18c55cf883f749b4d3 (diff) | |
[hid_core] Fix a specific case where all controllers get disconnected by certain games (#2759)
There's a bug in some games where all controllers get disconnected. This fixes those specific cases where controllers set to Handheld or Player 1 need to remain connected.
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2759
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: MaranBr <maranbr@outlook.com>
Co-committed-by: MaranBr <maranbr@outlook.com>
Diffstat (limited to 'src/hid_core/frontend')
| -rw-r--r-- | src/hid_core/frontend/emulated_controller.cpp | 18 | ||||
| -rw-r--r-- | src/hid_core/frontend/emulated_controller.h | 2 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp index 37a892c37f..604414c470 100644 --- a/src/hid_core/frontend/emulated_controller.cpp +++ b/src/hid_core/frontend/emulated_controller.cpp @@ -924,10 +924,20 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback lock.unlock(); - if (!is_connected && !controller_connected[player_index]) { - if (player.connected) { - Connect(); - controller_connected[player_index] = true; + if (!is_connected) { + if (npad_type == NpadStyleIndex::Handheld) { + if (npad_id_type == NpadIdType::Handheld) { + Connect(); + controller_connected[player_index] = true; + } + } else if (npad_type != NpadStyleIndex::Handheld) { + if (npad_id_type == NpadIdType::Player1) { + Connect(); + controller_connected[player_index] = true; + } else if (player.connected && !controller_connected[player_index]) { + Connect(); + controller_connected[player_index] = true; + } } } diff --git a/src/hid_core/frontend/emulated_controller.h b/src/hid_core/frontend/emulated_controller.h index 8e8293ff36..b8eafbae5c 100644 --- a/src/hid_core/frontend/emulated_controller.h +++ b/src/hid_core/frontend/emulated_controller.h @@ -589,7 +589,7 @@ private: std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE, DEFAULT_VIBRATION_VALUE}; std::array<std::chrono::steady_clock::time_point, 2> last_vibration_timepoint{}; - std::array<bool, HIDCore::available_controllers - 2> controller_connected{}; + std::array<bool, HIDCore::available_controllers> controller_connected{}; // Temporary values to avoid doing changes while the controller is in configuring mode NpadStyleIndex tmp_npad_type{NpadStyleIndex::None}; |
