summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-11-16 22:20:09 -0500
committerGravatar Zach Hilman2018-11-18 10:53:47 -0500
commit6209fe0c27a5557c20ff6350a94f6e074e0285dc (patch)
tree31157e18ae9d17cac100aac80b371aae6cc84faf /src
parentsoftware_keyboard: Make GetText asynchronous (diff)
downloadyuzu-6209fe0c27a5557c20ff6350a94f6e074e0285dc.tar.gz
yuzu-6209fe0c27a5557c20ff6350a94f6e074e0285dc.tar.xz
yuzu-6209fe0c27a5557c20ff6350a94f6e074e0285dc.zip
software_keyboard: Push buffer size to offset 0x4 in output data
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/am/am.cpp30
-rw-r--r--src/core/hle/service/am/applets/applets.h4
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.cpp18
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.h5
4 files changed, 39 insertions, 18 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index d040d4776..470253ef1 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -583,31 +583,38 @@ private:
583 rb.Push(RESULT_SUCCESS); 583 rb.Push(RESULT_SUCCESS);
584 rb.PushCopyObjects(state_changed_event); 584 rb.PushCopyObjects(state_changed_event);
585 585
586 LOG_WARNING(Service_AM, "(STUBBED) called"); 586 LOG_DEBUG(Service_AM, "called");
587 } 587 }
588 588
589 void IsCompleted(Kernel::HLERequestContext& ctx) { 589 void IsCompleted(Kernel::HLERequestContext& ctx) {
590 IPC::ResponseBuilder rb{ctx, 3}; 590 IPC::ResponseBuilder rb{ctx, 3};
591 rb.Push(RESULT_SUCCESS); 591 rb.Push(RESULT_SUCCESS);
592 rb.Push<u32>(applet->TransactionComplete()); 592 rb.Push<u32>(applet->TransactionComplete());
593
594 LOG_DEBUG(Service_AM, "called");
593 } 595 }
594 596
595 void GetResult(Kernel::HLERequestContext& ctx) { 597 void GetResult(Kernel::HLERequestContext& ctx) {
596 IPC::ResponseBuilder rb{ctx, 2}; 598 IPC::ResponseBuilder rb{ctx, 2};
597 rb.Push(applet->GetStatus()); 599 rb.Push(applet->GetStatus());
600
601 LOG_DEBUG(Service_AM, "called");
598 } 602 }
599 603
600 void Start(Kernel::HLERequestContext& ctx) { 604 void Start(Kernel::HLERequestContext& ctx) {
601 ASSERT(applet != nullptr); 605 ASSERT(applet != nullptr);
602 606
603 applet->Initialize(storage_stack); 607 applet->Initialize(storage_stack);
604 applet->Execute( 608 storage_stack.clear();
605 [this](IStorage storage) { AppletStorageProxyOutData(storage); }, 609 interactive_storage_stack.clear();
606 [this](IStorage storage) { AppletStorageProxyOutInteractiveData(storage); }); 610 applet->Execute([this](IStorage storage) { AppletStorageProxyOutData(storage); },
607 state_changed_event->Signal(); 611 [this](IStorage storage) { AppletStorageProxyOutInteractiveData(storage); },
612 [this] { state_changed_event->Signal(); });
608 613
609 IPC::ResponseBuilder rb{ctx, 2}; 614 IPC::ResponseBuilder rb{ctx, 2};
610 rb.Push(RESULT_SUCCESS); 615 rb.Push(RESULT_SUCCESS);
616
617 LOG_DEBUG(Service_AM, "called");
611 } 618 }
612 619
613 void PushInData(Kernel::HLERequestContext& ctx) { 620 void PushInData(Kernel::HLERequestContext& ctx) {
@@ -636,10 +643,9 @@ private:
636 643
637 ASSERT(applet->IsInitialized()); 644 ASSERT(applet->IsInitialized());
638 applet->ReceiveInteractiveData(interactive_storage_stack.back()); 645 applet->ReceiveInteractiveData(interactive_storage_stack.back());
639 applet->Execute( 646 applet->Execute([this](IStorage storage) { AppletStorageProxyOutData(storage); },
640 [this](IStorage storage) { AppletStorageProxyOutData(storage); }, 647 [this](IStorage storage) { AppletStorageProxyOutInteractiveData(storage); },
641 [this](IStorage storage) { AppletStorageProxyOutInteractiveData(storage); }); 648 [this] { state_changed_event->Signal(); });
642 state_changed_event->Signal();
643 649
644 IPC::ResponseBuilder rb{ctx, 2}; 650 IPC::ResponseBuilder rb{ctx, 2};
645 rb.Push(RESULT_SUCCESS); 651 rb.Push(RESULT_SUCCESS);
@@ -661,6 +667,8 @@ private:
661 IPC::ResponseBuilder rb{ctx, 2, 1}; 667 IPC::ResponseBuilder rb{ctx, 2, 1};
662 rb.Push(RESULT_SUCCESS); 668 rb.Push(RESULT_SUCCESS);
663 rb.PushCopyObjects(pop_out_data_event); 669 rb.PushCopyObjects(pop_out_data_event);
670
671 LOG_DEBUG(Service_AM, "called");
664 } 672 }
665 673
666 void GetPopInteractiveOutDataEvent(Kernel::HLERequestContext& ctx) { 674 void GetPopInteractiveOutDataEvent(Kernel::HLERequestContext& ctx) {
@@ -668,7 +676,7 @@ private:
668 rb.Push(RESULT_SUCCESS); 676 rb.Push(RESULT_SUCCESS);
669 rb.PushCopyObjects(pop_interactive_out_data_event); 677 rb.PushCopyObjects(pop_interactive_out_data_event);
670 678
671 LOG_WARNING(Service_AM, "(STUBBED) called"); 679 LOG_DEBUG(Service_AM, "called");
672 } 680 }
673 681
674 std::shared_ptr<Applets::Applet> applet; 682 std::shared_ptr<Applets::Applet> applet;
@@ -734,7 +742,7 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
734 const u64 offset{rp.Pop<u64>()}; 742 const u64 offset{rp.Pop<u64>()};
735 std::size_t size{ctx.GetWriteBufferSize()}; 743 std::size_t size{ctx.GetWriteBufferSize()};
736 744
737 size = std::min(size, backing.buffer.size() - offset); 745 size = std::min<std::size_t>(size, backing.buffer.size() - offset);
738 746
739 ctx.WriteBuffer(backing.buffer.data() + offset, size); 747 ctx.WriteBuffer(backing.buffer.data() + offset, size);
740 748
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h
index 7fbaaf2f3..1ffa09420 100644
--- a/src/core/hle/service/am/applets/applets.h
+++ b/src/core/hle/service/am/applets/applets.h
@@ -22,6 +22,7 @@ class IStorage;
22namespace Applets { 22namespace Applets {
23 23
24using AppletStorageProxyFunction = std::function<void(IStorage)>; 24using AppletStorageProxyFunction = std::function<void(IStorage)>;
25using AppletStateProxyFunction = std::function<void()>;
25 26
26class Applet { 27class Applet {
27public: 28public:
@@ -34,7 +35,8 @@ public:
34 virtual ResultCode GetStatus() const = 0; 35 virtual ResultCode GetStatus() const = 0;
35 virtual void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) = 0; 36 virtual void ReceiveInteractiveData(std::shared_ptr<IStorage> storage) = 0;
36 virtual void Execute(AppletStorageProxyFunction out_data, 37 virtual void Execute(AppletStorageProxyFunction out_data,
37 AppletStorageProxyFunction out_interactive_data) = 0; 38 AppletStorageProxyFunction out_interactive_data,
39 AppletStateProxyFunction state) = 0;
38 40
39 bool IsInitialized() const { 41 bool IsInitialized() const {
40 return initialized; 42 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 66b34d5ac..bb28a2e8d 100644
--- a/src/core/hle/service/am/applets/software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/software_keyboard.cpp
@@ -69,7 +69,7 @@ bool SoftwareKeyboard::TransactionComplete() const {
69} 69}
70 70
71ResultCode SoftwareKeyboard::GetStatus() const { 71ResultCode SoftwareKeyboard::GetStatus() const {
72 return RESULT_SUCCESS; 72 return status;
73} 73}
74 74
75void SoftwareKeyboard::ReceiveInteractiveData(std::shared_ptr<IStorage> storage) { 75void SoftwareKeyboard::ReceiveInteractiveData(std::shared_ptr<IStorage> storage) {
@@ -92,7 +92,8 @@ void SoftwareKeyboard::ReceiveInteractiveData(std::shared_ptr<IStorage> storage)
92} 92}
93 93
94void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data, 94void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data,
95 AppletStorageProxyFunction out_interactive_data) { 95 AppletStorageProxyFunction out_interactive_data,
96 AppletStateProxyFunction state) {
96 if (complete) 97 if (complete)
97 return; 98 return;
98 99
@@ -102,6 +103,7 @@ void SoftwareKeyboard::Execute(AppletStorageProxyFunction out_data,
102 103
103 this->out_data = out_data; 104 this->out_data = out_data;
104 this->out_interactive_data = out_interactive_data; 105 this->out_interactive_data = out_interactive_data;
106 this->state = state;
105 frontend.RequestText([this](std::optional<std::u16string> text) { WriteText(text); }, 107 frontend.RequestText([this](std::optional<std::u16string> text) { WriteText(text); },
106 parameters); 108 parameters);
107} 109}
@@ -110,6 +112,7 @@ void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) {
110 std::vector<u8> output(SWKBD_OUTPUT_BUFFER_SIZE); 112 std::vector<u8> output(SWKBD_OUTPUT_BUFFER_SIZE);
111 113
112 if (text.has_value()) { 114 if (text.has_value()) {
115 status = RESULT_SUCCESS;
113 if (config.text_check) { 116 if (config.text_check) {
114 const auto size = static_cast<u32>(text->size() * 2 + 4); 117 const auto size = static_cast<u32>(text->size() * 2 + 4);
115 std::memcpy(output.data(), &size, sizeof(u32)); 118 std::memcpy(output.data(), &size, sizeof(u32));
@@ -117,9 +120,12 @@ void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) {
117 output[0] = 1; 120 output[0] = 1;
118 } 121 }
119 122
120 std::memcpy(output.data() + 4, text->data(), 123 const auto size = static_cast<u32>(text->size());
121 std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 4)); 124 std::memcpy(output.data() + 4, &size, sizeof(u32));
125 std::memcpy(output.data() + 8, text->data(),
126 std::min(text->size() * 2, SWKBD_OUTPUT_BUFFER_SIZE - 8));
122 } else { 127 } else {
128 status = ResultCode(-1);
123 complete = true; 129 complete = true;
124 out_data(IStorage{output}); 130 out_data(IStorage{output});
125 return; 131 return;
@@ -127,6 +133,8 @@ void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) {
127 133
128 complete = !config.text_check; 134 complete = !config.text_check;
129 135
130 (complete ? out_data : out_interactive_data)(IStorage{output}); 136 out_data(IStorage{output});
137 out_interactive_data(IStorage{output});
138 state();
131} 139}
132} // namespace Service::AM::Applets 140} // 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 b08bff3d7..9629f6408 100644
--- a/src/core/hle/service/am/applets/software_keyboard.h
+++ b/src/core/hle/service/am/applets/software_keyboard.h
@@ -55,7 +55,8 @@ public:
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 void Execute(AppletStorageProxyFunction out_data, 57 void Execute(AppletStorageProxyFunction out_data,
58 AppletStorageProxyFunction out_interactive_data) override; 58 AppletStorageProxyFunction out_interactive_data,
59 AppletStateProxyFunction state) override;
59 60
60 void WriteText(std::optional<std::u16string> text); 61 void WriteText(std::optional<std::u16string> text);
61 62
@@ -64,9 +65,11 @@ private:
64 std::u16string initial_text; 65 std::u16string initial_text;
65 bool complete = false; 66 bool complete = false;
66 std::vector<u8> final_data; 67 std::vector<u8> final_data;
68 ResultCode status = ResultCode(-1);
67 69
68 AppletStorageProxyFunction out_data; 70 AppletStorageProxyFunction out_data;
69 AppletStorageProxyFunction out_interactive_data; 71 AppletStorageProxyFunction out_interactive_data;
72 AppletStateProxyFunction state;
70}; 73};
71 74
72} // namespace Service::AM::Applets 75} // namespace Service::AM::Applets