From 19b2571aecfff680c7a414c505eafc26264b6f2f Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 17 Nov 2018 12:18:03 -0500 Subject: [PATCH] applet: Add operation completed callback --- src/core/frontend/applets/software_keyboard.cpp | 4 +++- src/core/frontend/applets/software_keyboard.h | 6 ++++-- src/core/hle/service/am/am.cpp | 6 ++++-- .../hle/service/am/applets/software_keyboard.cpp | 2 +- src/yuzu/applets/software_keyboard.cpp | 14 +++++++++++++- src/yuzu/applets/software_keyboard.h | 5 ++++- src/yuzu/main.cpp | 5 ++++- src/yuzu/main.h | 1 + 8 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/core/frontend/applets/software_keyboard.cpp b/src/core/frontend/applets/software_keyboard.cpp index 4105101b36..856ed33da5 100644 --- a/src/core/frontend/applets/software_keyboard.cpp +++ b/src/core/frontend/applets/software_keyboard.cpp @@ -18,10 +18,12 @@ void DefaultSoftwareKeyboardApplet::RequestText( out(parameters.initial_text); } -void DefaultSoftwareKeyboardApplet::SendTextCheckDialog(std::u16string error_message) const { +void DefaultSoftwareKeyboardApplet::SendTextCheckDialog( + std::u16string error_message, std::function finished_check) const { LOG_WARNING(Service_AM, "(STUBBED) called - Default fallback software keyboard does not support text " "check! (error_message={})", Common::UTF16ToUTF8(error_message)); + finished_check(); } } // namespace Core::Frontend diff --git a/src/core/frontend/applets/software_keyboard.h b/src/core/frontend/applets/software_keyboard.h index 5420ea8833..f9b2026642 100644 --- a/src/core/frontend/applets/software_keyboard.h +++ b/src/core/frontend/applets/software_keyboard.h @@ -39,14 +39,16 @@ public: virtual void RequestText(std::function)> out, SoftwareKeyboardParameters parameters) const = 0; - virtual void SendTextCheckDialog(std::u16string error_message) const = 0; + virtual void SendTextCheckDialog(std::u16string error_message, + std::function finished_check) const = 0; }; class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet { public: void RequestText(std::function)> out, SoftwareKeyboardParameters parameters) const override; - void SendTextCheckDialog(std::u16string error_message) const override; + void SendTextCheckDialog(std::u16string error_message, + std::function finished_check) const override; }; } // namespace Core::Frontend diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 470253ef1d..5cbcb8d91b 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -605,8 +605,10 @@ private: ASSERT(applet != nullptr); applet->Initialize(storage_stack); - storage_stack.clear(); - interactive_storage_stack.clear(); + while (!storage_stack.empty()) + storage_stack.pop(); + while (!interactive_storage_stack.empty()) + interactive_storage_stack.pop(); applet->Execute([this](IStorage storage) { AppletStorageProxyOutData(storage); }, [this](IStorage storage) { AppletStorageProxyOutInteractiveData(storage); }, [this] { state_changed_event->Signal(); }); diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp index bb28a2e8db..039bfcc0f0 100644 --- a/src/core/hle/service/am/applets/software_keyboard.cpp +++ b/src/core/hle/service/am/applets/software_keyboard.cpp @@ -87,7 +87,7 @@ void SoftwareKeyboard::ReceiveInteractiveData(std::shared_ptr storage) std::array string; std::memcpy(string.data(), data.data() + 4, string.size() * 2); frontend.SendTextCheckDialog( - Common::UTF16StringFromFixedZeroTerminatedBuffer(string.data(), string.size())); + Common::UTF16StringFromFixedZeroTerminatedBuffer(string.data(), string.size()), state); } } diff --git a/src/yuzu/applets/software_keyboard.cpp b/src/yuzu/applets/software_keyboard.cpp index 9fb179f5c0..83b9c320be 100644 --- a/src/yuzu/applets/software_keyboard.cpp +++ b/src/yuzu/applets/software_keyboard.cpp @@ -3,11 +3,13 @@ // Refer to the license.txt file included. #include +#include #include #include #include #include #include +#include "core/hle/lock.h" #include "yuzu/applets/software_keyboard.h" #include "yuzu/main.h" @@ -122,10 +124,20 @@ void QtSoftwareKeyboard::RequestText(std::function finished_check) const { + this->finished_check = finished_check; emit MainWindowTextCheckDialog(error_message); } void QtSoftwareKeyboard::MainWindowFinishedText(std::optional text) { + // Acquire the HLE mutex + std::lock_guard lock(HLE::g_hle_lock); text_output(text); } + +void QtSoftwareKeyboard::MainWindowFinishedCheckDialog() { + // Acquire the HLE mutex + std::lock_guard lock(HLE::g_hle_lock); + finished_check(); +} diff --git a/src/yuzu/applets/software_keyboard.h b/src/yuzu/applets/software_keyboard.h index 670b05dc98..8d56f5db2e 100644 --- a/src/yuzu/applets/software_keyboard.h +++ b/src/yuzu/applets/software_keyboard.h @@ -62,7 +62,8 @@ public: void RequestText(std::function)> out, Core::Frontend::SoftwareKeyboardParameters parameters) const override; - void SendTextCheckDialog(std::u16string error_message) const override; + void SendTextCheckDialog(std::u16string error_message, + std::function finished_check) const override; signals: void MainWindowGetText(Core::Frontend::SoftwareKeyboardParameters parameters) const; @@ -70,7 +71,9 @@ signals: public slots: void MainWindowFinishedText(std::optional text); + void MainWindowFinishedCheckDialog(); private: mutable std::function)> text_output; + mutable std::function finished_check; }; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 28c53cc876..4262bd0eb9 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -215,14 +215,17 @@ void GMainWindow::SoftwareKeyboardGetText( dialog.setWindowModality(Qt::WindowModal); dialog.exec(); - if (!dialog.GetStatus()) + if (!dialog.GetStatus()) { emit SoftwareKeyboardFinishedText(std::nullopt); + return; + } emit SoftwareKeyboardFinishedText(dialog.GetText()); } void GMainWindow::SoftwareKeyboardInvokeCheckDialog(std::u16string error_message) { QMessageBox::warning(this, tr("Text Check Failed"), QString::fromStdU16String(error_message)); + emit SoftwareKeyboardFinishedCheckDialog(); } void GMainWindow::InitializeWidgets() { diff --git a/src/yuzu/main.h b/src/yuzu/main.h index d83169805e..674e734125 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -100,6 +100,7 @@ signals: void UpdateThemedIcons(); void SoftwareKeyboardFinishedText(std::optional text); + void SoftwareKeyboardFinishedCheckDialog(); public slots: void SoftwareKeyboardGetText(const Core::Frontend::SoftwareKeyboardParameters& parameters);