mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 22:11:26 +12:00
cellPad: do not use recusrive mutex
This commit is contained in:
parent
6ff9aab2ca
commit
7d89938624
3 changed files with 28 additions and 33 deletions
|
@ -137,6 +137,8 @@ error_code cellPadClearBuf(u32 port_no)
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pad_get_data(u32 port_no, CellPadData* data);
|
||||||
|
|
||||||
error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
|
error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
|
||||||
{
|
{
|
||||||
sys_io.trace("cellPadGetData(port_no=%d, data=*0x%x)", port_no, data);
|
sys_io.trace("cellPadGetData(port_no=%d, data=*0x%x)", port_no, data);
|
||||||
|
@ -163,12 +165,21 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
|
||||||
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
|
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
|
||||||
return CELL_PAD_ERROR_NO_DEVICE;
|
return CELL_PAD_ERROR_NO_DEVICE;
|
||||||
|
|
||||||
|
pad_get_data(port_no, data.get_ptr());
|
||||||
|
return CELL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pad_get_data(u32 port_no, CellPadData* data)
|
||||||
|
{
|
||||||
|
auto& config = g_fxo->get<pad_info>();
|
||||||
|
const auto handler = pad::get_current_handler();
|
||||||
|
const auto& pad = handler->GetPads()[port_no];
|
||||||
const PadInfo& rinfo = handler->GetInfo();
|
const PadInfo& rinfo = handler->GetInfo();
|
||||||
|
|
||||||
if (rinfo.system_info & CELL_PAD_INFO_INTERCEPTED)
|
if (rinfo.system_info & CELL_PAD_INFO_INTERCEPTED)
|
||||||
{
|
{
|
||||||
data->len = CELL_PAD_LEN_NO_CHANGE;
|
data->len = CELL_PAD_LEN_NO_CHANGE;
|
||||||
return CELL_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto setting = config.port_setting[port_no];
|
const auto setting = config.port_setting[port_no];
|
||||||
|
@ -182,12 +193,12 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
|
||||||
}
|
}
|
||||||
else if (pad->ldd)
|
else if (pad->ldd)
|
||||||
{
|
{
|
||||||
memcpy(data.get_ptr(), pad->ldd_data, sizeof(CellPadData));
|
std::memcpy(data, pad->ldd_data, sizeof(CellPadData));
|
||||||
if (setting & CELL_PAD_SETTING_SENSOR_ON)
|
if (setting & CELL_PAD_SETTING_SENSOR_ON)
|
||||||
data->len = CELL_PAD_LEN_CHANGE_SENSOR_ON;
|
data->len = CELL_PAD_LEN_CHANGE_SENSOR_ON;
|
||||||
else
|
else
|
||||||
data->len = (setting & CELL_PAD_SETTING_PRESS_ON) ? CELL_PAD_LEN_CHANGE_PRESS_ON : CELL_PAD_LEN_CHANGE_DEFAULT;
|
data->len = (setting & CELL_PAD_SETTING_PRESS_ON) ? CELL_PAD_LEN_CHANGE_PRESS_ON : CELL_PAD_LEN_CHANGE_DEFAULT;
|
||||||
return CELL_OK;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -409,8 +420,6 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
|
||||||
data->button[CELL_PAD_BTN_OFFSET_SENSOR_G] = pad->m_sensor_g;
|
data->button[CELL_PAD_BTN_OFFSET_SENSOR_G] = pad->m_sensor_g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CELL_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
|
error_code cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
|
||||||
|
@ -478,16 +487,18 @@ error_code cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
|
||||||
if (port_no >= config.max_connect)
|
if (port_no >= config.max_connect)
|
||||||
return CELL_PAD_ERROR_NO_DEVICE;
|
return CELL_PAD_ERROR_NO_DEVICE;
|
||||||
|
|
||||||
const auto pad = pads[port_no];
|
const auto& pad = pads[port_no];
|
||||||
|
|
||||||
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
|
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
|
||||||
return CELL_PAD_ERROR_NO_DEVICE;
|
return CELL_PAD_ERROR_NO_DEVICE;
|
||||||
|
|
||||||
|
pad_get_data(port_no, &data->cellpad_data);
|
||||||
|
|
||||||
data->pclass_type = pad->m_class_type;
|
data->pclass_type = pad->m_class_type;
|
||||||
data->pclass_profile = pad->m_class_profile;
|
data->pclass_profile = pad->m_class_profile;
|
||||||
|
|
||||||
// TODO: support for 'unique' controllers, which goes in offsets 24+ in padData (CELL_PAD_PCLASS_BTN_OFFSET)
|
// TODO: support for 'unique' controllers, which goes in offsets 24+ in padData (CELL_PAD_PCLASS_BTN_OFFSET)
|
||||||
return cellPadGetData(port_no, data.ptr(&CellPadPeriphData::cellpad_data));
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code cellPadGetRawData(u32 port_no, vm::ptr<CellPadData> data)
|
error_code cellPadGetRawData(u32 port_no, vm::ptr<CellPadData> data)
|
||||||
|
@ -525,41 +536,24 @@ error_code cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<Ce
|
||||||
{
|
{
|
||||||
sys_io.trace("cellPadGetDataExtra(port_no=%d, device_type=*0x%x, data=*0x%x)", port_no, device_type, data);
|
sys_io.trace("cellPadGetDataExtra(port_no=%d, device_type=*0x%x, data=*0x%x)", port_no, device_type, data);
|
||||||
|
|
||||||
std::lock_guard lock(pad::g_pad_mutex);
|
|
||||||
|
|
||||||
auto& config = g_fxo->get<pad_info>();
|
|
||||||
|
|
||||||
if (!config.max_connect)
|
|
||||||
return CELL_PAD_ERROR_UNINITIALIZED;
|
|
||||||
|
|
||||||
const auto handler = pad::get_current_handler();
|
|
||||||
|
|
||||||
if (port_no >= CELL_MAX_PADS || !data)
|
|
||||||
return CELL_PAD_ERROR_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
const auto& pads = handler->GetPads();
|
|
||||||
|
|
||||||
if (port_no >= config.max_connect)
|
|
||||||
return CELL_PAD_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
const auto pad = pads[port_no];
|
|
||||||
|
|
||||||
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
|
|
||||||
return CELL_PAD_ERROR_NO_DEVICE;
|
|
||||||
|
|
||||||
// TODO: This is used just to get data from a BD/CEC remote,
|
// TODO: This is used just to get data from a BD/CEC remote,
|
||||||
// but if the port isnt a remote, device type is set to 0 and just regular cellPadGetData is returned
|
// but if the port isnt a remote, device type is set to 0 and just regular cellPadGetData is returned
|
||||||
|
|
||||||
|
if (auto err = cellPadGetData(port_no, data))
|
||||||
|
{
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
if (device_type) // no error is returned on NULL
|
if (device_type) // no error is returned on NULL
|
||||||
{
|
{
|
||||||
*device_type = 0;
|
*device_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set BD data before just incase
|
// Set BD data
|
||||||
data->button[24] = 0x0;
|
data->button[24] = 0x0;
|
||||||
data->button[25] = 0x0;
|
data->button[25] = 0x0;
|
||||||
|
|
||||||
return cellPadGetData(port_no, data);
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
|
error_code cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
|
||||||
|
|
|
@ -20,7 +20,7 @@ LOG_CHANNEL(input_log, "Input");
|
||||||
namespace pad
|
namespace pad
|
||||||
{
|
{
|
||||||
atomic_t<pad_thread*> g_current = nullptr;
|
atomic_t<pad_thread*> g_current = nullptr;
|
||||||
std::recursive_mutex g_pad_mutex;
|
shared_mutex g_pad_mutex;
|
||||||
std::string g_title_id;
|
std::string g_title_id;
|
||||||
atomic_t<bool> g_reset{false};
|
atomic_t<bool> g_reset{false};
|
||||||
atomic_t<bool> g_enabled{true};
|
atomic_t<bool> g_enabled{true};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "util/atomic.hpp"
|
#include "util/atomic.hpp"
|
||||||
#include "Emu/Io/pad_types.h"
|
#include "Emu/Io/pad_types.h"
|
||||||
#include "Emu/Io/pad_config_types.h"
|
#include "Emu/Io/pad_config_types.h"
|
||||||
|
#include "Utilities/mutex.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
@ -52,7 +53,7 @@ protected:
|
||||||
namespace pad
|
namespace pad
|
||||||
{
|
{
|
||||||
extern atomic_t<pad_thread*> g_current;
|
extern atomic_t<pad_thread*> g_current;
|
||||||
extern std::recursive_mutex g_pad_mutex;
|
extern shared_mutex g_pad_mutex;
|
||||||
extern std::string g_title_id;
|
extern std::string g_title_id;
|
||||||
extern atomic_t<bool> g_enabled;
|
extern atomic_t<bool> g_enabled;
|
||||||
extern atomic_t<bool> g_reset;
|
extern atomic_t<bool> g_reset;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue