Clean up JoystickController. Modernize more Objective-C syntax. Remove direct public...
[enjoyable.git] / JSActionButton.m
1 //
2 // JSActionButton.m
3 // Enjoy
4 //
5 // Created by Sam McCall on 5/05/09.
6 //
7
8 @implementation JSActionButton {
9 BOOL active;
10 }
11
12 @synthesize max;
13 @synthesize active;
14
15 - (id)initWithName:(NSString *)name_ idx:(int)idx max:(int)max_ {
16 if ((self = [super init])) {
17 self.index = idx;
18 self.max = max_;
19 if (name_.length)
20 self.name = [NSString stringWithFormat:@"Button %d - %@", self.index + 1, name_];
21 else
22 self.name = [NSString stringWithFormat:@"Button %d", self.index + 1];
23 }
24 return self;
25 }
26
27 - (id)findSubActionForValue:(IOHIDValueRef)val {
28 return (IOHIDValueGetIntegerValue(val) == max) ? self : nil;
29 }
30
31 - (void)notifyEvent:(IOHIDValueRef)value {
32 active = IOHIDValueGetIntegerValue(value) == max;
33 }
34
35 @end