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

overlays: Double dpad repeat rate #5919

Merged
merged 4 commits into from May 6, 2019
Merged
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
18 changes: 15 additions & 3 deletions rpcs3/Emu/RSX/Overlays/overlays.cpp
Expand Up @@ -159,9 +159,14 @@ namespace rsx

s32 user_interface::run_input_loop()
{
const u64 ms_interval = 200;
std::array<std::chrono::steady_clock::time_point, CELL_PAD_MAX_PORT_NUM> timestamp;
timestamp.fill(std::chrono::steady_clock::now());

const u64 ms_threshold = 500;
std::array<std::chrono::steady_clock::time_point, CELL_PAD_MAX_PORT_NUM> initial_timestamp;
initial_timestamp.fill(std::chrono::steady_clock::now());

std::array<std::array<bool, pad_button::pad_button_max_enum>, CELL_PAD_MAX_PORT_NUM> button_state;
for (auto& state : button_state)
{
Expand Down Expand Up @@ -257,16 +262,23 @@ namespace rsx
{
if (button_id < 4) // d-pad button
{
if (!button_state[pad_index][button_id] || input_timer.GetMsSince(timestamp[pad_index]) > 400)
if (!button_state[pad_index][button_id])
{
// the d-pad button was not pressed before, so this is a new button press
timestamp[pad_index] = std::chrono::steady_clock::now();
initial_timestamp[pad_index] = timestamp[pad_index];
on_button_pressed(static_cast<pad_button>(button_id));
}
else if (input_timer.GetMsSince(initial_timestamp[pad_index]) > ms_threshold && input_timer.GetMsSince(timestamp[pad_index]) > ms_interval)
{
// d-pad button was not pressed, or was pressed more than 400ms ago
// the d-pad button was pressed for at least the given threshold in ms and will trigger at an interval
timestamp[pad_index] = std::chrono::steady_clock::now();
on_button_pressed(static_cast<pad_button>(button_id));
}
}
else if (!button_state[pad_index][button_id])
{
// button was not pressed
// the button was not pressed before, so this is a new button press
on_button_pressed(static_cast<pad_button>(button_id));
}
}
Expand Down