From c5e66650105bd1943a79f8241f6c81a325faa7b5 Mon Sep 17 00:00:00 2001 From: al0xf Date: Thu, 16 Mar 2017 10:34:47 +0100 Subject: [PATCH] Fix async OSK loading (#2531) --- rpcs3/Emu/Cell/Modules/cellMsgDialog.h | 1 + rpcs3/Emu/Cell/Modules/cellOskDialog.cpp | 11 ++++++++++- rpcs3/Gui/OskDialog.cpp | 9 +++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h index 76b2a4666c..0d49fa40d7 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h @@ -79,6 +79,7 @@ public: MsgDialogType type{}; std::function on_close; + std::function on_osk_input_entered; virtual ~MsgDialogBase(); virtual void Create(const std::string& msg) = 0; diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp index d1e8bd69c1..4272280138 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp @@ -21,7 +21,7 @@ s32 cellOskDialogLoadAsync(u32 container, vm::ptr dialogPara osk->on_close = [&](s32 status) { - if (status == 1) { + if (status == CELL_MSGDIALOG_BUTTON_OK) { sysutil_send_system_cmd(CELL_SYSUTIL_OSKDIALOG_FINISHED, 0); } else { @@ -30,11 +30,18 @@ s32 cellOskDialogLoadAsync(u32 container, vm::ptr dialogPara result = true; }; + osk->on_osk_input_entered = [&]() + { + sysutil_send_system_cmd(CELL_SYSUTIL_OSKDIALOG_INPUT_ENTERED, 0); + }; + Emu.CallAfter([&]() { osk->CreateOsk("On Screen Keyboard", s_osk_text); }); + sysutil_send_system_cmd(CELL_SYSUTIL_OSKDIALOG_LOADED, 0); + while (!result) { thread_ctrl::wait_for(1000); @@ -52,6 +59,8 @@ s32 cellOskDialogUnloadAsync(vm::ptr OutputInf *(OutputInfo->pResultString + i) = (be_t)*(s_osk_text + i); } + sysutil_send_system_cmd(CELL_SYSUTIL_OSKDIALOG_UNLOADED, 0); + return CELL_OSKDIALOG_OK; } diff --git a/rpcs3/Gui/OskDialog.cpp b/rpcs3/Gui/OskDialog.cpp index 987c4459ba..ac545b5a1e 100644 --- a/rpcs3/Gui/OskDialog.cpp +++ b/rpcs3/Gui/OskDialog.cpp @@ -26,6 +26,13 @@ void MsgDialogFrame::CreateOsk(const std::string& msg, char16_t* osk_text) osk_text_input->SetFocus(); } + osk_text_input->Bind(wxEVT_TEXT, [&](wxCommandEvent& event) + { + wxUString wx_osk_string = osk_text_input->GetValue(); + std::memcpy(osk_text_return, wx_osk_string.utf16_str(), wx_osk_string.size() * 2); + on_osk_input_entered(); + }); + osk_button_ok = new wxButton(m_dialog, wxID_OK); osk_button_sizer->Add(osk_button_ok, 0, wxLEFT | wxRIGHT | wxBOTTOM, 4); @@ -39,8 +46,6 @@ void MsgDialogFrame::CreateOsk(const std::string& msg, char16_t* osk_text) m_dialog->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) { - wxUString wx_osk_string = osk_text_input->GetValue(); - std::memcpy(osk_text_return, wx_osk_string.utf16_str(), wx_osk_string.size() * 2); on_close(CELL_MSGDIALOG_BUTTON_OK); });