diff options
| author | MaranBr <maranbr@outlook.com> | 2025-10-16 03:14:39 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2025-10-16 03:14:39 +0200 |
| commit | bb836ed6c28d608b3cf9da4116bb6f9a2fb6f273 (patch) | |
| tree | aea18360e9f78cda6965668662113c87f9f33940 /src/hid_core/frontend/emulated_controller.cpp | |
| parent | f273ac446bb4d0badc8c3ac949fe0ed3534eb034 (diff) | |
[hid_core] Fix a crash related to setting controls while the game is running (#2747)
This fixes a crash related to setting controls while the game is running. Fixes BOTW, TOTK, MK8D and possibly others as well.
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2747
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: Lizzie <lizzie@eden-emu.dev>
Co-authored-by: MaranBr <maranbr@outlook.com>
Co-committed-by: MaranBr <maranbr@outlook.com>
Diffstat (limited to 'src/hid_core/frontend/emulated_controller.cpp')
| -rw-r--r-- | src/hid_core/frontend/emulated_controller.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp index 0ddab89da3..6c1fc63821 100644 --- a/src/hid_core/frontend/emulated_controller.cpp +++ b/src/hid_core/frontend/emulated_controller.cpp @@ -763,14 +763,11 @@ void EmulatedController::StartMotionCalibration() { } } -void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, Common::UUID uuid) { - const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); - const auto& player = Settings::values.players.GetValue()[player_index]; - +void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, + Common::UUID uuid) { if (index >= controller.button_values.size()) { return; } - std::unique_lock lock{mutex}; bool value_changed = false; const auto new_status = TransformToButton(callback); @@ -923,9 +920,12 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback lock.unlock(); - if (player.connected) { + const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type); + if (!is_connected && !controller_connected[player_index]) { Connect(); + controller_connected[player_index] = true; } + TriggerOnChange(ControllerTriggerType::Button, true); } |
