This commit is contained in:
Aaron Jacobs 2016-02-08 19:34:01 +00:00
commit 0986df1c53

View File

@ -29,6 +29,7 @@
#include <unistd.h> #include <unistd.h>
#include <ctype.h> #include <ctype.h>
#include <string.h>
#include <mach/mach.h> #include <mach/mach.h>
#include <mach/mach_error.h> #include <mach/mach_error.h>
@ -287,11 +288,17 @@ static void matchCallback(void* context,
CFStringRef name = IOHIDDeviceGetProperty(deviceRef, CFStringRef name = IOHIDDeviceGetProperty(deviceRef,
CFSTR(kIOHIDProductKey)); CFSTR(kIOHIDProductKey));
CFStringGetCString(name, if (name)
joystick->name, {
sizeof(joystick->name), CFStringGetCString(name,
kCFStringEncodingUTF8); joystick->name,
sizeof(joystick->name),
kCFStringEncodingUTF8);
}
else
{
strncpy(joystick->name, "Unknown", sizeof(joystick->name));
}
joystick->axisElements = CFArrayCreateMutable(NULL, 0, NULL); joystick->axisElements = CFArrayCreateMutable(NULL, 0, NULL);
joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL); joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL);
joystick->hatElements = CFArrayCreateMutable(NULL, 0, NULL); joystick->hatElements = CFArrayCreateMutable(NULL, 0, NULL);