internal bool GetInfo(IntPtr handle)
 {
     NativeMethods.HIDD_ATTRIBUTES attributes = new NativeMethods.HIDD_ATTRIBUTES();
     attributes.Size = Marshal.SizeOf(attributes);
     if (!NativeMethods.HidD_GetAttributes(handle, ref attributes)) { return false; }
     
     _pid = attributes.ProductID;
     _vid = attributes.VendorID;
     _version = attributes.VersionNumber;
     return true;
 }
Exemple #2
0
        internal bool GetInfo(IntPtr handle)
        {
            NativeMethods.HIDD_ATTRIBUTES attributes = new NativeMethods.HIDD_ATTRIBUTES();
            attributes.Size = Marshal.SizeOf(attributes);
            if (!NativeMethods.HidD_GetAttributes(handle, ref attributes))
            {
                return(false);
            }

            _pid     = attributes.ProductID;
            _vid     = attributes.VendorID;
            _version = attributes.VersionNumber;
            return(true);
        }
Exemple #3
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);
        }