From 9873d909d0afa1d1e64c0dcea01c7d81db5230ed Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Thu, 1 Jan 2015 12:25:37 +0200 Subject: [PATCH] Implement cellPadPeriphGetInfo Also minor fixes --- rpcs3/Emu/SysCalls/Modules/cellFont.cpp | 6 ++--- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellPad.cpp | 30 ++++++++++++++++++++--- rpcs3/Emu/SysCalls/Modules/cellPad.h | 24 ++++++++++++++++++ 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp index 59130605eb..0d709d6d39 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp @@ -385,8 +385,7 @@ int cellFontGetEffectSlant(vm::ptr font, vm::ptr> slantPar int cellFontGetFontIdCode(vm::ptr font, u32 code, vm::ptr fontId, vm::ptr fontCode) { - cellFont->Todo("cellFontGetFontIdCode(font_addr=0x%x, code=0x%x, fontId_addr=0x%x, fontCode_addr=0x%x", - font.addr(), code, fontId.addr(), fontCode.addr()); + cellFont->Todo("cellFontGetFontIdCode(font_addr=0x%x, code=0x%x, fontId_addr=0x%x, fontCode_addr=0x%x)", font.addr(), code, fontId.addr(), fontCode.addr()); // TODO: ? return CELL_FONT_OK; @@ -406,8 +405,7 @@ int cellFontCloseFont(vm::ptr font) int cellFontGetCharGlyphMetrics(vm::ptr font, u32 code, vm::ptr metrics) { - cellFont->Log("cellFontGetCharGlyphMetrics(font_addr=0x%x, code=0x%x, metrics_addr=0x%x", - font.addr(), code, metrics.addr()); + cellFont->Log("cellFontGetCharGlyphMetrics(font_addr=0x%x, code=0x%x, metrics_addr=0x%x)", font.addr(), code, metrics.addr()); int x0, y0, x1, y1; int advanceWidth, leftSideBearing; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index c8e0b87038..f91f4cb1c6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -92,7 +92,7 @@ vm::ptr cellGcmGetReportDataAddressLocation(u32 index, u32 lo } if (location == CELL_GCM_LOCATION_MAIN) { - if (index >= 1024*1024) { + if (index >= 1024 * 1024) { cellGcmSys->Error("cellGcmGetReportDataAddressLocation: Wrong main index (%d)", index); return vm::ptr::make(0); } diff --git a/rpcs3/Emu/SysCalls/Modules/cellPad.cpp b/rpcs3/Emu/SysCalls/Modules/cellPad.cpp index 5bdc078089..29671843ef 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPad.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPad.cpp @@ -54,16 +54,39 @@ int cellPadClearBuf(u32 port_no) return CELL_OK; } +int cellPadPeriphGetInfo(vm::ptr info) +{ + sys_io->Warning("cellPadPeriphGetInfo(info_addr=0x%x)", info.addr()); + + // TODO: Support other types of controllers + for (int i = 0; i < info->now_connect; i++) + { + info->pclass_type[i] = CELL_PAD_PCLASS_TYPE_STANDARD; + } + + return CELL_OK; +} + int cellPadGetData(u32 port_no, vm::ptr data) { sys_io->Log("cellPadGetData(port_no=%d, data_addr=0x%x)", port_no, data.addr()); std::vector& pads = Emu.GetPadManager().GetPads(); - if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED; + + if (!Emu.GetPadManager().IsInited()) { + return CELL_PAD_ERROR_UNINITIALIZED; + } + const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); - if(port_no >= rinfo.max_connect) return CELL_PAD_ERROR_INVALID_PARAMETER; + + if (port_no >= rinfo.max_connect) { + return CELL_PAD_ERROR_INVALID_PARAMETER; + } + //We have a choice here of NO_DEVICE or READ_FAILED...lets try no device for now - if(port_no >= rinfo.now_connect) return CELL_PAD_ERROR_NO_DEVICE; + if (port_no >= rinfo.now_connect) { + return CELL_PAD_ERROR_NO_DEVICE; + } Pad& pad = pads[port_no]; @@ -409,6 +432,7 @@ void cellPad_init() sys_io->AddFunc(0xf65544ee, cellPadSetActDirect); sys_io->AddFunc(0x3aaad464, cellPadGetInfo); sys_io->AddFunc(0xa703a51d, cellPadGetInfo2); + sys_io->AddFunc(0x4cc9b68d, cellPadPeriphGetInfo); sys_io->AddFunc(0x578e3c98, cellPadSetPortSetting); sys_io->AddFunc(0x0e2dfaad, cellPadInfoPressMode); sys_io->AddFunc(0x78200559, cellPadInfoSensorMode); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPad.h b/rpcs3/Emu/SysCalls/Modules/cellPad.h index 8b9f77ac40..c87a6c8dc5 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPad.h +++ b/rpcs3/Emu/SysCalls/Modules/cellPad.h @@ -14,6 +14,17 @@ enum CELL_PAD_ERROR_CODE CELL_PAD_ERROR_EBUSY = 0x8012110a, }; +// Controller types +enum +{ + CELL_PAD_PCLASS_TYPE_STANDARD = 0x00, + CELL_PAD_PCLASS_TYPE_GUITAR = 0x01, + CELL_PAD_PCLASS_TYPE_DRUM = 0x02, + CELL_PAD_PCLASS_TYPE_DJ = 0x03, + CELL_PAD_PCLASS_TYPE_DANCEMAT = 0x04, + CELL_PAD_PCLASS_TYPE_NAVIGATION = 0x05, +}; + struct CellPadData { be_t len; @@ -41,6 +52,19 @@ struct CellPadInfo2 be_t device_type[CELL_PAD_MAX_PORT_NUM]; }; +struct CellPadPeriphInfo +{ + be_t max_connect; + be_t now_connect; + be_t system_info; + be_t port_status[CELL_PAD_MAX_PORT_NUM]; + be_t port_setting[CELL_PAD_MAX_PORT_NUM]; + be_t device_capability[CELL_PAD_MAX_PORT_NUM]; + be_t device_type[CELL_PAD_MAX_PORT_NUM]; + be_t pclass_type[CELL_PAD_MAX_PORT_NUM]; + be_t pclass_profile[CELL_PAD_MAX_PORT_NUM]; +}; + struct CellCapabilityInfo { be_t info[CELL_PAD_MAX_CAPABILITY_INFO];