X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Classes%2FNJInputController.m;h=84c8b69cd093b1a7962b1702c31c330b849823b5;hp=2200cb0dbbbb1ad5fa9ebfc307bdfbce3a8650c0;hb=85f90334bb98a2bb91aca5c78b4a0779207b8ce0;hpb=0a8d6333a3ac4684b70ab7f3581a93bf96638d6f diff --git a/Classes/NJInputController.m b/Classes/NJInputController.m index 2200cb0..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]; } }