小编roc*_*ing的帖子

Mac IOKit USB信号检测

 matchingDict = IOServiceMatching(kIOUSBDeviceClassName); 

 numberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vendorId);  
 CFDictionarySetValue(matchingDict, CFSTR(kUSBVendorID), numberRef);  
 CFRelease(numberRef);  

 numberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &deviceProductId);  
 CFDictionarySetValue(matchingDict, CFSTR(kUSBProductID), numberRef);  
 CFRelease(numberRef);  
 numberRef = NULL;  

 kr = IOServiceAddMatchingNotification(gNotifyPort,   
                                       kIOFirstMatchNotification,   
                                       matchingDict,   
                                       DeviceAdded,   
                                       NULL,  
                                       &gAddedIter);
Run Code Online (Sandbox Code Playgroud)

为了在将USB设备添加到Mac PC时处理通知是可以的,但是当用户按下USB设备上的按钮时,我能获得信号吗?

谢谢大家!

macos usb iokit core-foundation

1
推荐指数
1
解决办法
4551
查看次数

标签 统计

core-foundation ×1

iokit ×1

macos ×1

usb ×1