X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Joystick.m;h=2d50fa4d87124ae572c66b856b58236c96bf8c49;hp=d6c436224221dd25787c1a15ddcc7109f19a7481;hb=d2b45b2c32dcc7c3cc553b62252ca48842e08d48;hpb=8ab26ba60a5cf895797e24a432949a1c11622fed diff --git a/Joystick.m b/Joystick.m index d6c4362..2d50fa4 100644 --- a/Joystick.m +++ b/Joystick.m @@ -5,36 +5,26 @@ // Created by Sam McCall on 4/05/09. // -@implementation Joystick - +@implementation Joystick { + NSMutableArray *children; +} -@synthesize vendorId, productId, productName, name, index, device, children; +@synthesize vendorId, productId, productName, index, device, children; --(id)initWithDevice: (IOHIDDeviceRef) newDevice { - if(self=[super init]) { - children = [[NSMutableArray alloc]init]; - - device = newDevice; - productName = (__bridge NSString*)IOHIDDeviceGetProperty( device, CFSTR(kIOHIDProductKey) ); - vendorId = [(__bridge NSNumber*)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)) intValue]; - productId = [(__bridge NSNumber*)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)) intValue]; +- (id)initWithDevice: (IOHIDDeviceRef) newDevice { + if ((self = [super init])) { + children = [[NSMutableArray alloc] init]; - name = productName; + self.device = newDevice; + self.productName = (__bridge NSString *)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey)); + self.vendorId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)) intValue]; + self.productId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)) intValue]; } return self; } --(void) setIndex: (int) newIndex { - index = newIndex; - name = [[NSString alloc] initWithFormat: @"%@ #%d", productName, (index+1)]; -} --(int) index { - return index; -} - --(void) invalidate { - IOHIDDeviceClose(device, kIOHIDOptionsTypeNone); - NSLog(@"Removed a device: %@", [self name]); +- (NSString *)name { + return [[NSString alloc] initWithFormat: @"%@ #%d", productName, index + 1]; } -(id) base {