Fix for dropping input events in OS X 10.10.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Mon, 27 Oct 2014 10:40:03 +0000 (11:40 +0100)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Mon, 27 Oct 2014 10:40:03 +0000 (11:40 +0100)
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
Classes/NJHIDManager.m
Classes/NJInputController.m
Info.plist

index af86b3bd1b594f09420f4d07b940de44998d3193..c287cfe1b5cc11408d9873c364ab0b450277e92e 100644 (file)
@@ -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;
 
index 3dbaec3a6cb87335402790f48a54f5bde99b9a71..5c2b7cdf145f7efaee5d523e6e825565dbe0bf49 100644 (file)
@@ -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) {
index 2200cb0dbbbb1ad5fa9ebfc307bdfbce3a8650c0..84c8b69cd093b1a7962b1702c31c330b849823b5 100644 (file)
@@ -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];
     }
 }
 
index 71ed29e9fb6e4aec694c5fdcdc90c6ecc5a0d7c5..12fb106f107e72ccb8044557bee208fc27dfb505 100644 (file)
@@ -46,7 +46,7 @@
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>636</string>
+       <string>647</string>
        <key>LSApplicationCategoryType</key>
        <string>public.app-category.utilities</string>
        <key>NSHumanReadableCopyright</key>