int _ykusb_start(void)
{
ykosxManager = IOHIDManagerCreate( kCFAllocatorDefault, 0L );
-
+
return 1;
}
if (ykosxManager != NULL) {
_ykusb_IOReturn = IOHIDManagerClose( ykosxManager, 0L );
CFRelease(ykosxManager);
-
+
if (_ykusb_IOReturn == kIOReturnSuccess) {
ykosxManager = NULL;
return 1;
}
}
-
+
yk_errno = YK_EUSBERR;
return 0;
}
CFDictionaryRef dict;
CFStringRef keys[2];
CFStringRef values[2];
-
+
yk_errno = YK_EUSBERR;
-
+
CFNumberRef vendorID = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &vendor_id );
CFNumberRef productID = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &product_id );
-
+
keys[0] = CFSTR( kIOHIDVendorIDKey ); values[0] = (void *) vendorID;
keys[1] = CFSTR( kIOHIDProductIDKey ); values[1] = (void *) productID;
dict = CFDictionaryCreate( kCFAllocatorDefault, (const void **) &keys, (const void **) &values, 1, NULL, NULL);
IOHIDManagerSetDeviceMatching( ykosxManager, dict );
-
+
CFSetRef devSet = IOHIDManagerCopyDevices( ykosxManager );
-
+
if ( devSet ) {
-
+
CFMutableArrayRef array = CFArrayCreateMutable( kCFAllocatorDefault, 0, NULL );
-
+
CFSetApplyFunction( devSet, _ykosx_CopyToCFArray, array );
CFIndex cnt = CFArrayGetCount( array );
-
+
if (cnt > 0) {
yk = (void *) CFArrayGetValueAtIndex( array, 0 );
}
else
yk_errno = YK_ENOKEY;
-
+
CFRelease( array );
CFRelease( devSet );
}
-
+
CFRelease( dict );
CFRelease( vendorID );
CFRelease( productID );
-
+
if (yk) {
_ykusb_IOReturn = IOHIDDeviceOpen( yk, 0L );
-
+
if ( _ykusb_IOReturn != kIOReturnSuccess ) {
yk_release();
return 0;
yk_errno = 0;
return yk;
}
-
+
return 0;
}
int _ykusb_close_device(void *dev)
{
_ykusb_IOReturn = IOHIDDeviceClose( dev, 0L );
-
+
if ( _ykusb_IOReturn == kIOReturnSuccess )
return 1;
-
+
yk_errno = YK_EUSBERR;
return 0;
}
yk_errno = YK_ENOTYETIMPL;
return 0;
}
-
+
_ykusb_IOReturn = IOHIDDeviceGetReport( dev, kIOHIDReportTypeFeature, report_number, (uint8_t *)buffer, (CFIndex *) &sizecf );
-
+
if ( _ykusb_IOReturn != kIOReturnSuccess )
{
yk_errno = YK_EUSBERR;
yk_errno = YK_ENOTYETIMPL;
return 0;
}
-
+
_ykusb_IOReturn = IOHIDDeviceSetReport( dev, kIOHIDReportTypeFeature, report_number, (unsigned char *)buffer, size);
-
+
if ( _ykusb_IOReturn != kIOReturnSuccess )
{
yk_errno = YK_EUSBERR;
return 0;
}
-
+
return 1;
}