public void WrapsGetDevice() { IHidDevice enumDevice = enumerator.GetDevice(devicePath); IHidDevice hidDevice = HidDevices.GetDevice(devicePath); enumDevice.DevicePath.ShouldEqual(hidDevice.DevicePath); }
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); } }
public void WrapsGetDevice() { BeforeEach(); var enumDevice = _enumerator.GetDevice(_devicePath); IHidDevice hidDevice = HidDevices.GetDevice(_devicePath); enumDevice.DevicePath.ShouldEqual(hidDevice.DevicePath); }
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(); } }
private void HIDDisconnected(object sender, EventArgs e) { string hidPath = INI.ReadINI(webcam.DevicePath, "HID"); hid = HidDevices.GetDevice(hidPath); if (hid == null) { HIDDeInit(); } }
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(); }
/// <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)); }
/// <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)); }
/// <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); }
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"); } }
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); }); } } }
/// <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(); }
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; }
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; }
/// <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; }
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; } }); } } }
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; } } }
/// <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!"); }
public Scanner(string devicePath) : this(HidDevices.GetDevice(devicePath)) { }
/// <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())); }
public lr4(string devicePath) : this(HidDevices.GetDevice(devicePath)) { }
public SDP_Handler(string devicePath) : this(HidDevices.GetDevice(devicePath)) { }