X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=JSActionButton.m;h=12449ce99dfa50c362c020df761801bcc660a2ca;hp=98a186a8b49d30d68eb6c3f0bd9e0697eeb1d1a5;hb=c262a3d0972ba16257fd24a948ab04f528f80d33;hpb=530009447c5bbd360ac5023979cffc6d32a28df3 diff --git a/JSActionButton.m b/JSActionButton.m index 98a186a..12449ce 100644 --- a/JSActionButton.m +++ b/JSActionButton.m @@ -5,27 +5,32 @@ // Created by Sam McCall on 5/05/09. // -@implementation JSActionButton +#import "JSActionButton.h" -@synthesize max, active; +@implementation JSActionButton { + BOOL 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.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 { + active = IOHIDValueGetIntegerValue(value) == max; } @end