cellPad: Fix LDD pads registration

This commit is contained in:
Eladash 2024-01-01 09:18:55 +02:00 committed by Elad Ashkenazi
parent 858e493b52
commit 9aff2d5ee1
2 changed files with 11 additions and 3 deletions

View file

@ -75,7 +75,7 @@ void pad_info::save(utils::serial& ar)
extern void send_sys_io_connect_event(usz index, u32 state);
void cellPad_NotifyStateChange(usz index, u64 /*state*/)
void cellPad_NotifyStateChange(usz index, u64 /*state*/, bool locked)
{
auto info = g_fxo->try_get<pad_info>();
@ -84,7 +84,12 @@ void cellPad_NotifyStateChange(usz index, u64 /*state*/)
return;
}
std::lock_guard lock(pad::g_pad_mutex);
std::unique_lock lock(pad::g_pad_mutex, std::defer_lock);
if (locked)
{
lock.lock();
}
if (index >= info->get_max_connect())
{
@ -1158,6 +1163,8 @@ error_code cellPadLddDataInsert(s32 handle, vm::ptr<CellPadData> data)
pads[handle]->ldd_data = *data;
cellPad_NotifyStateChange(handle, CELL_PAD_STATUS_CONNECTED, false);
return CELL_OK;
}
@ -1206,6 +1213,7 @@ error_code cellPadLddUnregisterController(s32 handle)
return CELL_PAD_ERROR_NO_DEVICE;
handler->UnregisterLddPad(handle);
cellPad_NotifyStateChange(handle, CELL_PAD_STATUS_DISCONNECTED, false);
return CELL_OK;
}

View file

@ -36,7 +36,7 @@ extern void sys_io_serialize(utils::serial& ar)
ensure(g_fxo->try_get<libio_sys_config>())->save_or_load(ar);
}
extern void cellPad_NotifyStateChange(usz index, u64 state);
extern void cellPad_NotifyStateChange(usz index, u64 state, bool lock = true);
void config_event_entry(ppu_thread& ppu)
{