I would like to turn my computer into an Android accessory using my application. So instead of a specialized hardware this will be just PC that will switch the phone into accessory mode, thus launching some Java app on the phone associated with the host hardware and create a communication channel.
I've found a sample code (plus some Java Android app) to do this on Linux using libusb. It works by "opening" the phone using the standard VID and PID. Then it sends a command to turn on the accessory mode, along with the metadata like model, version etc.
If the phone supports accessory mode it'll then disconnect and reenumerate with a different PID. The sample code then checks if it did and opens the new device.
However, I'm trying to get this running on Windows. I've found a few USB libraries, like LibUsbDotNet, but they all seem to require the device using a WinUSB/libusb driver. I've used a tool in LibUsbDotNet to generate a libusb driver for my phone, installing it over the old generic removable drive one. But this means I now can't access the phone as a removable drive when I want to, so this is not a solution.
Is there a way (preferably a library) that can open any connected USB device based on VID and PID, and then send a few raw commands to it?
After that the device will reenumerate with a different PID, which I can use to create my own WinUSB driver, so that is not an issue. I just need to inject some commands through/around the default driver to turn the accessory mode on.
(I would prefer .NET solution, but anything Windows is fine and I can write my own interop wrapper)