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