mirror of
https://github.com/glfw/glfw.git
synced 2024-11-23 02:25:10 +00:00
Do not recurse over IOHIDElement children.
This commit is contained in:
parent
1a96c294ee
commit
fec6f187d1
@ -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);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user