mirror of https://github.com/RPCS3/rpcs3.git
commit
93cb2a0af9
|
@ -86,12 +86,14 @@ enum ButtonDataOffset
|
||||||
static const u32 CELL_MAX_PADS = 127;
|
static const u32 CELL_MAX_PADS = 127;
|
||||||
static const u32 CELL_PAD_MAX_PORT_NUM = 7;
|
static const u32 CELL_PAD_MAX_PORT_NUM = 7;
|
||||||
static const u32 CELL_PAD_MAX_CODES = 64;
|
static const u32 CELL_PAD_MAX_CODES = 64;
|
||||||
|
static const u32 CELL_PAD_MAX_CAPABILITY_INFO = 32;
|
||||||
|
|
||||||
struct Button
|
struct Button
|
||||||
{
|
{
|
||||||
u32 m_offset;
|
u32 m_offset;
|
||||||
u32 m_keyCode;
|
u32 m_keyCode;
|
||||||
u32 m_outKeyCode;
|
u32 m_outKeyCode;
|
||||||
|
u16 m_value;
|
||||||
bool m_pressed;
|
bool m_pressed;
|
||||||
bool m_flush;
|
bool m_flush;
|
||||||
|
|
||||||
|
@ -101,6 +103,7 @@ struct Button
|
||||||
, m_offset(offset)
|
, m_offset(offset)
|
||||||
, m_keyCode(keyCode)
|
, m_keyCode(keyCode)
|
||||||
, m_outKeyCode(outKeyCode)
|
, m_outKeyCode(outKeyCode)
|
||||||
|
, m_value(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -110,15 +113,13 @@ struct AnalogStick
|
||||||
u32 m_offset;
|
u32 m_offset;
|
||||||
u32 m_keyCodeMin;
|
u32 m_keyCodeMin;
|
||||||
u32 m_keyCodeMax;
|
u32 m_keyCodeMax;
|
||||||
bool m_min_pressed;
|
u16 m_value;
|
||||||
bool m_max_pressed;
|
|
||||||
|
|
||||||
AnalogStick(u32 offset, u32 keyCodeMin, u32 keyCodeMax)
|
AnalogStick(u32 offset, u32 keyCodeMin, u32 keyCodeMax)
|
||||||
: m_min_pressed(false)
|
: m_offset(offset)
|
||||||
, m_max_pressed(false)
|
|
||||||
, m_offset(offset)
|
|
||||||
, m_keyCodeMin(keyCodeMin)
|
, m_keyCodeMin(keyCodeMin)
|
||||||
, m_keyCodeMax(keyCodeMax)
|
, m_keyCodeMax(keyCodeMax)
|
||||||
|
, m_value(128)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -133,10 +134,15 @@ struct Pad
|
||||||
std::vector<Button> m_buttons;
|
std::vector<Button> m_buttons;
|
||||||
std::vector<AnalogStick> m_sticks;
|
std::vector<AnalogStick> m_sticks;
|
||||||
|
|
||||||
s16 m_analog_left_x;
|
//These hold bits for their respective buttons
|
||||||
s16 m_analog_left_y;
|
u16 m_digital_1;
|
||||||
s16 m_analog_right_x;
|
u16 m_digital_2;
|
||||||
s16 m_analog_right_y;
|
|
||||||
|
//All sensors go from 0-255
|
||||||
|
u16 m_analog_left_x;
|
||||||
|
u16 m_analog_left_y;
|
||||||
|
u16 m_analog_right_x;
|
||||||
|
u16 m_analog_right_y;
|
||||||
|
|
||||||
u16 m_press_right;
|
u16 m_press_right;
|
||||||
u16 m_press_left;
|
u16 m_press_left;
|
||||||
|
@ -151,6 +157,8 @@ struct Pad
|
||||||
u16 m_press_R1;
|
u16 m_press_R1;
|
||||||
u16 m_press_R2;
|
u16 m_press_R2;
|
||||||
|
|
||||||
|
//Except for these...0-1023
|
||||||
|
//~399 on sensor y is a level non moving controller
|
||||||
u16 m_sensor_x;
|
u16 m_sensor_x;
|
||||||
u16 m_sensor_y;
|
u16 m_sensor_y;
|
||||||
u16 m_sensor_z;
|
u16 m_sensor_z;
|
||||||
|
@ -162,6 +170,9 @@ struct Pad
|
||||||
, m_device_capability(device_capability)
|
, m_device_capability(device_capability)
|
||||||
, m_device_type(device_type)
|
, m_device_type(device_type)
|
||||||
|
|
||||||
|
, m_digital_1(0)
|
||||||
|
, m_digital_2(0)
|
||||||
|
|
||||||
, m_analog_left_x(128)
|
, m_analog_left_x(128)
|
||||||
, m_analog_left_y(128)
|
, m_analog_left_y(128)
|
||||||
, m_analog_right_x(128)
|
, m_analog_right_x(128)
|
||||||
|
@ -181,7 +192,7 @@ struct Pad
|
||||||
, m_press_R2(0)
|
, m_press_R2(0)
|
||||||
|
|
||||||
, m_sensor_x(0)
|
, m_sensor_x(0)
|
||||||
, m_sensor_y(0)
|
, m_sensor_y(399)
|
||||||
, m_sensor_z(0)
|
, m_sensor_z(0)
|
||||||
, m_sensor_g(0)
|
, m_sensor_g(0)
|
||||||
{
|
{
|
||||||
|
@ -206,24 +217,34 @@ public:
|
||||||
virtual void Close()=0;
|
virtual void Close()=0;
|
||||||
virtual ~PadHandlerBase() = default;
|
virtual ~PadHandlerBase() = default;
|
||||||
|
|
||||||
void Key(const u32 code, bool pressed)
|
//Set value to set pressure/axi to certain level, otherwise 0/255 default
|
||||||
|
void Key(const u32 code, bool pressed, u16 value=256)
|
||||||
{
|
{
|
||||||
for(Pad& pad : m_pads)
|
for(Pad& pad : m_pads)
|
||||||
{
|
{
|
||||||
for(Button& button : pad.m_buttons)
|
for (Button& button : pad.m_buttons)
|
||||||
{
|
{
|
||||||
if(button.m_keyCode != code)
|
if (button.m_keyCode != code)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
|
//This is for reporting when a controller connects/disconnects, shouldn't be here
|
||||||
|
//pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
|
||||||
|
|
||||||
if(button.m_pressed && !pressed)
|
if (value >= 256){ value = 255; }
|
||||||
|
|
||||||
|
//Todo: Is this flush necessary once games hit decent speeds?
|
||||||
|
if (button.m_pressed && !pressed)
|
||||||
{
|
{
|
||||||
button.m_flush = true;
|
button.m_flush = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
button.m_pressed = pressed;
|
button.m_pressed = pressed;
|
||||||
|
if (pressed)
|
||||||
|
button.m_value = value;
|
||||||
|
else
|
||||||
|
button.m_value = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,17 +253,21 @@ public:
|
||||||
if (stick.m_keyCodeMax != code && stick.m_keyCodeMin != code)
|
if (stick.m_keyCodeMax != code && stick.m_keyCodeMin != code)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
|
//slightly less hack job for key based analog stick
|
||||||
|
// should also fix/make transitions when using keys smoother
|
||||||
|
// the logic here is that when a key is released,
|
||||||
|
// if we are at the opposite end of the axis, dont reset to middle
|
||||||
if (stick.m_keyCodeMax == code)
|
if (stick.m_keyCodeMax == code)
|
||||||
{
|
{
|
||||||
stick.m_min_pressed = false; //!!! need fix !!!
|
if (pressed) stick.m_value = 255;
|
||||||
stick.m_max_pressed = pressed;
|
else if (stick.m_value==0) stick.m_value = 0;
|
||||||
|
else stick.m_value = 128;
|
||||||
}
|
}
|
||||||
if (stick.m_keyCodeMin == code)
|
if (stick.m_keyCodeMin == code)
|
||||||
{
|
{
|
||||||
stick.m_max_pressed = false; //!!!
|
if (pressed) stick.m_value = 0;
|
||||||
stick.m_min_pressed = pressed;
|
else if (stick.m_value == 255) stick.m_value = 255;
|
||||||
|
else stick.m_value = 128;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,10 @@ public:
|
||||||
|
|
||||||
void LoadSettings()
|
void LoadSettings()
|
||||||
{
|
{
|
||||||
|
//Fixed assign change, default is both sensor and press off
|
||||||
m_pads.emplace_back(
|
m_pads.emplace_back(
|
||||||
CELL_PAD_STATUS_CONNECTED, CELL_PAD_SETTING_PRESS_ON | CELL_PAD_SETTING_SENSOR_OFF,
|
CELL_PAD_STATUS_CONNECTED | CELL_PAD_STATUS_ASSIGN_CHANGES,
|
||||||
|
CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF,
|
||||||
CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE,
|
CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE,
|
||||||
CELL_PAD_DEV_TYPE_STANDARD);
|
CELL_PAD_DEV_TYPE_STANDARD);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ void sys_io_init()
|
||||||
sys_io.AddFunc(0x78200559, cellPadInfoSensorMode);
|
sys_io.AddFunc(0x78200559, cellPadInfoSensorMode);
|
||||||
sys_io.AddFunc(0xf83f8182, cellPadSetPressMode);
|
sys_io.AddFunc(0xf83f8182, cellPadSetPressMode);
|
||||||
sys_io.AddFunc(0xbe5be3ba, cellPadSetSensorMode);
|
sys_io.AddFunc(0xbe5be3ba, cellPadSetSensorMode);
|
||||||
|
sys_io.AddFunc(0xdbf4c59c, cellPadGetCapabilityInfo);
|
||||||
|
|
||||||
sys_io.AddFunc(0x433f6ec0, cellKbInit);
|
sys_io.AddFunc(0x433f6ec0, cellKbInit);
|
||||||
sys_io.AddFunc(0xbfce3285, cellKbEnd);
|
sys_io.AddFunc(0xbfce3285, cellKbEnd);
|
||||||
|
|
|
@ -314,6 +314,7 @@ extern int cellPadInfoPressMode(u32 port_no);
|
||||||
extern int cellPadInfoSensorMode(u32 port_no);
|
extern int cellPadInfoSensorMode(u32 port_no);
|
||||||
extern int cellPadSetPressMode(u32 port_no, u32 mode);
|
extern int cellPadSetPressMode(u32 port_no, u32 mode);
|
||||||
extern int cellPadSetSensorMode(u32 port_no, u32 mode);
|
extern int cellPadSetSensorMode(u32 port_no, u32 mode);
|
||||||
|
extern int cellPadGetCapabilityInfo(u32 port_no, mem32_t info_addr);
|
||||||
|
|
||||||
//cellKb
|
//cellKb
|
||||||
extern int cellKbInit(u32 max_connect);
|
extern int cellKbInit(u32 max_connect);
|
||||||
|
|
|
@ -45,10 +45,16 @@ struct CellPadInfo2
|
||||||
be_t<u32> device_type[CELL_PAD_MAX_PORT_NUM];
|
be_t<u32> device_type[CELL_PAD_MAX_PORT_NUM];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CellCapabilityInfo
|
||||||
|
{
|
||||||
|
be_t<u32> info[CELL_PAD_MAX_CAPABILITY_INFO];
|
||||||
|
};
|
||||||
|
|
||||||
int cellPadInit(u32 max_connect)
|
int cellPadInit(u32 max_connect)
|
||||||
{
|
{
|
||||||
sys_io.Log("cellPadInit(max_connect=%d)", max_connect);
|
sys_io.Log("cellPadInit(max_connect=%d)", max_connect);
|
||||||
if(Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_ALREADY_INITIALIZED;
|
if(Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_ALREADY_INITIALIZED;
|
||||||
|
if (max_connect > CELL_PAD_MAX_PORT_NUM) return CELL_PAD_ERROR_INVALID_PARAMETER;
|
||||||
Emu.GetPadManager().Init(max_connect);
|
Emu.GetPadManager().Init(max_connect);
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -65,10 +71,28 @@ int cellPadClearBuf(u32 port_no)
|
||||||
{
|
{
|
||||||
sys_io.Log("cellPadClearBuf(port_no=%d)", port_no);
|
sys_io.Log("cellPadClearBuf(port_no=%d)", port_no);
|
||||||
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||||
if(port_no >= Emu.GetPadManager().GetPads().size()) 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;
|
||||||
|
|
||||||
//?
|
//It seems the system is supposed keeps track of previous values, and reports paddata with len 0 if
|
||||||
|
//nothing has changed.
|
||||||
|
|
||||||
|
//We can at least reset the pad back to its default values for now
|
||||||
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
||||||
|
Pad& pad = pads[port_no];
|
||||||
|
|
||||||
|
pad.m_analog_left_x = pad.m_analog_left_y = pad.m_analog_right_x = pad.m_analog_right_y = 128;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
//~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;
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,65 +101,85 @@ int cellPadGetData(u32 port_no, u32 data_addr)
|
||||||
sys_io.Log("cellPadGetData[port_no: %d, data_addr: 0x%x]", port_no, data_addr);
|
sys_io.Log("cellPadGetData[port_no: %d, data_addr: 0x%x]", port_no, data_addr);
|
||||||
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
||||||
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||||
if(port_no >= pads.size()) return CELL_PAD_ERROR_INVALID_PARAMETER;
|
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;
|
||||||
|
|
||||||
Pad& pad = pads[port_no];
|
Pad& pad = pads[port_no];
|
||||||
CellPadData data;
|
CellPadData data;
|
||||||
memset(&data, 0, sizeof(CellPadData));
|
memset(&data, 0, sizeof(CellPadData));
|
||||||
|
|
||||||
u16 d1 = 0;
|
|
||||||
u16 d2 = 0;
|
|
||||||
|
|
||||||
pad.m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
|
|
||||||
|
|
||||||
for(Button& button : pad.m_buttons)
|
for(Button& button : pad.m_buttons)
|
||||||
{
|
{
|
||||||
switch(button.m_offset)
|
//using an if/else here, not doing switch in switch
|
||||||
|
//plus side is this gives us the ability to check if anything changed eventually
|
||||||
|
|
||||||
|
if (button.m_offset == CELL_PAD_BTN_OFFSET_DIGITAL1)
|
||||||
{
|
{
|
||||||
case CELL_PAD_BTN_OFFSET_DIGITAL1:
|
if (button.m_pressed) pad.m_digital_1 |= button.m_outKeyCode;
|
||||||
if (button.m_pressed) d1 |= button.m_outKeyCode;
|
else pad.m_digital_1 &= ~button.m_outKeyCode;
|
||||||
break;
|
|
||||||
case CELL_PAD_BTN_OFFSET_DIGITAL2:
|
switch (button.m_outKeyCode)
|
||||||
if (button.m_pressed) d2 |= button.m_outKeyCode;
|
{
|
||||||
break;
|
case CELL_PAD_CTRL_LEFT: pad.m_press_left = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_DOWN: pad.m_press_down = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_RIGHT: pad.m_press_right = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_UP: pad.m_press_up = button.m_value; break;
|
||||||
|
//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;
|
||||||
|
else pad.m_digital_2 &= ~button.m_outKeyCode;
|
||||||
|
|
||||||
|
switch (button.m_outKeyCode)
|
||||||
|
{
|
||||||
|
case CELL_PAD_CTRL_SQUARE: pad.m_press_square = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_CROSS: pad.m_press_cross = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_CIRCLE: pad.m_press_circle = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_TRIANGLE: pad.m_press_triangle = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_R1: pad.m_press_R1 = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_L1: pad.m_press_L1 = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_R2: pad.m_press_R2 = button.m_value; break;
|
||||||
|
case CELL_PAD_CTRL_L2: pad.m_press_L2 = button.m_value; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(button.m_flush)
|
if(button.m_flush)
|
||||||
{
|
{
|
||||||
button.m_pressed = false;
|
button.m_pressed = false;
|
||||||
button.m_flush = false;
|
button.m_flush = false;
|
||||||
|
button.m_value = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 lx = 128;
|
|
||||||
u16 ly = 128;
|
|
||||||
u16 rx = 128;
|
|
||||||
u16 ry = 128;
|
|
||||||
for (const AnalogStick& stick : pads[port_no].m_sticks)
|
for (const AnalogStick& stick : pads[port_no].m_sticks)
|
||||||
{
|
{
|
||||||
u16* res;
|
|
||||||
switch (stick.m_offset)
|
switch (stick.m_offset)
|
||||||
{
|
{
|
||||||
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X: res = &lx; break;
|
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X: pad.m_analog_left_x = stick.m_value; break;
|
||||||
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y: res = &ly; break;
|
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y: pad.m_analog_left_y = stick.m_value; break;
|
||||||
case CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X: res = ℞ break;
|
case CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X: pad.m_analog_right_x = stick.m_value; break;
|
||||||
case CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y: res = &ry; break;
|
case CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y: pad.m_analog_right_y = stick.m_value; break;
|
||||||
default: continue;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stick.m_max_pressed && !stick.m_min_pressed)
|
|
||||||
*res = 255;
|
|
||||||
if (stick.m_min_pressed && !stick.m_max_pressed)
|
|
||||||
*res = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data.len = pad.m_buttons.size();
|
data.len = pad.m_buttons.size();
|
||||||
data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] = d1;
|
data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] = pad.m_digital_1;
|
||||||
data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] = d2;
|
data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] = pad.m_digital_2;
|
||||||
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] = rx;
|
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] = pad.m_analog_right_x;
|
||||||
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] = ry;
|
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] = pad.m_analog_right_y;
|
||||||
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] = lx;
|
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] = pad.m_analog_left_x;
|
||||||
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] = ly;
|
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] = pad.m_analog_left_y;
|
||||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_RIGHT] = pad.m_press_right;
|
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_LEFT] = pad.m_press_left;
|
||||||
data.button[CELL_PAD_BTN_OFFSET_PRESS_UP] = pad.m_press_up;
|
data.button[CELL_PAD_BTN_OFFSET_PRESS_UP] = pad.m_press_up;
|
||||||
|
@ -162,7 +206,10 @@ int cellPadGetDataExtra(u32 port_no, u32 device_type_addr, u32 data_addr)
|
||||||
{
|
{
|
||||||
sys_io.Log("cellPadGetDataExtra(port_no=%d, device_type_addr=0x%x, device_type_addr=0x%x)", port_no, device_type_addr, data_addr);
|
sys_io.Log("cellPadGetDataExtra(port_no=%d, device_type_addr=0x%x, device_type_addr=0x%x)", port_no, device_type_addr, data_addr);
|
||||||
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||||
if(port_no >= Emu.GetPadManager().GetPads().size()) 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;
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +217,10 @@ int cellPadSetActDirect(u32 port_no, u32 param_addr)
|
||||||
{
|
{
|
||||||
sys_io.Log("cellPadSetActDirect(port_no=%d, param_addr=0x%x)", port_no, param_addr);
|
sys_io.Log("cellPadSetActDirect(port_no=%d, param_addr=0x%x)", port_no, param_addr);
|
||||||
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||||
if(port_no >= Emu.GetPadManager().GetPads().size()) 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;
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +237,8 @@ int cellPadGetInfo(u32 info_addr)
|
||||||
info.now_connect = rinfo.now_connect;
|
info.now_connect = rinfo.now_connect;
|
||||||
info.system_info = rinfo.system_info;
|
info.system_info = rinfo.system_info;
|
||||||
|
|
||||||
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
//Can't have this as const, we need to reset Assign Changes Flag here
|
||||||
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
||||||
|
|
||||||
for(u32 i=0; i<CELL_MAX_PADS; ++i)
|
for(u32 i=0; i<CELL_MAX_PADS; ++i)
|
||||||
{
|
{
|
||||||
|
@ -195,6 +246,7 @@ int cellPadGetInfo(u32 info_addr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
info.status[i] = pads[i].m_port_status;
|
info.status[i] = pads[i].m_port_status;
|
||||||
|
pads[i].m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
|
||||||
info.product_id[i] = 0x0268;
|
info.product_id[i] = 0x0268;
|
||||||
info.vendor_id[i] = 0x054C;
|
info.vendor_id[i] = 0x054C;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +269,7 @@ int cellPadGetInfo2(u32 info_addr)
|
||||||
info.now_connect = rinfo.now_connect;
|
info.now_connect = rinfo.now_connect;
|
||||||
info.system_info = rinfo.system_info;
|
info.system_info = rinfo.system_info;
|
||||||
|
|
||||||
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
||||||
|
|
||||||
for(u32 i=0; i<CELL_PAD_MAX_PORT_NUM; ++i)
|
for(u32 i=0; i<CELL_PAD_MAX_PORT_NUM; ++i)
|
||||||
{
|
{
|
||||||
|
@ -225,6 +277,7 @@ int cellPadGetInfo2(u32 info_addr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
info.port_status[i] = pads[i].m_port_status;
|
info.port_status[i] = pads[i].m_port_status;
|
||||||
|
pads[i].m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
|
||||||
info.port_setting[i] = pads[i].m_port_setting;
|
info.port_setting[i] = pads[i].m_port_setting;
|
||||||
info.device_capability[i] = pads[i].m_device_capability;
|
info.device_capability[i] = pads[i].m_device_capability;
|
||||||
info.device_type[i] = pads[i].m_device_type;
|
info.device_type[i] = pads[i].m_device_type;
|
||||||
|
@ -235,13 +288,38 @@ int cellPadGetInfo2(u32 info_addr)
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cellPadGetCapabilityInfo(u32 port_no, mem32_t info_addr)
|
||||||
|
{
|
||||||
|
sys_io.Log("cellPadGetCapabilityInfo[port_no: %d, data_addr: 0x%x]", port_no, info_addr.GetAddr());
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
int cellPadSetPortSetting(u32 port_no, u32 port_setting)
|
int cellPadSetPortSetting(u32 port_no, u32 port_setting)
|
||||||
{
|
{
|
||||||
sys_io.Log("cellPadSetPortSetting(port_no=%d, port_setting=0x%x)", port_no, port_setting);
|
sys_io.Log("cellPadSetPortSetting(port_no=%d, port_setting=0x%x)", port_no, port_setting);
|
||||||
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||||
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
if ((port_setting < CELL_PAD_SETTING_PRESS_ON) || port_setting >(CELL_PAD_SETTING_PRESS_ON | CELL_PAD_SETTING_SENSOR_ON) && port_setting != 0)
|
||||||
if(port_no >= pads.size()) return CELL_PAD_ERROR_INVALID_PARAMETER;
|
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;
|
||||||
|
|
||||||
|
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
|
||||||
pads[port_no].m_port_setting = port_setting;
|
pads[port_no].m_port_setting = port_setting;
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
|
@ -249,24 +327,64 @@ int cellPadSetPortSetting(u32 port_no, u32 port_setting)
|
||||||
|
|
||||||
int cellPadInfoPressMode(u32 port_no)
|
int cellPadInfoPressMode(u32 port_no)
|
||||||
{
|
{
|
||||||
sys_io.Error("cellPadInfoPressMode(port_no=%d)", port_no);
|
sys_io.Log("cellPadInfoPressMode(port_no=%d)", port_no);
|
||||||
return CELL_OK;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cellPadInfoSensorMode(u32 port_no)
|
int cellPadInfoSensorMode(u32 port_no)
|
||||||
{
|
{
|
||||||
sys_io.Error("cellPadInfoSensorMode(port_no=%d)", port_no);
|
sys_io.Log("cellPadInfoSensorMode(port_no=%d)", port_no);
|
||||||
return CELL_OK;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cellPadSetPressMode(u32 port_no, u32 mode)
|
int cellPadSetPressMode(u32 port_no, u32 mode)
|
||||||
{
|
{
|
||||||
sys_io.Error("cellPadSetPressMode(port_no=%d)", port_no);
|
sys_io.Log("cellPadSetPressMode(port_no=%d)", port_no);
|
||||||
|
if (!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||||
|
if (mode != 0 || mode != 1) 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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cellPadSetSensorMode(u32 port_no, u32 mode)
|
int cellPadSetSensorMode(u32 port_no, u32 mode)
|
||||||
{
|
{
|
||||||
sys_io.Error("cellPadSetPressMode(port_no=%d)", port_no);
|
sys_io.Log("cellPadSetPressMode(port_no=%d)", port_no);
|
||||||
|
if (!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
|
||||||
|
if (mode != 0 || mode != 1) 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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
Loading…
Reference in New Issue