Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: keep pads intercepted while regular buttons are still pressed #6218

Merged
merged 2 commits into from
Jul 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 45 additions & 1 deletion rpcs3/pad_thread.cpp
Expand Up @@ -160,10 +160,11 @@ void pad_thread::SetIntercepted(bool intercepted)
if (intercepted)
{
m_info.system_info |= CELL_PAD_INFO_INTERCEPTED;
m_is_intercepted = true;
}
else
{
m_info.system_info &= ~CELL_PAD_INFO_INTERCEPTED;
m_is_intercepted = false;
}
}

Expand All @@ -177,17 +178,60 @@ void pad_thread::ThreadFunc()
std::this_thread::sleep_for(1ms);
continue;
}

if (reset && reset.exchange(false))
{
Init();
}

u32 connected = 0;

for (auto& cur_pad_handler : handlers)
{
cur_pad_handler.second->ThreadProc();
connected += cur_pad_handler.second->connected;
}

m_info.now_connect = connected;

// 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))
{
bool any_button_pressed = false;

for (const auto& pad : m_pads)
{
if (pad->m_port_status & CELL_PAD_STATUS_CONNECTED)
{
for (const auto& button : pad->m_buttons)
{
if (button.m_pressed && (
button.m_outKeyCode == CELL_PAD_CTRL_CROSS ||
button.m_outKeyCode == CELL_PAD_CTRL_CIRCLE ||
button.m_outKeyCode == CELL_PAD_CTRL_TRIANGLE ||
button.m_outKeyCode == CELL_PAD_CTRL_SQUARE ||
button.m_outKeyCode == CELL_PAD_CTRL_START ||
button.m_outKeyCode == CELL_PAD_CTRL_SELECT))
{
any_button_pressed = true;
break;
}
}

if (any_button_pressed)
{
break;
}
}
}

if (!any_button_pressed)
{
m_info.system_info &= ~CELL_PAD_INFO_INTERCEPTED;
}
}

std::this_thread::sleep_for(1ms);
}
}
1 change: 1 addition & 0 deletions rpcs3/pad_thread.h
Expand Up @@ -43,6 +43,7 @@ class pad_thread
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;
};

Expand Down