From 6e7e808b6614f98674dba7290bea2ea044c4d5d2 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Wed, 29 Jan 2025 02:02:46 -0600 Subject: DolphinQt/Mapping: Add setting to enable waiting for alternate mappings using the OR-operator. --- .../ControllerInterface/MappingCommon.cpp | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp index cb06a7ed30..3765ef24a6 100644 --- a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp +++ b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp @@ -51,11 +51,10 @@ std::string GetExpressionForControl(const std::string& control_name, return expr; } -std::string -BuildExpression(const std::vector& detections, - const ciface::Core::DeviceQualifier& default_device, Quote quote) +std::string BuildExpression(const Core::InputDetector::Results& detections, + const ciface::Core::DeviceQualifier& default_device, Quote quote) { - std::vector pressed_inputs; + std::vector pressed_inputs; std::vector alternations; @@ -135,8 +134,7 @@ BuildExpression(const std::vector return fmt::to_string(fmt::join(alternations, "|")); } -void RemoveSpuriousTriggerCombinations( - std::vector* detections) +void RemoveSpuriousTriggerCombinations(Core::InputDetector::Results* detections) { const auto is_spurious = [&](const auto& detection) { return std::ranges::any_of(*detections, [&](const auto& d) { @@ -149,4 +147,21 @@ void RemoveSpuriousTriggerCombinations( std::erase_if(*detections, is_spurious); } +void RemoveDetectionsAfterTimePoint(Core::InputDetector::Results* results, + Core::DeviceContainer::Clock::time_point after) +{ + const auto is_after_time = [&](const Core::InputDetector::Detection& detection) { + return detection.release_time.value_or(after) >= after; + }; + + std::erase_if(*results, is_after_time); +} + +bool ContainsCompleteDetection(const Core::InputDetector::Results& results) +{ + return std::ranges::any_of(results, [](const Core::InputDetector::Detection& detection) { + return detection.release_time.has_value(); + }); +} + } // namespace ciface::MappingCommon -- cgit v1.2.3