2012-11-15 00:39:56 +01:00
|
|
|
#include "stdafx.h"
|
2014-06-17 17:44:03 +02:00
|
|
|
#include "Utilities/Log.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "Emu/Memory/Memory.h"
|
|
|
|
|
#include "Emu/System.h"
|
|
|
|
|
#include "Emu/Cell/PPUThread.h"
|
|
|
|
|
#include "Emu/SysCalls/SC_FUNC.h"
|
|
|
|
|
#include "Emu/SysCalls/Modules.h"
|
2012-11-15 00:39:56 +01:00
|
|
|
#include "Emu/Io/Pad.h"
|
|
|
|
|
#include "Emu/SysCalls/SysCalls.h"
|
|
|
|
|
|
2014-05-02 08:30:32 +02:00
|
|
|
extern Module *sys_io;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
|
|
|
enum CELL_PAD_ERROR_CODE
|
|
|
|
|
{
|
2014-04-04 15:25:38 +02:00
|
|
|
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,
|
2012-11-15 00:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CellPadData
|
|
|
|
|
{
|
2014-02-25 14:09:44 +01:00
|
|
|
be_t<s32> len;
|
|
|
|
|
be_t<u16> button[CELL_PAD_MAX_CODES];
|
2012-11-15 00:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
2013-12-08 14:47:54 +01:00
|
|
|
struct CellPadInfo
|
|
|
|
|
{
|
2014-02-25 14:09:44 +01:00
|
|
|
be_t<u32> max_connect;
|
|
|
|
|
be_t<u32> now_connect;
|
|
|
|
|
be_t<u32> system_info;
|
|
|
|
|
be_t<u16> vendor_id[CELL_MAX_PADS];
|
|
|
|
|
be_t<u16> product_id[CELL_MAX_PADS];
|
|
|
|
|
u8 status[CELL_MAX_PADS];
|
2013-12-08 14:47:54 +01:00
|
|
|
};
|
|
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
struct CellPadInfo2
|
|
|
|
|
{
|
2014-02-25 14:09:44 +01:00
|
|
|
be_t<u32> max_connect;
|
|
|
|
|
be_t<u32> now_connect;
|
|
|
|
|
be_t<u32> system_info;
|
|
|
|
|
be_t<u32> port_status[CELL_PAD_MAX_PORT_NUM];
|
|
|
|
|
be_t<u32> port_setting[CELL_PAD_MAX_PORT_NUM];
|
|
|
|
|
be_t<u32> device_capability[CELL_PAD_MAX_PORT_NUM];
|
|
|
|
|
be_t<u32> device_type[CELL_PAD_MAX_PORT_NUM];
|
2012-11-15 00:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
2014-05-07 05:46:18 +02:00
|
|
|
struct CellCapabilityInfo
|
|
|
|
|
{
|
|
|
|
|
be_t<u32> info[CELL_PAD_MAX_CAPABILITY_INFO];
|
|
|
|
|
};
|
|
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
int cellPadInit(u32 max_connect)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadInit(max_connect=%d)", max_connect);
|
2012-11-15 00:39:56 +01:00
|
|
|
if(Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_ALREADY_INITIALIZED;
|
2014-05-06 03:49:20 +02:00
|
|
|
if (max_connect > CELL_PAD_MAX_PORT_NUM) return CELL_PAD_ERROR_INVALID_PARAMETER;
|
2012-11-15 00:39:56 +01:00
|
|
|
Emu.GetPadManager().Init(max_connect);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cellPadEnd()
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadEnd()");
|
2012-11-15 00:39:56 +01:00
|
|
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
|
|
|
|
Emu.GetPadManager().Close();
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cellPadClearBuf(u32 port_no)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadClearBuf(port_no=%d)", port_no);
|
2012-11-15 00:39:56 +01:00
|
|
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
2014-05-07 06:09:10 +02:00
|
|
|
const PadInfo& rinfo = Emu.GetPadManager().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;
|
|
|
|
|
|
2014-05-21 02:56:36 +02:00
|
|
|
//Set 'm_buffer_cleared' to force a resend of everything
|
|
|
|
|
//might as well also reset everything in our pad 'buffer' to nothing as well
|
2014-05-07 06:09:10 +02:00
|
|
|
|
|
|
|
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
|
|
|
|
Pad& pad = pads[port_no];
|
|
|
|
|
|
2014-05-21 02:56:36 +02:00
|
|
|
pad.m_buffer_cleared = true;
|
2014-05-07 06:09:10 +02:00
|
|
|
pad.m_analog_left_x = pad.m_analog_left_y = pad.m_analog_right_x = pad.m_analog_right_y = 128;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-05-07 06:09:10 +02:00
|
|
|
pad.m_digital_1 = pad.m_digital_2 = 0;
|
|
|
|
|
pad.m_press_right = pad.m_press_left = pad.m_press_up = pad.m_press_down = 0;
|
|
|
|
|
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;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-05-07 06:09:10 +02:00
|
|
|
//~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 = 0;
|
|
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cellPadGetData(u32 port_no, u32 data_addr)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadGetData[port_no: %d, data_addr: 0x%x]", port_no, data_addr);
|
2014-03-31 16:18:44 +02:00
|
|
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
2012-11-15 00:39:56 +01:00
|
|
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
2014-05-06 03:49:20 +02:00
|
|
|
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
|
|
|
|
|
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;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-04-27 14:33:31 +02:00
|
|
|
Pad& pad = pads[port_no];
|
2012-11-15 00:39:56 +01:00
|
|
|
CellPadData data;
|
|
|
|
|
memset(&data, 0, sizeof(CellPadData));
|
|
|
|
|
|
2014-05-21 02:56:36 +02:00
|
|
|
u16 d1Initial, d2Initial;
|
|
|
|
|
d1Initial = pad.m_digital_1;
|
|
|
|
|
d2Initial = pad.m_digital_2;
|
|
|
|
|
bool btnChanged = false;
|
2014-04-27 14:33:31 +02:00
|
|
|
for(Button& button : pad.m_buttons)
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2014-05-21 02:56:36 +02:00
|
|
|
//here we check btns, and set pad accordingly,
|
|
|
|
|
//if something changed, set btnChanged
|
2014-05-07 06:04:47 +02:00
|
|
|
|
|
|
|
|
if (button.m_offset == CELL_PAD_BTN_OFFSET_DIGITAL1)
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2014-05-07 06:04:47 +02:00
|
|
|
if (button.m_pressed) pad.m_digital_1 |= button.m_outKeyCode;
|
2014-05-08 01:08:16 +02:00
|
|
|
else pad.m_digital_1 &= ~button.m_outKeyCode;
|
2014-05-07 06:04:47 +02:00
|
|
|
|
|
|
|
|
switch (button.m_outKeyCode)
|
|
|
|
|
{
|
2014-05-21 02:56:36 +02:00
|
|
|
case CELL_PAD_CTRL_LEFT:
|
|
|
|
|
if (pad.m_press_left != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_left = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_DOWN:
|
|
|
|
|
if (pad.m_press_down != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_down = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_RIGHT:
|
|
|
|
|
if (pad.m_press_right != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_right = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_UP:
|
|
|
|
|
if (pad.m_press_up != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_up = button.m_value;
|
|
|
|
|
break;
|
2014-05-07 06:04:47 +02:00
|
|
|
//These arent pressure btns
|
|
|
|
|
case CELL_PAD_CTRL_R3:
|
|
|
|
|
case CELL_PAD_CTRL_L3:
|
|
|
|
|
case CELL_PAD_CTRL_START:
|
|
|
|
|
case CELL_PAD_CTRL_SELECT:
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (button.m_offset == CELL_PAD_BTN_OFFSET_DIGITAL2)
|
|
|
|
|
{
|
|
|
|
|
if (button.m_pressed) pad.m_digital_2 |= button.m_outKeyCode;
|
2014-05-08 01:08:16 +02:00
|
|
|
else pad.m_digital_2 &= ~button.m_outKeyCode;
|
|
|
|
|
|
2014-05-07 06:04:47 +02:00
|
|
|
switch (button.m_outKeyCode)
|
|
|
|
|
{
|
2014-05-21 02:56:36 +02:00
|
|
|
case CELL_PAD_CTRL_SQUARE:
|
|
|
|
|
if (pad.m_press_square != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_square = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_CROSS:
|
|
|
|
|
if (pad.m_press_cross != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_cross = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_CIRCLE:
|
|
|
|
|
if (pad.m_press_circle != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_circle = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_TRIANGLE:
|
|
|
|
|
if (pad.m_press_triangle != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_triangle = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_R1:
|
|
|
|
|
if (pad.m_press_R1 != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_R1 = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_L1:
|
|
|
|
|
if (pad.m_press_L1 != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_L1 = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_R2:
|
|
|
|
|
if (pad.m_press_R2 != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_R2 = button.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_CTRL_L2:
|
|
|
|
|
if (pad.m_press_L2 != button.m_value) btnChanged = true;
|
|
|
|
|
pad.m_press_L2 = button.m_value;
|
|
|
|
|
break;
|
2014-05-07 06:04:47 +02:00
|
|
|
default: break;
|
|
|
|
|
}
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|
2013-08-26 16:18:59 +02:00
|
|
|
|
2014-04-01 02:02:27 +02:00
|
|
|
if(button.m_flush)
|
2013-08-26 16:18:59 +02:00
|
|
|
{
|
2014-04-01 02:02:27 +02:00
|
|
|
button.m_pressed = false;
|
|
|
|
|
button.m_flush = false;
|
2014-05-07 06:04:47 +02:00
|
|
|
button.m_value = 0;
|
2013-08-26 16:18:59 +02:00
|
|
|
}
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:02:27 +02:00
|
|
|
for (const AnalogStick& stick : pads[port_no].m_sticks)
|
2014-01-14 20:03:48 +01:00
|
|
|
{
|
2014-04-01 02:02:27 +02:00
|
|
|
switch (stick.m_offset)
|
2014-01-14 20:03:48 +01:00
|
|
|
{
|
2014-05-21 02:56:36 +02:00
|
|
|
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X:
|
|
|
|
|
if (pad.m_analog_left_x != stick.m_value) btnChanged = true;
|
|
|
|
|
pad.m_analog_left_x = stick.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y:
|
|
|
|
|
if (pad.m_analog_left_y != stick.m_value) btnChanged = true;
|
|
|
|
|
pad.m_analog_left_y = stick.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X:
|
|
|
|
|
if (pad.m_analog_right_x != stick.m_value) btnChanged = true;
|
|
|
|
|
pad.m_analog_right_x = stick.m_value;
|
|
|
|
|
break;
|
|
|
|
|
case CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y:
|
|
|
|
|
if (pad.m_analog_right_y != stick.m_value) btnChanged = true;
|
|
|
|
|
pad.m_analog_right_y = stick.m_value;
|
|
|
|
|
break;
|
2014-05-07 06:04:47 +02:00
|
|
|
default: break;
|
2014-01-14 20:03:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
2014-05-21 02:56:36 +02:00
|
|
|
if (d1Initial != pad.m_digital_1 || d2Initial != pad.m_digital_2)
|
|
|
|
|
{
|
|
|
|
|
btnChanged = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//not sure if this should officially change with capabilities/portsettings :(
|
|
|
|
|
data.len = CELL_PAD_MAX_CODES;
|
|
|
|
|
|
|
|
|
|
//report len 0 if nothing changed and if we havent recently cleared buffer
|
|
|
|
|
if (pad.m_buffer_cleared)
|
|
|
|
|
{
|
|
|
|
|
pad.m_buffer_cleared = false;
|
|
|
|
|
}
|
|
|
|
|
else if (!btnChanged)
|
|
|
|
|
{
|
|
|
|
|
data.len = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//lets still send new data anyway, not sure whats expected still
|
2014-05-07 06:04:47 +02:00
|
|
|
data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] = pad.m_digital_1;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] = pad.m_digital_2;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] = pad.m_analog_right_x;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] = pad.m_analog_right_y;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] = pad.m_analog_left_x;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] = pad.m_analog_left_y;
|
2014-02-25 14:09:44 +01:00
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_RIGHT] = pad.m_press_right;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_LEFT] = pad.m_press_left;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_UP] = pad.m_press_up;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_DOWN] = pad.m_press_down;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_TRIANGLE] = pad.m_press_triangle;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_CIRCLE] = pad.m_press_circle;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_CROSS] = pad.m_press_cross;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_SQUARE] = pad.m_press_square;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_L1] = pad.m_press_L1;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_L2] = pad.m_press_L2;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_R1] = pad.m_press_R1;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_R2] = pad.m_press_R2;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_SENSOR_X] = pad.m_sensor_x;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_SENSOR_Y] = pad.m_sensor_y;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_SENSOR_Z] = pad.m_sensor_z;
|
|
|
|
|
data.button[CELL_PAD_BTN_OFFSET_SENSOR_G] = pad.m_sensor_g;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
|
|
|
Memory.WriteData(data_addr, data);
|
|
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cellPadGetDataExtra(u32 port_no, u32 device_type_addr, u32 data_addr)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadGetDataExtra(port_no=%d, device_type_addr=0x%x, device_type_addr=0x%x)", port_no, device_type_addr, data_addr);
|
2012-11-15 00:39:56 +01:00
|
|
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
2014-05-07 05:54:41 +02:00
|
|
|
const PadInfo& rinfo = Emu.GetPadManager().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;
|
|
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cellPadSetActDirect(u32 port_no, u32 param_addr)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadSetActDirect(port_no=%d, param_addr=0x%x)", port_no, param_addr);
|
2012-11-15 00:39:56 +01:00
|
|
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
2014-05-07 05:54:41 +02:00
|
|
|
const PadInfo& rinfo = Emu.GetPadManager().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;
|
|
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-08 14:47:54 +01:00
|
|
|
int cellPadGetInfo(u32 info_addr)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadGetInfo(info_addr=0x%x)", info_addr);
|
2013-12-08 14:47:54 +01:00
|
|
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
|
|
|
|
|
|
|
|
|
CellPadInfo info;
|
|
|
|
|
memset(&info, 0, sizeof(CellPadInfo));
|
|
|
|
|
|
|
|
|
|
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
|
2014-02-25 14:09:44 +01:00
|
|
|
info.max_connect = rinfo.max_connect;
|
|
|
|
|
info.now_connect = rinfo.now_connect;
|
|
|
|
|
info.system_info = rinfo.system_info;
|
2013-12-08 14:47:54 +01:00
|
|
|
|
2014-05-06 04:58:49 +02:00
|
|
|
//Can't have this as const, we need to reset Assign Changes Flag here
|
|
|
|
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
2013-12-08 14:47:54 +01:00
|
|
|
|
|
|
|
|
for(u32 i=0; i<CELL_MAX_PADS; ++i)
|
|
|
|
|
{
|
2014-03-31 16:18:44 +02:00
|
|
|
if(i >= pads.size())
|
|
|
|
|
break;
|
2013-12-08 14:47:54 +01:00
|
|
|
|
2014-02-25 14:09:44 +01:00
|
|
|
info.status[i] = pads[i].m_port_status;
|
2014-05-06 04:58:49 +02:00
|
|
|
pads[i].m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
|
2014-02-25 14:09:44 +01:00
|
|
|
info.product_id[i] = 0x0268;
|
|
|
|
|
info.vendor_id[i] = 0x054C;
|
2013-12-08 14:47:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Memory.WriteData(info_addr, info);
|
|
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
int cellPadGetInfo2(u32 info_addr)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadGetInfo2(info_addr=0x%x)", info_addr);
|
2012-11-15 00:39:56 +01:00
|
|
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
|
|
|
|
|
|
|
|
|
CellPadInfo2 info;
|
|
|
|
|
memset(&info, 0, sizeof(CellPadInfo2));
|
|
|
|
|
|
|
|
|
|
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
|
2014-02-25 14:09:44 +01:00
|
|
|
info.max_connect = rinfo.max_connect;
|
|
|
|
|
info.now_connect = rinfo.now_connect;
|
|
|
|
|
info.system_info = rinfo.system_info;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-05-06 04:58:49 +02:00
|
|
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
|
|
|
for(u32 i=0; i<CELL_PAD_MAX_PORT_NUM; ++i)
|
|
|
|
|
{
|
2014-03-31 16:18:44 +02:00
|
|
|
if(i >= pads.size())
|
|
|
|
|
break;
|
|
|
|
|
|
2014-02-25 14:09:44 +01:00
|
|
|
info.port_status[i] = pads[i].m_port_status;
|
2014-05-06 04:58:49 +02:00
|
|
|
pads[i].m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
|
2014-02-25 14:09:44 +01:00
|
|
|
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;
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Memory.WriteData(info_addr, info);
|
|
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-07 05:46:18 +02:00
|
|
|
int cellPadGetCapabilityInfo(u32 port_no, mem32_t info_addr)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadGetCapabilityInfo[port_no: %d, data_addr: 0x%x]", port_no, info_addr.GetAddr());
|
2014-05-07 05:46:18 +02:00
|
|
|
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.now_connect) return CELL_PAD_ERROR_NO_DEVICE;
|
|
|
|
|
|
|
|
|
|
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
|
|
|
|
|
|
|
|
|
CellCapabilityInfo data;
|
|
|
|
|
memset(&data, 0, sizeof(CellCapabilityInfo));
|
|
|
|
|
|
|
|
|
|
//Should return the same as device capability mask, psl1ght has it backwards in pad.h
|
|
|
|
|
data.info[0] = pads[port_no].m_device_capability;
|
|
|
|
|
|
|
|
|
|
Memory.WriteData(info_addr.GetAddr(), data);
|
|
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
int cellPadSetPortSetting(u32 port_no, u32 port_setting)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadSetPortSetting(port_no=%d, port_setting=0x%x)", port_no, port_setting);
|
2012-11-15 00:39:56 +01:00
|
|
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
2014-05-07 05:54:41 +02:00
|
|
|
if ((port_setting < CELL_PAD_SETTING_PRESS_ON) || port_setting >(CELL_PAD_SETTING_PRESS_ON | CELL_PAD_SETTING_SENSOR_ON) && port_setting != 0)
|
|
|
|
|
return CELL_PAD_ERROR_INVALID_PARAMETER;
|
|
|
|
|
const PadInfo& rinfo = Emu.GetPadManager().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;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-05-07 05:54:41 +02:00
|
|
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
2012-11-15 00:39:56 +01:00
|
|
|
pads[port_no].m_port_setting = port_setting;
|
|
|
|
|
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
2014-01-05 00:58:03 +01:00
|
|
|
|
|
|
|
|
int cellPadInfoPressMode(u32 port_no)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadInfoPressMode(port_no=%d)", port_no);
|
2014-05-07 05:54:41 +02:00
|
|
|
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.now_connect) return CELL_PAD_ERROR_NO_DEVICE;
|
|
|
|
|
|
|
|
|
|
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
|
|
|
|
|
|
|
|
|
return (pads[port_no].m_device_capability & CELL_PAD_CAPABILITY_PRESS_MODE) > 0;
|
2014-01-05 00:58:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cellPadInfoSensorMode(u32 port_no)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadInfoSensorMode(port_no=%d)", port_no);
|
2014-05-07 05:54:41 +02:00
|
|
|
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.now_connect) return CELL_PAD_ERROR_NO_DEVICE;
|
|
|
|
|
|
|
|
|
|
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
|
|
|
|
|
|
|
|
|
return (pads[port_no].m_device_capability & CELL_PAD_CAPABILITY_SENSOR_MODE) > 0;
|
2014-04-06 21:47:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cellPadSetPressMode(u32 port_no, u32 mode)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadSetPressMode(port_no=%u, mode=%u)", port_no, mode);
|
2014-05-07 05:54:41 +02:00
|
|
|
if (!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
2014-05-21 02:54:08 +02:00
|
|
|
if (mode != 0 && mode != 1) return CELL_PAD_ERROR_INVALID_PARAMETER;
|
2014-05-07 05:54:41 +02:00
|
|
|
const PadInfo& rinfo = Emu.GetPadManager().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;
|
|
|
|
|
|
|
|
|
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
|
|
|
|
|
|
|
|
|
if (mode)
|
|
|
|
|
pads[port_no].m_port_setting |= CELL_PAD_SETTING_PRESS_ON;
|
|
|
|
|
else
|
|
|
|
|
pads[port_no].m_port_setting &= ~CELL_PAD_SETTING_PRESS_ON;
|
|
|
|
|
|
2014-04-06 21:47:21 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cellPadSetSensorMode(u32 port_no, u32 mode)
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
sys_io->Log("cellPadSetSensorMode(port_no=%u, mode=%u)", port_no, mode);
|
2014-05-07 05:54:41 +02:00
|
|
|
if (!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
2014-05-21 02:54:08 +02:00
|
|
|
if (mode != 0 && mode != 1) return CELL_PAD_ERROR_INVALID_PARAMETER;
|
2014-05-07 05:54:41 +02:00
|
|
|
const PadInfo& rinfo = Emu.GetPadManager().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;
|
|
|
|
|
|
|
|
|
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
|
|
|
|
|
|
|
|
|
if (mode)
|
|
|
|
|
pads[port_no].m_port_setting |= CELL_PAD_SETTING_SENSOR_ON;
|
|
|
|
|
else
|
|
|
|
|
pads[port_no].m_port_setting &= ~CELL_PAD_SETTING_SENSOR_ON;
|
|
|
|
|
|
2014-04-06 21:47:21 +02:00
|
|
|
return CELL_OK;
|
2014-01-05 00:58:03 +01:00
|
|
|
}
|