mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
MacOS: Don't crash if no elements are returned by IOHIDDeviceCopyMatchingElements
Fixes #797
This commit is contained in:
parent
f72c72b36a
commit
791be4766a
@ -114,12 +114,14 @@ IOKitInputDevice(IOHIDDeviceRef device) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
CFArrayRef elements = IOHIDDeviceCopyMatchingElements(device, nullptr, 0);
|
CFArrayRef elements = IOHIDDeviceCopyMatchingElements(device, nullptr, 0);
|
||||||
CFIndex count = CFArrayGetCount(elements);
|
if (elements) {
|
||||||
for (CFIndex i = 0; i < count; ++i) {
|
CFIndex count = CFArrayGetCount(elements);
|
||||||
IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, i);
|
for (CFIndex i = 0; i < count; ++i) {
|
||||||
parse_element(element);
|
IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, i);
|
||||||
|
parse_element(element);
|
||||||
|
}
|
||||||
|
CFRelease(elements);
|
||||||
}
|
}
|
||||||
CFRelease(elements);
|
|
||||||
|
|
||||||
if (_hat_element != nullptr) {
|
if (_hat_element != nullptr) {
|
||||||
_hat_left_button = (int)_buttons.size();
|
_hat_left_button = (int)_buttons.size();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user