Style issues. Remove dead code.
[enjoyable.git] / Classes / NJDevice.m
index e2a0efa..3b0cc6a 100644 (file)
@@ -61,16 +61,16 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) {
 }
 
 @implementation NJDevice {
-    int vendorId;
-    int productId;
+    int _vendorId;
+    int _productId;
 }
 
 - (id)initWithDevice:(IOHIDDeviceRef)dev {
-    if ((self = [super init])) {
+    if ((self = [super initWithName:nil did:nil base:nil])) {
         self.device = dev;
         self.productName = (__bridge NSString *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductKey));
-        vendorId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDVendorIDKey)) intValue];
-        productId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductIDKey)) intValue];
+        _vendorId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDVendorIDKey)) intValue];
+        _productId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductIDKey)) intValue];
         self.children = InputsForElement(dev, self);
     }
     return self;
@@ -80,16 +80,12 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) {
     return [NSString stringWithFormat:@"%@ #%d", _productName, _index];
 }
 
-- (id)base {
-    return nil;
-}
-
 - (NSString *)uid {
-    return [NSString stringWithFormat: @"%d:%d:%d", vendorId, productId, _index];
+    return [NSString stringWithFormat: @"%d:%d:%d", _vendorId, _productId, _index];
 }
 
 - (NJInput *)findInputByCookie:(IOHIDElementCookie)cookie {
-    for (NJInput *child in _children)
+    for (NJInput *child in self.children)
         if (child.cookie == cookie)
             return child;
     return nil;
@@ -106,28 +102,4 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) {
     return [self findInputByCookie:cookie];
 }
 
-- (BOOL)isEqual:(id)object {
-    return [object isKindOfClass:NJDevice.class]
-        && [[object uid] isEqualToString:self.uid];
-}
-
-- (NSUInteger)hash {
-    return self.uid.hash;
-}
-
-- (id <NJInputPathElement>)elementForUID:(NSString *)uid {
-    if ([uid isEqualToString:self.uid])
-        return self;
-    else if (![uid hasPrefix:self.uid])
-        return nil;
-    else {
-        for (id <NJInputPathElement> elem in self.children) {
-            id <NJInputPathElement> ret = [elem elementForUID:uid];
-            if (ret)
-                return ret;
-        }
-    }
-    return nil;
-}
-
 @end