Remember expanded rows between activations / device insertion.
[enjoyable.git] / Classes / NJInput.m
index 077dac8..15b4687 100644 (file)
 }
 
 - (id)findSubInputForValue:(IOHIDValueRef)value {
-    return NULL;
+    return nil;
 }
 
 - (NSString *)uid {
-    return [NSString stringWithFormat:@"%@~%@", [_base uid], _name];
+    return [NSString stringWithFormat:@"%@~%@", _base.uid, _name];
 }
 
 - (void)notifyEvent:(IOHIDValueRef)value {
     [self doesNotRecognizeSelector:_cmd];
 }
 
+- (BOOL)isEqual:(id)object {
+    return [object isKindOfClass:NJInput.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 {
+        for (id <NJInputPathElement> elem in self.children) {
+            id <NJInputPathElement> ret = [elem elementForUID:uid];
+            if (ret)
+                return ret;
+        }
+    }
+    return nil;
+}
+
 @end