mirror of
https://github.com/glfw/glfw.git
synced 2024-11-29 21:37:27 +00:00
Reverted change of IOKit functions.
The previously used set of functions caused a regression where no axes or buttons were reported. Fixes #78.
This commit is contained in:
parent
cc4c7167fd
commit
4013f733fe
@ -319,8 +319,9 @@ void _glfwInitJoysticks(void)
|
||||
|
||||
while ((ioHIDDeviceObject = IOIteratorNext(objectIterator)))
|
||||
{
|
||||
CFMutableDictionaryRef propsRef = NULL;
|
||||
CFTypeRef valueRef = NULL;
|
||||
kern_return_t result;
|
||||
CFTypeRef valueRef = 0;
|
||||
|
||||
IOCFPlugInInterface** ppPlugInInterface = NULL;
|
||||
HRESULT plugInResult = S_OK;
|
||||
@ -329,26 +330,29 @@ void _glfwInitJoysticks(void)
|
||||
long usagePage, usage;
|
||||
|
||||
// Check device type
|
||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
||||
CFSTR(kIOHIDPrimaryUsagePageKey),
|
||||
result = IORegistryEntryCreateCFProperties(ioHIDDeviceObject,
|
||||
&propsRef,
|
||||
kCFAllocatorDefault,
|
||||
kNilOptions);
|
||||
|
||||
if (result != kIOReturnSuccess)
|
||||
continue;
|
||||
|
||||
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsagePageKey));
|
||||
if (valueRef)
|
||||
{
|
||||
CFNumberGetValue(valueRef, kCFNumberLongType, &usagePage);
|
||||
if (usagePage != kHIDPage_GenericDesktop)
|
||||
{
|
||||
// This device is not relevant to GLFW
|
||||
CFRelease(valueRef);
|
||||
continue;
|
||||
}
|
||||
|
||||
CFRelease(valueRef);
|
||||
}
|
||||
|
||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
||||
CFSTR(kIOHIDPrimaryUsageKey),
|
||||
kCFAllocatorDefault,
|
||||
kNilOptions);
|
||||
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsageKey));
|
||||
if (valueRef)
|
||||
{
|
||||
CFNumberGetValue(valueRef, kCFNumberLongType, &usage);
|
||||
@ -358,6 +362,7 @@ void _glfwInitJoysticks(void)
|
||||
usage != kHIDUsage_GD_MultiAxisController))
|
||||
{
|
||||
// This device is not relevant to GLFW
|
||||
CFRelease(valueRef);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -393,10 +398,7 @@ void _glfwInitJoysticks(void)
|
||||
joystick);
|
||||
|
||||
// Get product string
|
||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
||||
CFSTR(kIOHIDProductKey),
|
||||
kCFAllocatorDefault,
|
||||
kNilOptions);
|
||||
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDProductKey));
|
||||
if (valueRef)
|
||||
{
|
||||
CFStringGetCString(valueRef,
|
||||
@ -410,10 +412,7 @@ void _glfwInitJoysticks(void)
|
||||
joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL);
|
||||
joystick->hatElements = CFArrayCreateMutable(NULL, 0, NULL);
|
||||
|
||||
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
||||
CFSTR(kIOHIDElementKey),
|
||||
kCFAllocatorDefault,
|
||||
kNilOptions);
|
||||
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDElementKey));
|
||||
if (CFGetTypeID(valueRef) == CFArrayGetTypeID())
|
||||
{
|
||||
CFRange range = { 0, CFArrayGetCount(valueRef) };
|
||||
|
Loading…
Reference in New Issue
Block a user