Exemplo n.º 1
0
        /// <summary>
        /// Returns the raw byte data for a Hid feature code.
        /// </summary>
        /// <param name="featureCode">The Hid feature code to retrieve.</param>
        /// <param name="result">Receives the result of the operation.</param>
        /// <param name="expectedSize">The expected size, in bytes, of the result.</param>
        /// <returns>True if successful.</returns>
        /// <remarks></remarks>
        public bool HidGetFeature(byte featureCode, ref byte[] result, int expectedSize)
        {
            bool HidGetFeatureRet = default;
            var  hfile            = HidFeatures.OpenHid(this);

            if (hfile == IntPtr.Zero)
            {
                return(false);
            }
            var mm = new MemPtr();

            mm.Alloc(expectedSize + 1);
            mm.ByteAt(0L) = featureCode;
            if (!UsbLibHelpers.HidD_GetFeature(hfile, mm, expectedSize))
            {
                HidGetFeatureRet = false;
            }
            else
            {
                HidGetFeatureRet = true;
                result           = mm.ToByteArray(1L, expectedSize);
            }

            HidFeatures.CloseHid(hfile);
            mm.Free();
            return(HidGetFeatureRet);
        }