예제 #1
0
        private void FindBayer()
        {
            var l3           = _list.GetHidDevices();
            var bayerDevices = _list.GetHidDevices(_vendorIdFilter, _productIdFilter)?.ToList();

            if (bayerDevices != null && bayerDevices.Count == 1)
            {
                Device      = bayerDevices[0];
                IsConnected = true;
                Logger.LogInformation($"Device found: {Device.GetFriendlyName()}");
                Thread.Sleep(3000);

                OnDeviceAdded();
            }
            else
            {
                if (Device != null)
                {
                    IsConnected = false;
                    Device      = null;
                    Logger.LogInformation($"Device disconnected");
                    OnDeviceRemoved();
                }
            }
        }
        public static List <string> GetProductNames()
        // ===========================================================================================
        {
            HIDdeviceList = list.GetHidDevices().ToArray();
            List <string> ProductNames = new List <string>();

            foreach (HidDevice idev in HIDdeviceList)
            {
                try
                {
                    if (idev.GetProductName().Contains("EventExchanger"))
                    {
                        ProductNames.Add(idev.GetProductName() + " SN## " + idev.GetSerialNumber());
                        device = idev;
                    }
                }
                catch (Exception)
                { }
            }
            if (ProductNames.Count != 1)
            {
                device = null;
            }

            return(ProductNames);
        }
예제 #3
0
파일: HID.cs 프로젝트: N5FPP/moRFctrl
        public HID()
        {
            Console.WriteLine("\nDetecting HIDs");

            // Get list of HIDs
            devList = DeviceList.Local;
            hidList = devList.GetHidDevices().ToArray();

            // Loop through HID list
            foreach (HidDevice dev in hidList)
            {
                // Check for moRFeus IDs
                if (dev.VendorID == 4292 && dev.ProductID == 60105)
                {
                    moRFeusDetected = true;
                    moRFeusDevice   = dev;
                }
            }

            // Indicate connection status
            if (moRFeusDetected)
            {
                Program.MainClass.StatusMessage = "Found moRFeus";
                Console.WriteLine("Found moRFeus: ");
                Console.WriteLine(moRFeusDevice.DevicePath);

                ConfigDevice();
            }
            else
            {
                Program.MainClass.StatusMessage = "No moRFeus found";
                Console.WriteLine("No moRFeus found\n");
            }
        }
예제 #4
0
        public static IEnumerable <StreamDeckDeviceReference> GetStreamDecks(
            this DeviceList deviceList,
            params IUsbHidHardware[] hardware
            )
        {
            if (deviceList is null)
            {
                throw new ArgumentNullException(nameof(deviceList));
            }

            var matchAllKnowDevices = hardware is null || hardware.Length < 1;

            IHardwareInternalInfos MatchingHardware(HidDevice d)
            {
                var hwDetails = d.GetHardwareInformation();

                if (hwDetails is null)
                {
                    return(null);
                }

                if (matchAllKnowDevices)
                {
                    return(hwDetails);
                }

                foreach (var h in hardware)
                {
                    if (d.VendorID == h.UsbVendorId &&
                        d.ProductID == h.UsbProductId)
                    {
                        return(hwDetails);
                    }
                }

                return(null);
            }

            return(deviceList
                   .GetHidDevices()
                   .Select(device => new { HardwareInfo = MatchingHardware(device), Device = device })
                   .Where(i => i.HardwareInfo != null)
                   .Select(i => new StreamDeckDeviceReference(
                               i.Device.DevicePath,
                               i.HardwareInfo.DeviceName,
                               i.HardwareInfo.Keys
                               )));
        }
예제 #5
0
파일: HID.cs 프로젝트: sam210723/moRFctrl
        /// <summary>
        /// Detect HID with given Vendor and Product IDs
        /// </summary>
        /// <param name="vid">Vendor ID</param>
        /// <param name="pid">Product ID</param>
        /// <returns>HIDSharp.HidDevice or null</returns>
        private HidDevice DetectHID(int vid, int pid)
        {
            // Get list of HIDs
            devList = DeviceList.Local;
            hidList = devList.GetHidDevices().ToArray();

            // Loop through HID list
            foreach (HidDevice dev in hidList)
            {
                // Check for HID IDs
                if (dev.VendorID == vid && dev.ProductID == pid)
                {
                    return(dev);
                }
            }

            return(null);
        }
