X-Git-Url: https://git.yukkurigames.com/?a=blobdiff_plain;f=JSActionButton.m;h=f6a0fa76f003edc5ab89c3242c64e245de4f9bde;hb=19eadf9e688d8c087b47f83f8634593fddd641ac;hp=98a186a8b49d30d68eb6c3f0bd9e0697eeb1d1a5;hpb=530009447c5bbd360ac5023979cffc6d32a28df3;p=enjoyable.git diff --git a/JSActionButton.m b/JSActionButton.m index 98a186a..f6a0fa7 100644 --- a/JSActionButton.m +++ b/JSActionButton.m @@ -5,27 +5,31 @@ // Created by Sam McCall on 5/05/09. // -@implementation JSActionButton +@implementation JSActionButton { + BOOL active; +} -@synthesize max, active; +@synthesize max; +@synthesize active; --(id)initWithIndex: (int)newIndex andName: (NSString *)newName { - if(self= [ super init]) { - subActions = NULL; - index = newIndex; - name = [[NSString alloc] initWithFormat: @"Button %d %@", (index+1), newName]; - } - return self; +- (id)initWithName:(NSString *)name_ idx:(int)idx max:(int)max_ { + if ((self = [super init])) { + self.index = idx; + self.max = max_; + if (name_.length) + self.name = [NSString stringWithFormat:@"Button %d - %@", self.index, name_]; + else + self.name = [NSString stringWithFormat:@"Button %d", self.index]; + } + return self; } --(id) findSubActionForValue: (IOHIDValueRef) val { - if(IOHIDValueGetIntegerValue(val) == max) - return self; - return NULL; +- (id)findSubActionForValue:(IOHIDValueRef)val { + return (IOHIDValueGetIntegerValue(val) == max) ? self : nil; } --(void) notifyEvent: (IOHIDValueRef) value { - active = IOHIDValueGetIntegerValue(value) == max; +- (void)notifyEvent:(IOHIDValueRef)value { + active = IOHIDValueGetIntegerValue(value) == max; } @end