diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-11-17 18:19:06 +0100 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-11-18 16:53:47 +0100 |
commit | 4ee087fb3ca2b1e064422b73195a8ff7698721d9 (patch) | |
tree | 5dcd31972d79e324e8eb75e19c3c00ff2a83b03c /src/core/hle/service | |
parent | applet: Add operation completed callback (diff) | |
download | yuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.tar yuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.tar.gz yuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.tar.bz2 yuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.tar.lz yuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.tar.xz yuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.tar.zst yuzu-4ee087fb3ca2b1e064422b73195a8ff7698721d9.zip |
Diffstat (limited to 'src/core/hle/service')
-rw-r--r-- | src/core/hle/service/am/am.cpp | 32 | ||||
-rw-r--r-- | src/core/hle/service/am/applets/applets.cpp | 12 | ||||
-rw-r--r-- | src/core/hle/service/am/applets/applets.h | 7 | ||||
-rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.cpp | 9 | ||||
-rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.h | 2 |
5 files changed, 44 insertions, 18 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 5cbcb8d91..d92a46b00 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -567,12 +567,12 @@ public: private: void AppletStorageProxyOutData(IStorage storage) { - storage_stack.push_back(std::make_shared<IStorage>(storage)); + storage_stack.push(std::make_shared<IStorage>(storage)); pop_out_data_event->Signal(); } void AppletStorageProxyOutInteractiveData(IStorage storage) { - interactive_storage_stack.push_back(std::make_shared<IStorage>(storage)); + interactive_storage_stack.push(std::make_shared<IStorage>(storage)); pop_interactive_out_data_event->Signal(); } @@ -621,7 +621,7 @@ private: void PushInData(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - storage_stack.push_back(rp.PopIpcInterface<IStorage>()); + storage_stack.push(rp.PopIpcInterface<IStorage>()); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); @@ -631,17 +631,23 @@ private: void PopOutData(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + + if (storage_stack.empty()) { + rb.Push(ResultCode(-1)); + return; + } + rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IStorage>(std::move(storage_stack.back())); + rb.PushIpcInterface<IStorage>(std::move(storage_stack.front())); - storage_stack.pop_back(); + storage_stack.pop(); LOG_DEBUG(Service_AM, "called"); } void PushInteractiveInData(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - interactive_storage_stack.push_back(rp.PopIpcInterface<IStorage>()); + interactive_storage_stack.push(rp.PopIpcInterface<IStorage>()); ASSERT(applet->IsInitialized()); applet->ReceiveInteractiveData(interactive_storage_stack.back()); @@ -657,10 +663,16 @@ private: void PopInteractiveOutData(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + + if (interactive_storage_stack.empty()) { + rb.Push(ResultCode(-1)); + return; + } + rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IStorage>(std::move(interactive_storage_stack.back())); + rb.PushIpcInterface<IStorage>(std::move(interactive_storage_stack.front())); - interactive_storage_stack.pop_back(); + interactive_storage_stack.pop(); LOG_DEBUG(Service_AM, "called"); } @@ -682,8 +694,8 @@ private: } std::shared_ptr<Applets::Applet> applet; - std::vector<std::shared_ptr<IStorage>> storage_stack; - std::vector<std::shared_ptr<IStorage>> interactive_storage_stack; + std::queue<std::shared_ptr<IStorage>> storage_stack; + std::queue<std::shared_ptr<IStorage>> interactive_storage_stack; Kernel::SharedPtr<Kernel::Event> state_changed_event; Kernel::SharedPtr<Kernel::Event> pop_out_data_event; Kernel::SharedPtr<Kernel::Event> pop_interactive_out_data_event; diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index 03b9d83e7..be950d320 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -2,7 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <cstring> +#include "common/assert.h" #include "core/frontend/applets/software_keyboard.h" +#include "core/hle/service/am/am.h" #include "core/hle/service/am/applets/applets.h" namespace Service::AM::Applets { @@ -11,8 +14,15 @@ Applet::Applet() = default; Applet::~Applet() = default; -void Applet::Initialize(std::vector<std::shared_ptr<IStorage>> storage) { +void Applet::Initialize(std::queue<std::shared_ptr<IStorage>> storage) { storage_stack = std::move(storage); + + const auto common_data = storage_stack.front()->GetData(); + storage_stack.pop(); + + ASSERT(common_data.size() >= sizeof(CommonArguments)); + std::memcpy(&common_args, common_data.data(), sizeof(CommonArguments)); + initialized = true; } diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 1ffa09420..a6a9bf77b 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -6,7 +6,7 @@ #include <functional> #include <memory> -#include <vector> +#include <queue> #include "common/swap.h" union ResultCode; @@ -29,7 +29,7 @@ public: Applet(); virtual ~Applet(); - virtual void Initialize(std::vector<std::shared_ptr<IStorage>> storage); + virtual void Initialize(std::queue<std::shared_ptr<IStorage>> storage); virtual bool TransactionComplete() const = 0; virtual ResultCode GetStatus() const = 0; @@ -53,7 +53,8 @@ protected: }; static_assert(sizeof(CommonArguments) == 0x20, "CommonArguments has incorrect size."); - std::vector<std::shared_ptr<IStorage>> storage_stack; + CommonArguments common_args; + std::queue<std::shared_ptr<IStorage>> storage_stack; bool initialized = false; }; diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp index 039bfcc0f..a5ffa1f31 100644 --- a/src/core/hle/service/am/applets/software_keyboard.cpp +++ b/src/core/hle/service/am/applets/software_keyboard.cpp @@ -42,7 +42,7 @@ SoftwareKeyboard::SoftwareKeyboard() = default; SoftwareKeyboard::~SoftwareKeyboard() = default; -void SoftwareKeyboard::Initialize(std::vector<std::shared_ptr<IStorage>> storage_) { +void SoftwareKeyboard::Initialize(std::queue<std::shared_ptr<IStorage>> storage_) { complete = false; initial_text.clear(); final_data.clear(); @@ -50,11 +50,14 @@ void SoftwareKeyboard::Initialize(std::vector<std::shared_ptr<IStorage>> storage Applet::Initialize(std::move(storage_)); ASSERT(storage_stack.size() >= 2); - const auto& keyboard_config = storage_stack[1]->GetData(); + const auto& keyboard_config = storage_stack.front()->GetData(); + storage_stack.pop(); + ASSERT(keyboard_config.size() >= sizeof(KeyboardConfig)); std::memcpy(&config, keyboard_config.data(), sizeof(KeyboardConfig)); - const auto& work_buffer = storage_stack[2]->GetData(); + const auto& work_buffer = storage_stack.front()->GetData(); + storage_stack.pop(); if (config.initial_string_size == 0) return; diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h index 9629f6408..9544d6b1b 100644 --- a/src/core/hle/service/am/applets/software_keyboard.h +++ b/src/core/hle/service/am/applets/software_keyboard.h @@ -49,7 +49,7 @@ public: SoftwareKeyboard(); ~SoftwareKeyboard() override; - void Initialize(std::vector<std::shared_ptr<IStorage>> storage) override; + void Initialize(std::queue<std::shared_ptr<IStorage>> storage) override; bool TransactionComplete() const override; ResultCode GetStatus() const override; |