Show an error message if opening input devices fail. Move real vs. configuration...
[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.index = idx;
20 self.max = max_;
21 if (name_.length)
22 self.name = [NSString stringWithFormat:@"Button %d - %@", self.index, name_];
23 else
24 self.name = [NSString stringWithFormat:@"Button %d", self.index];
25 }
26 return self;
27 }
28
29 - (id)findSubActionForValue:(IOHIDValueRef)val {
30 return (IOHIDValueGetIntegerValue(val) == max) ? self : nil;
31 }
32
33 - (void)notifyEvent:(IOHIDValueRef)value {
34 active = IOHIDValueGetIntegerValue(value) == max;
35 }
36
37 @end