Input: don't intercept pads after system dialogs, but still ignore input

This commit is contained in:
Megamouse 2019-09-20 10:12:01 +02:00
parent 571bb914f5
commit caef52e3b3
3 changed files with 12 additions and 10 deletions

View File

@ -137,7 +137,7 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
const PadInfo& rinfo = handler->GetInfo();
if (rinfo.system_info & CELL_PAD_INFO_INTERCEPTED)
if (rinfo.ignore_input || (rinfo.system_info & CELL_PAD_INFO_INTERCEPTED))
{
data->len = CELL_PAD_LEN_NO_CHANGE;
return CELL_OK;

View File

@ -60,10 +60,11 @@ void pad_thread::Init()
}
}
const u32 system_info = m_info.system_info;
const PadInfo pad_info(m_info);
std::memset(&m_info, 0, sizeof(m_info));
m_info.now_connect = 0;
m_info.system_info |= system_info;
m_info.system_info |= pad_info.system_info;
m_info.ignore_input = pad_info.ignore_input;
handlers.clear();
@ -160,11 +161,11 @@ void pad_thread::SetIntercepted(bool intercepted)
if (intercepted)
{
m_info.system_info |= CELL_PAD_INFO_INTERCEPTED;
m_is_intercepted = true;
m_info.ignore_input = true;
}
else
{
m_is_intercepted = false;
m_info.system_info &= ~CELL_PAD_INFO_INTERCEPTED;
}
}
@ -195,8 +196,9 @@ void pad_thread::ThreadFunc()
m_info.now_connect = connected + num_ldd_pad;
// The following section is only reached when a dialog was closed and the pads are still intercepted.
// As long as any of the listed buttons is pressed the interception stays active.
if (!m_is_intercepted && (m_info.system_info & CELL_PAD_INFO_INTERCEPTED))
// As long as any of the listed buttons is pressed, cellPadGetData will ignore all input (needed for Hotline Miami).
// ignore_input was added because if we keep the pads intercepted, then some games will enter the menu due to unexpected system interception (tested with Ninja Gaiden Sigma).
if (!(m_info.system_info & CELL_PAD_INFO_INTERCEPTED) && m_info.ignore_input)
{
bool any_button_pressed = false;
@ -228,7 +230,7 @@ void pad_thread::ThreadFunc()
if (!any_button_pressed)
{
m_info.system_info &= ~CELL_PAD_INFO_INTERCEPTED;
m_info.ignore_input = false;
}
}

View File

@ -11,6 +11,7 @@ struct PadInfo
{
u32 now_connect;
u32 system_info;
bool ignore_input;
};
class pad_thread
@ -40,13 +41,12 @@ protected:
void *curthread;
void *curwindow;
PadInfo m_info{ 0, 0 };
PadInfo m_info{ 0, 0, false };
std::array<std::shared_ptr<Pad>, CELL_PAD_MAX_PORT_NUM> m_pads;
atomic_t<bool> active{ false };
atomic_t<bool> reset{ false };
atomic_t<bool> is_enabled{ true };
atomic_t<bool> m_is_intercepted{ false };
std::shared_ptr<std::thread> thread;
u32 num_ldd_pad = 0;