Fix localization changing mapping logical names.
[enjoyable.git] / Classes / NJInputButton.m
1 //
2 // NJInputButton.m
3 // Enjoy
4 //
5 // Created by Sam McCall on 5/05/09.
6 //
7
8 #import "NJInputButton.h"
9
10 @implementation NJInputButton {
11 long _max;
12 }
13
14 - (id)initWithName:(NSString *)name idx:(int)idx max:(long)max {
15 NSString *fullname = [NSString stringWithFormat:NSLocalizedString(@"button %d", @"button name"), idx];
16 if (name.length)
17 fullname = [fullname stringByAppendingFormat:@"- %@", name];
18 NSString *did = [[NSString alloc] initWithFormat:@"Button %d", idx];
19 if ((self = [super initWithName:fullname did:did base:nil])) {
20 _max = max;
21 }
22 return self;
23 }
24
25 - (id)findSubInputForValue:(IOHIDValueRef)val {
26 return (IOHIDValueGetIntegerValue(val) == _max) ? self : nil;
27 }
28
29 - (void)notifyEvent:(IOHIDValueRef)value {
30 self.active = IOHIDValueGetIntegerValue(value) == _max;
31 self.magnitude = IOHIDValueGetIntegerValue(value) / (float)_max;
32 }
33
34 @end