diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2024-01-31 17:25:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-31 17:25:28 +0100 |
commit | 7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c (patch) | |
tree | 24b2ed412f2683c8460839778ea7761d052bc38f /src/core/hle/service/am/applet_message_queue.cpp | |
parent | Merge pull request #12858 from liamwhite/non-blocking (diff) | |
parent | am: push storage from error applet with non-zero size (diff) | |
download | yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar.gz yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar.bz2 yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar.lz yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar.xz yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar.zst yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/am/applet_message_queue.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/core/hle/service/am/applet_message_queue.cpp b/src/core/hle/service/am/applet_message_queue.cpp new file mode 100644 index 000000000..5ed996b70 --- /dev/null +++ b/src/core/hle/service/am/applet_message_queue.cpp @@ -0,0 +1,73 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/am/applet_message_queue.h" +#include "core/hle/service/ipc_helpers.h" + +namespace Service::AM { + +AppletMessageQueue::AppletMessageQueue(Core::System& system) + : service_context{system, "AppletMessageQueue"} { + on_new_message = service_context.CreateEvent("AMMessageQueue:OnMessageReceived"); + on_operation_mode_changed = service_context.CreateEvent("AMMessageQueue:OperationModeChanged"); +} + +AppletMessageQueue::~AppletMessageQueue() { + service_context.CloseEvent(on_new_message); + service_context.CloseEvent(on_operation_mode_changed); +} + +Kernel::KReadableEvent& AppletMessageQueue::GetMessageReceiveEvent() { + return on_new_message->GetReadableEvent(); +} + +Kernel::KReadableEvent& AppletMessageQueue::GetOperationModeChangedEvent() { + return on_operation_mode_changed->GetReadableEvent(); +} + +void AppletMessageQueue::PushMessage(AppletMessage msg) { + { + std::scoped_lock lk{lock}; + messages.push(msg); + } + on_new_message->Signal(); +} + +AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() { + std::scoped_lock lk{lock}; + if (messages.empty()) { + on_new_message->Clear(); + return AppletMessage::None; + } + auto msg = messages.front(); + messages.pop(); + if (messages.empty()) { + on_new_message->Clear(); + } + return msg; +} + +std::size_t AppletMessageQueue::GetMessageCount() const { + std::scoped_lock lk{lock}; + return messages.size(); +} + +void AppletMessageQueue::RequestExit() { + PushMessage(AppletMessage::Exit); +} + +void AppletMessageQueue::RequestResume() { + PushMessage(AppletMessage::Resume); +} + +void AppletMessageQueue::FocusStateChanged() { + PushMessage(AppletMessage::FocusStateChanged); +} + +void AppletMessageQueue::OperationModeChanged() { + PushMessage(AppletMessage::OperationModeChanged); + PushMessage(AppletMessage::PerformanceModeChanged); + on_operation_mode_changed->Signal(); +} + +} // namespace Service::AM |