mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
overlays/osk: add analog movement if CELL_OSKDIALOG_NO_INPUT_ANALOG is unset
This commit is contained in:
parent
dc0230c476
commit
11c42eb8d4
4 changed files with 67 additions and 5 deletions
|
@ -256,9 +256,28 @@ namespace rsx
|
|||
break;
|
||||
}
|
||||
|
||||
// TODO: does the y offset need to be added or subtracted?
|
||||
|
||||
// Calculate initial position and analog movement range.
|
||||
constexpr f32 margin = 50.0f; // Let's add a minimal margin on all sides
|
||||
const u16 frame_x = static_cast<u16>(std::clamp<f32>(origin_x + m_x_offset, margin, static_cast<f32>(virtual_width - frame_w) - margin));
|
||||
const u16 frame_y = static_cast<u16>(std::clamp<f32>(origin_y + m_y_offset, margin, static_cast<f32>(virtual_height - (frame_h + button_height + button_margin)) - margin));
|
||||
const u16 x_min = static_cast<u16>(margin);
|
||||
const u16 x_max = static_cast<u16>(static_cast<f32>(virtual_width - frame_w) - margin);
|
||||
const u16 y_min = static_cast<u16>(margin);
|
||||
const u16 y_max = static_cast<u16>(static_cast<f32>(virtual_height - (frame_h + button_height + button_margin)) - margin);
|
||||
u16 frame_x = 0;
|
||||
u16 frame_y = 0;
|
||||
|
||||
// x pos should only be 0 the first time
|
||||
if (m_x_pos == 0)
|
||||
{
|
||||
frame_x = m_x_pos = static_cast<u16>(std::clamp<f32>(origin_x + m_x_offset, x_min, x_max));
|
||||
frame_y = m_y_pos = static_cast<u16>(std::clamp<f32>(origin_y + m_y_offset, y_min, y_max));
|
||||
}
|
||||
else
|
||||
{
|
||||
frame_x = m_x_pos = std::clamp(m_x_pos, x_min, x_max);
|
||||
frame_y = m_y_pos = std::clamp(m_y_pos, y_min, y_max);
|
||||
}
|
||||
|
||||
m_frame.set_pos(frame_x, frame_y);
|
||||
m_frame.set_size(frame_w, frame_h);
|
||||
|
@ -484,6 +503,20 @@ namespace rsx
|
|||
}
|
||||
};
|
||||
|
||||
// Increase auto repeat interval for some buttons
|
||||
switch (button_press)
|
||||
{
|
||||
case pad_button::rs_left:
|
||||
case pad_button::rs_right:
|
||||
case pad_button::rs_down:
|
||||
case pad_button::rs_up:
|
||||
m_auto_repeat_ms_interval = 10;
|
||||
break;
|
||||
default:
|
||||
m_auto_repeat_ms_interval = m_auto_repeat_ms_interval_default;
|
||||
break;
|
||||
}
|
||||
|
||||
bool play_cursor_sound = true;
|
||||
|
||||
switch (button_press)
|
||||
|
@ -632,6 +665,26 @@ namespace rsx
|
|||
step_panel(true);
|
||||
break;
|
||||
}
|
||||
case pad_button::rs_left:
|
||||
case pad_button::rs_right:
|
||||
case pad_button::rs_down:
|
||||
case pad_button::rs_up:
|
||||
{
|
||||
if (!(flags & CELL_OSKDIALOG_NO_INPUT_ANALOG))
|
||||
{
|
||||
switch (button_press)
|
||||
{
|
||||
case pad_button::rs_left: m_x_pos -= 5; break;
|
||||
case pad_button::rs_right: m_x_pos += 5; break;
|
||||
case pad_button::rs_down: m_y_pos += 5; break;
|
||||
case pad_button::rs_up: m_y_pos -= 5; break;
|
||||
default: break;
|
||||
}
|
||||
update_panel();
|
||||
}
|
||||
play_cursor_sound = false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,10 @@ namespace rsx
|
|||
// Pointer
|
||||
cursor_item m_pointer{};
|
||||
|
||||
// Analog movement
|
||||
u16 m_x_pos = 0;
|
||||
u16 m_y_pos = 0;
|
||||
|
||||
// Grid
|
||||
u16 cell_size_x = 0;
|
||||
u16 cell_size_y = 0;
|
||||
|
|
|
@ -49,11 +49,10 @@ namespace rsx
|
|||
{
|
||||
m_interactive = true;
|
||||
|
||||
const u64 ms_interval = 200;
|
||||
std::array<steady_clock::time_point, CELL_PAD_MAX_PORT_NUM> timestamp;
|
||||
timestamp.fill(steady_clock::now());
|
||||
|
||||
const u64 ms_threshold = 500;
|
||||
constexpr u64 ms_threshold = 500;
|
||||
std::array<steady_clock::time_point, CELL_PAD_MAX_PORT_NUM> initial_timestamp;
|
||||
initial_timestamp.fill(steady_clock::now());
|
||||
|
||||
|
@ -98,7 +97,7 @@ namespace rsx
|
|||
{
|
||||
if (last_auto_repeat_button[pad_index] == button_id
|
||||
&& m_input_timer.GetMsSince(initial_timestamp[pad_index]) > ms_threshold
|
||||
&& m_input_timer.GetMsSince(timestamp[pad_index]) > ms_interval)
|
||||
&& m_input_timer.GetMsSince(timestamp[pad_index]) > m_auto_repeat_ms_interval)
|
||||
{
|
||||
// The auto-repeat button was pressed for at least the given threshold in ms and will trigger at an interval.
|
||||
timestamp[pad_index] = steady_clock::now();
|
||||
|
|
|
@ -91,11 +91,17 @@ namespace rsx
|
|||
|
||||
protected:
|
||||
Timer m_input_timer;
|
||||
static constexpr u64 m_auto_repeat_ms_interval_default = 200;
|
||||
u64 m_auto_repeat_ms_interval = m_auto_repeat_ms_interval_default;
|
||||
std::set<u8> m_auto_repeat_buttons = {
|
||||
pad_button::dpad_up,
|
||||
pad_button::dpad_down,
|
||||
pad_button::dpad_left,
|
||||
pad_button::dpad_right,
|
||||
pad_button::rs_up,
|
||||
pad_button::rs_down,
|
||||
pad_button::rs_left,
|
||||
pad_button::rs_right,
|
||||
pad_button::ls_up,
|
||||
pad_button::ls_down,
|
||||
pad_button::ls_left,
|
||||
|
|
Loading…
Add table
Reference in a new issue