diff options
| author | 2018-11-18 23:14:48 -0500 | |
|---|---|---|
| committer | 2018-11-18 23:14:48 -0500 | |
| commit | ea680bea60ac772a80c797365edaa7c86ab8459a (patch) | |
| tree | 7890eee3eea0fb3d5b709e3cbcc9af37f9f71ce5 | |
| parent | software_keyboard: Add max and current length display to dialog (diff) | |
| download | yuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.tar.gz yuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.tar.xz yuzu-ea680bea60ac772a80c797365edaa7c86ab8459a.zip | |
software_keyboard: Check for UTF-8 config flag
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.cpp | 29 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.h | 3 |
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) { | |||
| 120 | std::vector<u8> output_sub(SWKBD_OUTPUT_BUFFER_SIZE); | 120 | std::vector<u8> output_sub(SWKBD_OUTPUT_BUFFER_SIZE); |
| 121 | status = RESULT_SUCCESS; | 121 | status = RESULT_SUCCESS; |
| 122 | 122 | ||
| 123 | const u64 size = text->size() * 2 + 8; | 123 | if (config.utf_8) { |
| 124 | std::memcpy(output_sub.data(), &size, sizeof(u64)); | 124 | const u64 size = text->size() + 8; |
| 125 | std::memcpy(output_sub.data() + 8, text->data(), | 125 | const auto new_text = Common::UTF16ToUTF8(*text); |
| 126 | std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 8)); | 126 | |
| 127 | 127 | std::memcpy(output_sub.data(), &size, sizeof(u64)); | |
| 128 | output_main[0] = config.text_check; | 128 | std::memcpy(output_sub.data() + 8, new_text.data(), |
| 129 | std::memcpy(output_main.data() + 4, text->data(), | 129 | std::min(new_text.size(), SWKBD_OUTPUT_BUFFER_SIZE - 8)); |
| 130 | std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4)); | 130 | |
| 131 | output_main[0] = config.text_check; | ||
| 132 | std::memcpy(output_main.data() + 4, new_text.data(), | ||
| 133 | std::min(new_text.size(), SWKBD_OUTPUT_BUFFER_SIZE - 4)); | ||
| 134 | } else { | ||
| 135 | const u64 size = text->size() * 2 + 8; | ||
| 136 | std::memcpy(output_sub.data(), &size, sizeof(u64)); | ||
| 137 | std::memcpy(output_sub.data() + 8, text->data(), | ||
| 138 | std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 8)); | ||
| 139 | |||
| 140 | output_main[0] = config.text_check; | ||
| 141 | std::memcpy(output_main.data() + 4, text->data(), | ||
| 142 | std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4)); | ||
| 143 | } | ||
| 131 | 144 | ||
| 132 | complete = !config.text_check; | 145 | complete = !config.text_check; |
| 133 | final_data = output_main; | 146 | 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 { | |||
| 33 | u32_le length_limit; | 33 | u32_le length_limit; |
| 34 | INSERT_PADDING_BYTES(4); | 34 | INSERT_PADDING_BYTES(4); |
| 35 | u32_le is_password; | 35 | u32_le is_password; |
| 36 | INSERT_PADDING_BYTES(6); | 36 | INSERT_PADDING_BYTES(5); |
| 37 | bool utf_8; | ||
| 37 | bool draw_background; | 38 | bool draw_background; |
| 38 | u32_le initial_string_offset; | 39 | u32_le initial_string_offset; |
| 39 | u32_le initial_string_size; | 40 | u32_le initial_string_size; |