From 17ba846a3fd7581484c98c6f20ba61751bd23108 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Sun, 1 Dec 2019 23:00:09 +0800 Subject: [PATCH] applets/swkbd: Remove text memory clearing The text shared memory wasn't supposed to be cleared according to my comparison with the LLE swkbd. This can cause issues in certain games such as Harvest Moon. A null terminator is added to the text copied to mark the end of the string. --- src/core/hle/applets/swkbd.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp index 74a542df4..7481a168c 100644 --- a/src/core/hle/applets/swkbd.cpp +++ b/src/core/hle/applets/swkbd.cpp @@ -99,9 +99,6 @@ ResultCode SoftwareKeyboard::StartImpl(Service::APT::AppletStartupParameter cons memcpy(&config, parameter.buffer.data(), parameter.buffer.size()); text_memory = std::static_pointer_cast(parameter.object); - // TODO(Subv): Verify if this is the correct behavior - memset(text_memory->GetPointer(), 0, text_memory->GetSize()); - DrawScreenKeyboard(); using namespace Frontend; @@ -121,7 +118,8 @@ void SoftwareKeyboard::Update() { using namespace Frontend; const KeyboardData& data = frontend_applet->ReceiveData(); std::u16string text = Common::UTF8ToUTF16(data.text); - memcpy(text_memory->GetPointer(), text.c_str(), text.length() * sizeof(char16_t)); + // Include a null terminator + memcpy(text_memory->GetPointer(), text.c_str(), (text.length() + 1) * sizeof(char16_t)); switch (config.num_buttons_m1) { case SoftwareKeyboardButtonConfig::SingleButton: config.return_code = SoftwareKeyboardResult::D0Click;