mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Cocoa: Fix segfault querying joystick elements
It is reportedly possible for IOHIDDeviceCopyMatchingElements to return
NULL on macOS 13 if the application lacks input monitoring permissions.
This commit only prevents the segfault. More work will be needed to
correctly handle this situation, including Game Controller support.
Related to #2320
Closes #2321
(cherry picked from commit 2c1d31009f
)
This commit is contained in:
parent
628385e99e
commit
7b60753aeb
@ -83,6 +83,7 @@ video tutorials.
|
||||
- Andrew Gutekanst
|
||||
- Stephen Gutekanst
|
||||
- Jonathan Hale
|
||||
- Daniel Hauser
|
||||
- hdf89shfdfs
|
||||
- Moritz Heinemann
|
||||
- Sylvain Hellegouarch
|
||||
|
@ -133,6 +133,8 @@ information on what to include when reporting a bug.
|
||||
- [Cocoa] Bugfix: Full screen windows were resizable by the user (#2377,#2405)
|
||||
- [Cocoa] Bugfix: Full screen windows were miniaturized when clicked on macOS
|
||||
10.15 (#2377,#2405)
|
||||
- [Cocoa] Bugfix: Querying joystick elements could reportedly segfault on macOS
|
||||
13 Ventura (#2320)
|
||||
- [Wayland] Added improved fallback window decorations via libdecor (#1639,#1693)
|
||||
- [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450)
|
||||
- [Wayland] Disabled alpha channel for opaque windows on systems lacking
|
||||
|
@ -137,6 +137,14 @@ static void matchCallback(void* context,
|
||||
return;
|
||||
}
|
||||
|
||||
CFArrayRef elements =
|
||||
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
||||
|
||||
// It is reportedly possible for this to fail on macOS 13 Ventura
|
||||
// if the application does not have input monitoring permissions
|
||||
if (!elements)
|
||||
return;
|
||||
|
||||
axes = CFArrayCreateMutable(NULL, 0, NULL);
|
||||
buttons = CFArrayCreateMutable(NULL, 0, NULL);
|
||||
hats = CFArrayCreateMutable(NULL, 0, NULL);
|
||||
@ -180,9 +188,6 @@ static void matchCallback(void* context,
|
||||
name[8], name[9], name[10]);
|
||||
}
|
||||
|
||||
CFArrayRef elements =
|
||||
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
||||
|
||||
for (i = 0; i < CFArrayGetCount(elements); i++)
|
||||
{
|
||||
IOHIDElementRef native = (IOHIDElementRef)
|
||||
|
Loading…
Reference in New Issue
Block a user