Fix axis not working with Switch Pro controller on macOS

Each axis would appear as multiple elements with 0 min/max.
Filter the list of elements using the correct usage page like
done for buttons.
This commit is contained in:
Jocelyn Turcotte 2017-08-01 01:58:30 +02:00
parent 131c97e87c
commit 200fb26148
1 changed files with 4 additions and 1 deletions

View File

@ -39,7 +39,10 @@ Joystick::Joystick(IOHIDDeviceRef device, std::string name)
} }
// Axes // Axes
NSDictionary* axisDict = @{ @kIOHIDElementTypeKey : @(kIOHIDElementTypeInput_Misc) }; NSDictionary* axisDict = @{
@kIOHIDElementTypeKey : @(kIOHIDElementTypeInput_Misc),
@kIOHIDElementUsagePageKey : @(kHIDPage_GenericDesktop)
};
CFArrayRef axes = CFArrayRef axes =
IOHIDDeviceCopyMatchingElements(m_device, (CFDictionaryRef)axisDict, kIOHIDOptionsTypeNone); IOHIDDeviceCopyMatchingElements(m_device, (CFDictionaryRef)axisDict, kIOHIDOptionsTypeNone);