protected override bool TryCreateHidDevice(object key, out Device device) { var path = (HidDevicePath)key; device = WinHidDevice.TryCreate(path.DevicePath, path.DeviceID); return(device != null); }
internal static WinHidDevice TryCreate(string path, string id) { var d = new WinHidDevice() { _path = path, _id = id }; return(d.TryOpenToGetInfo(handle => { NativeMethods.HIDD_ATTRIBUTES attributes = new NativeMethods.HIDD_ATTRIBUTES(); attributes.Size = Marshal.SizeOf(attributes); if (!NativeMethods.HidD_GetAttributes(handle, ref attributes)) { return false; } // Get VID, PID, version. d._pid = attributes.ProductID; d._vid = attributes.VendorID; d._version = attributes.VersionNumber; return true; }) ? d : null); }
internal WinHidStream(WinHidDevice device) : base(device) { _closeEventHandle = NativeMethods.CreateManualResetEventOrThrow(); }