diff options
| author | 2021-11-10 13:42:11 +0100 | |
|---|---|---|
| committer | 2021-11-10 13:42:11 +0100 | |
| commit | bdabd17c765a9f8372e838368e2a7d6567bee052 (patch) | |
| tree | fc34ff9929b59a913f2c555dcf8067fff5c9e5bf /src/core | |
| parent | service/pctl: Stub EndFreeCommunication (diff) | |
| parent | applets/swkbd: Fix text check message encoding (diff) | |
| download | yuzu-bdabd17c765a9f8372e838368e2a7d6567bee052.tar.gz yuzu-bdabd17c765a9f8372e838368e2a7d6567bee052.tar.xz yuzu-bdabd17c765a9f8372e838368e2a7d6567bee052.zip | |
Merge pull request #7303 from Morph1984/swkbd-confirm-skip-textcheck
applets/swkbd: Skip text checking if the text has been confirmed
Diffstat (limited to 'src/core')
4 files changed, 36 insertions, 20 deletions
diff --git a/src/core/frontend/applets/software_keyboard.cpp b/src/core/frontend/applets/software_keyboard.cpp index 12c76c9ee..c4863ee73 100644 --- a/src/core/frontend/applets/software_keyboard.cpp +++ b/src/core/frontend/applets/software_keyboard.cpp | |||
| @@ -16,7 +16,8 @@ DefaultSoftwareKeyboardApplet::~DefaultSoftwareKeyboardApplet() = default; | |||
| 16 | 16 | ||
| 17 | void DefaultSoftwareKeyboardApplet::InitializeKeyboard( | 17 | void DefaultSoftwareKeyboardApplet::InitializeKeyboard( |
| 18 | bool is_inline, KeyboardInitializeParameters initialize_parameters, | 18 | bool is_inline, KeyboardInitializeParameters initialize_parameters, |
| 19 | std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> submit_normal_callback_, | 19 | std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)> |
| 20 | submit_normal_callback_, | ||
| 20 | std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> | 21 | std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> |
| 21 | submit_inline_callback_) { | 22 | submit_inline_callback_) { |
| 22 | if (is_inline) { | 23 | if (is_inline) { |
| @@ -128,7 +129,7 @@ void DefaultSoftwareKeyboardApplet::ExitKeyboard() const { | |||
| 128 | } | 129 | } |
| 129 | 130 | ||
| 130 | void DefaultSoftwareKeyboardApplet::SubmitNormalText(std::u16string text) const { | 131 | void DefaultSoftwareKeyboardApplet::SubmitNormalText(std::u16string text) const { |
| 131 | submit_normal_callback(Service::AM::Applets::SwkbdResult::Ok, text); | 132 | submit_normal_callback(Service::AM::Applets::SwkbdResult::Ok, text, true); |
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | void DefaultSoftwareKeyboardApplet::SubmitInlineText(std::u16string_view text) const { | 135 | void DefaultSoftwareKeyboardApplet::SubmitInlineText(std::u16string_view text) const { |
diff --git a/src/core/frontend/applets/software_keyboard.h b/src/core/frontend/applets/software_keyboard.h index 29109306b..490c55cc2 100644 --- a/src/core/frontend/applets/software_keyboard.h +++ b/src/core/frontend/applets/software_keyboard.h | |||
| @@ -57,7 +57,7 @@ public: | |||
| 57 | 57 | ||
| 58 | virtual void InitializeKeyboard( | 58 | virtual void InitializeKeyboard( |
| 59 | bool is_inline, KeyboardInitializeParameters initialize_parameters, | 59 | bool is_inline, KeyboardInitializeParameters initialize_parameters, |
| 60 | std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> | 60 | std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)> |
| 61 | submit_normal_callback_, | 61 | submit_normal_callback_, |
| 62 | std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> | 62 | std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> |
| 63 | submit_inline_callback_) = 0; | 63 | submit_inline_callback_) = 0; |
| @@ -82,7 +82,7 @@ public: | |||
| 82 | 82 | ||
| 83 | void InitializeKeyboard( | 83 | void InitializeKeyboard( |
| 84 | bool is_inline, KeyboardInitializeParameters initialize_parameters, | 84 | bool is_inline, KeyboardInitializeParameters initialize_parameters, |
| 85 | std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> | 85 | std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)> |
| 86 | submit_normal_callback_, | 86 | submit_normal_callback_, |
| 87 | std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> | 87 | std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> |
| 88 | submit_inline_callback_) override; | 88 | submit_inline_callback_) override; |
| @@ -106,7 +106,7 @@ private: | |||
| 106 | 106 | ||
| 107 | KeyboardInitializeParameters parameters; | 107 | KeyboardInitializeParameters parameters; |
| 108 | 108 | ||
| 109 | mutable std::function<void(Service::AM::Applets::SwkbdResult, std::u16string)> | 109 | mutable std::function<void(Service::AM::Applets::SwkbdResult, std::u16string, bool)> |
| 110 | submit_normal_callback; | 110 | submit_normal_callback; |
| 111 | mutable std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> | 111 | mutable std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)> |
| 112 | submit_inline_callback; | 112 | submit_inline_callback; |
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.cpp b/src/core/hle/service/am/applets/applet_software_keyboard.cpp index c89aa1bbf..f38f53f69 100644 --- a/src/core/hle/service/am/applets/applet_software_keyboard.cpp +++ b/src/core/hle/service/am/applets/applet_software_keyboard.cpp | |||
| @@ -109,13 +109,18 @@ void SoftwareKeyboard::Execute() { | |||
| 109 | ShowNormalKeyboard(); | 109 | ShowNormalKeyboard(); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | void SoftwareKeyboard::SubmitTextNormal(SwkbdResult result, std::u16string submitted_text) { | 112 | void SoftwareKeyboard::SubmitTextNormal(SwkbdResult result, std::u16string submitted_text, |
| 113 | bool confirmed) { | ||
| 113 | if (complete) { | 114 | if (complete) { |
| 114 | return; | 115 | return; |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | if (swkbd_config_common.use_text_check && result == SwkbdResult::Ok) { | 118 | if (swkbd_config_common.use_text_check && result == SwkbdResult::Ok) { |
| 118 | SubmitForTextCheck(submitted_text); | 119 | if (confirmed) { |
| 120 | SubmitNormalOutputAndExit(result, submitted_text); | ||
| 121 | } else { | ||
| 122 | SubmitForTextCheck(submitted_text); | ||
| 123 | } | ||
| 119 | } else { | 124 | } else { |
| 120 | SubmitNormalOutputAndExit(result, submitted_text); | 125 | SubmitNormalOutputAndExit(result, submitted_text); |
| 121 | } | 126 | } |
| @@ -273,13 +278,21 @@ void SoftwareKeyboard::ProcessTextCheck() { | |||
| 273 | 278 | ||
| 274 | std::memcpy(&swkbd_text_check, text_check_data.data(), sizeof(SwkbdTextCheck)); | 279 | std::memcpy(&swkbd_text_check, text_check_data.data(), sizeof(SwkbdTextCheck)); |
| 275 | 280 | ||
| 276 | std::u16string text_check_message = | 281 | std::u16string text_check_message = [this, &swkbd_text_check]() -> std::u16string { |
| 277 | swkbd_text_check.text_check_result == SwkbdTextCheckResult::Failure || | 282 | if (swkbd_text_check.text_check_result == SwkbdTextCheckResult::Failure || |
| 278 | swkbd_text_check.text_check_result == SwkbdTextCheckResult::Confirm | 283 | swkbd_text_check.text_check_result == SwkbdTextCheckResult::Confirm) { |
| 279 | ? Common::UTF16StringFromFixedZeroTerminatedBuffer( | 284 | return swkbd_config_common.use_utf8 |
| 280 | swkbd_text_check.text_check_message.data(), | 285 | ? Common::UTF8ToUTF16(Common::StringFromFixedZeroTerminatedBuffer( |
| 281 | swkbd_text_check.text_check_message.size()) | 286 | reinterpret_cast<const char*>( |
| 282 | : u""; | 287 | swkbd_text_check.text_check_message.data()), |
| 288 | swkbd_text_check.text_check_message.size() * sizeof(char16_t))) | ||
| 289 | : Common::UTF16StringFromFixedZeroTerminatedBuffer( | ||
| 290 | swkbd_text_check.text_check_message.data(), | ||
| 291 | swkbd_text_check.text_check_message.size()); | ||
| 292 | } else { | ||
| 293 | return u""; | ||
| 294 | } | ||
| 295 | }(); | ||
| 283 | 296 | ||
| 284 | LOG_INFO(Service_AM, "\nTextCheckResult: {}\nTextCheckMessage: {}", | 297 | LOG_INFO(Service_AM, "\nTextCheckResult: {}\nTextCheckMessage: {}", |
| 285 | GetTextCheckResultName(swkbd_text_check.text_check_result), | 298 | GetTextCheckResultName(swkbd_text_check.text_check_result), |
| @@ -583,11 +596,12 @@ void SoftwareKeyboard::InitializeFrontendKeyboard() { | |||
| 583 | .disable_cancel_button{disable_cancel_button}, | 596 | .disable_cancel_button{disable_cancel_button}, |
| 584 | }; | 597 | }; |
| 585 | 598 | ||
| 586 | frontend.InitializeKeyboard(false, std::move(initialize_parameters), | 599 | frontend.InitializeKeyboard( |
| 587 | [this](SwkbdResult result, std::u16string submitted_text) { | 600 | false, std::move(initialize_parameters), |
| 588 | SubmitTextNormal(result, submitted_text); | 601 | [this](SwkbdResult result, std::u16string submitted_text, bool confirmed) { |
| 589 | }, | 602 | SubmitTextNormal(result, submitted_text, confirmed); |
| 590 | {}); | 603 | }, |
| 604 | {}); | ||
| 591 | } | 605 | } |
| 592 | } | 606 | } |
| 593 | 607 | ||
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.h b/src/core/hle/service/am/applets/applet_software_keyboard.h index 6009c10c7..a0fddd965 100644 --- a/src/core/hle/service/am/applets/applet_software_keyboard.h +++ b/src/core/hle/service/am/applets/applet_software_keyboard.h | |||
| @@ -36,8 +36,9 @@ public: | |||
| 36 | * | 36 | * |
| 37 | * @param result SwkbdResult enum | 37 | * @param result SwkbdResult enum |
| 38 | * @param submitted_text UTF-16 encoded string | 38 | * @param submitted_text UTF-16 encoded string |
| 39 | * @param confirmed Whether the text has been confirmed after TextCheckResult::Confirm | ||
| 39 | */ | 40 | */ |
| 40 | void SubmitTextNormal(SwkbdResult result, std::u16string submitted_text); | 41 | void SubmitTextNormal(SwkbdResult result, std::u16string submitted_text, bool confirmed); |
| 41 | 42 | ||
| 42 | /** | 43 | /** |
| 43 | * Submits the input text to the application. | 44 | * Submits the input text to the application. |