#include "stdafx.h" #include "Emu/Io/Pad.h" #include "Emu/SysCalls/SysCalls.h" extern Module sys_io; enum CELL_PAD_ERROR_CODE { CELL_PAD_ERROR_FATAL = 0x80121101, CELL_PAD_ERROR_INVALID_PARAMETER = 0x80121102, CELL_PAD_ERROR_ALREADY_INITIALIZED = 0x80121103, CELL_PAD_ERROR_UNINITIALIZED = 0x80121104, CELL_PAD_ERROR_RESOURCE_ALLOCATION_FAILED = 0x80121105, CELL_PAD_ERROR_DATA_READ_FAILED = 0x80121106, CELL_PAD_ERROR_NO_DEVICE = 0x80121107, CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD = 0x80121108, CELL_PAD_ERROR_TOO_MANY_DEVICES = 0x80121109, CELL_PAD_ERROR_EBUSY = 0x8012110a, }; struct CellPadData { s32 len; u16 button[CELL_PAD_MAX_CODES]; }; struct CellPadInfo2 { u32 max_connect; u32 now_connect; u32 system_info; u32 port_status[CELL_PAD_MAX_PORT_NUM]; u32 port_setting[CELL_PAD_MAX_PORT_NUM]; u32 device_capability[CELL_PAD_MAX_PORT_NUM]; u32 device_type[CELL_PAD_MAX_PORT_NUM]; }; int cellPadInit(u32 max_connect) { sys_io.Log("cellPadInit(max_connect=%d)", max_connect); if(Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_ALREADY_INITIALIZED; Emu.GetPadManager().Init(max_connect); return CELL_OK; } int cellPadEnd() { sys_io.Log("cellPadEnd()"); if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED; Emu.GetPadManager().Close(); return CELL_OK; } int cellPadClearBuf(u32 port_no) { sys_io.Log("cellPadClearBuf(port_no=%d)", port_no); if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED; if(port_no >= Emu.GetPadManager().GetPads().GetCount()) return CELL_PAD_ERROR_INVALID_PARAMETER; //? return CELL_OK; } int cellPadGetData(u32 port_no, u32 data_addr) { //ConLog.Warning("cellPadGetData[port_no: %d, data_addr: 0x%x]", port_no, data_addr); const Array& pads = Emu.GetPadManager().GetPads(); if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED; if(port_no >= pads.GetCount()) return CELL_PAD_ERROR_INVALID_PARAMETER; const Pad& pad = pads[port_no]; CellPadData data; memset(&data, 0, sizeof(CellPadData)); u16 d1 = 0; u16 d2 = 0; const Array