-- (id)initWithIndex:(int)index {
- if ((self = [super init])) {
- self.children = @[[[NJInput alloc] initWithName:@"Up" base:self],
- [[NJInput alloc] initWithName:@"Down" base:self],
- [[NJInput alloc] initWithName:@"Left" base:self],
- [[NJInput alloc] initWithName:@"Right" base:self]];
- self.name = [NSString stringWithFormat:@"Hat Switch %d", index];
+- (id)initWithElement:(IOHIDElementRef)element
+ index:(int)index
+ parent:(NJInputPathElement *)parent
+{
+ if ((self = [super initWithName:NJINPUT_NAME(NSLocalizedString(@"hat switch %d", @"hat switch name"), index)
+ eid:NJINPUT_EID("Hat Switch", index)
+ element:element
+ parent:parent])) {
+ self.children = @[[[NJInput alloc] initWithName:NSLocalizedString(@"hat up", @"hat switch up state")
+ eid:@"Up"
+ parent:self],
+ [[NJInput alloc] initWithName:NSLocalizedString(@"hat down", @"hat switch down state")
+ eid:@"Down"
+ parent:self],
+ [[NJInput alloc] initWithName:NSLocalizedString(@"hat left", @"hat switch left state")
+ eid:@"Left"
+ parent:self],
+ [[NJInput alloc] initWithName:NSLocalizedString(@"hat right", @"hat switch right state")
+ eid:@"Right"
+ parent:self]];
+ _max = IOHIDElementGetLogicalMax(element);