Exemple #1
0
 public bool ReadFeatureData(out byte[] data, byte reportId = 0)
 {
     data = new byte[internalDevice.GetMaxFeatureReportLength()];
     try
     {
         data[0] = reportId;
         //byte[] buffer = new byte[data.Length];
         GetStream().GetFeature(data);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #2
0
        public HidDevice(HidSharp.HidDevice internalDevice)
        {
            Properties = new Dictionary <string, dynamic>();

            Properties["MaxFeatureReportLength"] = internalDevice.GetMaxFeatureReportLength();
            Properties["MaxInputReportLength"]   = internalDevice.GetMaxInputReportLength();
            Properties["MaxOutputReportLength"]  = internalDevice.GetMaxOutputReportLength();

            try
            {
                Properties["Manufacturer"] = internalDevice.GetManufacturer();
            }
            catch { }
            try
            {
                Properties["ProductName"] = internalDevice.GetProductName();
            }
            catch { }

            try
            {
                bool           FoundAny = false;
                HashSet <uint> Usages   = new HashSet <uint>();
                foreach (var descriptor in internalDevice.GetReportDescriptor().DeviceItems)
                {
                    try
                    {
                        foreach (uint usage in descriptor.Usages.GetAllValues())
                        {
                            Usages.Add(usage);
                            FoundAny = true;
                        }
                    }
                    catch { }
                }
                if (FoundAny)
                {
                    this.Usages          = Usages.ToArray();
                    Properties["Usages"] = this.Usages;
                }
            }
            catch { }

            this.internalDevice = internalDevice;
        }