cellSysutil: Implement DRAWING callbacks

Also fixed a minor race in cellUserInfo regarding status of dialog
This commit is contained in:
Eladash 2022-05-30 16:31:01 +03:00 committed by Megamouse
parent 248809ca1f
commit f5beaabded
7 changed files with 80 additions and 11 deletions

View file

@ -155,10 +155,17 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString,
return CELL_SYSUTIL_ERROR_BUSY;
}
if (s32 ret = sysutil_send_system_cmd(CELL_SYSUTIL_DRAWING_BEGIN, 0); ret < 0)
{
return CellSysutilError{ret + 0u};
}
g_last_user_response = CELL_MSGDIALOG_BUTTON_NONE;
const auto res = manager->create<rsx::overlays::message_dialog>()->show(is_blocking, msgString.get_ptr(), _type, [callback, userData](s32 status)
{
sysutil_send_system_cmd(CELL_SYSUTIL_DRAWING_END, 0);
if (callback)
{
sysutil_register_cb([=](ppu_thread& ppu) -> s32
@ -179,6 +186,11 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString,
return CELL_SYSUTIL_ERROR_BUSY;
}
if (s32 ret = sysutil_send_system_cmd(CELL_SYSUTIL_DRAWING_BEGIN, 0); ret < 0)
{
return CellSysutilError{ret + 0u};
}
dlg->type = _type;
dlg->on_close = [callback, userData, wptr = std::weak_ptr<MsgDialogBase>(dlg)](s32 status)
@ -187,6 +199,8 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString,
if (dlg && dlg->state.compare_and_swap_test(MsgDialogState::Open, MsgDialogState::Close))
{
sysutil_send_system_cmd(CELL_SYSUTIL_DRAWING_END, 0);
if (callback)
{
sysutil_register_cb([=](ppu_thread& ppu) -> s32
@ -208,11 +222,14 @@ error_code open_msg_dialog(bool is_blocking, u32 type, vm::cptr<char> msgString,
auto& ppu = *get_current_cpu_thread();
lv2_obj::sleep(ppu);
// PS3 memory must not be accessed by Main thread
std::string msg_string = msgString.get_ptr();
// Run asynchronously in GUI thread
Emu.CallFromMainThread([&]()
Emu.CallFromMainThread([&, msg_string = std::move(msg_string)]()
{
g_last_user_response = CELL_MSGDIALOG_BUTTON_NONE;
dlg->Create(msgString.get_ptr());
dlg->Create(msg_string);
lv2_obj::awake(&ppu);
});
@ -487,6 +504,7 @@ error_code cellMsgDialogAbort()
g_fxo->get<msg_dlg_thread>().wait_until = 0;
g_fxo->get<msg_info>().remove(); // this shouldn't call on_close
input::SetIntercepted(false); // so we need to reenable the pads here
sysutil_send_system_cmd(CELL_SYSUTIL_DRAWING_END, 0);
return CELL_OK;
}