mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -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:
parent
cc4c7167fd
commit
4013f733fe
|
@ -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) };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user