1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00

Replaced expensive IOKit function.

This commit is contained in:
Camilla Berglund 2013-05-02 18:02:52 +02:00
parent b0e66c925c
commit 58ae11778a

View File

@ -317,7 +317,6 @@ void _glfwInitJoysticks(void)
while ((ioHIDDeviceObject = IOIteratorNext(objectIterator))) while ((ioHIDDeviceObject = IOIteratorNext(objectIterator)))
{ {
CFMutableDictionaryRef hidProperties = 0;
kern_return_t result; kern_return_t result;
CFTypeRef refCF = 0; CFTypeRef refCF = 0;
@ -327,16 +326,11 @@ void _glfwInitJoysticks(void)
long usagePage, usage; long usagePage, usage;
result = IORegistryEntryCreateCFProperties(ioHIDDeviceObject, // Check device type
&hidProperties, refCF = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
CFSTR(kIOHIDPrimaryUsagePageKey),
kCFAllocatorDefault, kCFAllocatorDefault,
kNilOptions); kNilOptions);
if (result != kIOReturnSuccess)
continue;
// Check device type
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey));
if (refCF) if (refCF)
{ {
CFNumberGetValue(refCF, kCFNumberLongType, &usagePage); CFNumberGetValue(refCF, kCFNumberLongType, &usagePage);
@ -347,7 +341,10 @@ void _glfwInitJoysticks(void)
} }
} }
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsageKey)); refCF = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
CFSTR(kIOHIDPrimaryUsageKey),
kCFAllocatorDefault,
kNilOptions);
if (refCF) if (refCF)
{ {
CFNumberGetValue(refCF, kCFNumberLongType, &usage); CFNumberGetValue(refCF, kCFNumberLongType, &usage);
@ -391,7 +388,10 @@ void _glfwInitJoysticks(void)
joystick); joystick);
// Get product string // Get product string
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); refCF = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
CFSTR(kIOHIDProductKey),
kCFAllocatorDefault,
kNilOptions);
if (refCF) if (refCF)
{ {
CFStringGetCString(refCF, CFStringGetCString(refCF,
@ -407,8 +407,12 @@ void _glfwInitJoysticks(void)
joystick->buttons = CFArrayCreateMutable(NULL, 0, NULL); joystick->buttons = CFArrayCreateMutable(NULL, 0, NULL);
joystick->hats = CFArrayCreateMutable(NULL, 0, NULL); joystick->hats = CFArrayCreateMutable(NULL, 0, NULL);
CFTypeRef refTopElement = CFDictionaryGetValue(hidProperties, CFTypeRef refTopElement;
CFSTR(kIOHIDElementKey));
refTopElement = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
CFSTR(kIOHIDElementKey),
kCFAllocatorDefault,
kNilOptions);
CFTypeID type = CFGetTypeID(refTopElement); CFTypeID type = CFGetTypeID(refTopElement);
if (type == CFArrayGetTypeID()) if (type == CFArrayGetTypeID())
{ {