diff options
author | german77 <juangerman-13@hotmail.com> | 2024-01-29 02:19:21 +0100 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2024-01-29 02:28:37 +0100 |
commit | b8f16f3538fac8d4434905d531885b9862706bd0 (patch) | |
tree | 2e582d1d36fbc340f0175ad816362faccb20eee8 /src/hid_core/resources/system_buttons/capture_button.cpp | |
parent | Merge pull request #12555 from flodavid/fix-gamemode-setting (diff) | |
download | yuzu-b8f16f3538fac8d4434905d531885b9862706bd0.tar yuzu-b8f16f3538fac8d4434905d531885b9862706bd0.tar.gz yuzu-b8f16f3538fac8d4434905d531885b9862706bd0.tar.bz2 yuzu-b8f16f3538fac8d4434905d531885b9862706bd0.tar.lz yuzu-b8f16f3538fac8d4434905d531885b9862706bd0.tar.xz yuzu-b8f16f3538fac8d4434905d531885b9862706bd0.tar.zst yuzu-b8f16f3538fac8d4434905d531885b9862706bd0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/hid_core/resources/system_buttons/capture_button.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/hid_core/resources/system_buttons/capture_button.cpp b/src/hid_core/resources/system_buttons/capture_button.cpp index 70973ae25..95eb60424 100644 --- a/src/hid_core/resources/system_buttons/capture_button.cpp +++ b/src/hid_core/resources/system_buttons/capture_button.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/core_timing.h" +#include "hid_core/frontend/emulated_controller.h" +#include "hid_core/hid_core.h" #include "hid_core/resources/applet_resource.h" #include "hid_core/resources/shared_memory_format.h" #include "hid_core/resources/system_buttons/capture_button.h" @@ -17,10 +19,6 @@ void CaptureButton::OnInit() {} void CaptureButton::OnRelease() {} void CaptureButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - if (!smart_update) { - return; - } - std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); @@ -29,11 +27,21 @@ void CaptureButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) { return; } - auto& header = data->shared_memory_format->capture_button.header; - header.timestamp = core_timing.GetGlobalTimeNs().count(); - header.total_entry_count = 17; - header.entry_count = 0; - header.last_entry_index = 0; + auto& shared_memory = data->shared_memory_format->capture_button; + + if (!IsControllerActivated()) { + shared_memory.capture_lifo.buffer_count = 0; + shared_memory.capture_lifo.buffer_tail = 0; + return; + } + + const auto& last_entry = shared_memory.capture_lifo.ReadCurrentEntry().state; + next_state.sampling_number = last_entry.sampling_number + 1; + + auto* controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); + next_state.buttons.raw = controller->GetHomeButtons().raw; + + shared_memory.capture_lifo.WriteNextEntry(next_state); } } // namespace Service::HID |