diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/frontend/applets/software_keyboard.cpp | 10 | ||||
| -rw-r--r-- | src/core/frontend/applets/software_keyboard.h | 5 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 34 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applets.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.cpp | 27 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.h | 3 |
6 files changed, 41 insertions, 44 deletions
diff --git a/src/core/frontend/applets/software_keyboard.cpp b/src/core/frontend/applets/software_keyboard.cpp index cf5e2ea31..2445a980d 100644 --- a/src/core/frontend/applets/software_keyboard.cpp +++ b/src/core/frontend/applets/software_keyboard.cpp | |||
| @@ -9,14 +9,12 @@ | |||
| 9 | namespace Core::Frontend { | 9 | namespace Core::Frontend { |
| 10 | SoftwareKeyboardApplet::~SoftwareKeyboardApplet() = default; | 10 | SoftwareKeyboardApplet::~SoftwareKeyboardApplet() = default; |
| 11 | 11 | ||
| 12 | bool DefaultSoftwareKeyboardApplet::GetText(SoftwareKeyboardParameters parameters, | 12 | std::optional<std::u16string> DefaultSoftwareKeyboardApplet::GetText( |
| 13 | std::u16string& text) const { | 13 | SoftwareKeyboardParameters parameters) const { |
| 14 | if (parameters.initial_text.empty()) | 14 | if (parameters.initial_text.empty()) |
| 15 | text = u"yuzu"; | 15 | return u"yuzu"; |
| 16 | else | ||
| 17 | text = parameters.initial_text; | ||
| 18 | 16 | ||
| 19 | return true; | 17 | return parameters.initial_text; |
| 20 | } | 18 | } |
| 21 | 19 | ||
| 22 | void DefaultSoftwareKeyboardApplet::SendTextCheckDialog(std::u16string error_message) const { | 20 | void DefaultSoftwareKeyboardApplet::SendTextCheckDialog(std::u16string error_message) const { |
diff --git a/src/core/frontend/applets/software_keyboard.h b/src/core/frontend/applets/software_keyboard.h index 0a82aac0d..7387ee8d7 100644 --- a/src/core/frontend/applets/software_keyboard.h +++ b/src/core/frontend/applets/software_keyboard.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <optional> | ||
| 7 | #include <string> | 8 | #include <string> |
| 8 | #include "common/bit_field.h" | 9 | #include "common/bit_field.h" |
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| @@ -35,13 +36,13 @@ class SoftwareKeyboardApplet { | |||
| 35 | public: | 36 | public: |
| 36 | virtual ~SoftwareKeyboardApplet(); | 37 | virtual ~SoftwareKeyboardApplet(); |
| 37 | 38 | ||
| 38 | virtual bool GetText(SoftwareKeyboardParameters parameters, std::u16string& text) const = 0; | 39 | virtual std::optional<std::u16string> GetText(SoftwareKeyboardParameters parameters) const = 0; |
| 39 | virtual void SendTextCheckDialog(std::u16string error_message) const = 0; | 40 | virtual void SendTextCheckDialog(std::u16string error_message) const = 0; |
| 40 | }; | 41 | }; |
| 41 | 42 | ||
| 42 | class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet { | 43 | class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet { |
| 43 | public: | 44 | public: |
| 44 | bool GetText(SoftwareKeyboardParameters parameters, std::u16string& text) const override; | 45 | std::optional<std::u16string> GetText(SoftwareKeyboardParameters parameters) const override; |
| 45 | void SendTextCheckDialog(std::u16string error_message) const override; | 46 | void SendTextCheckDialog(std::u16string error_message) const override; |
| 46 | }; | 47 | }; |
| 47 | 48 | ||
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 3201e2d4b..3f8d97d31 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -566,6 +566,16 @@ public: | |||
| 566 | } | 566 | } |
| 567 | 567 | ||
| 568 | private: | 568 | private: |
| 569 | void AppletStorageProxyOutData(IStorage storage) { | ||
| 570 | storage_stack.push_back(std::make_shared<IStorage>(storage)); | ||
| 571 | pop_out_data_event->Signal(); | ||
| 572 | } | ||
| 573 | |||
| 574 | void AppletStorageProxyOutInteractiveData(IStorage storage) { | ||
| 575 | interactive_storage_stack.push_back(std::make_shared<IStorage>(storage)); | ||
| 576 | pop_interactive_out_data_event->Signal(); | ||
| 577 | } | ||
| 578 | |||
| 569 | void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) { | 579 | void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) { |
| 570 | state_changed_event->Signal(); | 580 | state_changed_event->Signal(); |
| 571 | 581 | ||
| @@ -591,17 +601,11 @@ private: | |||
| 591 | ASSERT(applet != nullptr); | 601 | ASSERT(applet != nullptr); |
| 592 | 602 | ||
| 593 | applet->Initialize(storage_stack); | 603 | applet->Initialize(storage_stack); |
| 594 | const auto data = std::make_shared<IStorage>(applet->Execute()); | 604 | applet->Execute( |
| 605 | [this](IStorage storage) { AppletStorageProxyOutData(storage); }, | ||
| 606 | [this](IStorage storage) { AppletStorageProxyOutInteractiveData(storage); }); | ||
| 595 | state_changed_event->Signal(); | 607 | state_changed_event->Signal(); |
| 596 | 608 | ||
| 597 | if (applet->TransactionComplete()) { | ||
| 598 | storage_stack.push_back(data); | ||
| 599 | pop_out_data_event->Signal(); | ||
| 600 | } else { | ||
| 601 | interactive_storage_stack.push_back(data); | ||
| 602 | pop_interactive_out_data_event->Signal(); | ||
| 603 | } | ||
| 604 | |||
| 605 | IPC::ResponseBuilder rb{ctx, 2}; | 609 | IPC::ResponseBuilder rb{ctx, 2}; |
| 606 | rb.Push(RESULT_SUCCESS); | 610 | rb.Push(RESULT_SUCCESS); |
| 607 | } | 611 | } |
| @@ -632,17 +636,11 @@ private: | |||
| 632 | 636 | ||
| 633 | ASSERT(applet->IsInitialized()); | 637 | ASSERT(applet->IsInitialized()); |
| 634 | applet->ReceiveInteractiveData(interactive_storage_stack.back()); | 638 | applet->ReceiveInteractiveData(interactive_storage_stack.back()); |
| 635 | const auto data = std::make_shared<IStorage>(applet->Execute()); | 639 | applet->Execute( |
| 640 | [this](IStorage storage) { AppletStorageProxyOutData(storage); }, | ||
| 641 | [this](IStorage storage) { AppletStorageProxyOutInteractiveData(storage); }); | ||
| 636 | state_changed_event->Signal(); | 642 | state_changed_event->Signal(); |
| 637 | 643 | ||
| 638 | if (applet->TransactionComplete()) { | ||
| 639 | storage_stack.push_back(data); | ||
| 640 | pop_out_data_event->Signal(); | ||
| 641 | } else { | ||
| 642 | interactive_storage_stack.push_back(data); | ||
| 643 | pop_interactive_out_data_event->Signal(); | ||
| 644 | } | ||
| 645 | |||
| 646 | IPC::ResponseBuilder rb{ctx, 2}; | 644 | IPC::ResponseBuilder rb{ctx, 2}; |
| 647 | rb.Push(RESULT_SUCCESS); | 645 | rb.Push(RESULT_SUCCESS); |
| 648 | 646 | ||
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 6d90eb608..7fbaaf2f3 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <functional> | ||
| 7 | #include <memory> | 8 | #include <memory> |
| 8 | #include <vector> | 9 | #include <vector> |
| 9 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| @@ -20,6 +21,8 @@ class IStorage; | |||
| 20 | 21 | ||
| 21 | namespace Applets { | 22 | namespace Applets { |
| 22 | 23 | ||
| 24 | using AppletStorageProxyFunction = std::function<void(IStorage)>; | ||
| 25 | |||
| 23 | class Applet { | 26 | class Applet { |
| 24 | public: | 27 | public: |
| 25 | Applet(); | 28 | Applet(); |
| @@ -30,7 +33,8 @@ public: | |||
| 30 | virtual bool TransactionComplete() const = 0; | 33 | virtual bool TransactionComplete() const = 0; |
| 31 | virtual ResultCode GetStatus() const = 0; | 34 | virtual ResultCode GetStatus() const = 0; |
| 32 | virtual void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) = 0; | 35 | virtual void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) = 0; |
| 33 | virtual IStorage Execute() = 0; | 36 | virtual void Execute(AppletStorageProxyFunction out_data, |
| 37 | AppletStorageProxyFunction out_interactive_data) = 0; | ||
| 34 | 38 | ||
| 35 | bool IsInitialized() const { | 39 | bool IsInitialized() const { |
| 36 | return initialized; | 40 | return initialized; |
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp index 044a16264..7352f3bdf 100644 --- a/src/core/hle/service/am/applets/software_keyboard.cpp +++ b/src/core/hle/service/am/applets/software_keyboard.cpp | |||
| @@ -87,42 +87,37 @@ void SoftwareKeyboard::ReceiveInteractiveData(std::shared_ptr<IStorage> storage) | |||
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | IStorage SoftwareKeyboard::Execute() { | 90 | void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data, |
| 91 | AppletStorageProxyFunction out_interactive_data) { | ||
| 91 | if (complete) | 92 | if (complete) |
| 92 | return IStorage{final_data}; | 93 | return; |
| 93 | 94 | ||
| 94 | const auto& frontend{Core::System::GetInstance().GetSoftwareKeyboard()}; | 95 | const auto& frontend{Core::System::GetInstance().GetSoftwareKeyboard()}; |
| 95 | 96 | ||
| 96 | const auto parameters = ConvertToFrontendParameters(config, initial_text); | 97 | const auto parameters = ConvertToFrontendParameters(config, initial_text); |
| 97 | 98 | ||
| 98 | std::u16string text; | 99 | const auto res = frontend.GetText(parameters); |
| 99 | const auto success = frontend.GetText(parameters, text); | ||
| 100 | 100 | ||
| 101 | std::vector<u8> output(SWKBD_OUTPUT_BUFFER_SIZE); | 101 | std::vector<u8> output(SWKBD_OUTPUT_BUFFER_SIZE); |
| 102 | 102 | ||
| 103 | if (success) { | 103 | if (res.has_value()) { |
| 104 | if (config.text_check) { | 104 | if (config.text_check) { |
| 105 | const auto size = static_cast<u32>(text.size() * 2 + 4); | 105 | const auto size = static_cast<u32>(res->size() * 2 + 4); |
| 106 | std::memcpy(output.data(), &size, sizeof(u32)); | 106 | std::memcpy(output.data(), &size, sizeof(u32)); |
| 107 | } else { | 107 | } else { |
| 108 | output[0] = 1; | 108 | output[0] = 1; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | std::memcpy(output.data() + 4, text.data(), | 111 | std::memcpy(output.data() + 4, res->data(), |
| 112 | std::min(text.size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4)); | 112 | std::min(res->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4)); |
| 113 | } else { | 113 | } else { |
| 114 | complete = true; | 114 | complete = true; |
| 115 | final_data = std::move(output); | 115 | out_data(IStorage{output}); |
| 116 | return IStorage{final_data}; | 116 | return; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | complete = !config.text_check; | 119 | complete = !config.text_check; |
| 120 | 120 | ||
| 121 | if (complete) { | 121 | (complete ? out_data : out_interactive_data)(IStorage{output}); |
| 122 | final_data = std::move(output); | ||
| 123 | return IStorage{final_data}; | ||
| 124 | } | ||
| 125 | |||
| 126 | return IStorage{output}; | ||
| 127 | } | 122 | } |
| 128 | } // namespace Service::AM::Applets | 123 | } // namespace Service::AM::Applets |
diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h index 9d77f5802..66de4bc59 100644 --- a/src/core/hle/service/am/applets/software_keyboard.h +++ b/src/core/hle/service/am/applets/software_keyboard.h | |||
| @@ -54,7 +54,8 @@ public: | |||
| 54 | bool TransactionComplete() const override; | 54 | bool TransactionComplete() const override; |
| 55 | ResultCode GetStatus() const override; | 55 | ResultCode GetStatus() const override; |
| 56 | void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) override; | 56 | void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) override; |
| 57 | IStorage Execute() override; | 57 | void Execute(AppletStorageProxyFunction out_data, |
| 58 | AppletStorageProxyFunction out_interactive_data) override; | ||
| 58 | 59 | ||
| 59 | private: | 60 | private: |
| 60 | KeyboardConfig config; | 61 | KeyboardConfig config; |