Пример #1
0
 /// <summary>
 /// Tries to find a RailDriver and initialize it
 /// </summary>
 /// <param name="basePath"></param>
 public UserInputRailDriver(string basePath)
 {
     try
     {
         PIEDevice[] devices = PIEHidDotNet.PIEDevice.EnumeratePIE();
         for (int i = 0; i < devices.Length; i++)
         {
             if (devices[i].HidUsagePage == 0xc && devices[i].Pid == 210)
             {
                 Device = devices[i];
                 Device.SetupInterface();
                 Device.SetErrorCallback(this);
                 Device.SetDataCallback(this, DataCallbackFilterType.callOnChangedData);
                 WriteBuffer = new byte[Device.WriteLength];
                 State       = new RailDriverState();
                 SetLEDs(0x40, 0x40, 0x40);
                 ReadCalibrationData(basePath);
                 break;
             }
         }
     }
     catch (Exception error)
     {
         Device = null;
         Trace.WriteLine(error);
     }
 }
Пример #2
0
 /// <summary>
 /// Tries to find a RailDriver and initialize it
 /// </summary>
 /// <param name="basePath"></param>
 public UserInputRailDriver(string basePath)
 {
     try
     {
         Device = RailDriverBase.GetInstance();
         if (Device != null)
         {
             WriteBuffer = new byte[Device.WriteBufferSize];
             State       = new RailDriverState();
             SetLEDs(0x40, 0x40, 0x40);
             ReadCalibrationData(basePath);
             Device.OnDataRead += HandlePIEHidData;
         }
     }
     catch (Exception error)
     {
         Device = null;
         Trace.WriteLine(error);
     }
 }