From caef52e3b3cf9f2c22e1d5d29ec8416b4941ce73 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 20 Sep 2019 10:12:01 +0200 Subject: [PATCH] Input: don't intercept pads after system dialogs, but still ignore input --- rpcs3/Emu/Cell/Modules/cellPad.cpp | 2 +- rpcs3/pad_thread.cpp | 16 +++++++++------- rpcs3/pad_thread.h | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellPad.cpp b/rpcs3/Emu/Cell/Modules/cellPad.cpp index 49d84306b6..cbb44fd96c 100644 --- a/rpcs3/Emu/Cell/Modules/cellPad.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPad.cpp @@ -137,7 +137,7 @@ error_code cellPadGetData(u32 port_no, vm::ptr 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; diff --git a/rpcs3/pad_thread.cpp b/rpcs3/pad_thread.cpp index 58b6a90c5a..5e66319bfa 100644 --- a/rpcs3/pad_thread.cpp +++ b/rpcs3/pad_thread.cpp @@ -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; } } diff --git a/rpcs3/pad_thread.h b/rpcs3/pad_thread.h index ae9d3f225f..aa6750f6ad 100644 --- a/rpcs3/pad_thread.h +++ b/rpcs3/pad_thread.h @@ -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, CELL_PAD_MAX_PORT_NUM> m_pads; atomic_t active{ false }; atomic_t reset{ false }; atomic_t is_enabled{ true }; - atomic_t m_is_intercepted{ false }; std::shared_ptr thread; u32 num_ldd_pad = 0;