X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=JSActionButton.m;h=c358c8dfc873d38d5ca56bbc741c56f3eac9cf15;hp=98a186a8b49d30d68eb6c3f0bd9e0697eeb1d1a5;hb=e68c19b5923618b763543c74bf8dd6f85d4d323e;hpb=fad073260e61084c4962e172c58a0595261bd811 diff --git a/JSActionButton.m b/JSActionButton.m index 98a186a..c358c8d 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 + 1, name_]; + else + self.name = [NSString stringWithFormat:@"Button %d", self.index + 1]; + } + 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