mirror of
https://github.com/SFML/SFML.git
synced 2024-12-01 15:51:04 +08:00
Implement predicate with lambdas
This commit is contained in:
parent
bdf676aec1
commit
2c4ffe997a
@ -38,10 +38,6 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
bool joystickButtonSortPredicate(IOHIDElementRef b1, IOHIDElementRef b2)
|
|
||||||
{
|
|
||||||
return IOHIDElementGetUsage(b1) < IOHIDElementGetUsage(b2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert a CFStringRef to std::string
|
// Convert a CFStringRef to std::string
|
||||||
std::string stringFromCFString(CFStringRef cfString)
|
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
|
// Ensure that the buttons will be indexed in the same order as their
|
||||||
// HID Usage (assigned by manufacturer and/or a driver).
|
// 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
|
// Retain all these objects for personal use
|
||||||
for (IOHIDElementRef iohidElementRef : m_buttons)
|
for (IOHIDElementRef iohidElementRef : m_buttons)
|
||||||
|
Loading…
Reference in New Issue
Block a user