summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2025-02-15 12:59:23 -0500
committerGitHub <noreply@github.com>2025-02-15 12:59:23 -0500
commita8fae9b82683dd0ea766cb8c282b414707962255 (patch)
tree6ab551bcd3d7ef3459f369bf45206577c60d5231 /Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
parentc360ea0d9d5caaa0d305711eb1a86ad30d6353da (diff)
parent6e7e808b6614f98674dba7290bea2ea044c4d5d2 (diff)
Merge pull request #13320 from jordan-woyak/detect-alternations
DolphinQt/Mapping: Add setting to enable waiting for alternate mappings.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp27
1 files changed, 21 insertions, 6 deletions
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<ciface::Core::DeviceContainer::InputDetection>& 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<const ciface::Core::DeviceContainer::InputDetection*> pressed_inputs;
+ std::vector<const Core::InputDetector::Detection*> pressed_inputs;
std::vector<std::string> alternations;
@@ -135,8 +134,7 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection>
return fmt::to_string(fmt::join(alternations, "|"));
}
-void RemoveSpuriousTriggerCombinations(
- std::vector<ciface::Core::DeviceContainer::InputDetection>* 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