2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

software_keyboard: Push all data over all channels on dialog completion

This commit is contained in:
Zach Hilman 2018-11-17 12:20:16 -05:00
parent 4ee087fb3c
commit 02e6602baa

View file

@ -97,8 +97,10 @@ void SoftwareKeyboard::ReceiveInteractiveData(std::shared_ptr<IStorage> storage)
void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data, void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data,
AppletStorageProxyFunction out_interactive_data, AppletStorageProxyFunction out_interactive_data,
AppletStateProxyFunction state) { AppletStateProxyFunction state) {
if (complete) if (complete) {
out_data(IStorage{final_data});
return; return;
}
const auto& frontend{Core::System::GetInstance().GetSoftwareKeyboard()}; const auto& frontend{Core::System::GetInstance().GetSoftwareKeyboard()};
@ -112,32 +114,38 @@ void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data,
} }
void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) { void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) {
std::vector<u8> output(SWKBD_OUTPUT_BUFFER_SIZE); std::vector<u8> output_main(SWKBD_OUTPUT_BUFFER_SIZE);
if (text.has_value()) { if (text.has_value()) {
std::vector<u8> output_sub(SWKBD_OUTPUT_BUFFER_SIZE);
status = RESULT_SUCCESS; status = RESULT_SUCCESS;
if (config.text_check) {
const auto size = static_cast<u32>(text->size() * 2 + 4);
std::memcpy(output.data(), &size, sizeof(u32));
} else {
output[0] = 1;
}
const auto size = static_cast<u32>(text->size()); const u64 size = text->size() * 2 + 8;
std::memcpy(output.data() + 4, &size, sizeof(u32)); std::memcpy(output_sub.data(), &size, sizeof(u64));
std::memcpy(output.data() + 8, text->data(), std::memcpy(output_sub.data() + 8, text->data(),
std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 8)); std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 8));
} else {
status = ResultCode(-1); output_main[0] = config.text_check;
complete = true; std::memcpy(output_main.data() + 4, text->data(),
out_data(IStorage{output}); std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4));
return;
}
complete = !config.text_check; complete = !config.text_check;
final_data = output_main;
if (complete) {
out_data(IStorage{output_main});
} else {
out_data(IStorage{output_main});
out_interactive_data(IStorage{output_sub});
}
out_data(IStorage{output});
out_interactive_data(IStorage{output});
state(); state();
} else {
status = ResultCode(-1);
output_main[0] = 1;
complete = true;
out_data(IStorage{output_main});
state();
}
} }
} // namespace Service::AM::Applets } // namespace Service::AM::Applets