From 85f90334bb98a2bb91aca5c78b4a0779207b8ce0 Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Mon, 27 Oct 2014 11:40:03 +0100 Subject: [PATCH] Fix for dropping input events in OS X 10.10. Value callbacks no longer include the device in the sender (or at least, IOHIDQueueGetDevice now returns NULL). Instead, you need to query the device directly from the IOHIDValueRef via its IOHIDElementRef. --- Classes/NJHIDManager.h | 4 +--- Classes/NJHIDManager.m | 3 +-- Classes/NJInputController.m | 19 ++++++++++--------- Info.plist | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Classes/NJHIDManager.h b/Classes/NJHIDManager.h index af86b3b..c287cfe 100644 --- a/Classes/NJHIDManager.h +++ b/Classes/NJHIDManager.h @@ -33,9 +33,7 @@ - (void)HIDManager:(NJHIDManager *)manager deviceAdded:(IOHIDDeviceRef)device; - (void)HIDManager:(NJHIDManager *)manager deviceRemoved:(IOHIDDeviceRef)device; -- (void)HIDManager:(NJHIDManager *)manager - valueChanged:(IOHIDValueRef)value - fromDevice:(IOHIDDeviceRef)device; +- (void)HIDManager:(NJHIDManager *)manager valueChanged:(IOHIDValueRef)value; - (void)HIDManager:(NJHIDManager *)manager didError:(NSError *)error; diff --git a/Classes/NJHIDManager.m b/Classes/NJHIDManager.m index 3dbaec3..5c2b7cd 100644 --- a/Classes/NJHIDManager.m +++ b/Classes/NJHIDManager.m @@ -21,8 +21,7 @@ static void _input(void *ctx, IOReturn inResult, void *inSender, IOHIDValueRef value) { NJHIDManager *self = (__bridge NJHIDManager *)ctx; - IOHIDDeviceRef device = IOHIDQueueGetDevice(inSender); - [self.delegate HIDManager:self valueChanged:value fromDevice:device]; + [self.delegate HIDManager:self valueChanged:value]; } static void _add(void *ctx, IOReturn inResult, void *inSender, IOHIDDeviceRef device) { 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]; } } diff --git a/Info.plist b/Info.plist index 71ed29e..12fb106 100644 --- a/Info.plist +++ b/Info.plist @@ -46,7 +46,7 @@ CFBundleSignature ???? CFBundleVersion - 636 + 647 LSApplicationCategoryType public.app-category.utilities NSHumanReadableCopyright -- 2.30.2