diff options
author | Garrett Brown <themagnificentmrb@gmail.com> | 2024-01-28 21:59:51 -0800 |
---|---|---|
committer | Garrett Brown <themagnificentmrb@gmail.com> | 2024-05-09 21:29:25 -0700 |
commit | 808b2bd9a56468f71646538b1686ed507b7fe5fe (patch) | |
tree | 40b24087fd9af3dd6340d7f792fe136c1172f937 | |
parent | f1267ebf159d937477e9998e67e47d64ac85d6be (diff) | |
download | xbmc-808b2bd9a56468f71646538b1686ed507b7fe5fe.tar.xz |
[Joysticks] Fix mapping PS4 trigger analog semiaxes
Rapid input is dropped when buttonmapping, because some controllers send
multiple events per button press with different button IDs.
For example, on many PlayStation controllers, the triggers send an analog
event, and a digital event when the trigger crosses about halfway. The 0.5
analog event arrives shortly before or shortly after the digital event.
The bug: If the digital button is ignored, the analog event may be detected
as rapid input and dropped. This is fixed by prioritizing the "IsIngored"
check.
-rw-r--r-- | xbmc/input/joysticks/generic/ButtonMapping.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/xbmc/input/joysticks/generic/ButtonMapping.cpp b/xbmc/input/joysticks/generic/ButtonMapping.cpp index 4b5dd8aca5..03faf73926 100644 --- a/xbmc/input/joysticks/generic/ButtonMapping.cpp +++ b/xbmc/input/joysticks/generic/ButtonMapping.cpp @@ -451,31 +451,34 @@ bool CButtonMapping::MapPrimitive(const CDriverPrimitive& primitive) { bool bHandled = false; - auto now = std::chrono::steady_clock::now(); - - bool bTimeoutElapsed = true; - - if (m_buttonMapper->NeedsCooldown()) - bTimeoutElapsed = (now >= m_lastAction + std::chrono::milliseconds(MAPPING_COOLDOWN_MS)); - - if (bTimeoutElapsed) - { - bHandled = m_buttonMapper->MapPrimitive(m_buttonMap, m_keymap, primitive); - - if (bHandled) - m_lastAction = std::chrono::steady_clock::now(); - } - else if (m_buttonMap->IsIgnored(primitive)) + if (m_buttonMap->IsIgnored(primitive)) { bHandled = true; } else { - auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastAction); + auto now = std::chrono::steady_clock::now(); - CLog::Log(LOGDEBUG, "Button mapping: rapid input after {}ms dropped for profile \"{}\"", - duration.count(), m_buttonMapper->ControllerID()); - bHandled = true; + bool bTimeoutElapsed = true; + + if (m_buttonMapper->NeedsCooldown()) + bTimeoutElapsed = (now >= m_lastAction + std::chrono::milliseconds(MAPPING_COOLDOWN_MS)); + + if (bTimeoutElapsed) + { + bHandled = m_buttonMapper->MapPrimitive(m_buttonMap, m_keymap, primitive); + + if (bHandled) + m_lastAction = std::chrono::steady_clock::now(); + } + else + { + auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastAction); + + CLog::Log(LOGDEBUG, "Button mapping: rapid input after {}ms dropped for profile \"{}\"", + duration.count(), m_buttonMapper->ControllerID()); + bHandled = true; + } } return bHandled; |