Beispiel #1
0
        public void WrapsGetDevice()
        {
            IHidDevice enumDevice = enumerator.GetDevice(devicePath);
            IHidDevice hidDevice  = HidDevices.GetDevice(devicePath);

            enumDevice.DevicePath.ShouldEqual(hidDevice.DevicePath);
        }
Beispiel #2
0
        public void Process()
        {
            //_myDevice = HidDevices.Enumerate(1, 0005).FirstOrDefault();
            IEnumerable <string> devices   = HidDevices.Enumerate().Select(x => x.DevicePath).ToList();
            HidDevice            _myDevice = HidDevices.GetDevice("\\\\?\\hid#vid_1bcf&pid_0005#6&e3d5557&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}");

            //            foreach (var item in HidDevices.GetDevice("PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(1)"
            //"))
            //            {

            //            }



            if (_myDevice != null)
            {
                _myDevice.OpenDevice();

                _myDevice.Inserted += DeviceAttachedHandler;
                _myDevice.Removed  += DeviceRemovedHandler;
                // _myDevice.ReadReportSync
                _myDevice.MonitorDeviceEvents = true;
                _myDevice.Read();
                // this is where we start listening for data

                //while (true)
                //{
                _myDevice.ReadReport(OnReport);
                //   }
                //System.Threading.Thread.Sleep(100);
            }
        }
Beispiel #3
0
        public void WrapsGetDevice()
        {
            BeforeEach();
            var        enumDevice = _enumerator.GetDevice(_devicePath);
            IHidDevice hidDevice  = HidDevices.GetDevice(_devicePath);

            enumDevice.DevicePath.ShouldEqual(hidDevice.DevicePath);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            bool deviceConnected = false;

            //These rfids are hardcoded.  Ideally, with more hardware Id's could be dynamically assigned to
            //any application.
            apps.Add(new RfidApp()
            {
                RFID = "67005DC3B64F", ProgramName = @"C:\Program Files (x86)\Microsoft Office\Office14\WinWord.exe"
            });
            apps.Add(new RfidApp()
            {
                RFID = "67005DA120BB", ProgramName = @"C:\Program Files\Internet Explorer\iexplore.exe"
            });
            apps.Add(new RfidApp()
            {
                RFID = "690025D364FB", ProgramName = @"C:\Windows\System32\cmd.exe"
            });
            apps.Add(new RfidApp()
            {
                RFID = "690025BD00F1", ProgramName = @"C:\Windows\notepad.exe"
            });
            apps.Add(new RfidApp()
            {
                RFID = "690025C366E9", ProgramName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
            });
            apps.Add(new RfidApp()
            {
                RFID = "690025FF59EA", ProgramName = @"C:\Windows\explorer.exe"
            });
            apps.Add(new RfidApp()
            {
                RFID = "67005D9D0CAB", ProgramName = @"C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\photoshop.exe"
            });

            IEnumerable <HidDevice> _device = HidDevices.Enumerate();
            HidDevice hd = _device.FirstOrDefault(p => p.DevicePath.Contains(devicePid));

            if (hd != null)
            {
                device = HidDevices.GetDevice(hd.DevicePath);
                Console.WriteLine("Vendor ID:" + hd.Attributes.VendorId);
                if (device != null)
                {
                    Console.WriteLine("Vendor ID:" + hd.Attributes.VendorId);
                    deviceConnected = true;
                }

                listen();
            }
            else
            {
                Console.WriteLine("Device Not Found");
                Console.Read();
            }
        }
Beispiel #5
0
        private void HIDDisconnected(object sender, EventArgs e)
        {
            string hidPath = INI.ReadINI(webcam.DevicePath, "HID");

            hid = HidDevices.GetDevice(hidPath);
            if (hid == null)
            {
                HIDDeInit();
            }
        }
Beispiel #6
0
        void DeviceTest()
        {
            var device = HidDevices.GetDevice(Logitech, G13);

            device.Inserted           += d => Debug.WriteLine("Inserted");
            device.Removed            += d => Debug.WriteLine("Removed");
            device.DataRead           += (dev, data) => ReadG13Data(data); // Debug.WriteLine(data.ToString());
            device.MonitorDeviceEvents = true;
            device.StartReading();
        }
Beispiel #7
0
        /// <summary>
        /// Get <see cref="IStreamDeck"/> with given <paramref name="devicePath"/>
        /// </summary>
        /// <param name="devicePath"></param>
        /// <returns><see cref="IStreamDeck"/> specified by <paramref name="devicePath"/></returns>
        public static IStreamDeck FromHID(string devicePath)
        {
            var dev = HidDevices.GetDevice(devicePath);

            if (dev == null)
            {
                throw new StreamDeckNotFoundException();
            }

            return(new StreamDeckHID(dev));
        }
