I am working with a logitec c920 webcam. If the camera is plugged in on startup, the videograbber reads it with a 2K resolution instead of HD. I have to physically unplug and replug the camera to get the right resolution. but can’t do that in reality as its for an installation that should run alone.
I found the IOReturn (*USBDeviceReEnumerate)(void *self, UInt32 options)
function in the OSX documentation. But honestly, I have no idea how to use that. Does someone has any codeexamples on how to do that?
Thanks for your help!
maybe somewhere in this addon you can find a way to make a new function to do this.
Thanks for the suggestion. I finally came up with a programmatically plug/unplug of the device by vendor and product id.
Not sure if i did that right with memory and stuff as i have only a very basic understanding of objective-c and googled the code from various examples together.
So here is what i endet with.
SInt32 usbVendor =0x046d;
SInt32 usbProduct = 0x0825;
IOCFPlugInInterface **plugInInterface = NULL;
// to get vendorid and productid in termina: system_profiler SPUSBDataType
//Create a master port for communication with the I/O Kit
kr = IOMasterPort(MACH_PORT_NULL, &masterPort);
if (kr || !masterPort)
//Set up matching dictionary for class IOUSBDevice and its subclasses
matchingDict = IOServiceMatching(kIOUSBDeviceClassName);
// Only get the Device you are looking for:
//Add the vendor and product IDs to the matching dictionary.
/*Get an iterator.*/
kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &iterator);
if (kr != KERN_SUCCESS)
return -1;// fail
while (usbDevice = IOIteratorNext(iterator))
IORegistryEntryGetName( usbDevice, deviceName );
//Create an intermediate plug-in
kr = IOCreatePlugInInterfaceForService(usbDevice,
//Don’t need the device object after intermediate plug-in is created
kr = IOObjectRelease(usbDevice);
if ((kIOReturnSuccess != kr) || !plugInInterface)
printf("Unable to create a plug-in (%08x)\n", kr);
//Now create the device interface
result = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID187), (LPVOID *)&deviceInterface);
// Now done with the plugin interface.
kr = (*deviceInterface)->USBDeviceOpen(deviceInterface);
if(kr == kIOReturnSuccess)
kr = (*deviceInterface)->USBDeviceReEnumerate(deviceInterface, 0);