Do not rely on cellPadInit in native ui

This commit is contained in:
eladash 2018-12-13 07:24:17 +02:00 committed by Megamouse
parent 2e7e2bb07e
commit 8cbaa8627c
13 changed files with 160 additions and 146 deletions

View file

@ -140,23 +140,16 @@ static bool check_gem_num(const u32 gem_num)
*/
static bool map_to_ds3_input(const u32 port_no, be_t<u16>& digital_buttons, be_t<u16>& analog_t)
{
const auto handler = fxm::get<pad_thread>();
if (!handler)
{
return false;
}
const auto handler = pad::get_current_handler();
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect || port_no >= rinfo.now_connect)
{
return false;
}
auto& pads = handler->GetPads();
auto pad = pads[port_no];
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return false;
for (Button& button : pad->m_buttons)
{
//here we check btns, and set pad accordingly,
@ -240,30 +233,17 @@ static bool map_to_ds3_input(const u32 port_no, be_t<u16>& digital_buttons, be_t
*/
static bool map_ext_to_ds3_input(const u32 port_no, CellGemExtPortData& ext)
{
const auto handler = fxm::get<pad_thread>();
if (!handler)
{
return false;
}
const auto handler = pad::get_current_handler();
auto& pads = handler->GetPads();
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect)
{
return false;
}
//We have a choice here of NO_DEVICE or READ_FAILED...lets try no device for now
if (port_no >= rinfo.now_connect)
{
return false;
}
auto pad = pads[port_no];
if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return false;
ext.status = 0; // CELL_GEM_EXT_CONNECTED | CELL_GEM_EXT_EXT0 | CELL_GEM_EXT_EXT1
ext.analog_left_x = pad->m_analog_left_x;
ext.analog_left_y = pad->m_analog_left_y;