From 02e6602baaf36d7c148739eae922fa91ba4818fd Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 17 Nov 2018 12:20:16 -0500 Subject: [PATCH] software_keyboard: Push all data over all channels on dialog completion --- .../service/am/applets/software_keyboard.cpp | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp index a5ffa1f31..5661cc98d 100644 --- a/src/core/hle/service/am/applets/software_keyboard.cpp +++ b/src/core/hle/service/am/applets/software_keyboard.cpp @@ -97,8 +97,10 @@ void SoftwareKeyboard::ReceiveInteractiveData(std::shared_ptr storage) void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data, AppletStorageProxyFunction out_interactive_data, AppletStateProxyFunction state) { - if (complete) + if (complete) { + out_data(IStorage{final_data}); return; + } const auto& frontend{Core::System::GetInstance().GetSoftwareKeyboard()}; @@ -112,32 +114,38 @@ void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data, } void SoftwareKeyboard::WriteText(std::optional text) { - std::vector output(SWKBD_OUTPUT_BUFFER_SIZE); + std::vector output_main(SWKBD_OUTPUT_BUFFER_SIZE); if (text.has_value()) { + std::vector output_sub(SWKBD_OUTPUT_BUFFER_SIZE); status = RESULT_SUCCESS; - if (config.text_check) { - const auto size = static_cast(text->size() * 2 + 4); - std::memcpy(output.data(), &size, sizeof(u32)); + + const u64 size = text->size() * 2 + 8; + std::memcpy(output_sub.data(), &size, sizeof(u64)); + std::memcpy(output_sub.data() + 8, text->data(), + std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 8)); + + output_main[0] = config.text_check; + std::memcpy(output_main.data() + 4, text->data(), + std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4)); + + complete = !config.text_check; + final_data = output_main; + + if (complete) { + out_data(IStorage{output_main}); } else { - output[0] = 1; + out_data(IStorage{output_main}); + out_interactive_data(IStorage{output_sub}); } - const auto size = static_cast(text->size()); - std::memcpy(output.data() + 4, &size, sizeof(u32)); - std::memcpy(output.data() + 8, text->data(), - std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 8)); + state(); } else { status = ResultCode(-1); + output_main[0] = 1; complete = true; - out_data(IStorage{output}); - return; + out_data(IStorage{output_main}); + state(); } - - complete = !config.text_check; - - out_data(IStorage{output}); - out_interactive_data(IStorage{output}); - state(); } } // namespace Service::AM::Applets