summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-11-19 05:14:48 +0100
committerZach Hilman <zachhilman@gmail.com>2018-11-19 05:14:48 +0100
commitea680bea60ac772a80c797365edaa7c86ab8459a (patch)
tree7890eee3eea0fb3d5b709e3cbcc9af37f9f71ce5 /src/core/hle
parentsoftware_keyboard: Add max and current length display to dialog (diff)
downloadyuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.tar
yuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.tar.gz
yuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.tar.bz2
yuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.tar.lz
yuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.tar.xz
yuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.tar.zst
yuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.zip
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.cpp29
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.h3
2 files changed, 23 insertions, 9 deletions
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp
index 5661cc98d..0ef052be6 100644
--- a/src/core/hle/service/am/applets/software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/software_keyboard.cpp
@@ -120,14 +120,27 @@ void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) {
std::vector<u8> output_sub(SWKBD_OUTPUT_BUFFER_SIZE);
status = RESULT_SUCCESS;
- 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));
+ if (config.utf_8) {
+ const u64 size = text->size() + 8;
+ const auto new_text = Common::UTF16ToUTF8(*text);
+
+ std::memcpy(output_sub.data(), &size, sizeof(u64));
+ std::memcpy(output_sub.data() + 8, new_text.data(),
+ std::min(new_text.size(), SWKBD_OUTPUT_BUFFER_SIZE - 8));
+
+ output_main[0] = config.text_check;
+ std::memcpy(output_main.data() + 4, new_text.data(),
+ std::min(new_text.size(), SWKBD_OUTPUT_BUFFER_SIZE - 4));
+ } else {
+ 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;
diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h
index 9544d6b1b..e0a9479c2 100644
--- a/src/core/hle/service/am/applets/software_keyboard.h
+++ b/src/core/hle/service/am/applets/software_keyboard.h
@@ -33,7 +33,8 @@ struct KeyboardConfig {
u32_le length_limit;
INSERT_PADDING_BYTES(4);
u32_le is_password;
- INSERT_PADDING_BYTES(6);
+ INSERT_PADDING_BYTES(5);
+ bool utf_8;
bool draw_background;
u32_le initial_string_offset;
u32_le initial_string_size;