diff options
Diffstat (limited to 'src/hid_core/resources/system_buttons')
6 files changed, 198 insertions, 0 deletions
diff --git a/src/hid_core/resources/system_buttons/capture_button.cpp b/src/hid_core/resources/system_buttons/capture_button.cpp new file mode 100644 index 000000000..70973ae25 --- /dev/null +++ b/src/hid_core/resources/system_buttons/capture_button.cpp @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/core_timing.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" + +namespace Service::HID { + +CaptureButton::CaptureButton(Core::HID::HIDCore& hid_core_) : ControllerBase{hid_core_} {} + +CaptureButton::~CaptureButton() = default; + +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); + + if (data == nullptr || !data->flag.is_assigned) { + 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; +} + +} // namespace Service::HID diff --git a/src/hid_core/resources/system_buttons/capture_button.h b/src/hid_core/resources/system_buttons/capture_button.h new file mode 100644 index 000000000..ad95d7cad --- /dev/null +++ b/src/hid_core/resources/system_buttons/capture_button.h @@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "hid_core/resources/controller_base.h" + +namespace Service::HID { + +class CaptureButton final : public ControllerBase { +public: + explicit CaptureButton(Core::HID::HIDCore& hid_core_); + ~CaptureButton() override; + + // Called when the controller is initialized + void OnInit() override; + + // When the controller is released + void OnRelease() override; + + // When the controller is requesting an update for the shared memory + void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; + +private: + bool smart_update{}; +}; +} // namespace Service::HID diff --git a/src/hid_core/resources/system_buttons/home_button.cpp b/src/hid_core/resources/system_buttons/home_button.cpp new file mode 100644 index 000000000..f9c1f44b5 --- /dev/null +++ b/src/hid_core/resources/system_buttons/home_button.cpp @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/core_timing.h" +#include "hid_core/resources/applet_resource.h" +#include "hid_core/resources/shared_memory_format.h" +#include "hid_core/resources/system_buttons/home_button.h" + +namespace Service::HID { + +HomeButton::HomeButton(Core::HID::HIDCore& hid_core_) : ControllerBase{hid_core_} {} + +HomeButton::~HomeButton() = default; + +void HomeButton::OnInit() {} + +void HomeButton::OnRelease() {} + +void HomeButton::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); + + if (data == nullptr || !data->flag.is_assigned) { + return; + } + + auto& header = data->shared_memory_format->home_button.header; + header.timestamp = core_timing.GetGlobalTimeNs().count(); + header.total_entry_count = 17; + header.entry_count = 0; + header.last_entry_index = 0; +} + +} // namespace Service::HID diff --git a/src/hid_core/resources/system_buttons/home_button.h b/src/hid_core/resources/system_buttons/home_button.h new file mode 100644 index 000000000..ecf8327f4 --- /dev/null +++ b/src/hid_core/resources/system_buttons/home_button.h @@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "hid_core/resources/controller_base.h" + +namespace Service::HID { + +class HomeButton final : public ControllerBase { +public: + explicit HomeButton(Core::HID::HIDCore& hid_core_); + ~HomeButton() override; + + // Called when the controller is initialized + void OnInit() override; + + // When the controller is released + void OnRelease() override; + + // When the controller is requesting an update for the shared memory + void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; + +private: + bool smart_update{}; +}; +} // namespace Service::HID diff --git a/src/hid_core/resources/system_buttons/sleep_button.cpp b/src/hid_core/resources/system_buttons/sleep_button.cpp new file mode 100644 index 000000000..22adf501f --- /dev/null +++ b/src/hid_core/resources/system_buttons/sleep_button.cpp @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/core_timing.h" +#include "hid_core/resources/applet_resource.h" +#include "hid_core/resources/shared_memory_format.h" +#include "hid_core/resources/system_buttons/sleep_button.h" + +namespace Service::HID { + +SleepButton::SleepButton(Core::HID::HIDCore& hid_core_) : ControllerBase{hid_core_} {} + +SleepButton::~SleepButton() = default; + +void SleepButton::OnInit() {} + +void SleepButton::OnRelease() {} + +void SleepButton::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); + + if (data == nullptr || !data->flag.is_assigned) { + 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; +} + +} // namespace Service::HID diff --git a/src/hid_core/resources/system_buttons/sleep_button.h b/src/hid_core/resources/system_buttons/sleep_button.h new file mode 100644 index 000000000..f9ed38c33 --- /dev/null +++ b/src/hid_core/resources/system_buttons/sleep_button.h @@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "hid_core/resources/controller_base.h" + +namespace Service::HID { + +class SleepButton final : public ControllerBase { +public: + explicit SleepButton(Core::HID::HIDCore& hid_core_); + ~SleepButton() override; + + // Called when the controller is initialized + void OnInit() override; + + // When the controller is released + void OnRelease() override; + + // When the controller is requesting an update for the shared memory + void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; + +private: + bool smart_update{}; +}; +} // namespace Service::HID |