15b4687059b657343efcd22af02e0ab5d10d193c
[enjoyable.git] / Classes / NJInput.m
1 //
2 // NJInput.m
3 // Enjoy
4 //
5 // Created by Sam McCall on 4/05/09.
6 //
7
8 #import "NJInput.h"
9
10 @implementation NJInput
11
12 - (id)initWithName:(NSString *)newName base:(id <NJInputPathElement>)newBase {
13 if ((self = [super init])) {
14 self.name = newName;
15 self.base = newBase;
16 }
17 return self;
18 }
19
20 - (id)findSubInputForValue:(IOHIDValueRef)value {
21 return nil;
22 }
23
24 - (NSString *)uid {
25 return [NSString stringWithFormat:@"%@~%@", _base.uid, _name];
26 }
27
28 - (void)notifyEvent:(IOHIDValueRef)value {
29 [self doesNotRecognizeSelector:_cmd];
30 }
31
32 - (BOOL)isEqual:(id)object {
33 return [object isKindOfClass:NJInput.class]
34 && [[object uid] isEqualToString:self.uid];
35 }
36
37 - (NSUInteger)hash {
38 return self.uid.hash;
39 }
40
41 - (id <NJInputPathElement>)elementForUID:(NSString *)uid {
42 if ([uid isEqualToString:self.uid])
43 return self;
44 else {
45 for (id <NJInputPathElement> elem in self.children) {
46 id <NJInputPathElement> ret = [elem elementForUID:uid];
47 if (ret)
48 return ret;
49 }
50 }
51 return nil;
52 }
53
54 @end