cellPad: improvements

This commit is contained in:
Megamouse 2018-06-07 15:26:07 +02:00
parent 27820f0371
commit f8c8a3a26c
3 changed files with 208 additions and 117 deletions

View File

@ -8,21 +8,48 @@
extern logs::channel sys_io;
s32 cellPadInit(u32 max_connect)
template<>
void fmt_class_string<CellPadError>::format(std::string& out, u64 arg)
{
format_enum(out, arg, [](auto error)
{
switch (error)
{
STR_CASE(CELL_PAD_ERROR_FATAL);
STR_CASE(CELL_PAD_ERROR_INVALID_PARAMETER);
STR_CASE(CELL_PAD_ERROR_ALREADY_INITIALIZED);
STR_CASE(CELL_PAD_ERROR_UNINITIALIZED);
STR_CASE(CELL_PAD_ERROR_RESOURCE_ALLOCATION_FAILED);
STR_CASE(CELL_PAD_ERROR_DATA_READ_FAILED);
STR_CASE(CELL_PAD_ERROR_NO_DEVICE);
STR_CASE(CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD);
STR_CASE(CELL_PAD_ERROR_TOO_MANY_DEVICES);
STR_CASE(CELL_PAD_ERROR_EBUSY);
}
return unknown;
});
}
error_code cellPadInit(u32 max_connect)
{
sys_io.warning("cellPadInit(max_connect=%d)", max_connect);
const auto handler = fxm::import<pad_thread>(Emu.GetCallbacks().get_pad_handler);
auto handler = fxm::get<pad_thread>();
if (!handler)
if (handler)
return CELL_PAD_ERROR_ALREADY_INITIALIZED;
handler->Init(std::min(max_connect, CELL_PAD_MAX_PORT_NUM));
if (max_connect == 0 || max_connect > CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;
handler = fxm::import<pad_thread>(Emu.GetCallbacks().get_pad_handler);
handler->Init(std::min(max_connect, (u32)CELL_PAD_MAX_PORT_NUM));
return CELL_OK;
}
s32 cellPadEnd()
error_code cellPadEnd()
{
sys_io.notice("cellPadEnd()");
@ -32,7 +59,7 @@ s32 cellPadEnd()
return CELL_OK;
}
s32 cellPadClearBuf(u32 port_no)
error_code cellPadClearBuf(u32 port_no)
{
sys_io.trace("cellPadClearBuf(port_no=%d)", port_no);
@ -41,20 +68,22 @@ s32 cellPadClearBuf(u32 port_no)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect)
if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;
//Set 'm_buffer_cleared' to force a resend of everything
//might as well also reset everything in our pad 'buffer' to nothing as well
const auto& pads = handler->GetPads();
if (port_no >= pads.size() || port_no >= handler->GetInfo().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;
// Set 'm_buffer_cleared' to force a resend of everything
// might as well also reset everything in our pad 'buffer' to nothing as well
pad->m_buffer_cleared = true;
pad->m_analog_left_x = pad->m_analog_left_y = pad->m_analog_right_x = pad->m_analog_right_y = 128;
@ -63,14 +92,14 @@ s32 cellPadClearBuf(u32 port_no)
pad->m_press_triangle = pad->m_press_circle = pad->m_press_cross = pad->m_press_square = 0;
pad->m_press_L1 = pad->m_press_L2 = pad->m_press_R1 = pad->m_press_R2 = 0;
//~399 on sensor y is a level non moving controller
// ~399 on sensor y is a level non moving controller
pad->m_sensor_y = 399;
pad->m_sensor_x = pad->m_sensor_z = pad->m_sensor_g = 512;
return CELL_OK;
}
s32 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);
@ -79,26 +108,28 @@ s32 cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect || !data)
if (port_no >= CELL_MAX_PADS || !data)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
//We have a choice here of NO_DEVICE or READ_FAILED...lets try no device for now
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return CELL_PAD_ERROR_NO_DEVICE;
u16 d1Initial, d2Initial;
u16 d1Initial, d2Initial;
d1Initial = pad->m_digital_1;
d2Initial = pad->m_digital_2;
bool btnChanged = false;
for(Button& button : pad->m_buttons)
for (Button& button : pad->m_buttons)
{
//here we check btns, and set pad accordingly,
//if something changed, set btnChanged
// here we check btns, and set pad accordingly,
// if something changed, set btnChanged
if (button.m_offset == CELL_PAD_BTN_OFFSET_DIGITAL1)
{
@ -123,7 +154,7 @@ s32 cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
if (pad->m_press_up != button.m_value) btnChanged = true;
pad->m_press_up = button.m_value;
break;
//These arent pressure btns
// These arent pressure btns
case CELL_PAD_CTRL_R3:
case CELL_PAD_CTRL_L3:
case CELL_PAD_CTRL_START:
@ -174,7 +205,7 @@ s32 cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
}
}
if(button.m_flush)
if (button.m_flush)
{
button.m_pressed = false;
button.m_flush = false;
@ -310,7 +341,7 @@ s32 cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
return CELL_OK;
}
s32 cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
error_code cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
{
sys_io.trace("cellPadPeriphGetInfo(info=*0x%x)", info);
@ -350,7 +381,7 @@ s32 cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
return CELL_OK;
}
s32 cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
error_code cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
{
sys_io.trace("cellPadPeriphGetData(port_no=%d, data=*0x%x)", port_no, data);
const auto handler = fxm::get<pad_thread>();
@ -358,12 +389,15 @@ s32 cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect || !data)
// port_no can only be 0-6 in this function
if (port_no >= CELL_PAD_MAX_PORT_NUM || !data)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
@ -372,29 +406,54 @@ s32 cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
// 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<CellPadData> data)
error_code cellPadGetRawData(u32 port_no, vm::ptr<CellPadData> data)
{
fmt::throw_exception("Unimplemented" HERE);
}
s32 cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<CellPadData> data)
{
sys_io.trace("cellPadGetDataExtra(port_no=%d, device_type=*0x%x, device_type=*0x%x)", port_no, device_type, data);
sys_io.todo("cellPadGetRawData(port_no=%d, data=*0x%x)", port_no, data);
const auto handler = fxm::get<pad_thread>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect || !device_type || !data)
if (port_no >= CELL_MAX_PADS || !data)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
if (port_no >= pads.size() || port_no >= handler->GetInfo().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;
// ?
return CELL_OK;
}
error_code cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<CellPadData> data)
{
sys_io.trace("cellPadGetDataExtra(port_no=%d, device_type=*0x%x, data=*0x%x)", port_no, device_type, data);
const auto handler = fxm::get<pad_thread>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
if (port_no >= CELL_MAX_PADS || !data)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
@ -403,7 +462,10 @@ s32 cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<CellPadDa
// 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
*device_type = 0;
if (device_type) // no error is returned on NULL
{
*device_type = 0;
}
// set BD data before just incase
data->button[24] = 0x0;
@ -412,7 +474,7 @@ s32 cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<CellPadDa
return cellPadGetData(port_no, data);
}
s32 cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
error_code cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
{
sys_io.trace("cellPadSetActDirect(port_no=%d, param=*0x%x)", port_no, param);
@ -421,23 +483,34 @@ s32 cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect || !param)
if (port_no >= CELL_MAX_PADS || !param)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
if (port_no >= pads.size() || port_no >= handler->GetInfo().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: find out if this is checked here or later or at all
if (!(pad->m_device_capability & CELL_PAD_CAPABILITY_ACTUATOR))
return CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD;
// make sure reserved bits are 0. Looks like this happens after checking the pad status
for (int i = 0; i < 6; i++)
if (param->reserved[i])
return CELL_PAD_ERROR_INVALID_PARAMETER;
handler->SetRumble(port_no, param->motor[1], param->motor[0] > 0);
return CELL_OK;
}
s32 cellPadGetInfo(vm::ptr<CellPadInfo> info)
error_code cellPadGetInfo(vm::ptr<CellPadInfo> info)
{
sys_io.trace("cellPadGetInfo(info=*0x%x)", info);
@ -458,7 +531,7 @@ s32 cellPadGetInfo(vm::ptr<CellPadInfo> info)
const auto& pads = handler->GetPads();
for (u32 i=0; i<CELL_MAX_PADS; ++i)
for (u32 i = 0; i < CELL_MAX_PADS; ++i)
{
if (i >= pads.size())
break;
@ -472,7 +545,7 @@ s32 cellPadGetInfo(vm::ptr<CellPadInfo> info)
return CELL_OK;
}
s32 cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
error_code cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
{
sys_io.trace("cellPadGetInfo2(info=*0x%x)", info);
@ -493,7 +566,7 @@ s32 cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
const auto& pads = handler->GetPads();
for (u32 i=0; i<CELL_PAD_MAX_PORT_NUM; ++i)
for (u32 i = 0; i < CELL_PAD_MAX_PORT_NUM; ++i)
{
if (i >= pads.size())
break;
@ -508,7 +581,7 @@ s32 cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
return CELL_OK;
}
s32 cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellCapabilityInfo> info)
error_code cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellPadCapabilityInfo> info)
{
sys_io.trace("cellPadGetCapabilityInfo(port_no=%d, data_addr:=0x%x)", port_no, info.addr());
@ -517,24 +590,26 @@ s32 cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellCapabilityInfo> info)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect || !info)
if (port_no >= CELL_MAX_PADS || !info)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
if (port_no >= pads.size() || port_no >= handler->GetInfo().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;
//Should return the same as device capability mask, psl1ght has it backwards in pad->h
info->info[0] = pad->m_device_capability;
// Should return the same as device capability mask, psl1ght has it backwards in pad->h
info->info[port_no] = pad->m_device_capability;
return CELL_OK;
}
s32 cellPadSetPortSetting(u32 port_no, u32 port_setting)
error_code cellPadSetPortSetting(u32 port_no, u32 port_setting)
{
sys_io.trace("cellPadSetPortSetting(port_no=%d, port_setting=0x%x)", port_no, port_setting);
@ -543,18 +618,20 @@ s32 cellPadSetPortSetting(u32 port_no, u32 port_setting)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect)
if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
const auto pad = pads[port_no];
// CELL_PAD_ERROR_NO_DEVICE is not returned in this case.
// TODO: Set the setting regardless
if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
return CELL_OK;
const auto pad = pads[port_no];
pad->m_port_setting = port_setting;
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return CELL_PAD_ERROR_NO_DEVICE;
// can also return CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD
return CELL_OK;
}
@ -568,12 +645,14 @@ s32 cellPadInfoPressMode(u32 port_no)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect)
if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
@ -591,12 +670,14 @@ s32 cellPadInfoSensorMode(u32 port_no)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect)
if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
return CELL_PAD_ERROR_NO_DEVICE;
const auto pad = pads[port_no];
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
@ -605,7 +686,7 @@ s32 cellPadInfoSensorMode(u32 port_no)
return (pad->m_device_capability & CELL_PAD_CAPABILITY_SENSOR_MODE) > 0;
}
s32 cellPadSetPressMode(u32 port_no, u32 mode)
error_code cellPadSetPressMode(u32 port_no, u32 mode)
{
sys_io.trace("cellPadSetPressMode(port_no=%d, mode=%d)", port_no, mode);
@ -614,29 +695,31 @@ s32 cellPadSetPressMode(u32 port_no, u32 mode)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
if (mode != 0 && mode != 1)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect)
if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
// CELL_PAD_ERROR_NO_DEVICE is not returned in this case.
// TODO: Set the setting regardless
if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
return CELL_OK;
const auto pad = pads[port_no];
// TODO: find out if this is checked here or later or at all
if (!(pad->m_device_capability & CELL_PAD_CAPABILITY_PRESS_MODE))
return CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD;
if (mode)
pad->m_port_setting |= CELL_PAD_SETTING_PRESS_ON;
else
pad->m_port_setting &= ~CELL_PAD_SETTING_PRESS_ON;
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return CELL_PAD_ERROR_NO_DEVICE;
return CELL_OK;
}
s32 cellPadSetSensorMode(u32 port_no, u32 mode)
error_code cellPadSetSensorMode(u32 port_no, u32 mode)
{
sys_io.trace("cellPadSetSensorMode(port_no=%d, mode=%d)", port_no, mode);
@ -645,29 +728,31 @@ s32 cellPadSetSensorMode(u32 port_no, u32 mode)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
if (mode != 0 && mode != 1)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect)
if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto& pads = handler->GetPads();
// CELL_PAD_ERROR_NO_DEVICE is not returned in this case.
// TODO: Set the setting regardless
if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
return CELL_OK;
const auto pad = pads[port_no];
// TODO: find out if this is checked here or later or at all
if (!(pad->m_device_capability & CELL_PAD_CAPABILITY_SENSOR_MODE))
return CELL_PAD_ERROR_UNSUPPORTED_GAMEPAD;
if (mode)
pad->m_port_setting |= CELL_PAD_SETTING_SENSOR_ON;
else
pad->m_port_setting &= ~CELL_PAD_SETTING_SENSOR_ON;
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return CELL_PAD_ERROR_NO_DEVICE;
return CELL_OK;
}
s32 cellPadLddRegisterController()
error_code cellPadLddRegisterController()
{
sys_io.todo("cellPadLddRegisterController()");
@ -676,10 +761,12 @@ s32 cellPadLddRegisterController()
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
// can return CELL_PAD_ERROR_TOO_MANY_DEVICES
return CELL_OK;
}
s32 cellPadLddDataInsert(s32 handle, vm::ptr<CellPadData> data)
error_code cellPadLddDataInsert(s32 handle, vm::ptr<CellPadData> data)
{
sys_io.todo("cellPadLddDataInsert(handle=%d, data=*0x%x)", handle, data);
@ -688,29 +775,30 @@ s32 cellPadLddDataInsert(s32 handle, vm::ptr<CellPadData> data)
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
if (handle < 0 || !data)
if (handle < 0 || !data) // data == NULL stalls on decr
return CELL_PAD_ERROR_INVALID_PARAMETER;
// can return CELL_PAD_ERROR_NO_DEVICE
return CELL_OK;
}
s32 cellPadLddGetPortNo(s32 handle)
error_code cellPadLddGetPortNo(s32 handle)
{
sys_io.todo("cellPadLddGetPortNo(handle=%d)", handle);
if (handle < 0)
return CELL_PAD_ERROR_INVALID_PARAMETER;
const auto handler = fxm::get<pad_thread>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
// CELL_OK would return port 0 (Nascar [BLUS30932] stopped looking for custom controllers after a few seconds, fixing normal input)
return CELL_PAD_ERROR_EBUSY;
if (handle < 0)
return CELL_PAD_ERROR_INVALID_PARAMETER;
return CELL_PAD_ERROR_EBUSY; // or CELL_PAD_ERROR_FATAL or CELL_EBUSY
}
s32 cellPadLddUnregisterController(s32 handle)
error_code cellPadLddUnregisterController(s32 handle)
{
sys_io.todo("cellPadLddUnregisterController(handle=%d)", handle);
@ -722,19 +810,19 @@ s32 cellPadLddUnregisterController(s32 handle)
if (handle < 0)
return CELL_PAD_ERROR_INVALID_PARAMETER;
// can return CELL_PAD_ERROR_NO_DEVICE
return CELL_OK;
}
s32 sys_io_3733EA3C(u32 port_no, vm::ptr<u32> device_type, vm::ptr<CellPadData> data)
{
//Used by the ps1 emulator built into the firmware
//Seems to call the same function that getdataextra does
// Used by the ps1 emulator built into the firmware
// Seems to call the same function that getdataextra does
sys_io.trace("sys_io_3733EA3C(port_no=%d, device_type=*0x%x, data=*0x%x)", port_no, device_type, data);
return cellPadGetDataExtra(port_no, device_type, data);
}
void cellPad_init()
{
REG_FUNC(sys_io, cellPadInit);

View File

@ -2,18 +2,18 @@
enum
enum CellPadError : u32
{
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_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,
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,
};
// Controller types
@ -83,7 +83,7 @@ struct CellPadPeriphData
CellPadData cellpad_data;
};
struct CellCapabilityInfo
struct CellPadCapabilityInfo
{
be_t<u32> info[CELL_PAD_MAX_CAPABILITY_INFO];
};

View File

@ -91,11 +91,14 @@ enum ButtonDataOffset
CELL_PAD_BTN_OFFSET_SENSOR_G = 23,
};
static const u32 CELL_MAX_PADS = 127;
static const u32 CELL_PAD_MAX_PORT_NUM = 7;
static const u32 CELL_PAD_MAX_CODES = 64;
static const u32 CELL_PAD_MAX_CAPABILITY_INFO = 32;
static const u32 CELL_PAD_ACTUATOR_MAX = 2;
enum
{
CELL_PAD_ACTUATOR_MAX = 2,
CELL_PAD_MAX_PORT_NUM = 7,
CELL_PAD_MAX_CAPABILITY_INFO = 32,
CELL_PAD_MAX_CODES = 64,
CELL_MAX_PADS = 127,
};
struct Button
{