这篇教程C++ CFSetGetCount函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CFSetGetCount函数的典型用法代码示例。如果您正苦于以下问题:C++ CFSetGetCount函数的具体用法?C++ CFSetGetCount怎么用?C++ CFSetGetCount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CFSetGetCount函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CFSetCreateMutableCopyCFMutableSetRefCFSetCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity, CFSetRef set){ if (CF_IS_OBJC (_kCFSetTypeID, set)) { CFMutableSetRef result; const CFIndex count = CFSetGetCount (set); void **values = (void **) CFAllocatorAllocate (allocator, sizeof (void *) * count, 0); CFIndex i; CFSetGetValues (set, (const void **) values); result = CFSetCreateMutable (allocator, count, &kCFTypeSetCallBacks); for (i = 0; i < count; i++) GSHashTableAddValue ((GSHashTableRef) result, values[i], values[i]); CFAllocatorDeallocate (allocator, (void *) values); return result; } return (CFMutableSetRef) GSHashTableCreateMutableCopy (allocator, (GSHashTableRef) set, capacity);}
开发者ID:NSKevin,项目名称:gnustep-corebase,代码行数:26,
示例2: imp_rb_set_countstatic CFIndeximp_rb_set_count(void *rcv, SEL sel){ CFIndex count; PREPARE_RCV(rcv); count = CFSetGetCount((CFSetRef)rcv); RESTORE_RCV(rcv); return count;}
开发者ID:alloy,项目名称:mr-experimental,代码行数:9,
示例3: CFSetCreateCopyCFSetRef CFSetCreateCopy(CFAllocatorRef allocator, CFSetRef set) { CFSetRef result; const CFSetCallBacks *cb; CFIndex numValues = CFSetGetCount(set); const void **list, *buffer[256]; list = (numValues <= 256) ? buffer : CFAllocatorAllocate(allocator, numValues * sizeof(void *), 0); if (list != buffer && __CFOASafe) __CFSetLastAllocationEventName(list, "CFSet (temp)"); CFSetGetValues(set, list); cb = CF_IS_OBJC(__kCFSetTypeID, set) ? &kCFTypeSetCallBacks : __CFSetGetCallBacks(set); result = CFSetCreate(allocator, list, numValues, cb); if (list != buffer) CFAllocatorDeallocate(allocator, list); return result;}
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:13,
示例4: SOSAccountVerifyAndAcceptHSAApplicantsbool SOSAccountVerifyAndAcceptHSAApplicants(SOSAccountRef account, SOSCircleRef newCircle, CFErrorRef *error) { SOSFullPeerInfoRef fpi = account->my_identity; __block bool circleChanged = false; CFMutableSetRef approvals = SOSAccountCopyPreApprovedHSA2Info(account); if(approvals && CFSetGetCount(approvals) > 0) { SOSCircleForEachApplicant(newCircle, ^(SOSPeerInfoRef peer) { CFStringRef peerID = SOSPeerInfoGetPeerID(peer); if(CFSetContainsValue(approvals, peerID)) { SOSPeerInfoRef copypi = SOSPeerInfoCreateCopy(NULL, peer, NULL); circleChanged = SOSCircleAcceptRequest(newCircle, SOSAccountGetPrivateCredential(account, NULL), fpi, copypi, error); CFSetRemoveValue(approvals, peerID); } });
开发者ID:darlinghq,项目名称:darling-security,代码行数:13,
示例5: IOHIDManagerCopyDevicesbool HIDDeviceManager::Enumerate(HIDEnumerateVisitor* enumVisitor){ if (!initializeManager()) { return false; } CFSetRef deviceSet = IOHIDManagerCopyDevices(HIDManager); CFIndex deviceCount = CFSetGetCount(deviceSet); // Allocate a block of memory and read the set into it. IOHIDDeviceRef* devices = (IOHIDDeviceRef*) OVR_ALLOC(sizeof(IOHIDDeviceRef) * deviceCount); CFSetGetValues(deviceSet, (const void **) devices); // Iterate over devices. for (CFIndex deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++) { IOHIDDeviceRef hidDev = devices[deviceIndex]; if (!hidDev) { continue; } HIDDeviceDesc devDesc; if (getPath(hidDev, &(devDesc.Path)) && initVendorProductVersion(hidDev, &devDesc) && enumVisitor->MatchVendorProduct(devDesc.VendorId, devDesc.ProductId) && initUsage(hidDev, &devDesc)) { initStrings(hidDev, &devDesc); initSerialNumber(hidDev, &devDesc); // Construct minimal device that the visitor callback can get feature reports from. OSX::HIDDevice device(this, hidDev); enumVisitor->Visit(device, devDesc); } } OVR_FREE(devices); CFRelease(deviceSet); return true;}
开发者ID:ReallyRad,项目名称:ofxOculusRift,代码行数:48,
示例6: FindDeviceIOHIDDeviceRef FindDevice(IOHIDManagerRef manager, long vendorId, long productId){ IOHIDDeviceRef theDevice = NULL; // setup dictionary CFMutableDictionaryRef dictionary = CFDictionaryCreateMutable( kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFNumberRef cfVendorId = CFNumberCreate(kCFAllocatorDefault, kCFNumberLongType, &vendorId); CFStringRef cfVendorSt = CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDVendorIDKey, kCFStringEncodingUTF8); CFDictionaryAddValue(dictionary, cfVendorSt, cfVendorId); CFRelease(cfVendorId); CFRelease(cfVendorSt); CFNumberRef cfProductId = CFNumberCreate(kCFAllocatorDefault, kCFNumberLongType, &productId); CFStringRef cfProductSt = CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDProductIDKey, kCFStringEncodingUTF8); CFDictionaryAddValue(dictionary, cfProductSt, cfProductId); CFRelease(cfProductId); CFRelease(cfProductSt); // look for devices matching criteria IOHIDManagerSetDeviceMatching(manager, dictionary); CFSetRef foundDevices = IOHIDManagerCopyDevices(manager); CFIndex foundCount = foundDevices ? CFSetGetCount(foundDevices) : 0; // what the API does not say is that it could be null if(foundCount > 0) { CFTypeRef* array = new CFTypeRef[foundCount]; // array of IOHIDDeviceRef CFSetGetValues(foundDevices, array); // get first matching device theDevice = (IOHIDDeviceRef)array[0]; CFRetain(theDevice); delete [] array; } if(foundDevices) { CFRelease(foundDevices); } CFRelease(dictionary); return theDevice;}
开发者ID:AndresPozo,项目名称:phd2,代码行数:47,
示例7: CFSetCreateMutableCopyCFMutableSetRef CFSetCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFSetRef set) { CFMutableSetRef result; const CFSetCallBacks *cb; CFIndex idx, numValues = CFSetGetCount(set); const void **list, *buffer[256]; CFAssert3(0 == capacity || numValues <= capacity, __kCFLogAssertion, "%s(): for fixed-mutable sets, capacity (%d) must be greater than or equal to initial number of values (%d)", __PRETTY_FUNCTION__, capacity, numValues); list = (numValues <= 256) ? buffer : CFAllocatorAllocate(allocator, numValues * sizeof(void *), 0); if (list != buffer && __CFOASafe) __CFSetLastAllocationEventName(list, "CFSet (temp)"); CFSetGetValues(set, list); cb = CF_IS_OBJC(__kCFSetTypeID, set) ? &kCFTypeSetCallBacks : __CFSetGetCallBacks(set); result = CFSetCreateMutable(allocator, capacity, cb); if (0 == capacity) _CFSetSetCapacity(result, numValues); for (idx = 0; idx < numValues; idx++) { CFSetAddValue(result, list[idx]); } if (list != buffer) CFAllocatorDeallocate(allocator, list); return result;}
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:18,
示例8: CFSetApplyFunctionvoidCFSetApplyFunction (CFSetRef set, CFSetApplierFunction applier, void *context){ // TODO: could be made more efficient by providing a specialized // implementation for the CF_IS_OBJC case const CFIndex count = CFSetGetCount (set); void **values = (void **) CFAllocatorAllocate (NULL, sizeof (void *) * count, 0); CFIndex i; CFSetGetValues (set, (const void **) values); for (i = 0; i < count; i++) { applier (values[i], context); } CFAllocatorDeallocate (NULL, (void *) values);}
开发者ID:NSKevin,项目名称:gnustep-corebase,代码行数:20,
示例9: getDevRefstatic IOHIDDeviceRef* getDevRef(OSX_HID_REF *hid, CFIndex *deviceCount){ CFSetRef deviceCFSetRef; IOHIDDeviceRef *dev_refs=NULL; *deviceCount = 0; yEnterCriticalSection(&hid->hidMCS); deviceCFSetRef = IOHIDManagerCopyDevices(hid->manager); yLeaveCriticalSection(&hid->hidMCS); if (deviceCFSetRef!= NULL) { // how many devices in the set? *deviceCount = CFSetGetCount( deviceCFSetRef ); dev_refs = yMalloc( sizeof(IOHIDDeviceRef) * (u32)*deviceCount ); // now extract the device ref's from the set CFSetGetValues( deviceCFSetRef, (const void **) dev_refs ); } return dev_refs;}
开发者ID:LudovicRousseau,项目名称:yoctolib_cpp,代码行数:20,
示例10: setAllKeyboardsvoid setAllKeyboards(LedState changes[]){ IOHIDManagerRef manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (!manager) { fprintf(stderr, "Failed to create IOHID manager./n"); return; } CFDictionaryRef keyboard = getKeyboardDictionary(); if (!keyboard) { fprintf(stderr, "Failed to get dictionary usage page for kHIDUsage_GD_Keyboard./n"); return; } IOHIDManagerOpen(manager, kIOHIDOptionsTypeNone); IOHIDManagerSetDeviceMatching(manager, keyboard); CFSetRef devices = IOHIDManagerCopyDevices(manager); if (devices) { CFIndex deviceCount = CFSetGetCount(devices); if (deviceCount == 0) { fprintf(stderr, "Could not find any keyboard devices./n"); } else { // Loop through all keyboards attempting to get or display led state IOHIDDeviceRef *deviceRefs = malloc(sizeof(IOHIDDeviceRef) * deviceCount); if (deviceRefs) { CFSetGetValues(devices, (const void **) deviceRefs); for (CFIndex deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++) if (isKeyboardDevice(deviceRefs[deviceIndex])) setKeyboard(deviceRefs[deviceIndex], keyboard, changes); free(deviceRefs); } } CFRelease(devices); } CFRelease(keyboard);}
开发者ID:pawlowskialex,项目名称:CAPS,代码行数:41,
示例11: CFSetCreateCopyCFSetRefCFSetCreateCopy (CFAllocatorRef allocator, CFSetRef set){ if (CF_IS_OBJC (_kCFSetTypeID, set)) { CFSetRef result; const CFIndex count = CFSetGetCount (set); void **values = (void **) CFAllocatorAllocate (allocator, sizeof (void *) * count, 0); CFSetGetValues (set, (const void **) values); result = CFSetCreate (allocator, (const void **) values, count, &kCFTypeSetCallBacks); CFAllocatorDeallocate (allocator, (void *) values); return result; } return (CFSetRef) GSHashTableCreateCopy (allocator, (GSHashTableRef) set);}
开发者ID:NSKevin,项目名称:gnustep-corebase,代码行数:21,
示例12: adjustExternalDiskAssertionstatic void adjustExternalDiskAssertion(){ CFIndex deviceCount = CFSetGetCount(gExternalMediaSet); if (0 == deviceCount) { /* * Release assertion */ InternalReleaseAssertion(&gDiskAssertionID); return; } if (0 < deviceCount) { /* * Create new assertion */ CFMutableDictionaryRef assertionDescription = NULL; assertionDescription = _IOPMAssertionDescriptionCreate( _kIOPMAssertionTypeExternalMedia, CFSTR(_kExternalMediaAssertionName), NULL, CFSTR("An external media device is attached."), NULL, 0, NULL); InternalCreateAssertion(assertionDescription, &gDiskAssertionID); CFRelease(assertionDescription); return; } return;}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:40,
示例13: stopvoid IOKitHIDEventPublisher::restart() { if (run_loop_ == nullptr) { // There is no run loop to restart. return; } // Remove any existing stream. stop(); if (manager_ == nullptr) { manager_ = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); } // Match anything. IOHIDManagerSetDeviceMatching(manager_, nullptr); auto status = IOHIDManagerOpen(manager_, kIOHIDOptionsTypeNone); if (status != kIOReturnSuccess) { LOG(WARNING) << RLOG(617) << "Cannot open IOKit HID Manager"; return; } // Enumerate initial set of devices matched before time=0. CFSetRef devices = IOHIDManagerCopyDevices(manager_); if (devices == nullptr) { return; } initial_device_count_ = CFSetGetCount(devices); CFRelease(devices); // Register callbacks. IOHIDManagerRegisterDeviceMatchingCallback( manager_, IOKitHIDEventPublisher::MatchingCallback, nullptr); IOHIDManagerRegisterDeviceRemovalCallback( manager_, IOKitHIDEventPublisher::RemovalCallback, nullptr); IOHIDManagerScheduleWithRunLoop(manager_, run_loop_, kCFRunLoopDefaultMode); manager_started_ = true;}
开发者ID:eastebry,项目名称:osquery,代码行数:40,
示例14: mainint main(void){ IOHIDManagerRef mgr; int i; mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); IOHIDManagerSetDeviceMatching(mgr, NULL); IOHIDManagerOpen(mgr, kIOHIDOptionsTypeNone); CFSetRef device_set = IOHIDManagerCopyDevices(mgr); if (device_set==NULL) { return 0; } CFIndex num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); for (i = 0; i < num_devices; i++) { IOHIDDeviceRef dev = device_array[i]; printf("Device: %p/n", dev); printf(" %04hx %04hx/n", get_vendor_id(dev), get_product_id(dev)); wchar_t serial[256], buf[256]; char cbuf[256]; get_serial_number(dev, serial, 256); printf(" Serial: %ls/n", serial); printf(" Loc: %ld/n", get_location_id(dev)); get_transport(dev, buf, 256); printf(" Trans: %ls/n", buf); make_path(dev, cbuf, 256); printf(" Path: %s/n", cbuf); } return 0;}
开发者ID:rsravanreddy,项目名称:hidapi,代码行数:39,
示例15: CFLocaleCopyAvailableLocaleIdentifiersCFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void) { int32_t locale, localeCount = uloc_countAvailable(); CFMutableSetRef working = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeSetCallBacks); for (locale = 0; locale < localeCount; ++locale) { const char *localeID = uloc_getAvailable(locale); CFStringRef string1 = CFStringCreateWithCString(kCFAllocatorSystemDefault, localeID, kCFStringEncodingASCII); CFStringRef string2 = CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorSystemDefault, string1); CFSetAddValue(working, string1); // do not include canonicalized version as IntlFormats cannot cope with that in its popup CFRelease(string1); CFRelease(string2); } CFIndex cnt = CFSetGetCount(working);#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || (DEPLOYMENT_TARGET_WINDOWS && __GNUC__) STACK_BUFFER_DECL(const void *, buffer, cnt);#else const void* buffer[BUFFER_SIZE];#endif CFSetGetValues(working, buffer); CFArrayRef result = CFArrayCreate(kCFAllocatorSystemDefault, buffer, cnt, &kCFTypeArrayCallBacks); CFRelease(working); return result;}
开发者ID:AbhinavBansal,项目名称:opencflite,代码行数:23,
示例16: CFSetGetCountbool JoystickImpl::isConnected(unsigned int index){ bool state = false; // Is the index-th joystick connected? // First, let's check if the device was previously detected: if (m_locationIDs[index] != 0) { state = true; } else { // Otherwise, let's check if it is now connected // i.e., m_locationIDs[index] == 0 // if there is more connected joystick to the HID manager than // opened joystick devices then we find the new one. unsigned int openedCount = 0; for (unsigned int i(0); i < sf::Joystick::Count; ++i) { if (m_locationIDs[i] != 0) openedCount++; } unsigned int connectedCount = HIDJoystickManager::getInstance().getJoystickCount(); if (connectedCount > openedCount) { // Get all devices CFSetRef devices = HIDJoystickManager::getInstance().copyJoysticks(); if (devices != NULL) { CFIndex size = CFSetGetCount(devices); if (size > 0) { CFTypeRef array[size]; // array of IOHIDDeviceRef CFSetGetValues(devices, array); // If there exists a device d s.t. there is no j s.t. // m_locationIDs[j] == d's location then we have a new device. for (CFIndex didx(0); didx < size; ++didx) { IOHIDDeviceRef d = (IOHIDDeviceRef)array[didx]; Location dloc = HIDInputManager::getLocationID(d); bool foundJ = false; for (unsigned int j(0); j < Joystick::Count; ++j) { if (m_locationIDs[j] == dloc) { foundJ = true; break; // no need to loop again } } if (!foundJ) { // This is a new device // We set it up for Open(..) m_locationIDs[index] = dloc; state = true; break; // We stop looking for a new device } } } CFRelease(devices); } } } return state;}
开发者ID:AnatoliiPotapov,项目名称:SFML,代码行数:75,
示例17: setlocalestruct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short product_id){ struct hid_device_info *root = NULL; // return object struct hid_device_info *cur_dev = NULL; CFIndex num_devices; int i; setlocale(LC_ALL,""); /* Set up the HID Manager if it hasn't been done */ hid_init(); /* Get a list of the Devices */ CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr); /* Convert the list into a C array so we can iterate easily. */ num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); /* Iterate over each device, making an entry for it. */ for (i = 0; i < num_devices; i++) { unsigned short dev_vid; unsigned short dev_pid; #define BUF_LEN 256 wchar_t buf[BUF_LEN]; char cbuf[BUF_LEN]; IOHIDDeviceRef dev = device_array[i]; if (!dev) { continue; } dev_vid = get_vendor_id(dev); dev_pid = get_product_id(dev); /* Check the VID/PID against the arguments */ if ((vendor_id == 0x0 && product_id == 0x0) || (vendor_id == dev_vid && product_id == dev_pid)) { struct hid_device_info *tmp; size_t len; /* VID/PID match. Create the record. */ tmp = malloc(sizeof(struct hid_device_info)); if (cur_dev) { cur_dev->next = tmp; } else { root = tmp; } cur_dev = tmp; // Get the Usage Page and Usage for this device. cur_dev->usage_page = get_int_property(dev, CFSTR(kIOHIDPrimaryUsagePageKey)); cur_dev->usage = get_int_property(dev, CFSTR(kIOHIDPrimaryUsageKey)); /* Fill out the record */ cur_dev->next = NULL; len = make_path(dev, cbuf, sizeof(cbuf)); cur_dev->path = strdup(cbuf); /* Serial Number */ get_serial_number(dev, buf, BUF_LEN); cur_dev->serial_number = dup_wcs(buf); /* Manufacturer and Product strings */ get_manufacturer_string(dev, buf, BUF_LEN); cur_dev->manufacturer_string = dup_wcs(buf); get_product_string(dev, buf, BUF_LEN); cur_dev->product_string = dup_wcs(buf); /* VID/PID */ cur_dev->vendor_id = dev_vid; cur_dev->product_id = dev_pid; /* Release Number */ cur_dev->release_number = get_int_property(dev, CFSTR(kIOHIDVersionNumberKey)); /* Interface Number (Unsupported on Mac)*/ cur_dev->interface_number = -1; } } free(device_array); CFRelease(device_set); return root;}
开发者ID:AaronPerl,项目名称:HackRU-DigitalTheremin,代码行数:88,
示例18: mainint main( int argc, const char * argv[] ){ Boolean initialized = FALSE; if (( argc != 4 ) && ( argc != 5 )) { printf ( "usage: Dream Cheeky Notifier R G B [A]/n/tRGB values should be 0-31. A is an optional parameter on whether to do the LED activation sequence. Anything larger than 0 is YES, default is 0 (activate)./n/n"); exit ( -1 ); } char r = (int)strtol ( argv[1], NULL, 10 ); char g = (int)strtol ( argv[2], NULL, 10 ); char b = (int)strtol ( argv[3], NULL, 10 ); if ( argc == 5 ) { initialized = TRUE; } if ((r < 0) || (r > 31) || (g < 0) || (g > 31) || (b < 0) || (b > 31)) { printf("RGB values must be within 0-31."); exit -1; } // create a IO HID Manager reference IOHIDManagerRef tIOHIDManagerRef = IOHIDManagerCreate( kCFAllocatorDefault, kIOHIDOptionsTypeNone ); // Create a device matching dictionary CFDictionaryRef matchingCFDictRef = hu_CreateMatchingDictionaryUsagePageUsage( TRUE, kHIDPage_GenericDesktop, 0x10 ); // set the HID device matching dictionary IOHIDManagerSetDeviceMatching( tIOHIDManagerRef, matchingCFDictRef ); if ( matchingCFDictRef ) { CFRelease( matchingCFDictRef ); } // Now open the IO HID Manager reference IOReturn tIOReturn = IOHIDManagerOpen( tIOHIDManagerRef, kIOHIDOptionsTypeNone ); // and copy out its devices CFSetRef deviceCFSetRef = IOHIDManagerCopyDevices( tIOHIDManagerRef ); // how many devices in the set? CFIndex deviceIndex, deviceCount = CFSetGetCount( deviceCFSetRef ); // allocate a block of memory to extact the device ref's from the set into IOHIDDeviceRef * tIOHIDDeviceRefs = malloc( sizeof( IOHIDDeviceRef ) * deviceCount ); // now extract the device ref's from the set CFSetGetValues( deviceCFSetRef, (const void **) tIOHIDDeviceRefs ); // before we get into the device loop we'll setup our element matching dictionary (Note: we don't do element matching anymore) matchingCFDictRef = hu_CreateMatchingDictionaryUsagePageUsage( FALSE, 0, 0 ); for ( deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++ ) { // if this isn't the notifier device... TODO: let's detect via vendor/product ids instead long vendor_id = 0; IOHIDDevice_GetLongProperty(tIOHIDDeviceRefs[deviceIndex], CFSTR(kIOHIDVendorIDKey), &vendor_id); long product_id = 0; IOHIDDevice_GetLongProperty(tIOHIDDeviceRefs[deviceIndex], CFSTR(kIOHIDProductIDKey), &product_id); if ((vendor_id != 0x1D34 ) || (product_id != 0x0004 )) { printf(" skipping device %p./n", tIOHIDDeviceRefs[deviceIndex] ); continue; // ...skip it } printf( " device = %p./n", tIOHIDDeviceRefs[deviceIndex] ); unsigned char report[8]; if (initialized == FALSE) { report[0] = 0x1F; // turn on LEDs report[1] = 0x02; report[2] = 0x00; report[3] = 0x5F; report[4] = 0x00; report[5] = 0x00; report[6] = 0x1A; report[7] = 0x03; // Note: We don't use the returned value here, so the compiler might throw a warning. IOReturn tIOReturn = IOHIDDeviceSetReport( tIOHIDDeviceRefs[deviceIndex], // IOHIDDeviceRef for the HID device kIOHIDReportTypeInput, // IOHIDReportType for the report (input, output, feature) 0, // CFIndex for the report ID report, // address of report buffer 8); // length of the report initialized = TRUE; } report[0] = r; // set brightness on LEDs to r, g, & b report[1] = g; report[2] = b; report[3] = 0x00; report[4] = 0x00; report[5] = 0x00; report[6] = 0x1A; report[7] = 0x05; tIOReturn = IOHIDDeviceSetReport( tIOHIDDeviceRefs[deviceIndex], // IOHIDDeviceRef for the HID device kIOHIDReportTypeInput, // IOHIDReportType for the report (input, output, feature) 0, // CFIndex for the report ID report, // address of report buffer//.........这里部分代码省略.........
开发者ID:edelbrp,项目名称:dream-cheeky-notifier-macosx,代码行数:101,
示例19: rb_set_empty_qstatic VALUErb_set_empty_q(VALUE set, SEL sel){ return CFSetGetCount((CFSetRef)set) == 0 ? Qtrue : Qnil;}
开发者ID:alloy,项目名称:mr-experimental,代码行数:5,
示例20: process_pending_eventsstruct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short product_id){ struct hid_device_info *root = NULL; /* return object */ struct hid_device_info *cur_dev = NULL; CFIndex num_devices; int i; /* Set up the HID Manager if it hasn't been done */ if (hid_init() < 0) return NULL; /* give the IOHIDManager a chance to update itself */ process_pending_events(); /* Get a list of the Devices */ IOHIDManagerSetDeviceMatching(hid_mgr, NULL); CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr); /* Convert the list into a C array so we can iterate easily. */ num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); /* Iterate over each device, making an entry for it. */ for (i = 0; i < num_devices; i++) { unsigned short dev_vid; unsigned short dev_pid; #define BUF_LEN 256 wchar_t buf[BUF_LEN]; IOHIDDeviceRef dev = device_array[i]; if (!dev) { continue; } dev_vid = get_vendor_id(dev); dev_pid = get_product_id(dev); /* Check the VID/PID against the arguments */ if ((vendor_id == 0x0 || vendor_id == dev_vid) && (product_id == 0x0 || product_id == dev_pid)) { struct hid_device_info *tmp; io_object_t iokit_dev; kern_return_t res; io_string_t path; /* VID/PID match. Create the record. */ tmp = malloc(sizeof(struct hid_device_info)); if (cur_dev) { cur_dev->next = tmp; } else { root = tmp; } cur_dev = tmp; /* Get the Usage Page and Usage for this device. */ cur_dev->usage_page = get_int_property(dev, CFSTR(kIOHIDPrimaryUsagePageKey)); cur_dev->usage = get_int_property(dev, CFSTR(kIOHIDPrimaryUsageKey)); /* Fill out the record */ cur_dev->next = NULL; /* Fill in the path (IOService plane) */ iokit_dev = hidapi_IOHIDDeviceGetService(dev); res = IORegistryEntryGetPath(iokit_dev, kIOServicePlane, path); if (res == KERN_SUCCESS) cur_dev->path = strdup(path); else cur_dev->path = strdup(""); /* Serial Number */ get_serial_number(dev, buf, BUF_LEN); cur_dev->serial_number = dup_wcs(buf); /* Manufacturer and Product strings */ get_manufacturer_string(dev, buf, BUF_LEN); cur_dev->manufacturer_string = dup_wcs(buf); get_product_string(dev, buf, BUF_LEN); cur_dev->product_string = dup_wcs(buf); /* VID/PID */ cur_dev->vendor_id = dev_vid; cur_dev->product_id = dev_pid; /* Release Number */ cur_dev->release_number = get_int_property(dev, CFSTR(kIOHIDVersionNumberKey)); /* Interface Number (Unsupported on Mac)*/ cur_dev->interface_number = -1; } } free(device_array); CFRelease(device_set); return root;}
开发者ID:billsq,项目名称:hidapi,代码行数:98,
示例21: rb_set_sizestatic VALUErb_set_size(VALUE set, SEL sel){ return INT2FIX(CFSetGetCount((CFSetRef)set));}
开发者ID:alloy,项目名称:mr-experimental,代码行数:5,
示例22: IOHIDManagerCopyDevicesbool HIDDevice::openDevice(){ // Have to iterate through devices again to generate paths. CFSetRef deviceSet = IOHIDManagerCopyDevices(HIDManager->HIDManager); CFIndex deviceCount = CFSetGetCount(deviceSet); // Allocate a block of memory and read the set into it. IOHIDDeviceRef* devices = (IOHIDDeviceRef*) OVR_ALLOC(sizeof(IOHIDDeviceRef) * deviceCount); CFSetGetValues(deviceSet, (const void **) devices); // Iterate over devices. IOHIDDeviceRef device = NULL; for (CFIndex deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++) { IOHIDDeviceRef tmpDevice = devices[deviceIndex]; if (!tmpDevice) { continue; } String path; if (!HIDManager->getPath(tmpDevice, &path)) { continue; } if (path == DevDesc.Path) { device = tmpDevice; break; } } OVR_FREE(devices); if (!device) { CFRelease(deviceSet); return false; } // Attempt to open device. if (IOHIDDeviceOpen(device, kIOHIDOptionsTypeSeizeDevice) != kIOReturnSuccess) { CFRelease(deviceSet); return false; } // Retain the device before we release the set. CFRetain(device); CFRelease(deviceSet); Device = device; if (!initInfo()) { IOHIDDeviceClose(Device, kIOHIDOptionsTypeSeizeDevice); CFRelease(Device); Device = NULL; return false; } // Setup the Run Loop and callbacks. IOHIDDeviceScheduleWithRunLoop(Device, HIDManager->getRunLoop(), kCFRunLoopDefaultMode); IOHIDDeviceRegisterInputReportCallback(Device, ReadBuffer, ReadBufferSize, staticHIDReportCallback, this); IOHIDDeviceRegisterRemovalCallback(Device, staticDeviceRemovedCallback, this); return true;}
开发者ID:123woodman,项目名称:minko,代码行数:88,
示例23: SCNetworkSetCopyAvailableInterfacesCFArrayRef /* of SCNetworkInterfaceRef's */SCNetworkSetCopyAvailableInterfaces(SCNetworkSetRef set){ CFMutableArrayRef available; CFMutableSetRef excluded = NULL; int i; CFArrayRef interfaces; CFIndex n_interfaces; CFIndex n_exclusions = 0; SCPreferencesRef prefs; SCNetworkSetPrivateRef setPrivate; setPrivate = (SCNetworkSetPrivateRef)set; prefs = setPrivate->prefs; interfaces = _SCNetworkInterfaceCopyAllWithPreferences(prefs); n_interfaces = CFArrayGetCount(interfaces); if (n_interfaces == 0) { return interfaces; } if (prefs != NULL) { CFArrayRef bridges = NULL; excluded = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);#if !TARGET_OS_IPHONE CFArrayRef bonds = NULL; bonds = SCBondInterfaceCopyAll(prefs); if (bonds != NULL) { __SCBondInterfaceListCollectMembers(bonds, excluded); CFRelease(bonds); }#endif /* !TARGET_OS_IPHONE */ bridges = SCBridgeInterfaceCopyAll(prefs); if (bridges != NULL) { __SCBridgeInterfaceListCollectMembers(bridges, excluded); CFRelease(bridges); } n_exclusions = CFSetGetCount(excluded); } if (n_exclusions == 0) { if (excluded != NULL) { CFRelease(excluded); } return interfaces; } available = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); for (i = 0; i < n_interfaces; i++) { SCNetworkInterfaceRef interface; interface = CFArrayGetValueAtIndex(interfaces, i); if (CFSetContainsValue(excluded, interface)) { // if excluded continue; } CFArrayAppendValue(available, interface); } CFRelease(interfaces); CFRelease(excluded); return available;}
开发者ID:carriercomm,项目名称:osx-2,代码行数:72,
示例24: hid_open_pathhid_device * HID_API_EXPORT hid_open_path(const char *path){ int i; hid_device *dev = NULL; CFIndex num_devices; dev = new_hid_device(); /* Set up the HID Manager if it hasn't been done */ hid_init(); CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr); num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); for (i = 0; i < num_devices; i++) { char cbuf[BUF_LEN]; size_t len; IOHIDDeviceRef os_dev = device_array[i]; len = make_path(os_dev, cbuf, sizeof(cbuf)); if (!strcmp(cbuf, path)) { // Matched Paths. Open this Device. IOReturn ret = IOHIDDeviceOpen(os_dev, kIOHIDOptionsTypeNone); if (ret == kIOReturnSuccess) { char str[32]; free(device_array); CFRelease(device_set); dev->device_handle = os_dev; /* Create the buffers for receiving data */ dev->max_input_report_len = (CFIndex) get_max_report_length(os_dev); dev->input_report_buf = calloc(dev->max_input_report_len, sizeof(uint8_t)); /* Create the Run Loop Mode for this device. printing the reference seems to work. */ sprintf(str, "HIDAPI_%p", os_dev); dev->run_loop_mode = CFStringCreateWithCString(NULL, str, kCFStringEncodingASCII); /* Attach the device to a Run Loop */ IOHIDDeviceRegisterInputReportCallback( os_dev, dev->input_report_buf, dev->max_input_report_len, &hid_report_callback, dev); IOHIDManagerRegisterDeviceRemovalCallback(hid_mgr, hid_device_removal_callback, NULL); /* Start the read thread */ pthread_create(&dev->thread, NULL, read_thread, dev); /* Wait here for the read thread to be initialized. */ pthread_barrier_wait(&dev->barrier); return dev; } else { goto return_error; } } }return_error: free(device_array); CFRelease(device_set); free_hid_device(dev); return NULL;}
开发者ID:AaronPerl,项目名称:HackRU-DigitalTheremin,代码行数:68,
示例25: KJSValueToJSObjectbool UserObjectImp::toBoolean(ExecState *exec) const{ bool result = false; JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec); CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0; if (cfValue) { CFTypeID cfType = CFGetTypeID(cfValue); // toPrimitive if (cfValue == GetCFNull()) { // } else if (cfType == CFBooleanGetTypeID()) { if (cfValue == kCFBooleanTrue) { result = true; } } else if (cfType == CFStringGetTypeID()) { if (CFStringGetLength((CFStringRef)cfValue)) { result = true; } } else if (cfType == CFNumberGetTypeID()) { if (cfValue != kCFNumberNaN) { double d; if (CFNumberGetValue((CFNumberRef)cfValue, kCFNumberDoubleType, &d)) { if (d != 0) { result = true; } } } } else if (cfType == CFArrayGetTypeID()) { if (CFArrayGetCount((CFArrayRef)cfValue)) { result = true; } } else if (cfType == CFDictionaryGetTypeID()) { if (CFDictionaryGetCount((CFDictionaryRef)cfValue)) { result = true; } } else if (cfType == CFSetGetTypeID()) { if (CFSetGetCount((CFSetRef)cfValue)) { result = true; } } else if (cfType == CFURLGetTypeID()) { CFURLRef absURL = CFURLCopyAbsoluteURL((CFURLRef)cfValue); if (absURL) { CFStringRef cfStr = CFURLGetString(absURL); if (cfStr && CFStringGetLength(cfStr)) { result = true; } ReleaseCFType(absURL); } } } if (jsObjPtr) jsObjPtr->Release(); ReleaseCFType(cfValue); return result;}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:79,
示例26: GPDuplexClient_RemoveObserverWithNumberAndObserverSetstatic void GPDuplexClient_RemoveObserverWithNumberAndObserverSet(GPDuplexClientRef client, void* observer, GPDuplexClientCallback callback, CFNumberRef typeNumber, CFMutableSetRef observerSet) { CFDataRef observerData = GPDuplexClientCreateObserver(observer, callback); CFSetRemoveValue(observerSet, observerData); if (CFSetGetCount(observerSet) == 0) CFDictionaryRemoveValue(client->observers, typeNumber);}
开发者ID:525828027,项目名称:networkpx,代码行数:6,
注:本文中的CFSetGetCount函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CFSetGetValues函数代码示例 C++ CFRunLoopStop函数代码示例 |