Ejemplo n.º 1
0
        protected override bool TryCreateHidDevice(object key, out Device device)
        {
            var path = (HidDevicePath)key;

            device = WinHidDevice.TryCreate(path.DevicePath, path.DeviceID);
            return(device != null);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 internal WinHidStream(WinHidDevice device)
     : base(device)
 {
     _closeEventHandle = NativeMethods.CreateManualResetEventOrThrow();
 }