1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

Input: fix keyboard stick lerp

This commit is contained in:
Megamouse 2021-08-20 16:45:09 +02:00
parent 3eb37344cd
commit 62102293b5

View File

@ -850,16 +850,14 @@ void keyboard_pad_handler::ThreadProc()
return (v0 <= v1) ? std::ceil(res) : std::floor(res);
};
for (uint i = 0; i < m_bindings.size(); i++)
for (uint i = 0; i < m_pads_internal.size(); i++)
{
auto& pad = m_bindings[i];
pad->m_buttons = m_pads_internal[i].m_buttons;
pad->m_sticks = m_pads_internal[i].m_sticks;
auto& pad = m_pads_internal[i];
if (last_connection_status[i] == false)
{
pad->m_port_status |= CELL_PAD_STATUS_CONNECTED;
pad->m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
pad.m_port_status |= CELL_PAD_STATUS_CONNECTED;
pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
last_connection_status[i] = true;
connected_devices++;
}
@ -867,25 +865,25 @@ void keyboard_pad_handler::ThreadProc()
{
if (update_sticks)
{
for (int j = 0; j < static_cast<int>(pad->m_sticks.size()); j++)
for (int j = 0; j < static_cast<int>(pad.m_sticks.size()); j++)
{
const f32 stick_lerp_factor = (j < 2) ? m_l_stick_lerp_factor : m_r_stick_lerp_factor;
// we already applied the following values on keypress if we used factor 1
if (stick_lerp_factor < 1.0f)
{
const f32 v0 = static_cast<f32>(pad->m_sticks[j].m_value);
const f32 v0 = static_cast<f32>(pad.m_sticks[j].m_value);
const f32 v1 = static_cast<f32>(m_stick_val[j]);
const f32 res = get_lerped(v0, v1, stick_lerp_factor);
pad->m_sticks[j].m_value = static_cast<u16>(res);
pad.m_sticks[j].m_value = static_cast<u16>(res);
}
}
}
if (update_buttons)
{
for (auto& button : pad->m_buttons)
for (auto& button : pad.m_buttons)
{
if (button.m_analog)
{
@ -918,11 +916,8 @@ void keyboard_pad_handler::ThreadProc()
}
}
if (!m_mouse_wheel_used)
if (m_mouse_wheel_used)
{
return;
}
// Releases the wheel buttons 0,1 sec after they've been triggered
// Next activation is set to distant future to avoid activating this on every proc
const auto update_threshold = now - std::chrono::milliseconds(100);
@ -949,3 +944,12 @@ void keyboard_pad_handler::ThreadProc()
m_last_wheel_move_right = distant_future;
}
}
for (uint i = 0; i < m_bindings.size(); i++)
{
auto& pad = m_bindings[i];
pad->m_buttons = m_pads_internal[i].m_buttons;
pad->m_sticks = m_pads_internal[i].m_sticks;
pad->m_port_status = m_pads_internal[i].m_port_status;
}
}