Reenumerate device on osx

Hey all
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)

Apple Documentation

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.
Mostly from:

So here is what i endet with.

    mach_port_t             masterPort;
CFMutableDictionaryRef  matchingDict;
kern_return_t           kr;
SInt32                  usbVendor =0x046d;
SInt32                  usbProduct = 0x0825;

io_service_t                usbDevice;
IOCFPlugInInterface         **plugInInterface = NULL;
IOUSBDeviceInterface187     **deviceInterface;
HRESULT                     result;
SInt32                      score;

// 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)
    return -1;
//Set up matching dictionary for class IOUSBDevice and its subclasses
matchingDict = IOServiceMatching(kIOUSBDeviceClassName);
if (!matchingDict)
    mach_port_deallocate(mach_task_self(), masterPort);
    return -1;
// Only get the Device you are looking for:
//Add the vendor and product IDs to the matching dictionary.
CFDictionarySetValue(matchingDict, CFSTR(kUSBVendorName),
                                    kCFNumberSInt32Type, &usbVendor));
CFDictionarySetValue(matchingDict, CFSTR(kUSBProductName),
                                    kCFNumberSInt32Type, &usbProduct));

io_iterator_t iterator;
/*Get an iterator.*/
kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &iterator);
if (kr != KERN_SUCCESS)
    return -1;// fail

while (usbDevice = IOIteratorNext(iterator))
    io_name_t deviceName;
    IORegistryEntryGetName( usbDevice, deviceName );
    //Create an intermediate plug-in
    kr = IOCreatePlugInInterfaceForService(usbDevice,
                                           kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID,
                                           &plugInInterface, &score);
    //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);