#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 { be_t len; be_t button[CELL_PAD_MAX_CODES]; }; struct CellPadInfo { be_t max_connect; be_t now_connect; be_t system_info; be_t vendor_id[CELL_MAX_PADS]; be_t product_id[CELL_MAX_PADS]; u8 status[CELL_MAX_PADS]; }; struct CellPadInfo2 { 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]; }; 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) { sys_io.Log("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