mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-06-02 04:36:57 -06:00
input: move keyboard stick value buffers to pad
This should improve stick input when using the keyboard for 2 players.
This commit is contained in:
parent
e4a49cd425
commit
b533a560e6
@ -441,6 +441,9 @@ struct AnalogStick
|
|||||||
std::map<u32, u16> m_pressed_keys_max; // only used in keyboard_pad_handler
|
std::map<u32, u16> m_pressed_keys_max; // only used in keyboard_pad_handler
|
||||||
std::map<u32, u16> m_pressed_combos_min; // only used in keyboard_pad_handler
|
std::map<u32, u16> m_pressed_combos_min; // only used in keyboard_pad_handler
|
||||||
std::map<u32, u16> m_pressed_combos_max; // only used in keyboard_pad_handler
|
std::map<u32, u16> m_pressed_combos_max; // only used in keyboard_pad_handler
|
||||||
|
u8 m_stick_min = 0; // only used in keyboard_pad_handler
|
||||||
|
u8 m_stick_max = 128; // only used in keyboard_pad_handler
|
||||||
|
u8 m_stick_val = 128; // only used in keyboard_pad_handler
|
||||||
|
|
||||||
AnalogStick() {}
|
AnalogStick() {}
|
||||||
AnalogStick(u32 offset, std::vector<std::set<u32>> key_combos_min, std::vector<std::set<u32>> key_combos_max)
|
AnalogStick(u32 offset, std::vector<std::set<u32>> key_combos_min, std::vector<std::set<u32>> key_combos_max)
|
||||||
|
|||||||
@ -262,8 +262,8 @@ void keyboard_pad_handler::Key(const u32 code, bool pressed, u16 value)
|
|||||||
const u16 actual_max_value = is_max_pressed ? MultipliedInput(255, stick_multiplier) : 255;
|
const u16 actual_max_value = is_max_pressed ? MultipliedInput(255, stick_multiplier) : 255;
|
||||||
const u16 normalized_max_value = std::ceil(actual_max_value / 2.0);
|
const u16 normalized_max_value = std::ceil(actual_max_value / 2.0);
|
||||||
|
|
||||||
m_stick_min[i] = is_min_pressed ? std::min<u8>(normalized_min_value, 128) : 0;
|
stick.m_stick_min = is_min_pressed ? std::min<u8>(normalized_min_value, 128) : 0;
|
||||||
m_stick_max[i] = is_max_pressed ? std::min<int>(128 + normalized_max_value, 255) : 128;
|
stick.m_stick_max = is_max_pressed ? std::min<int>(128 + normalized_max_value, 255) : 128;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -345,25 +345,25 @@ void keyboard_pad_handler::Key(const u32 code, bool pressed, u16 value)
|
|||||||
{
|
{
|
||||||
const std::pair<bool, u16> stick_value = register_new_stick_value(true);
|
const std::pair<bool, u16> stick_value = register_new_stick_value(true);
|
||||||
|
|
||||||
m_stick_max[i] = stick_value.first ? std::min<int>(128 + stick_value.second, 255) : 128;
|
stick.m_stick_max = stick_value.first ? std::min<int>(128 + stick_value.second, 255) : 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_min)
|
if (is_min)
|
||||||
{
|
{
|
||||||
const std::pair<bool, u16> stick_value = register_new_stick_value(false);
|
const std::pair<bool, u16> stick_value = register_new_stick_value(false);
|
||||||
|
|
||||||
m_stick_min[i] = stick_value.first ? std::min<u8>(stick_value.second, 128) : 0;
|
stick.m_stick_min = stick_value.first ? std::min<u8>(stick_value.second, 128) : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_stick_val[i] = m_stick_max[i] - m_stick_min[i];
|
stick.m_stick_val = stick.m_stick_max - stick.m_stick_min;
|
||||||
|
|
||||||
const f32 stick_lerp_factor = is_left_stick ? m_l_stick_lerp_factor : m_r_stick_lerp_factor;
|
const f32 stick_lerp_factor = is_left_stick ? m_l_stick_lerp_factor : m_r_stick_lerp_factor;
|
||||||
|
|
||||||
// to get the fastest response time possible we don't wanna use any lerp with factor 1
|
// to get the fastest response time possible we don't wanna use any lerp with factor 1
|
||||||
if (stick_lerp_factor >= 1.0f)
|
if (stick_lerp_factor >= 1.0f)
|
||||||
{
|
{
|
||||||
stick.m_value = m_stick_val[i];
|
stick.m_value = stick.m_stick_val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,12 +380,16 @@ void keyboard_pad_handler::release_all_keys()
|
|||||||
button.m_actual_value = 0;
|
button.m_actual_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (usz i = 0; i < pad.m_sticks.size(); i++)
|
for (AnalogStick& stick : pad.m_sticks)
|
||||||
{
|
{
|
||||||
m_stick_min[i] = 0;
|
stick.m_value = 128;
|
||||||
m_stick_max[i] = 128;
|
stick.m_stick_min = 0;
|
||||||
m_stick_val[i] = 128;
|
stick.m_stick_max = 128;
|
||||||
pad.m_sticks[i].m_value = 128;
|
stick.m_stick_val = 128;
|
||||||
|
stick.m_pressed_keys_min.clear();
|
||||||
|
stick.m_pressed_keys_max.clear();
|
||||||
|
stick.m_pressed_combos_min.clear();
|
||||||
|
stick.m_pressed_combos_max.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1261,11 +1265,13 @@ void keyboard_pad_handler::process()
|
|||||||
// we already applied the following values on keypress if we used factor 1
|
// we already applied the following values on keypress if we used factor 1
|
||||||
if (stick_lerp_factor < 1.0f)
|
if (stick_lerp_factor < 1.0f)
|
||||||
{
|
{
|
||||||
const f32 v0 = static_cast<f32>(pad.m_sticks[j].m_value);
|
AnalogStick& stick = pad.m_sticks[j];
|
||||||
const f32 v1 = static_cast<f32>(m_stick_val[j]);
|
|
||||||
|
const f32 v0 = static_cast<f32>(stick.m_value);
|
||||||
|
const f32 v1 = static_cast<f32>(stick.m_stick_val);
|
||||||
const f32 res = get_lerped(v0, v1, stick_lerp_factor);
|
const f32 res = get_lerped(v0, v1, stick_lerp_factor);
|
||||||
|
|
||||||
pad.m_sticks[j].m_value = static_cast<u16>(res);
|
stick.m_value = static_cast<u16>(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,11 +129,6 @@ private:
|
|||||||
u32 m_l_stick_multiplier = 100;
|
u32 m_l_stick_multiplier = 100;
|
||||||
u32 m_r_stick_multiplier = 100;
|
u32 m_r_stick_multiplier = 100;
|
||||||
|
|
||||||
static constexpr usz max_sticks = 4;
|
|
||||||
std::array<u8, max_sticks> m_stick_min{ 0, 0, 0, 0 };
|
|
||||||
std::array<u8, max_sticks> m_stick_max{ 128, 128, 128, 128 };
|
|
||||||
std::array<u8, max_sticks> m_stick_val{ 128, 128, 128, 128 };
|
|
||||||
|
|
||||||
// Mouse Movements
|
// Mouse Movements
|
||||||
steady_clock::time_point m_last_mouse_move_left;
|
steady_clock::time_point m_last_mouse_move_left;
|
||||||
steady_clock::time_point m_last_mouse_move_right;
|
steady_clock::time_point m_last_mouse_move_right;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user