diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index 96b11e7192..35b64bf6de 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -1647,7 +1647,7 @@ error_code sceNpBasicMarkMessageAsUsed(SceNpBasicMessageId msgId) error_code sceNpBasicAbortGui() { - sceNp.todo("sceNpBasicAbortGui()"); + sceNp.warning("sceNpBasicAbortGui()"); auto& nph = g_fxo->get>(); @@ -1661,7 +1661,7 @@ error_code sceNpBasicAbortGui() return SCE_NP_BASIC_ERROR_NOT_REGISTERED; } - // TODO: abort GUI interaction + g_fxo->get().abort_gui_flag = true; return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/sceNp.h b/rpcs3/Emu/Cell/Modules/sceNp.h index 7a2ce8542d..9e35f65d74 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.h +++ b/rpcs3/Emu/Cell/Modules/sceNp.h @@ -1702,6 +1702,11 @@ struct message_data void print() const; }; +struct np_state +{ + std::atomic abort_gui_flag = false; +}; + namespace rpcn { class rpcn_client; diff --git a/rpcs3/Emu/RSX/Overlays/Network/overlay_recvmessage_dialog.cpp b/rpcs3/Emu/RSX/Overlays/Network/overlay_recvmessage_dialog.cpp index c470a494ae..d5a2e58f8a 100644 --- a/rpcs3/Emu/RSX/Overlays/Network/overlay_recvmessage_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/Network/overlay_recvmessage_dialog.cpp @@ -253,6 +253,7 @@ namespace rsx const auto notify = std::make_shared>(0); auto& overlayman = g_fxo->get(); + auto& nps = g_fxo->get(); // Block until the user exits the dialog overlayman.attach_thread_input( @@ -260,7 +261,7 @@ namespace rsx [notify](s32) { *notify = true; notify->notify_one(); } ); - while (!Emu.IsStopped() && !*notify) + while (!Emu.IsStopped() && !*notify && !nps.abort_gui_flag) { notify->wait(0, atomic_wait_timeout{1'000'000}); } @@ -269,6 +270,13 @@ namespace rsx error_code result = CELL_CANCEL; + if (nps.abort_gui_flag.exchange(false)) + { + rsx_log.warning("Recvmessage dialog aborted by sceNp!"); + close(false, true); + return result; + } + auto accept_or_deny = [preserve, this, &result, &recv_result, &chosen_msg_id](SceNpBasicMessageRecvAction result_from_action) { { diff --git a/rpcs3/Emu/RSX/Overlays/Network/overlay_sendmessage_dialog.cpp b/rpcs3/Emu/RSX/Overlays/Network/overlay_sendmessage_dialog.cpp index ce40b71a67..fced2c2a7a 100644 --- a/rpcs3/Emu/RSX/Overlays/Network/overlay_sendmessage_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/Network/overlay_sendmessage_dialog.cpp @@ -205,6 +205,7 @@ namespace rsx const auto notify = std::make_shared>(0); auto& overlayman = g_fxo->get(); + auto& nps = g_fxo->get(); // Block until the user exits the dialog overlayman.attach_thread_input( @@ -212,7 +213,7 @@ namespace rsx [notify](s32) { *notify = true; notify->notify_one(); } ); - while (!Emu.IsStopped() && !*notify) + while (!Emu.IsStopped() && !*notify && !nps.abort_gui_flag) { notify->wait(0, atomic_wait_timeout{1'000'000}); } @@ -221,6 +222,13 @@ namespace rsx error_code result = CELL_CANCEL; + if (nps.abort_gui_flag.exchange(false)) + { + rsx_log.warning("Sendmessage dialog aborted by sceNp!"); + close(false, true); + return result; + } + switch (return_code) { case selection_code::ok: diff --git a/rpcs3/rpcs3qt/recvmessage_dialog_frame.cpp b/rpcs3/rpcs3qt/recvmessage_dialog_frame.cpp index 67637f73ec..6b549d3e23 100644 --- a/rpcs3/rpcs3qt/recvmessage_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/recvmessage_dialog_frame.cpp @@ -2,7 +2,11 @@ #include #include #include +#include + #include "recvmessage_dialog_frame.h" +#include "Emu/IdManager.h" +#include "Emu/System.h" #include "util/logs.hpp" @@ -96,6 +100,31 @@ error_code recvmessage_dialog_frame::Exec(SceNpBasicMessageMainType type, SceNpB add_message(message, id); } + auto& nps = g_fxo->get(); + + QTimer timer; + connect(&timer, &QTimer::timeout, this, [this, &nps, &timer]() + { + bool abort = Emu.IsStopped(); + + if (!abort && nps.abort_gui_flag.exchange(false)) + { + recvmessage_dlg_log.warning("Aborted by sceNp!"); + abort = true; + } + + if (abort) + { + if (m_dialog) + { + m_dialog->close(); + } + + timer.stop(); + } + }); + timer.start(10ms); + m_dialog->exec(); m_rpcn->remove_message_cb(recvmessage_callback, this); diff --git a/rpcs3/rpcs3qt/sendmessage_dialog_frame.cpp b/rpcs3/rpcs3qt/sendmessage_dialog_frame.cpp index 5e6b7566ba..5815ed6b44 100644 --- a/rpcs3/rpcs3qt/sendmessage_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/sendmessage_dialog_frame.cpp @@ -2,7 +2,11 @@ #include #include #include +#include + #include "sendmessage_dialog_frame.h" +#include "Emu/IdManager.h" +#include "Emu/System.h" #include "util/logs.hpp" @@ -91,6 +95,31 @@ error_code sendmessage_dialog_frame::Exec(message_data& msg_data, std::setget(); + + QTimer timer; + connect(&timer, &QTimer::timeout, this, [this, &nps, &timer]() + { + bool abort = Emu.IsStopped(); + + if (!abort && nps.abort_gui_flag.exchange(false)) + { + sendmessage_dlg_log.warning("Aborted by sceNp!"); + abort = true; + } + + if (abort) + { + if (m_dialog) + { + m_dialog->close(); + } + + timer.stop(); + } + }); + timer.start(10ms); + m_dialog->exec(); m_rpcn->remove_friend_cb(sendmessage_friend_callback, this); diff --git a/rpcs3/rpcs3qt/sendmessage_dialog_frame.h b/rpcs3/rpcs3qt/sendmessage_dialog_frame.h index 82e758ceda..1a74eddba8 100644 --- a/rpcs3/rpcs3qt/sendmessage_dialog_frame.h +++ b/rpcs3/rpcs3qt/sendmessage_dialog_frame.h @@ -22,7 +22,7 @@ private: void remove_friend(QListWidget* list, const QString& name); private: - custom_dialog* m_dialog = nullptr; + custom_dialog* m_dialog = nullptr; QListWidget* m_lst_friends = nullptr; Q_SIGNALS: