131 :(IOHIDDeviceRef)device
132{
133 OOLog(
@"joystick.connect",
@"Joystick connected: %@", IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey)));
134
135 CFArrayAppendValue(
devices, device);
137
139 {
140
141 CFArrayRef elementList = IOHIDDeviceCopyMatchingElements(device, NULL, 0L);
142 if (elementList != NULL)
143 {
145
146 CFIndex idx,
count = CFArrayGetCount(elementList);
147
148 for (idx = 0; idx <
count; idx++)
149 {
150 IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elementList, idx);
151 IOHIDElementType elementType = IOHIDElementGetType(element);
152 if (elementType > kIOHIDElementTypeInput_ScanCodes)
153 {
154 continue;
155 }
156 IOHIDElementCookie elementCookie = IOHIDElementGetCookie(element);
157 uint32_t usagePage = IOHIDElementGetUsagePage(element);
158 uint32_t usage = IOHIDElementGetUsage(element);
159 uint32_t min = (uint32_t)IOHIDElementGetPhysicalMin(element);
160 uint32_t max = (uint32_t)IOHIDElementGetPhysicalMax(element);
161 NSString *name = (NSString *)IOHIDElementGetProperty(element, CFSTR(kIOHIDElementNameKey)) ?: @"unnamed";
162 OOLog(
@"joystick.connect.element",
@"%@ - usage %d:%d, cookie %d, range %d-%d", name, usagePage, usage, (
int) elementCookie, min, max);
163 }
164
166 CFRelease(elementList);
167 }
168 }
169}
static void HandleInputValueCallback(void *inContext, IOReturn inResult, void *inSender, IOHIDValueRef inIOHIDValueRef)