diff options
| author | 2018-11-12 11:08:09 -0500 | |
|---|---|---|
| committer | 2018-11-18 10:53:47 -0500 | |
| commit | 8b433beff34c382e50334bb59c4f71394845558c (patch) | |
| tree | f52f432b2ee5f4ef3917c1c0e2fa052930d68f3a /src/core/hle | |
| parent | am: Allow applets to push multiple and different channels of data (diff) | |
| download | yuzu-8b433beff34c382e50334bb59c4f71394845558c.tar.gz yuzu-8b433beff34c382e50334bb59c4f71394845558c.tar.xz yuzu-8b433beff34c382e50334bb59c4f71394845558c.zip | |
software_keyboard: Make GetText asynchronous
a
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.cpp | 19 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.h | 5 |
3 files changed, 20 insertions, 6 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 3f8d97d31..d040d4776 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -718,7 +718,7 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) { | |||
| 718 | const u64 offset{rp.Pop<u64>()}; | 718 | const u64 offset{rp.Pop<u64>()}; |
| 719 | const std::vector<u8> data{ctx.ReadBuffer()}; | 719 | const std::vector<u8> data{ctx.ReadBuffer()}; |
| 720 | 720 | ||
| 721 | const auto size = std::min(data.size(), backing.buffer.size() - offset); | 721 | const auto size = std::min<std::size_t>(data.size(), backing.buffer.size() - offset); |
| 722 | 722 | ||
| 723 | std::memcpy(&backing.buffer[offset], data.data(), size); | 723 | std::memcpy(&backing.buffer[offset], data.data(), size); |
| 724 | 724 | ||
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp index 7352f3bdf..66b34d5ac 100644 --- a/src/core/hle/service/am/applets/software_keyboard.cpp +++ b/src/core/hle/service/am/applets/software_keyboard.cpp | |||
| @@ -43,6 +43,10 @@ SoftwareKeyboard::SoftwareKeyboard() = default; | |||
| 43 | SoftwareKeyboard::~SoftwareKeyboard() = default; | 43 | SoftwareKeyboard::~SoftwareKeyboard() = default; |
| 44 | 44 | ||
| 45 | void SoftwareKeyboard::Initialize(std::vector<std::shared_ptr<IStorage>> storage_) { | 45 | void SoftwareKeyboard::Initialize(std::vector<std::shared_ptr<IStorage>> storage_) { |
| 46 | complete = false; | ||
| 47 | initial_text.clear(); | ||
| 48 | final_data.clear(); | ||
| 49 | |||
| 46 | Applet::Initialize(std::move(storage_)); | 50 | Applet::Initialize(std::move(storage_)); |
| 47 | 51 | ||
| 48 | ASSERT(storage_stack.size() >= 2); | 52 | ASSERT(storage_stack.size() >= 2); |
| @@ -96,20 +100,25 @@ void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data, | |||
| 96 | 100 | ||
| 97 | const auto parameters = ConvertToFrontendParameters(config, initial_text); | 101 | const auto parameters = ConvertToFrontendParameters(config, initial_text); |
| 98 | 102 | ||
| 99 | const auto res = frontend.GetText(parameters); | 103 | this->out_data = out_data; |
| 104 | this->out_interactive_data = out_interactive_data; | ||
| 105 | frontend.RequestText([this](std::optional<std::u16string> text) { WriteText(text); }, | ||
| 106 | parameters); | ||
| 107 | } | ||
| 100 | 108 | ||
| 109 | void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) { | ||
| 101 | std::vector<u8> output(SWKBD_OUTPUT_BUFFER_SIZE); | 110 | std::vector<u8> output(SWKBD_OUTPUT_BUFFER_SIZE); |
| 102 | 111 | ||
| 103 | if (res.has_value()) { | 112 | if (text.has_value()) { |
| 104 | if (config.text_check) { | 113 | if (config.text_check) { |
| 105 | const auto size = static_cast<u32>(res->size() * 2 + 4); | 114 | const auto size = static_cast<u32>(text->size() * 2 + 4); |
| 106 | std::memcpy(output.data(), &size, sizeof(u32)); | 115 | std::memcpy(output.data(), &size, sizeof(u32)); |
| 107 | } else { | 116 | } else { |
| 108 | output[0] = 1; | 117 | output[0] = 1; |
| 109 | } | 118 | } |
| 110 | 119 | ||
| 111 | std::memcpy(output.data() + 4, res->data(), | 120 | std::memcpy(output.data() + 4, text->data(), |
| 112 | std::min(res->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4)); | 121 | std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4)); |
| 113 | } else { | 122 | } else { |
| 114 | complete = true; | 123 | complete = true; |
| 115 | out_data(IStorage{output}); | 124 | out_data(IStorage{output}); |
diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h index 66de4bc59..b08bff3d7 100644 --- a/src/core/hle/service/am/applets/software_keyboard.h +++ b/src/core/hle/service/am/applets/software_keyboard.h | |||
| @@ -57,11 +57,16 @@ public: | |||
| 57 | void Execute(AppletStorageProxyFunction out_data, | 57 | void Execute(AppletStorageProxyFunction out_data, |
| 58 | AppletStorageProxyFunction out_interactive_data) override; | 58 | AppletStorageProxyFunction out_interactive_data) override; |
| 59 | 59 | ||
| 60 | void WriteText(std::optional<std::u16string> text); | ||
| 61 | |||
| 60 | private: | 62 | private: |
| 61 | KeyboardConfig config; | 63 | KeyboardConfig config; |
| 62 | std::u16string initial_text; | 64 | std::u16string initial_text; |
| 63 | bool complete = false; | 65 | bool complete = false; |
| 64 | std::vector<u8> final_data; | 66 | std::vector<u8> final_data; |
| 67 | |||
| 68 | AppletStorageProxyFunction out_data; | ||
| 69 | AppletStorageProxyFunction out_interactive_data; | ||
| 65 | }; | 70 | }; |
| 66 | 71 | ||
| 67 | } // namespace Service::AM::Applets | 72 | } // namespace Service::AM::Applets |