X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Classes%2FNJDevice.m;h=3b0cc6a4c2c53e181ca73e79e863c15e35c30caa;hp=69775d835d399f3c315bb7e52519726bbdbb9560;hb=bdd3587bb3eadc9ddfe2ae385134de25bc13d770;hpb=0064c1fbff36795885a9724081af2a17d83c20a3 diff --git a/Classes/NJDevice.m b/Classes/NJDevice.m index 69775d8..3b0cc6a 100644 --- a/Classes/NJDevice.m +++ b/Classes/NJDevice.m @@ -61,16 +61,16 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) { } @implementation NJDevice { - int vendorId; - int productId; + int _vendorId; + int _productId; } - (id)initWithDevice:(IOHIDDeviceRef)dev { - if ((self = [super init])) { + if ((self = [super initWithName:nil did:nil base:nil])) { self.device = dev; self.productName = (__bridge NSString *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductKey)); - vendorId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDVendorIDKey)) intValue]; - productId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductIDKey)) intValue]; + _vendorId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDVendorIDKey)) intValue]; + _productId = [(__bridge NSNumber *)IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductIDKey)) intValue]; self.children = InputsForElement(dev, self); } return self; @@ -80,16 +80,12 @@ static NSArray *InputsForElement(IOHIDDeviceRef device, id base) { return [NSString stringWithFormat:@"%@ #%d", _productName, _index]; } -- (id)base { - return nil; -} - - (NSString *)uid { - return [NSString stringWithFormat: @"%d:%d:%d", vendorId, productId, _index]; + return [NSString stringWithFormat: @"%d:%d:%d", _vendorId, _productId, _index]; } - (NJInput *)findInputByCookie:(IOHIDElementCookie)cookie { - for (NJInput *child in _children) + for (NJInput *child in self.children) if (child.cookie == cookie) return child; return nil;