Fix sysutil_send_system_cmd at Emu.Stop()

This commit is contained in:
Eladash 2021-03-12 10:15:24 +02:00 committed by Ivan
parent 729cd9284e
commit 923ba6f3bb
2 changed files with 15 additions and 6 deletions

View File

@ -57,13 +57,13 @@ extern void sysutil_register_cb(std::function<s32(ppu_thread&)>&& cb)
extern void sysutil_send_system_cmd(u64 status, u64 param) extern void sysutil_send_system_cmd(u64 status, u64 param)
{ {
if (auto& cbm = g_fxo->get<sysutil_cb_manager>(); g_fxo->is_init<sysutil_cb_manager>() && !Emu.IsStopped()) if (auto cbm = g_fxo->try_get<sysutil_cb_manager>())
{ {
for (sysutil_cb_manager::registered_cb cb : cbm.callbacks) for (sysutil_cb_manager::registered_cb cb : cbm->callbacks)
{ {
if (cb.first) if (cb.first)
{ {
cbm.registered.push([=](ppu_thread& ppu) -> s32 cbm->registered.push([=](ppu_thread& ppu) -> s32
{ {
// TODO: check it and find the source of the return value (void isn't equal to CELL_OK) // TODO: check it and find the source of the return value (void isn't equal to CELL_OK)
cb.first(ppu, status, param, cb.second); cb.first(ppu, status, param, cb.second);

View File

@ -1373,6 +1373,11 @@ void main_window::OnEmuStop()
} }
ui->actionManage_Users->setEnabled(true); ui->actionManage_Users->setEnabled(true);
if (std::exchange(m_sys_menu_opened, false))
{
ui->sysSendOpenMenuAct->setText(tr("Send open system menu cmd"));
}
// Refresh game list in order to update time played // Refresh game list in order to update time played
if (m_game_list_frame) if (m_game_list_frame)
{ {
@ -1781,15 +1786,19 @@ void main_window::CreateConnects()
connect(ui->sysStopAct, &QAction::triggered, [this]() { Emu.Stop(); }); connect(ui->sysStopAct, &QAction::triggered, [this]() { Emu.Stop(); });
connect(ui->sysRebootAct, &QAction::triggered, [this]() { Emu.Restart(); }); connect(ui->sysRebootAct, &QAction::triggered, [this]() { Emu.Restart(); });
connect(ui->sysSendOpenMenuAct, &QAction::triggered, [this]() connect(ui->sysSendOpenMenuAct, &QAction::triggered, this, [this]()
{ {
if (Emu.IsStopped()) return;
sysutil_send_system_cmd(m_sys_menu_opened ? 0x0132 /* CELL_SYSUTIL_SYSTEM_MENU_CLOSE */ : 0x0131 /* CELL_SYSUTIL_SYSTEM_MENU_OPEN */, 0); sysutil_send_system_cmd(m_sys_menu_opened ? 0x0132 /* CELL_SYSUTIL_SYSTEM_MENU_CLOSE */ : 0x0131 /* CELL_SYSUTIL_SYSTEM_MENU_OPEN */, 0);
m_sys_menu_opened = !m_sys_menu_opened; m_sys_menu_opened ^= true;
ui->sysSendOpenMenuAct->setText(tr("Send &%0 system menu cmd").arg(m_sys_menu_opened ? tr("close") : tr("open"))); ui->sysSendOpenMenuAct->setText(tr("Send &%0 system menu cmd").arg(m_sys_menu_opened ? tr("close") : tr("open")));
}); });
connect(ui->sysSendExitAct, &QAction::triggered, [this]() connect(ui->sysSendExitAct, &QAction::triggered, this, []()
{ {
if (Emu.IsStopped()) return;
sysutil_send_system_cmd(0x0101 /* CELL_SYSUTIL_REQUEST_EXITGAME */, 0); sysutil_send_system_cmd(0x0101 /* CELL_SYSUTIL_REQUEST_EXITGAME */, 0);
}); });