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:
parent
b0e66c925c
commit
58ae11778a
|
@ -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,
|
|
||||||
&hidProperties,
|
|
||||||
kCFAllocatorDefault,
|
|
||||||
kNilOptions);
|
|
||||||
|
|
||||||
if (result != kIOReturnSuccess)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Check device type
|
// Check device type
|
||||||
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey));
|
refCF = IORegistryEntryCreateCFProperty(ioHIDDeviceObject,
|
||||||
|
CFSTR(kIOHIDPrimaryUsagePageKey),
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
kNilOptions);
|
||||||
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())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user