mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
input: move pressure sensitivity to the handlers
This removes a data race where the button was kept pressed but the values ingame could vary
This commit is contained in:
parent
977d729ee0
commit
b07960d3bc
@ -552,12 +552,25 @@ void PadHandlerBase::get_mapping(const std::shared_ptr<PadDevice>& device, const
|
||||
|
||||
auto button_values = get_button_values(device);
|
||||
|
||||
// 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;
|
||||
|
||||
// Translate any corresponding keycodes to our normal DS3 buttons and triggers
|
||||
for (auto& btn : pad->m_buttons)
|
||||
{
|
||||
Button tmp = btn; // Using a buffer because the values can change during translation
|
||||
// Using a temporary buffer because the values can change during translation
|
||||
Button tmp = btn;
|
||||
tmp.m_value = button_values[btn.m_keyCode];
|
||||
|
||||
TranslateButtonPress(device, tmp.m_keyCode, tmp.m_pressed, tmp.m_value);
|
||||
|
||||
// Modify pressure if necessary if the button was pressed
|
||||
if (adjust_pressure && tmp.m_pressed)
|
||||
{
|
||||
tmp.m_value = pad->m_pressure_intensity;
|
||||
}
|
||||
|
||||
btn = tmp;
|
||||
}
|
||||
|
||||
|
@ -753,6 +753,10 @@ void evdev_joystick_handler::get_mapping(const std::shared_ptr<PadDevice>& devic
|
||||
|
||||
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;
|
||||
|
||||
// Translate any corresponding keycodes to our normal DS3 buttons and triggers
|
||||
for (int i = 0; i < static_cast<int>(pad->m_buttons.size()); i++)
|
||||
{
|
||||
@ -782,9 +786,18 @@ void evdev_joystick_handler::get_mapping(const std::shared_ptr<PadDevice>& devic
|
||||
}
|
||||
}
|
||||
|
||||
Button tmp = button; // Using a buffer because the values can change during translation
|
||||
// Using a temporary buffer because the values can change during translation
|
||||
Button tmp = button;
|
||||
tmp.m_value = static_cast<u16>(value);
|
||||
|
||||
TranslateButtonPress(m_dev, button_code, tmp.m_pressed, tmp.m_value);
|
||||
|
||||
// Modify pressure if necessary if the button was pressed
|
||||
if (adjust_pressure && tmp.m_pressed)
|
||||
{
|
||||
tmp.m_value = pad->m_pressure_intensity;
|
||||
}
|
||||
|
||||
button = tmp;
|
||||
}
|
||||
|
||||
|
@ -244,11 +244,8 @@ void pad_thread::ThreadFunc()
|
||||
{
|
||||
const auto& pad = m_pads[i];
|
||||
|
||||
// I guess this is the best place to add pressure sensitivity without too much code duplication.
|
||||
if (pad->m_port_status & CELL_PAD_STATUS_CONNECTED)
|
||||
{
|
||||
const bool adjust_pressure = pad->m_pressure_intensity_button_index >= 0 && pad->m_buttons[pad->m_pressure_intensity_button_index].m_pressed;
|
||||
|
||||
for (auto& button : pad->m_buttons)
|
||||
{
|
||||
if (button.m_pressed)
|
||||
@ -262,11 +259,6 @@ void pad_thread::ThreadFunc()
|
||||
{
|
||||
any_button_pressed = true;
|
||||
}
|
||||
|
||||
if (adjust_pressure)
|
||||
{
|
||||
button.m_value = pad->m_pressure_intensity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user