Implement predicate with lambdas

This commit is contained in:
Chris Thrasher 2023-05-15 15:41:47 -06:00
parent bdf676aec1
commit 2c4ffe997a

View File

@ -38,10 +38,6 @@
namespace
{
bool joystickButtonSortPredicate(IOHIDElementRef b1, IOHIDElementRef b2)
{
return IOHIDElementGetUsage(b1) < IOHIDElementGetUsage(b2);
}
// Convert a CFStringRef to std::string
std::string stringFromCFString(CFStringRef cfString)
@ -320,7 +316,9 @@ bool JoystickImpl::open(unsigned int index)
// Ensure that the buttons will be indexed in the same order as their
// HID Usage (assigned by manufacturer and/or a driver).
std::sort(m_buttons.begin(), m_buttons.end(), joystickButtonSortPredicate);
std::sort(m_buttons.begin(),
m_buttons.end(),
[](IOHIDElementRef b1, IOHIDElementRef b2) { return IOHIDElementGetUsage(b1) < IOHIDElementGetUsage(b2); });
// Retain all these objects for personal use
for (IOHIDElementRef iohidElementRef : m_buttons)