X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=JSActionButton.m;h=7d2572a32a09f4a92c0074eed851fbcdc80975e1;hp=98a186a8b49d30d68eb6c3f0bd9e0697eeb1d1a5;hb=62aa5b73be6ec1e499e6b155cd0e7687c338cbaa;hpb=530009447c5bbd360ac5023979cffc6d32a28df3 diff --git a/JSActionButton.m b/JSActionButton.m index 98a186a..7d2572a 100644 --- a/JSActionButton.m +++ b/JSActionButton.m @@ -5,27 +5,29 @@ // Created by Sam McCall on 5/05/09. // -@implementation JSActionButton +#import "JSActionButton.h" -@synthesize max, active; +@implementation JSActionButton { + long _max; +} --(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:(long)max { + if ((self = [super init])) { + _max = max; + if (name.length) + self.name = [NSString stringWithFormat:@"Button %d - %@", idx, name]; + else + self.name = [NSString stringWithFormat:@"Button %d", idx]; + } + 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 { + self.active = IOHIDValueGetIntegerValue(value) == _max; } @end