forked from spiliot/USBHid
-
Notifications
You must be signed in to change notification settings - Fork 2
/
VidPidMatchers.cs
32 lines (28 loc) · 873 Bytes
/
VidPidMatchers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using UsbHid.USB.Classes;
namespace UsbHid
{
public class VidPidMatchers : IUsbDeviceMatchable
{
public (uint Vid, uint Pid)[] VidPids;
public VidPidMatchers((uint Vid, uint Pid)[] VidPids)
{
this.VidPids = VidPids;
}
public bool BasicMatch(string deviceInstancePath)
{
for (int i = 0; i < VidPids.Length; i++)
{
if (deviceInstancePath.IndexOf("#vid_" + VidPids[i].Vid.ToString("x4") + "&") != -1
&& deviceInstancePath.IndexOf("&pid_" + VidPids[i].Pid.ToString("x4") + "#") != -1)
{
return true;
}
}
return false;
}
public virtual bool DescriptorsMatch(UsbDescriptorStrings descriptorStrings)
{
return true;
}
}
}