summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon
diff options
context:
space:
mode:
authormitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-09-30 17:26:50 -0700
committermitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-12-15 19:54:16 -0800
commit140252ffc0ae71e8b5309bff7d6550189c602702 (patch)
tree7e6fe317fc93e0d9fc91e089ec3af86af25565f1 /Source/Core/InputCommon
parent860e6cf5cb7d96499aecf6f6067783bdb71c29ad (diff)
Modernize `std::any_of` with ranges
In WiimoteReal.cpp, JitRegCache.cpp, lambda predicates were replaced by pointers to member functions because ranges algorithms are able invoke those. In ConvertDialog.cpp, the `std::mem_fn` helper was removed because ranges algorithms are able to handle pointers to member functions as predicates.
Diffstat (limited to 'Source/Core/InputCommon')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp8
-rw-r--r--Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp4
3 files changed, 7 insertions, 9 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp
index 0ad720dcdb..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();
}
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 fb9d43f22f..40ef725b66 100644
--- a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
@@ -137,8 +137,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;