OpenMacroBoard / StreamDeckSharp

A simple .NET wrapper for Stream Deck
MIT License
351 stars 47 forks source link

device id #48

Closed flat-eric147 closed 1 year ago

flat-eric147 commented 2 years ago

Hi! First of all thanks for this library, I am a long time user and I love it !!! I have a question concerning the device id that is returned StreamDeck.EnumerateDevices method. The Device ID I get looks like

\?\hid#vid_0fd9&pid_006c#6&ec79805&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}

From what I understand there is a vendor id, a product id and at the end a guid. In the middle the "ec79805" seems like a device id? I wonder where I can find a unique ID for the device so that I can identify a device independently on which usb slot it is connected to. That would help me to "sort" the devices if there are multiple StramDecks connected. I can of course just use the DeviceName to sort, but I'd like to understand the encoding of the above string. Any insight would be appreciated, thanks!

wischi-chr commented 2 years ago

Hi. Sorry for my late reply.

The reported "deviceId" depends on the implementation of the MacroBoardProvider (like StreamDeckSharp). This Id is just to identify the device (if the id matches - the device is the same) but it doesn't (in general) have any further meaning. In fact there might be other MacroBoardProviders in the future with ids that are totally different and may not even have a vendor or product id because they are not USB devices.

In case of StreamDeckSharp I use the device path of the USB device which looks something like the string you posted. Even though you can "see" that the device path is composed of a few different things like vendorId, productId, etc. you should treat it like an opaque string and not try to extract information out of that string.

Here is the Microsoft documentation also noting that the device identification should not be parsed: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/device-identification-strings

If you want to "sort" the devices you should first try to define some rules about the order of the devices - there might be better options than parsing the device path.

flat-eric147 commented 1 year ago

Thank you!