From 44801c50f3c4ce3ae490ada8d49a678d7e562669 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 28 Jun 2023 23:35:56 +0200 Subject: [PATCH] Input: update buttons on pressure button toggle --- rpcs3/Emu/Io/pad_types.h | 1 + rpcs3/Input/keyboard_pad_handler.cpp | 31 +++++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/Io/pad_types.h b/rpcs3/Emu/Io/pad_types.h index c25cc3c021..7d1f91d994 100644 --- a/rpcs3/Emu/Io/pad_types.h +++ b/rpcs3/Emu/Io/pad_types.h @@ -343,6 +343,7 @@ struct Pad bool m_pressure_intensity_button_pressed{}; // Last sensitivity button press state, used for toggle. bool m_pressure_intensity_toggled{}; // Whether the sensitivity is toggled on or off. u8 m_pressure_intensity{127}; // 0-255 + bool m_adjust_pressure_last{}; // only used in keyboard_pad_handler bool get_pressure_intensity_enabled(bool is_toggle_mode); // Cable State: 0 - 1 plugged in ? diff --git a/rpcs3/Input/keyboard_pad_handler.cpp b/rpcs3/Input/keyboard_pad_handler.cpp index 011781e4bf..c565e7f484 100644 --- a/rpcs3/Input/keyboard_pad_handler.cpp +++ b/rpcs3/Input/keyboard_pad_handler.cpp @@ -113,6 +113,12 @@ void keyboard_pad_handler::Key(const u32 code, bool pressed, u16 value) } const bool adjust_pressure = pad.get_pressure_intensity_enabled(m_pressure_intensity_toggle_mode); + const bool adjust_pressure_changed = pad.m_adjust_pressure_last != adjust_pressure; + + if (adjust_pressure_changed) + { + pad.m_adjust_pressure_last = adjust_pressure; + } // Handle buttons for (usz i = 0; i < pad.m_buttons.size(); i++) @@ -123,21 +129,26 @@ void keyboard_pad_handler::Key(const u32 code, bool pressed, u16 value) Button& button = pad.m_buttons[i]; - if (!button.m_key_codes.contains(code)) - continue; - - button.m_actual_value = register_new_button_value(button.m_pressed_keys); - bool update_button = true; - // to get the fastest response time possible we don't wanna use any lerp with factor 1 - if (button.m_analog) + if (!button.m_key_codes.contains(code)) { - update_button = m_analog_lerp_factor >= 1.0f; + // Handle pressure changes anyway + update_button = adjust_pressure_changed; } - else if (button.m_trigger) + else { - update_button = m_trigger_lerp_factor >= 1.0f; + button.m_actual_value = register_new_button_value(button.m_pressed_keys); + + // to get the fastest response time possible we don't wanna use any lerp with factor 1 + if (button.m_analog) + { + update_button = m_analog_lerp_factor >= 1.0f; + } + else if (button.m_trigger) + { + update_button = m_trigger_lerp_factor >= 1.0f; + } } if (update_button)