Clean-up of Joystick class. Refactor constructor to avoid mandatory 'post-constructor...
[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
10 @synthesize max, active;
11
12 -(id)initWithIndex: (int)newIndex andName: (NSString *)newName {
13 if(self= [ super init]) {
14 subActions = NULL;
15 index = newIndex;
16 name = [[NSString alloc] initWithFormat: @"Button %d %@", (index+1), newName];
17 }
18 return self;
19 }
20
21 -(id) findSubActionForValue: (IOHIDValueRef) val {
22 if(IOHIDValueGetIntegerValue(val) == max)
23 return self;
24 return NULL;
25 }
26
27 -(void) notifyEvent: (IOHIDValueRef) value {
28 active = IOHIDValueGetIntegerValue(value) == max;
29 }
30
31 @end