예제 #6
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     try
     {
         List     = DeviceList.Local;
         MyDevice = List.GetHidDevices(0x1781, 0x7D1).FirstOrDefault();
         if (MyDevice != null && MyDevice.TryOpen(out Stream))
         {
             Stream.ReadTimeout = 32767;
             textBox1.Text      = MyDevice.DevicePath;
             btnConnect.Text    = "Connected!";
             Buffer             = new byte[9];                                                         // 65
             Result             = Stream.BeginRead(Buffer, 0, 9, new AsyncCallback(BytesReady), null); // 64
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #7
0
        private void DeviceListChanged(object sender, DeviceListChangedEventArgs e)
        {
            Array HidDevices = deviceList.GetHidDevices().ToArray();

            deviceListCombobox.Invoke(new Action(() => {
                deviceListCombobox.Items.Clear();
                foreach (HidDevice device in HidDevices)
                {
                    if (!device.ToString().Contains("MaMe82") || device.GetMaxInputReportLength() != 65)
                    {
                        continue;
                    }

                    deviceListCombobox.Items.Add(device.GetFriendlyName() + " " + String.Join(",", device.GetSerialPorts()));
                    shownDevices.Add(device);
                }

                if (shownDevices.Count == 1)
                {
                    deviceListCombobox.SelectedIndex = 0;
                    selectedDevice = shownDevices[0];
                }
            }));
        }
예제 #8
0
 public HIDSharpIHID()
 {
     list.Changed += DevicesChanged;
     ListOfDevices = list.GetHidDevices().ToArray();
 }
 private void list_Changed(object sender, EventArgs e)
 {
     Console.WriteLine("Device list changed.");
     hidDeviceList = list.GetHidDevices().ToArray();
     checkIfConnected();
 }
예제 #10
0
        private void LookForDevices()
        {
            var devicesFound = new List <RoxyDevice>();

            SetFlashButtonStatus(false);
            foreach (var device in devList.GetHidDevices())
            {
                if (device.VendorID == 7504 && device.ProductID == 24704)
                {
                    if (device.GetProductName() != null && device.GetProductName().Contains("Roxy"))
                    {
                        var dev = new RoxyDevice(device, BoardType.arcinRoxy, false);
                        if (devicesFound.FirstOrDefault(x => x.Equals(dev)) == null && dev.IsConfigLoaded)
                        {
                            devicesFound.Add(dev);
                        }
                    }
                    else
                    {
                        var dev = new RoxyDevice(device, BoardType.arcin, false);
                        if (devicesFound.FirstOrDefault(x => x.Equals(dev)) == null && dev.IsConfigLoaded)
                        {
                            devicesFound.Add(dev);
                        }
                    }
                }
                else if (device.VendorID == 7504 && device.ProductID == 24708)
                {
                    var dev = new RoxyDevice(device, BoardType.arcin, true);
                    if (devicesFound.FirstOrDefault(x => x.Equals(dev)) == null)
                    {
                        devicesFound.Add(dev);
                    }

                    if (waitingForBootloader && dev.Device.GetSerialNumber() == serialForBootloader)
                    {
                        flashElfEvent?.Invoke(this, new FlashEventArgs(dev.Device));
                    }
                }
                else if (device.VendorID == 0x16D0 && device.ProductID == 0x0F8B && device.ReleaseNumberBcd == 0x0002)
                {
                    var dev = new RoxyDevice(device, BoardType.Roxy, false);
                    if (devicesFound.FirstOrDefault(x => x.Equals(dev)) == null && dev.IsConfigLoaded)
                    {
                        devicesFound.Add(dev);
                    }
                }
                else if (device.VendorID == 0x16D0 && device.ProductID == 0x0F8B && device.ReleaseNumberBcd == 0x0001)
                {
                    var dev = new RoxyDevice(device, BoardType.Roxy, true);
                    if (devicesFound.FirstOrDefault(x => x.Equals(dev)) == null)
                    {
                        devicesFound.Add(dev);
                    }

                    if (waitingForBootloader && dev.Device.GetSerialNumber() == serialForBootloader)
                    {
                        flashElfEvent?.Invoke(this, new FlashEventArgs(dev.Device));
                    }
                }
                else if (device.VendorID == 0x1CCF && device.ProductID == 0x8048)
                {
                    var dev = new RoxyDevice(device, BoardType.Roxy, false, SpoofType.IIDX);
                    if (devicesFound.FirstOrDefault(x => x.Equals(dev)) == null && dev.IsConfigLoaded)
                    {
                        devicesFound.Add(dev);
                    }
                }
                else if (device.VendorID == 0x1CCF && device.ProductID == 0x101C)
                {
                    var dev = new RoxyDevice(device, BoardType.Roxy, false, SpoofType.SDVX);
                    if (devicesFound.FirstOrDefault(x => x.Equals(dev)) == null && dev.IsConfigLoaded)
                    {
                        devicesFound.Add(dev);
                    }
                }
            }

            Dispatcher.UIThread.InvokeAsync(new Action(() =>
            {
                var devToRemove = ConnectedDevices.Except(devicesFound);
                ConnectedDevices.RemoveMany(devToRemove);
                foreach (var dev in devicesFound)
                {
                    if (!ConnectedDevices.Contains(dev))
                    {
                        ConnectedDevices.Add(dev);
                    }
                }
                if (ConnectedDevices.Count == 0)
                {
                    configTab.IsEnabled = false;
                    StatusWrite("No devices found. If one is connected, please unplug it and try again.");
#if DEBUG
                    // Enable tab in debug
                    configTab.IsEnabled = true;
#endif
                }
                else
                {
                    StatusWrite($"Found {ConnectedDevices.Count} device(s). Select from the table above.");
                    SetFlashButtonStatus(isElfLoaded);
                    boardGrid.InvalidateVisual();
                }
            }));
        }