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

Do not recurse over IOHIDElement children.

This commit is contained in:
Aaron Jacobs 2015-06-23 13:14:07 -07:00 committed by Camilla Berglund
parent 1a96c294ee
commit fec6f187d1

View File

@ -67,65 +67,53 @@ static void addJoystickElement(_GLFWjoydevice* joystick, IOHIDElementRef element
usagePage = IOHIDElementGetUsagePage(elementRef); usagePage = IOHIDElementGetUsagePage(elementRef);
usage = IOHIDElementGetUsage(elementRef); usage = IOHIDElementGetUsage(elementRef);
if ((elementType == kIOHIDElementTypeInput_Axis) || if ((elementType != kIOHIDElementTypeInput_Axis) &&
(elementType == kIOHIDElementTypeInput_Button) || (elementType != kIOHIDElementTypeInput_Button) &&
(elementType == kIOHIDElementTypeInput_Misc)) (elementType != kIOHIDElementTypeInput_Misc))
{ return;
switch (usagePage)
{
case kHIDPage_GenericDesktop:
{
switch (usage)
{
case kHIDUsage_GD_X:
case kHIDUsage_GD_Y:
case kHIDUsage_GD_Z:
case kHIDUsage_GD_Rx:
case kHIDUsage_GD_Ry:
case kHIDUsage_GD_Rz:
case kHIDUsage_GD_Slider:
case kHIDUsage_GD_Dial:
case kHIDUsage_GD_Wheel:
elementsArray = joystick->axisElements;
break;
case kHIDUsage_GD_Hatswitch:
elementsArray = joystick->hatElements;
break;
}
break; switch (usagePage)
{
case kHIDPage_GenericDesktop:
{
switch (usage)
{
case kHIDUsage_GD_X:
case kHIDUsage_GD_Y:
case kHIDUsage_GD_Z:
case kHIDUsage_GD_Rx:
case kHIDUsage_GD_Ry:
case kHIDUsage_GD_Rz:
case kHIDUsage_GD_Slider:
case kHIDUsage_GD_Dial:
case kHIDUsage_GD_Wheel:
elementsArray = joystick->axisElements;
break;
case kHIDUsage_GD_Hatswitch:
elementsArray = joystick->hatElements;
break;
} }
case kHIDPage_Button: break;
elementsArray = joystick->buttonElements;
break;
default:
break;
} }
if (elementsArray) case kHIDPage_Button:
{ elementsArray = joystick->buttonElements;
_GLFWjoyelement* element = calloc(1, sizeof(_GLFWjoyelement)); break;
default:
CFArrayAppendValue(elementsArray, element); break;
element->elementRef = elementRef;
element->minReport = IOHIDElementGetLogicalMin(elementRef);
element->maxReport = IOHIDElementGetLogicalMax(elementRef);
}
} }
else
if (elementsArray)
{ {
CFArrayRef array = IOHIDElementGetChildren(elementRef); _GLFWjoyelement* element = calloc(1, sizeof(_GLFWjoyelement));
if (array)
{ CFArrayAppendValue(elementsArray, element);
if (CFGetTypeID(array) == CFArrayGetTypeID())
{ element->elementRef = elementRef;
CFRange range = { 0, CFArrayGetCount(array) };
CFArrayApplyFunction(array, range, getElementsCFArrayHandler, joystick); element->minReport = IOHIDElementGetLogicalMin(elementRef);
} element->maxReport = IOHIDElementGetLogicalMax(elementRef);
}
} }
} }