Beispiel #8
0
        /// <summary>
        /// Get <see cref="IStreamDeck"/> with given <paramref name="devicePath"/>
        /// </summary>
        /// <param name="devicePath"></param>
        /// <returns><see cref="IStreamDeck"/> specified by <paramref name="devicePath"/></returns>
        public static IStreamDeck OpenDevice(string devicePath)
        {
            var dev = HidDevices.GetDevice(devicePath);

            if (dev == null)
            {
                throw new StreamDeckNotFoundException();
            }

            return(new HidClient(dev));
        }
Beispiel #9
0
        /// <summary>
        /// Open the Stream Deck device at the given location.
        /// </summary>
        /// <exception cref="SharpLib.StreamDeck.NotFoundException">Thrown when no Stream Deck is found</exception>
        public void Open(string devicePath)
        {
            var dev = HidDevices.GetDevice(devicePath);

            if (dev == null)
            {
                throw new NotFoundException();
            }

            Open(dev);
        }
Beispiel #10
0
 public PVRReader()
 {
     _hidDevice = HidDevices.GetDevice("\\\\?\\hid#vid_0483&pid_0021#7&1b9e8dbf&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}");
     try
     {
         Path = _hidDevice.DevicePath;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error Opening Device:\r\n" + ex, "HID Error");
     }
 }
Beispiel #11
0
        public void StartCommunication(bool force = false)
        {
            if (Device != null)
            {
                if (Device.IsConnected)
                {
                    if (!Device.IsOpen || force)
                    {
                        Device.OpenDevice();
                        DeviceOpened?.Invoke();
                        Device.ReadReport(OnReport);
                    }
                }
            }
            else
            {
                if (HidDevices.IsConnected(devicePath))
                {
                    Device = HidDevices.GetDevice(devicePath);

                    if (!Device.IsOpen || force)
                    {
                        Device.OpenDevice();
                        DeviceOpened?.Invoke();
                        Device.ReadReport(OnReport);
                    }
                }
                else
                {
                    Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1)).TakeUntil(stopSubject).Subscribe(
                        l =>
                    {
                        var dev = HidDevices.GetDevice(devicePath);

                        if (Device == null && dev != null)
                        {
                            Device = dev;
                        }

                        if (Device == null)
                        {
                            return;
                        }

                        Device.OpenDevice();
                        DeviceOpened?.Invoke();
                        Device.ReadReport(OnReport);
                        stopSubject.OnNext(Unit.Default);
                    });
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// Open a connection to a Blink(1) device by its HID path.
        /// </summary>
        /// <param name="devicePath">
        /// The Blink(1) HID device path.
        /// </param>
        public void Open(string devicePath)
        {
            if (string.IsNullOrEmpty(devicePath))
            {
                throw new ArgumentNullException("devicePath", "Argument must not be null or empty.");
            }

            this.hidDevice = HidDevices.GetDevice(devicePath);

            if (this.hidDevice == null)
            {
                throw new InvalidOperationException("No Blink(1) device found.");
            }

            this.hidDevice.OpenDevice();
        }
Beispiel #13
0
        public MiGamepad(string device, ViGEmClient client)
        {
            _Device = HidDevices.GetDevice(device);
            _Device.MonitorDeviceEvents = false;

            _Target = new Xbox360Controller(client);
            _Target.FeedbackReceived += Target_OnFeedbackReceived;

            // TODO mark the threads as background?
            _InputThread = new Thread(DeviceWorker);

            _CTS    = new CancellationTokenSource();
            _Report = new Xbox360Report();

            LedNumber = 0xFF;
        }
Beispiel #14
0
        public MiGamepad(string device, ViGEmClient client)
        {
            _Logger.Information("Initializing MiGamepad handler for device {Device}", device);

            _Device = HidDevices.GetDevice(device);
            _Device.MonitorDeviceEvents = false;

            _Target = client.CreateXbox360Controller();
            _Target.AutoSubmitReport  = false;
            _Target.FeedbackReceived += Target_OnFeedbackReceived;

            // TODO mark the threads as background?
            _InputThread = new Thread(DeviceWorker);

            _CTS            = new CancellationTokenSource();
            _VibrationTimer = new Timer(VibrationTimer_Trigger);

            LedNumber = 0xFF;
        }
Beispiel #15
0
        /// <summary>
        /// Do req startup work, check for braille device.
        /// </summary>
        private void init()
        {
            lblDevice.Text = "Connecting to Braille Device...";
            Application.DoEvents();
            //Put this in for dramatic effect to show that a reconnection
            //is occuring in the UI.
            System.Threading.Thread.Sleep(3000);
            IEnumerable <HidDevice> _device = HidDevices.Enumerate();
            HidDevice hd = _device.FirstOrDefault(p => p.DevicePath.Contains(devicePid));

            if (hd != null)
            {
                device = HidDevices.GetDevice(hd.DevicePath);
                if (device != null)
                {
                    lblDevice.Text = "Connected.";
                    Application.DoEvents();
                    deviceConnected = true;
                    //start listening to device.
                    if (!hidWorker.IsBusy)
                    {
                        hidWorker.RunWorkerAsync();
                    }
                }
            }
            else
            {
                lblDevice.Text = "Device Not Found.";
                Application.DoEvents();
            }

            //TODO: Add crash check.
            //Review the log data to see if a crash occured and prompt user to reload current.
            addPhrases();

            t.Interval = 1000;
            t.Tick    += t_Tick;
        }
Beispiel #16
0
        public void Initialize()
        {
            if (Device == null)
            {
                if (HidDevices.IsConnected(devicePath))
                {
                    Device = HidDevices.GetDevice(devicePath);
                }
                else
                {
                    Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1)).TakeUntil(stopSubject).Subscribe(
                        l =>
                    {
                        var dev = HidDevices.GetDevice(devicePath);

                        if (Device == null && dev != null)
                        {
                            Device = dev;
                        }
                    });
                }
            }
        }
