X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Classes%2FNJInputController.m;h=84c8b69cd093b1a7962b1702c31c330b849823b5;hp=ed0d72d8208c14ef0f771bff4bb7ec66bc7be188;hb=HEAD;hpb=dc526070b502b03b2c98c679bbbde371b21eeb9a diff --git a/Classes/NJInputController.m b/Classes/NJInputController.m index ed0d72d..84c8b69 100644 --- a/Classes/NJInputController.m +++ b/Classes/NJInputController.m @@ -115,7 +115,9 @@ static CVReturn _updateDL(CVDisplayLinkRef displayLink, 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]; @@ -129,7 +131,9 @@ static CVReturn _updateDL(CVDisplayLinkRef displayLink, } } -- (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) @@ -138,14 +142,11 @@ static CVReturn _updateDL(CVDisplayLinkRef displayLink, [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]; } } @@ -380,7 +381,8 @@ static CVReturn _updateDL(CVDisplayLinkRef displayLink, - (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]; }