CVDisplayLinkStart(_displayLink);
}
-- (void)runOutputForDevice:(IOHIDDeviceRef)device value:(IOHIDValueRef)value {
+- (void)runOutputForValue:(IOHIDValueRef)value {
+ IOHIDElementRef elt = value ? IOHIDValueGetElement(value) : NULL;
+ IOHIDDeviceRef device = elt ? IOHIDElementGetDevice(elt) : NULL;
NJDevice *dev = [self findDeviceByRef:device];
NJInput *mainInput = [dev inputForEvent:value];
[mainInput notifyEvent:value];
}
}
-- (void)showOutputForDevice:(IOHIDDeviceRef)device value:(IOHIDValueRef)value {
+- (void)showOutputForValue:(IOHIDValueRef)value {
+ IOHIDElementRef elt = value ? IOHIDValueGetElement(value) : NULL;
+ IOHIDDeviceRef device = elt ? IOHIDElementGetDevice(elt) : NULL;
NJDevice *dev = [self findDeviceByRef:device];
NJInput *handler = [dev handlerForEvent:value];
if (!handler)
[self.delegate inputController:self didInput:handler];
}
-- (void)HIDManager:(NJHIDManager *)manager
- valueChanged:(IOHIDValueRef)value
- fromDevice:(IOHIDDeviceRef)device {
- if (self.simulatingEvents
- && !NSApplication.sharedApplication.isActive) {
- [self runOutputForDevice:device value:value];
+- (void)HIDManager:(NJHIDManager *)manager valueChanged:(IOHIDValueRef)value {
+ if (self.simulatingEvents && !NSApplication.sharedApplication.isActive) {
+ [self runOutputForValue:value];
} else {
- [self showOutputForDevice:device value:value];
+ [self showOutputForValue:value];
}
}
- (void)removeMappingAtIndex:(NSInteger)idx {
NSInteger currentIdx = [self indexOfMapping:_currentMapping];
[_mappings removeObjectAtIndex:idx];
- [self activateMapping:self.mappings[MIN(currentIdx, _mappings.count - 1)]];
+ NSInteger activeIdx = MIN(currentIdx, (NSInteger)_mappings.count - 1);
+ [self activateMapping:self.mappings[activeIdx]];
[self mappingsChanged];
}