mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-09-28 03:56:28 -05:00
input+kpad: Avoid overwriting values before use
This commit is contained in:
@@ -30,9 +30,10 @@ const ControllerState& ControllerBase::update_state()
|
||||
// ignore default buttons
|
||||
result.buttons.UnsetButtons(m_default_state.buttons);
|
||||
// apply deadzone and range and ignore default axis values
|
||||
apply_axis_setting(result.axis, m_default_state.axis, m_settings.axis);
|
||||
apply_axis_setting(result.rotation, m_default_state.rotation, m_settings.rotation);
|
||||
apply_axis_setting(result.trigger, m_default_state.trigger, m_settings.trigger);
|
||||
auto settings = get_settings();
|
||||
apply_axis_setting(result.axis, m_default_state.axis, settings.axis);
|
||||
apply_axis_setting(result.rotation, m_default_state.rotation, settings.rotation);
|
||||
apply_axis_setting(result.trigger, m_default_state.trigger, settings.trigger);
|
||||
|
||||
apply_axis_button(result.buttons, result.axis, kAxisXP);
|
||||
apply_axis_button(result.buttons, result.rotation, kRotationXP);
|
||||
|
||||
@@ -112,14 +112,15 @@ void VPADController::VPADRead(VPADStatus_t& status, const BtnRepeat& repeat)
|
||||
|
||||
// button repeat
|
||||
const auto now = std::chrono::high_resolution_clock::now();
|
||||
if (status.hold != m_last_holdvalue)
|
||||
uint32 currentHold = status.hold;
|
||||
if (currentHold != m_last_holdvalue)
|
||||
{
|
||||
m_last_hold_change = m_last_pulse = now;
|
||||
}
|
||||
|
||||
if (repeat.pulse > 0)
|
||||
{
|
||||
if (m_last_hold_change + std::chrono::milliseconds(repeat.delay) >= now)
|
||||
if (currentHold != 0 && m_last_hold_change + std::chrono::milliseconds(repeat.delay) <= now)
|
||||
{
|
||||
if ((m_last_pulse + std::chrono::milliseconds(repeat.pulse)) < now)
|
||||
{
|
||||
@@ -130,9 +131,9 @@ void VPADController::VPADRead(VPADStatus_t& status, const BtnRepeat& repeat)
|
||||
}
|
||||
|
||||
// general
|
||||
status.release = m_last_holdvalue & ~status.hold;
|
||||
status.trig = ~m_last_holdvalue & status.hold;
|
||||
m_last_holdvalue = status.hold;
|
||||
status.release = m_last_holdvalue & ~currentHold;
|
||||
status.trig = ~m_last_holdvalue & currentHold;
|
||||
m_last_holdvalue = currentHold;
|
||||
|
||||
// touch
|
||||
update_touch(status);
|
||||
|
||||
Reference in New Issue
Block a user