HidLibrary.NativeMethods.HidD_GetFeature C# (CSharp) Method

HidD_GetFeature() private method

private HidD_GetFeature ( IntPtr hidDeviceObject, byte lpReportBuffer, int reportBufferLength ) : bool
hidDeviceObject System.IntPtr
lpReportBuffer byte
reportBufferLength int
return bool
        internal static extern bool HidD_GetFeature(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength);

Usage Example

Example #1
0
 public bool ReadFeatureData(out byte[] data, byte reportId = 0)
 {
     if (_deviceCapabilities.FeatureReportByteLength > 0)
     {
         data = new byte[_deviceCapabilities.FeatureReportByteLength];
         byte[] array = CreateFeatureOutputBuffer();
         array[0] = reportId;
         IntPtr intPtr = IntPtr.Zero;
         bool   flag   = false;
         try
         {
             intPtr = OpenDeviceIO(_devicePath, 0u);
             flag   = NativeMethods.HidD_GetFeature(intPtr, array, array.Length);
             if (flag)
             {
                 Array.Copy(array, 0, data, 0, Math.Min(data.Length, _deviceCapabilities.FeatureReportByteLength));
             }
         }
         catch (Exception innerException)
         {
             throw new Exception($"Error accessing HID device '{_devicePath}'.", innerException);
         }
         finally
         {
             if (intPtr != IntPtr.Zero)
             {
                 CloseDeviceIO(intPtr);
             }
         }
         return(flag);
     }
     data = new byte[0];
     return(false);
 }
All Usage Examples Of HidLibrary.NativeMethods::HidD_GetFeature