diff options
| author | JMC47 <JMC4789@gmail.com> | 2024-12-26 16:51:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-26 16:51:53 -0500 |
| commit | 532a8621daa5c0d8a3a55f64ffba9cb20209d455 (patch) | |
| tree | 21837ec63b1fe4a45a162a1f1bf4167efcd4d177 /Source/Core/InputCommon | |
| parent | f9ce2b9d764014ab59cf2c19e49c2c848604e6fc (diff) | |
| parent | 2b0cd16c8c266bc1e298e49d4009eab8c9c23f99 (diff) | |
Merge pull request #13116 from mitaclaw/ranges-modernization-8-trivial-of
Ranges Algorithms Modernization - Of
Diffstat (limited to 'Source/Core/InputCommon')
6 files changed, 19 insertions, 23 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp index b558d6b78f..7fdf677a91 100644 --- a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp @@ -305,9 +305,10 @@ bool HotkeySuppressions::IsSuppressedIgnoringModifiers(Device::Input* input, return i1 && i2 && (i1 == i2 || i1->IsChild(i2) || i2->IsChild(i1)); }; - return std::any_of(it, it_end, [&](auto& s) { - return std::none_of(begin(ignore_modifiers), end(ignore_modifiers), - [&](auto& m) { return is_same_modifier(m->GetInput(), s.first.second); }); + return std::any_of(it, it_end, [&](const auto& s) { + return std::ranges::none_of(ignore_modifiers, [&](const auto& m) { + return is_same_modifier(m->GetInput(), s.first.second); + }); }); } @@ -495,10 +496,8 @@ public: ControlState GetValue() const override { // True if we have no modifiers - const bool modifiers_pressed = std::all_of(m_modifiers.begin(), m_modifiers.end(), - [](const std::unique_ptr<ControlExpression>& input) { - return input->GetValue() > CONDITION_THRESHOLD; - }); + const bool modifiers_pressed = std::ranges::all_of( + m_modifiers, [](const auto& input) { return input->GetValue() > CONDITION_THRESHOLD; }); const auto final_input_state = m_final_input->GetValueIgnoringSuppression(); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp index dfd282d533..d6cb4b95ff 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp @@ -25,8 +25,8 @@ IMUAccelerometer::IMUAccelerometer(std::string name_, std::string ui_name_) bool IMUAccelerometer::AreInputsBound() const { - return std::all_of(controls.begin(), controls.end(), - [](const auto& control) { return control->control_ref->BoundCount() > 0; }); + return std::ranges::all_of( + controls, [](const auto& control) { return control->control_ref->BoundCount() > 0; }); } std::optional<IMUAccelerometer::StateData> IMUAccelerometer::GetState() const diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp index 2e8c4bb18c..787665b366 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp @@ -90,8 +90,8 @@ void IMUGyroscope::UpdateCalibration(const StateData& state) // Check for required calibration update frequency // and if current data is within deadzone distance of mean stable value. if (calibration_freq < WORST_ACCEPTABLE_CALIBRATION_UPDATE_FREQUENCY || - std::any_of(current_difference.data.begin(), current_difference.data.end(), - [&](auto c) { return std::abs(c) > deadzone; })) + std::ranges::any_of(current_difference.data, + [&](auto c) { return std::abs(c) > deadzone; })) { RestartCalibration(); } @@ -123,8 +123,8 @@ auto IMUGyroscope::GetRawState() const -> StateData bool IMUGyroscope::AreInputsBound() const { - return std::all_of(controls.begin(), controls.end(), - [](const auto& control) { return control->control_ref->BoundCount() > 0; }); + return std::ranges::all_of( + controls, [](const auto& control) { return control->control_ref->BoundCount() > 0; }); } bool IMUGyroscope::CanCalibrate() const diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 769e6c5f0e..10dd492ceb 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -248,7 +248,7 @@ bool ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device std::lock_guard lk(m_devices_mutex); const auto is_id_in_use = [&device, this](int id) { - return std::any_of(m_devices.begin(), m_devices.end(), [&device, &id](const auto& d) { + return std::ranges::any_of(m_devices, [&device, &id](const auto& d) { return d->GetSource() == device->GetSource() && d->GetName() == device->GetName() && d->GetId() == id; }); @@ -368,10 +368,8 @@ void ControllerInterface::UpdateInput() if (devices_to_remove.size() > 0) { RemoveDevice([&](const ciface::Core::Device* device) { - return std::any_of(devices_to_remove.begin(), devices_to_remove.end(), - [device](const std::weak_ptr<ciface::Core::Device>& d) { - return d.lock().get() == device; - }); + return std::ranges::any_of(devices_to_remove, + [device](const auto& d) { return d.lock().get() == device; }); }); } } diff --git a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp index b50621bc92..cb06a7ed30 100644 --- a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp +++ b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp @@ -44,7 +44,7 @@ std::string GetExpressionForControl(const std::string& control_name, { // If our expression contains any non-alpha characters // we should quote it - if (!std::all_of(expr.begin(), expr.end(), Common::IsAlpha)) + if (!std::ranges::all_of(expr, Common::IsAlpha)) expr = fmt::format("`{}`", expr); } @@ -138,8 +138,8 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection> void RemoveSpuriousTriggerCombinations( std::vector<ciface::Core::DeviceContainer::InputDetection>* detections) { - const auto is_spurious = [&](auto& detection) { - return std::any_of(detections->begin(), detections->end(), [&](auto& d) { + const auto is_spurious = [&](const auto& detection) { + return std::ranges::any_of(*detections, [&](const auto& d) { // This is a spurious digital detection if a "smooth" (analog) detection is temporally near. return &d != &detection && d.smoothness > 1 && d.smoothness > detection.smoothness && abs(d.press_time - detection.press_time) < SPURIOUS_TRIGGER_COMBO_THRESHOLD; diff --git a/Source/Core/InputCommon/DynamicInputTextures/DITSpecification.cpp b/Source/Core/InputCommon/DynamicInputTextures/DITSpecification.cpp index f5409b518f..70c4651a24 100644 --- a/Source/Core/InputCommon/DynamicInputTextures/DITSpecification.cpp +++ b/Source/Core/InputCommon/DynamicInputTextures/DITSpecification.cpp @@ -136,8 +136,7 @@ bool ProcessSpecificationV1(picojson::value& root, std::vector<Data>& input_text return false; } - if (!std::all_of(region_offsets.begin(), region_offsets.end(), - [](picojson::value val) { return val.is<double>(); })) + if (!std::ranges::all_of(region_offsets, &picojson::value::is<double>)) { ERROR_LOG_FMT( VIDEO, |
