diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/DDHidAppleMikey.m | 2 | ||||
| -rw-r--r-- | lib/DDHidAppleRemote.m | 2 | ||||
| -rw-r--r-- | lib/DDHidDevice.m | 32 | ||||
| -rw-r--r-- | lib/DDHidJoystick.m | 4 | ||||
| -rw-r--r-- | lib/DDHidKeyboard.m | 6 | ||||
| -rw-r--r-- | lib/DDHidMouse.m | 4 |
6 files changed, 30 insertions, 20 deletions
diff --git a/lib/DDHidAppleMikey.m b/lib/DDHidAppleMikey.m index d56db23..1460e57 100644 --- a/lib/DDHidAppleMikey.m +++ b/lib/DDHidAppleMikey.m @@ -152,7 +152,7 @@ - (void) ddhidQueueHasEvents: (DDHidQueue *) hidQueue; { DDHidEvent * event; - while (event = [hidQueue nextEvent]) + while ((event = [hidQueue nextEvent])) { DDHidElement * element = [self elementForCookie: [event elementCookie]]; unsigned usageId = [[element usage] usageId]; diff --git a/lib/DDHidAppleRemote.m b/lib/DDHidAppleRemote.m index e8b31b2..265db45 100644 --- a/lib/DDHidAppleRemote.m +++ b/lib/DDHidAppleRemote.m @@ -199,7 +199,7 @@ SInt32 sumOfValues = 0; DDHidEvent * event; - while (event = [hidQueue nextEvent]) + while ((event = [hidQueue nextEvent])) { if ([event elementCookie] == [mIdElement cookie]) { diff --git a/lib/DDHidDevice.m b/lib/DDHidDevice.m index 8000185..387a1e5 100644 --- a/lib/DDHidDevice.m +++ b/lib/DDHidDevice.m @@ -115,9 +115,14 @@ // name for all HID class devices CFMutableDictionaryRef hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); - return [self allDevicesMatchingCFDictionary: hidMatchDictionary + id retVal = nil; + if(hidMatchDictionary) { + retVal = [self allDevicesMatchingCFDictionary: hidMatchDictionary withClass: [DDHidDevice class] skipZeroLocations: NO]; + //CFRelease(hidMatchDictionary);//dont free, it is freed by IOServiceGetMatchingServices + } + return retVal; } + (NSArray *) allDevicesMatchingUsagePage: (unsigned) usagePage @@ -129,15 +134,20 @@ // name for all HID class devices CFMutableDictionaryRef hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); - NSMutableDictionary * objcMatchDictionary = - (NSMutableDictionary *) hidMatchDictionary; - [objcMatchDictionary ddhid_setObject: [NSNumber numberWithUnsignedInt: usagePage] - forString: kIOHIDDeviceUsagePageKey]; - [objcMatchDictionary ddhid_setObject: [NSNumber numberWithUnsignedInt: usageId] - forString: kIOHIDDeviceUsageKey]; - return [self allDevicesMatchingCFDictionary: hidMatchDictionary - withClass: hidClass - skipZeroLocations: skipZeroLocations]; + id retVal = nil; + if(hidMatchDictionary) { + NSMutableDictionary * objcMatchDictionary = + (NSMutableDictionary *) hidMatchDictionary; + [objcMatchDictionary ddhid_setObject: [NSNumber numberWithUnsignedInt: usagePage] + forString: kIOHIDDeviceUsagePageKey]; + [objcMatchDictionary ddhid_setObject: [NSNumber numberWithUnsignedInt: usageId] + forString: kIOHIDDeviceUsageKey]; + retVal = [self allDevicesMatchingCFDictionary: hidMatchDictionary + withClass: hidClass + skipZeroLocations: skipZeroLocations]; + //CFRelease(hidMatchDictionary);//dont free, it is freed by IOServiceGetMatchingServices + } +return retVal; } + (NSArray *) allDevicesMatchingCFDictionary: (CFDictionaryRef) matchDictionary @@ -157,7 +167,7 @@ return [NSArray array]; io_object_t hidDevice; - while (hidDevice = IOIteratorNext(hidObjectIterator)) + while ((hidDevice = IOIteratorNext(hidObjectIterator))) { [self addDevice: hidDevice withClass: hidClass diff --git a/lib/DDHidJoystick.m b/lib/DDHidJoystick.m index 601f9b3..986ea28 100644 --- a/lib/DDHidJoystick.m +++ b/lib/DDHidJoystick.m @@ -294,7 +294,7 @@ - (void) ddhidQueueHasEvents: (DDHidQueue *) hidQueue; { DDHidEvent * event; - while (event = [hidQueue nextEvent]) + while ((event = [hidQueue nextEvent])) { IOHIDElementCookie cookie = [event elementCookie]; SInt32 value = [event value]; @@ -346,7 +346,7 @@ else { DDHidElement * element = [self elementForCookie: [event elementCookie]]; - NSLog(@"Element: %@, value: %d", [[element usage] usageName], [event value]); + NSLog(@"Element: %@, value: %d", [[element usage] usageName], (int)[event value]); } } } diff --git a/lib/DDHidKeyboard.m b/lib/DDHidKeyboard.m index 7e37264..5b0db35 100644 --- a/lib/DDHidKeyboard.m +++ b/lib/DDHidKeyboard.m @@ -143,8 +143,8 @@ unsigned usageId = [[element usage] usageId]; if (usagePage == kHIDPage_KeyboardOrKeypad) { - if ((usageId >= 0x04) && (usageId <= 0xA4) || - (usageId >= 0xE0) && (usageId <= 0xE7)) + if (((usageId >= 0x04) && (usageId <= 0xA4)) || + ((usageId >= 0xE0) && (usageId <= 0xE7))) { [mKeyElements addObject: element]; } @@ -158,7 +158,7 @@ - (void) ddhidQueueHasEvents: (DDHidQueue *) hidQueue; { DDHidEvent * event; - while (event = [hidQueue nextEvent]) + while ((event = [hidQueue nextEvent])) { DDHidElement * element = [self elementForCookie: [event elementCookie]]; unsigned usageId = [[element usage] usageId]; diff --git a/lib/DDHidMouse.m b/lib/DDHidMouse.m index 7eeb5b3..ab478a3 100644 --- a/lib/DDHidMouse.m +++ b/lib/DDHidMouse.m @@ -224,7 +224,7 @@ - (void) ddhidQueueHasEvents: (DDHidQueue *) hidQueue; { DDHidEvent * event; - while (event = [hidQueue nextEvent]) + while ((event = [hidQueue nextEvent])) { IOHIDElementCookie cookie = [event elementCookie]; SInt32 value = [event value]; @@ -269,7 +269,7 @@ else { DDHidElement * element = [self elementForCookie: [event elementCookie]]; - NSLog(@"Element: %@, value: %d", [[element usage] usageName], [event value]); + NSLog(@"Element: %@, value: %d", [[element usage] usageName], (int)[event value]); } } } |
