Way to differentiate two USB devices with same product/vendor ID in retropie - usb

I am using a usb NES and usb SNES controller for emulators on retropie. I found out both of these controllers were made by the same vendor and have the same iProduct name, IdVendor, and IdProduct values, which makes my raspberry pi see these as the same device. Of course, now I keep overwriting config. Is there a way to do something where I can get this USB device name changed so the system can differentiate?
Both controllers show up in lsusb as "0079x0011 DragonRise inc, Gamepad" and have Product name as "2 USB Gamepad"

Related

hdmi usb dongle macrosilicon 2109 rename device

How can i change the product name|ID of hdmi usb dongle on the HDMI end? (how the device is named as HDMI. Currently (default) is recognized as "HDMI to USB". )
There are many similar devices based on "Macrosilicon 2109".
for example:
https://aliexpress.ru/item/4001058525465.html
(maybe from the usb connection i can change something like EEPROM)

How to query the serial number of a UVC camera?

I have two UVC cameras in a stereoscopic setup, controlled with a C++ MediaFoundation app. I need to uniquely identify them in order to assign left and right to each physical device. This camera model has a unique serial number in the USB descriptor. However I can't seem to find a way to get the serial number while enumerating using MediaFoundation.
The MF enumeration order of these cameras is not reliably in port order; 95% of the time, camera 1 is enumerated before camera 2, while on some machines, we get camera 2 before camera 1. So finding the serial number is very important.
Things I've tried:
MediaFoundation doesn't seem to provide a direct way to get the serial number at all
By querying the MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK attribute, you can get a USB symbolic link. The docs say this can be used to call SetupDiOpenDeviceInterface however this doesn't seem to be usable to get the serial number (or the USB descriptor) either.
WinUSB can be used to open some USB devices in a generic manner, so the USB descriptor might be accessible, but this method fails on these cameras also, after passing the handle from CreateFile.
IOCTL the lowest level method, apparently you can send a IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX to the hub device, with a port index, and it will return the descriptor from which you should be able to get the serial number. No idea how to get the hub device and port index from only the symlink though.
Related, but unresolved: How to get hardware ID when enumerating with Windows Media Foundation
I do not wish to reimplement half of the USBView example and enumerate the entire USB world just to get some specific info for a device for which I already have a handle.
Some symbolic links for USB devices can be parsed to extract the serial number, however in the case of composite devices (all the devices in question here) the symbolic link has the &MI_00# style format and does not contain the serial number in the symlink string. So it cannot simply be parsed out.
More generally, the Setup and related APIs in Win32 seem to make it easy to get information such as manufacturer, friendly name, and all sorts of other info. But serial number is conspicuously absent.
So how do you get the serial number associated with a MediaFoundation device instance?
You can do camera identification by USB port connection (Root-Hub-Port identifiers are the same if you don't connect new USB cards or hubs to the system)
Unfortunately StackOverflow doesn't give to attach images (I don't have good enough reputation).
I'll try to show data from debugger:
There is list of my available cameras
+Integrated_Webcam/R1.H2.P4/VID_1BCF&PID_2284&MI_00;
+HBVCAM FHD CAMERA/R4.H2.P4/VID_058F&PID_3821&MI_00;
+HD USB Camera/R5.H2.P5/VID_05A3&PID_9230&MI_00;
+Integrated_Webcam/R5.H2.P6/VID_1BCF&PID_2284&MI_00;
+Logitech HD Webcam C270/R1.H2.P1/VID_046D&PID_0825&MI_00;
Each string consists of Friendly camera name, Rx.Hx.Px camera connection port indexes, (i.e. Controller number"R"-Hub number"H"-Port number"P") and VID-PID-MI presentation string(vendor id, product id and interface number).
1st and 4th cameras are the same, but have different RHP indexes. These indexes I do use for camera identification.
I did USB enumerator which provides these indexes (I did this on the base of Microsoft USBView.exe application which is provided with sources in Windows SDK).
[1]: https://i.stack.imgur.com/6SQcS.png
Usually simple USB cameras (web cameras) doesn't have serial number or something like serial number is encoded inside USB instance ID. More expensive cameras have special drivers and you can read SN by driver.
I see only one way to know, what camera I do use now - by attached USB port. This port is unique... if you don't connect additional hubs or not insert additional USB interface cards in computer. There is USB enumeration process which provides Controller(Root)-Hub-Port enumeration indexes. I do use these indexes for camera identification.
Look on this dialog: you see 5 strings with 5 USB cameras descriptors. Each descriptor consists of "Friendly Camera Name", 3 enumeration indexes (Rx.Hx.Px) and camera vendor ID and product ID (VID and PID).
If I put different camera to the same port, my program will use this different camera. If several cameras of the same type are connected, I do differ between cameras by RHP indexes. For example, the first and the fourth camera in list are the same, but they have different
enter image description here

Understanding "driverless" USB HID

I'm at the beginning of trying to develop a USB HID bootloader for a Kinetis processor, and getting no help from that department. I have made some modifications to Kinetis firmware designed for a similar processor(I'm using the KL26Z, the original code is for KL25Z), and I do now see the beginning of the USB enumeration(on a PC running W7). However, the PC asks for driver software, and I don't understand why, as I thought the whole point of going the HID route was that one didn't need to install drivers. So the device shows up under device manager, but as a non-working problem device. My problem is that I don't really know what should happen. Any insights would be welcome.
Here's what should happen: the computer will ask your device for its USB descriptors when it detects your device. The descriptors must have certain fields like bDeviceClass set properly to indicate that it is an HID. If the computer sees those fields, it will attach the HID driver to your device.
In the Device Manager, you should look at the "Compatible Ids" of your device. Do you see USB\Class_03 in that list? If so, that should match the driver input.inf that comes with Windows, so the INF file will be applied to your device, and you device will show up as "USB Input Device" in the Device Manager. If you don't see USB\Class_03 in your list then there is probably some problem with your device's USB descriptors or its USB stack.

Is PID = 0 a valid for usb device?

I'm going to create device with Product Id (PID) = 0x0000, create driver for this device and sign it using Microsoft Windows Driver Kit (WDK). Is 0x0000 a valid PID for USB device in Windows?
PID=0x0000 will be a generic PID for all my devices (for development purposes), because I already have PID=0x0001, PID=0x0002 and so on.
Yes. As far as I know, there is nothing in the USB specification that prevents the product ID from being 0, so you should be fine. This listing of USB IDs contains several instances of USB devices with a product ID of 0.
Keep in mind that your product still must have a valid vendor ID, which you are supposed to get assigned to you by the USB Implementers Forum.

USB host recognition

I'm developing an embedded USB device which needs to be available to two different hosts.
The first is a normal PC, where it will be used as a MSC (mass storage) device, and the second is a specific hardware which the USB device needs to comunicate with a CDC profile.
during the enumeration, the USB device send descriptor table where it declares its capabilities.
Is there a way in the enumeration process to know to which host the device was connected to ?
The simplest solution perhaps would be to implement a "USB Composite Device", where the single device presented both the MSC and CDC class interfaces simultaneously. The host PC would see both interfaces, but you could simply leave one unused. The "specific hardware" would probably simply ignore the MSC class if it had no support for it.