input: add pressure intensity toggle mode

This commit is contained in:
Megamouse 2023-06-05 21:56:01 +02:00
parent 6f834e99d2
commit 8f66c50721
10 changed files with 59 additions and 17 deletions

View file

@ -1011,11 +1011,15 @@ void evdev_joystick_handler::handle_input_event(const input_event& evt, const st
if (button_code == NO_BUTTON || value < 0)
return;
const auto cfg = m_dev->config;
if (!cfg)
return;
auto axis_orientations = m_dev->axis_orientations;
// Find out if special buttons are pressed (introduced by RPCS3).
// These buttons will have a delay of one cycle, but whatever.
const bool adjust_pressure = pad->m_pressure_intensity_button_index >= 0 && pad->m_buttons[pad->m_pressure_intensity_button_index].m_pressed;
const bool adjust_pressure = pad->get_pressure_intensity_enabled(cfg->pressure_intensity_toggle_mode.get());
// Translate any corresponding keycodes to our normal DS3 buttons and triggers
for (int i = 0; i < static_cast<int>(pad->m_buttons.size()); i++)
@ -1128,10 +1132,6 @@ void evdev_joystick_handler::handle_input_event(const input_event& evt, const st
m_dev->stick_val[idx] = m_dev->val_max[idx] - m_dev->val_min[idx];
}
const auto cfg = m_dev->config;
if (!cfg)
return;
u16 lx, ly, rx, ry;
// Normalize and apply pad squircling

View file

@ -81,8 +81,6 @@ void keyboard_pad_handler::Key(const u32 code, bool pressed, u16 value)
{
// Find out if special buttons are pressed (introduced by RPCS3).
// Activate the buttons here if possible since keys don't auto-repeat. This ensures that they are already pressed in the following loop.
bool adjust_pressure = false;
if (pad.m_pressure_intensity_button_index >= 0)
{
Button& pressure_intensity_button = pad.m_buttons[pad.m_pressure_intensity_button_index];
@ -92,10 +90,10 @@ void keyboard_pad_handler::Key(const u32 code, bool pressed, u16 value)
pressure_intensity_button.m_pressed = pressed;
pressure_intensity_button.m_value = value;
}
adjust_pressure = pressure_intensity_button.m_pressed;
}
const bool adjust_pressure = pad.get_pressure_intensity_enabled(m_pressure_intensity_toggle_mode);
// Handle buttons
for (Button& button : pad.m_buttons)
{
@ -795,7 +793,7 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr<Pad> pad, u8 player_i
return false;
m_pad_configs[player_id].from_string(player_config->config.to_string());
cfg_pad* cfg = &m_pad_configs[player_id];
const cfg_pad* cfg = &m_pad_configs[player_id];
if (cfg == nullptr)
return false;
@ -812,6 +810,7 @@ bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr<Pad> pad, u8 player_i
m_trigger_lerp_factor = cfg->trigger_lerp_factor / 100.0f;
m_l_stick_multiplier = cfg->lstickmultiplier;
m_r_stick_multiplier = cfg->rstickmultiplier;
m_pressure_intensity_toggle_mode = cfg->pressure_intensity_toggle_mode.get();
const auto find_key = [this](const cfg::string& name)
{

View file

@ -116,6 +116,7 @@ private:
steady_clock::time_point m_button_time;
f32 m_analog_lerp_factor = 1.0f;
f32 m_trigger_lerp_factor = 1.0f;
bool m_pressure_intensity_toggle_mode{};
// Stick Movements
steady_clock::time_point m_stick_time;