summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am/applets
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/am/applets')
-rw-r--r--src/core/hle/service/am/applets/applets.h6
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.cpp27
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.h3
3 files changed, 18 insertions, 18 deletions
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h
index 6d90eb608..7fbaaf2f3 100644
--- a/src/core/hle/service/am/applets/applets.h
+++ b/src/core/hle/service/am/applets/applets.h
@@ -4,6 +4,7 @@
#pragma once
+#include <functional>
#include <memory>
#include <vector>
#include "common/swap.h"
@@ -20,6 +21,8 @@ class IStorage;
namespace Applets {
+using AppletStorageProxyFunction = std::function<void(IStorage)>;
+
class Applet {
public:
Applet();
@@ -30,7 +33,8 @@ public:
virtual bool TransactionComplete() const = 0;
virtual ResultCode GetStatus() const = 0;
virtual void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) = 0;
- virtual IStorage Execute() = 0;
+ virtual void Execute(AppletStorageProxyFunction out_data,
+ AppletStorageProxyFunction out_interactive_data) = 0;
bool IsInitialized() const {
return initialized;
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp
index 044a16264..7352f3bdf 100644
--- a/src/core/hle/service/am/applets/software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/software_keyboard.cpp
@@ -87,42 +87,37 @@ void SoftwareKeyboard::ReceiveInteractiveData(std::shared_ptr<IStorage> storage)
}
}
-IStorage SoftwareKeyboard::Execute() {
+void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data,
+ AppletStorageProxyFunction out_interactive_data) {
if (complete)
- return IStorage{final_data};
+ return;
const auto& frontend{Core::System::GetInstance().GetSoftwareKeyboard()};
const auto parameters = ConvertToFrontendParameters(config, initial_text);
- std::u16string text;
- const auto success = frontend.GetText(parameters, text);
+ const auto res = frontend.GetText(parameters);
std::vector<u8> output(SWKBD_OUTPUT_BUFFER_SIZE);
- if (success) {
+ if (res.has_value()) {
if (config.text_check) {
- const auto size = static_cast<u32>(text.size() * 2 + 4);
+ const auto size = static_cast<u32>(res->size() * 2 + 4);
std::memcpy(output.data(), &size, sizeof(u32));
} else {
output[0] = 1;
}
- std::memcpy(output.data() + 4, text.data(),
- std::min(text.size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4));
+ std::memcpy(output.data() + 4, res->data(),
+ std::min(res->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4));
} else {
complete = true;
- final_data = std::move(output);
- return IStorage{final_data};
+ out_data(IStorage{output});
+ return;
}
complete = !config.text_check;
- if (complete) {
- final_data = std::move(output);
- return IStorage{final_data};
- }
-
- return IStorage{output};
+ (complete ? out_data : out_interactive_data)(IStorage{output});
}
} // namespace Service::AM::Applets
diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h
index 9d77f5802..66de4bc59 100644
--- a/src/core/hle/service/am/applets/software_keyboard.h
+++ b/src/core/hle/service/am/applets/software_keyboard.h
@@ -54,7 +54,8 @@ public:
bool TransactionComplete() const override;
ResultCode GetStatus() const override;
void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) override;
- IStorage Execute() override;
+ void Execute(AppletStorageProxyFunction out_data,
+ AppletStorageProxyFunction out_interactive_data) override;
private:
KeyboardConfig config;