Beispiel #17
0
 private void InitHID()
 {
     if (INI.KeyExists("HID", webcam.DevicePath))
     {
         string hidPath = INI.ReadINI(webcam.DevicePath, "HID");
         if (hid != null)
         {
             hid.CloseDevice();
         }
         hid = HidDevices.GetDevice(hidPath);
         if (hid != null)
         {
             hid.OpenDevice();
             mulTimer = new System.Timers.Timer
             {
                 Interval  = 600,
                 AutoReset = true,
                 Enabled   = true,
             };
             mulTimer.Elapsed += HIDTimedEvent;
             if (currentProperty == null)
             {
                 SelectNextProperty();
             }
             else
             {
                 currentProperty.SelectItem(true);
             }
             hid.ReadReport(OnReport);
             Globals._USBControl.HIDDisconnected += HIDDisconnectEvent;
         }
         else
         {
             Globals._USBControl.HIDConnected -= HIDConnectEvent;
         }
     }
 }
Beispiel #18
0
        /// <summary>
        /// Open connection to LNP device with USB device path
        /// </summary>
        /// <param name="devicepath">LNP USB device path</param>
        /// <returns>Return connected LNP device</returns>
        public static LNP Connect(string devicepath)
        {
            var device = HidDevices.GetDevice(devicepath);

            if (device.Attributes.VendorId == VENDOR_ID)
            {
                bool sameproduct = false;
                foreach (int id in PRODUCT_ID)
                {
                    if (device.Attributes.ProductId == id)
                    {
                        sameproduct = true;
                        break;
                    }
                }

                if (sameproduct)
                {
                    device.OpenDevice(DeviceMode.Overlapped, DeviceMode.Overlapped, ShareMode.Exclusive);
                    int count = 5;
                    while (!device.IsConnected && !device.IsOpen)
                    {
                        Thread.Sleep(1000);
                        count--;
                        if (count < 0)
                        {
                            device.CloseDevice();
                            throw new Exception("Failed to connect LNP device!");
                        }
                    }

                    return(new LNP(device));
                }
            }
            throw new Exception("No such LNP device exist or not LNP device!");
        }
Beispiel #19
0
 public Scanner(string devicePath) : this(HidDevices.GetDevice(devicePath))
 {
 }
Beispiel #20
0
        /// <summary>
        /// Get <see cref="IMacroBoard"/> with given <paramref name="devicePath"/>
        /// </summary>
        /// <param name="devicePath"></param>
        /// <returns><see cref="IMacroBoard"/> specified by <paramref name="devicePath"/></returns>
        /// <exception cref="StreamDeckNotFoundException">Thrown if no Stream Deck is found</exception>
        public static IMacroBoard OpenDevice(string devicePath)
        {
            var dev = HidDevices.GetDevice(devicePath);

            return(CachedHidClient.FromHid(dev ?? throw new StreamDeckNotFoundException()));
        }
Beispiel #21
0
 public lr4(string devicePath) : this(HidDevices.GetDevice(devicePath))
 {
 }
Beispiel #22
0
 public SDP_Handler(string devicePath) : this(HidDevices.GetDevice(devicePath))
 {
 }