From 56b21fd4112258f585b04f57f259d40eb7014f0c Mon Sep 17 00:00:00 2001 From: Jake Date: Fri, 26 May 2017 16:02:36 -0500 Subject: [PATCH] cellPadPeriphGetData impl --- rpcs3/Emu/Cell/Modules/cellPad.cpp | 94 +++++++++++++++++------------- rpcs3/Emu/Cell/Modules/cellPad.h | 7 +++ 2 files changed, 62 insertions(+), 39 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellPad.cpp b/rpcs3/Emu/Cell/Modules/cellPad.cpp index 10ea702035..ccb40acb9e 100644 --- a/rpcs3/Emu/Cell/Modules/cellPad.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPad.cpp @@ -69,45 +69,6 @@ s32 cellPadClearBuf(u32 port_no) return CELL_OK; } -s32 cellPadPeriphGetInfo(vm::ptr info) -{ - sys_io.trace("cellPadPeriphGetInfo(info=*0x%x)", info); - - const auto handler = fxm::get(); - - if (!handler) - return CELL_PAD_ERROR_UNINITIALIZED; - - const PadInfo& rinfo = handler->GetInfo(); - - info->max_connect = rinfo.max_connect; - info->now_connect = rinfo.now_connect; - info->system_info = rinfo.system_info; - - std::vector& pads = handler->GetPads(); - - // TODO: Support other types of controllers - for (u32 i = 0; i < CELL_PAD_MAX_PORT_NUM; ++i) - { - if (i >= pads.size()) - break; - - info->port_status[i] = pads[i].m_port_status; - info->port_setting[i] = pads[i].m_port_setting; - info->device_capability[i] = pads[i].m_device_capability; - info->device_type[i] = pads[i].m_device_type; - info->pclass_type[i] = CELL_PAD_PCLASS_TYPE_STANDARD; - info->pclass_profile[i] = 0x0; - } - - return CELL_OK; -} - -s32 cellPadPeriphGetData() -{ - fmt::throw_exception("Unimplemented" HERE); -} - s32 cellPadGetData(u32 port_no, vm::ptr data) { sys_io.trace("cellPadGetData(port_no=%d, data=*0x%x)", port_no, data); @@ -315,6 +276,61 @@ s32 cellPadGetData(u32 port_no, vm::ptr data) return CELL_OK; } +s32 cellPadPeriphGetInfo(vm::ptr info) +{ + sys_io.trace("cellPadPeriphGetInfo(info=*0x%x)", info); + + const auto handler = fxm::get(); + + if (!handler) + return CELL_PAD_ERROR_UNINITIALIZED; + + const PadInfo& rinfo = handler->GetInfo(); + + info->max_connect = rinfo.max_connect; + info->now_connect = rinfo.now_connect; + info->system_info = rinfo.system_info; + + std::vector& pads = handler->GetPads(); + + // TODO: Support other types of controllers + for (u32 i = 0; i < CELL_PAD_MAX_PORT_NUM; ++i) + { + if (i >= pads.size()) + break; + + info->port_status[i] = pads[i].m_port_status; + info->port_setting[i] = pads[i].m_port_setting; + info->device_capability[i] = pads[i].m_device_capability; + info->device_type[i] = pads[i].m_device_type; + info->pclass_type[i] = CELL_PAD_PCLASS_TYPE_STANDARD; + info->pclass_profile[i] = 0x0; + } + + return CELL_OK; +} + +s32 cellPadPeriphGetData(u32 port_no, vm::ptr data) +{ + sys_io.trace("cellPadPeriphGetData(port_no=%d, data=*0x%x)", port_no, data); + const auto handler = fxm::get(); + + if (!handler) + return CELL_PAD_ERROR_UNINITIALIZED; + + const PadInfo& rinfo = handler->GetInfo(); + + if (port_no >= rinfo.max_connect) + return CELL_PAD_ERROR_INVALID_PARAMETER; + if (port_no >= rinfo.now_connect) + return CELL_PAD_ERROR_NO_DEVICE; + + // todo: support for 'unique' controllers, which goes in offsets 24+ in padData + data->pclass_type = CELL_PAD_PCLASS_TYPE_STANDARD; + data->pclass_profile = 0x0; + return cellPadGetData(port_no, vm::get_addr(&data->cellpad_data)); +} + s32 cellPadGetRawData(u32 port_no, vm::ptr data) { fmt::throw_exception("Unimplemented" HERE); diff --git a/rpcs3/Emu/Cell/Modules/cellPad.h b/rpcs3/Emu/Cell/Modules/cellPad.h index 71ab13f862..3f1d9ae6d4 100644 --- a/rpcs3/Emu/Cell/Modules/cellPad.h +++ b/rpcs3/Emu/Cell/Modules/cellPad.h @@ -67,6 +67,13 @@ struct CellPadPeriphInfo be_t pclass_profile[CELL_PAD_MAX_PORT_NUM]; }; +struct CellPadPeriphData +{ + be_t pclass_type; + be_t pclass_profile; + CellPadData cellpad_data; +}; + struct CellCapabilityInfo { be_t info[CELL_PAD_MAX_CAPABILITY_INFO];