Remove website, now in yukkurigames.com repository.
[enjoyable.git] / Classes / NJDevice.m
index b03898f..c6cc201 100644 (file)
@@ -66,18 +66,24 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id parent) {
 }
 
 - (id)initWithDevice:(IOHIDDeviceRef)dev {
-    if ((self = [super initWithName:nil eid:nil parent:nil])) {
+    NSString *name = (__bridge NSString *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductKey));
+    if ((self = [super initWithName:name eid:nil parent: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];
         self.children = InputsForElement(dev, self);
+        self.index = 1;
     }
     return self;
 }
 
+- (BOOL)isEqual:(id)object {
+    return [object isKindOfClass:NJDevice.class]
+        && [[(NJDevice *)object name] isEqualToString:self.name];
+}
+
 - (NSString *)name {
-    return [NSString stringWithFormat:@"%@ #%d", _productName, _index];
+    return [NSString stringWithFormat:@"%@ #%d", super.name, _index];
 }
 
 - (NSString *)uid {