1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-27 04:28:52 -05: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:
Camilla Berglund 2013-11-07 20:11:50 +01:00
parent cc4c7167fd
commit 4013f733fe

View File

@ -319,8 +319,9 @@ void _glfwInitJoysticks(void)
while ((ioHIDDeviceObject = IOIteratorNext(objectIterator))) while ((ioHIDDeviceObject = IOIteratorNext(objectIterator)))
{ {
CFMutableDictionaryRef propsRef = NULL;
CFTypeRef valueRef = NULL;
kern_return_t result; kern_return_t result;
CFTypeRef valueRef = 0;
IOCFPlugInInterface** ppPlugInInterface = NULL; IOCFPlugInInterface** ppPlugInInterface = NULL;
HRESULT plugInResult = S_OK; HRESULT plugInResult = S_OK;
@ -329,26 +330,29 @@ void _glfwInitJoysticks(void)
long usagePage, usage; long usagePage, usage;
// Check device type // Check device type
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject, result = IORegistryEntryCreateCFProperties(ioHIDDeviceObject,
CFSTR(kIOHIDPrimaryUsagePageKey), &propsRef,
kCFAllocatorDefault, kCFAllocatorDefault,
kNilOptions); kNilOptions);
if (result != kIOReturnSuccess)
continue;
valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsagePageKey));
if (valueRef) if (valueRef)
{ {
CFNumberGetValue(valueRef, kCFNumberLongType, &usagePage); CFNumberGetValue(valueRef, kCFNumberLongType, &usagePage);
if (usagePage != kHIDPage_GenericDesktop) if (usagePage != kHIDPage_GenericDesktop)
{ {
// This device is not relevant to GLFW // This device is not relevant to GLFW
CFRelease(valueRef);
continue; continue;
} }
CFRelease(valueRef); CFRelease(valueRef);
} }
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject, valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsageKey));
CFSTR(kIOHIDPrimaryUsageKey),
kCFAllocatorDefault,
kNilOptions);
if (valueRef) if (valueRef)
{ {
CFNumberGetValue(valueRef, kCFNumberLongType, &usage); CFNumberGetValue(valueRef, kCFNumberLongType, &usage);
@ -358,6 +362,7 @@ void _glfwInitJoysticks(void)
usage != kHIDUsage_GD_MultiAxisController)) usage != kHIDUsage_GD_MultiAxisController))
{ {
// This device is not relevant to GLFW // This device is not relevant to GLFW
CFRelease(valueRef);
continue; continue;
} }
@ -393,10 +398,7 @@ void _glfwInitJoysticks(void)
joystick); joystick);
// Get product string // Get product string
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject, valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDProductKey));
CFSTR(kIOHIDProductKey),
kCFAllocatorDefault,
kNilOptions);
if (valueRef) if (valueRef)
{ {
CFStringGetCString(valueRef, CFStringGetCString(valueRef,
@ -410,10 +412,7 @@ void _glfwInitJoysticks(void)
joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL); joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL);
joystick->hatElements = CFArrayCreateMutable(NULL, 0, NULL); joystick->hatElements = CFArrayCreateMutable(NULL, 0, NULL);
valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject, valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDElementKey));
CFSTR(kIOHIDElementKey),
kCFAllocatorDefault,
kNilOptions);
if (CFGetTypeID(valueRef) == CFArrayGetTypeID()) if (CFGetTypeID(valueRef) == CFArrayGetTypeID())
{ {
CFRange range = { 0, CFArrayGetCount(valueRef) }; CFRange range = { 0, CFArrayGetCount(valueRef) };