diff options
| author | JMC47 <JMC4789@gmail.com> | 2025-03-23 15:56:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-23 15:56:13 -0400 |
| commit | ad3650abfcae6432338ba976123958ee67a4106c (patch) | |
| tree | 23def284c9a42648ea0779f94903ba43903aa353 /Source/Core/InputCommon | |
| parent | 1515cf6ccdd1ba206c8e0eaabad07de28a4f5939 (diff) | |
| parent | e4efe011d71b668537bc551996848e911de079ab (diff) | |
Merge pull request #13093 from mitaclaw/ranges-modernization-4-projection
Ranges Algorithms Modernization - Projection
Diffstat (limited to 'Source/Core/InputCommon')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 10dd492ceb..b8651c608d 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -273,18 +273,14 @@ bool ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device NOTICE_LOG_FMT(CONTROLLERINTERFACE, "Added device: {}", device->GetQualifiedName()); m_devices.emplace_back(std::move(device)); - // We can't (and don't want) to control the order in which devices are added, but we - // need their order to be consistent, and we need the same one to always be the first, where - // present (the keyboard and mouse device usually). This is because when defaulting a - // controller profile, it will automatically select the first device in the list as its default. - std::stable_sort(m_devices.begin(), m_devices.end(), - [](const std::shared_ptr<ciface::Core::Device>& a, - const std::shared_ptr<ciface::Core::Device>& b) { - // It would be nice to sort devices by Source then Name then ID but it's - // better to leave them sorted by the add order, which also avoids breaking - // the order on other platforms that are less tested. - return a->GetSortPriority() > b->GetSortPriority(); - }); + // We can't (and don't want) to control the order in which devices are added, but we need + // their order to be consistent, and we need the same one to always be the first, where present + // (the keyboard and mouse device usually). This is because when defaulting a controller + // profile, it will automatically select the first device in the list as its default. It would + // be nice to sort devices by Source then Name then ID, but it's better to leave them sorted by + // the add order. This also avoids breaking the order on other platforms that are less tested. + std::ranges::stable_sort(m_devices, std::ranges::greater{}, + &ciface::Core::Device::GetSortPriority); } if (!m_populating_devices_counter) |
