コード例 #1
0
 internal void GetHidFeatureReport(byte[] featureReport)
 {
     // NOTE: Keep this method internal for a while.
     if (featureReport == null || featureReport.Length >= 256)
     {
         throw new ArgumentException("featureReport is null or too large.", "featureReport");
     }
     // TODO: It can be important to wait before Get.
     if (WaitTimeInMillisecondsBeforeGetFeatureReport > 0)
     {
         while (HidStopwatch.ElapsedMilliseconds <= WaitTimeInMillisecondsBeforeGetFeatureReport)
         {
             System.Threading.Thread.Sleep(1);
         }
     }
     // NOTE: Exceptions can occur.  But this method does NOT catch them here.
     Win32HidSimpleAccess.GetFeatureReport(HidDeviceDevicePath, featureReport);
     if (WaitTimeInMillisecondsBeforeGetFeatureReport > 0)
     {
         HidStopwatch.Reset(); HidStopwatch.Start();
     }
 }
コード例 #2
0
 internal void SetHidFeatureReport(byte[] featureReport)
 {
     // NOTE: Keep this method internal for a while.
     if (featureReport == null || featureReport.Length >= 256)
     {
         throw new ArgumentException("featureReport is null or too large.", "featureReport");
     }
     // TODO (en): I'm not sure this waiting is unnecessary or not.  If this function fails once, it continues to fail after waiting 100[ms], 10[sec].
     // TODO (ja): Setの前の待機は関係ないかも?!一度この関数が失敗すると、100ミリ秒とか10秒とか待機しても失敗している。
     if (WaitTimeInMillisecondsBeforeSetFeatureReport > 0)
     {
         while (HidStopwatch.ElapsedMilliseconds <= WaitTimeInMillisecondsBeforeSetFeatureReport)
         {
             System.Threading.Thread.Sleep(1);
         }
     }
     // NOTE: Exceptions can occur.  But this method does NOT catch them here.
     Win32HidSimpleAccess.SetFeatureReport(HidDeviceDevicePath, featureReport);
     if (WaitTimeInMillisecondsBeforeSetFeatureReport > 0)
     {
         HidStopwatch.Reset(); HidStopwatch.Start();
     }
 }