Пример #1
0
        public HidReport(int reportSize, HidDeviceData deviceData)
        {
            _status = deviceData.Status;

            Array.Resize(ref _data, reportSize - 1);

            if ((deviceData.Data != null))
            {
                if (deviceData.Data.Length > 0)
                {
                    _reportId = deviceData.Data[0];
                    Exists    = true;

                    if (deviceData.Data.Length > 1)
                    {
                        var dataLength = reportSize - 1;
                        if (deviceData.Data.Length < reportSize - 1)
                        {
                            dataLength = deviceData.Data.Length;
                        }
                        Array.Copy(deviceData.Data, 1, _data, 0, dataLength);
                    }
                }
                else
                {
                    Exists = false;
                }
            }
            else
            {
                Exists = false;
            }
        }
Пример #2
0
        /// <summary>
        /// Reads an input report from the Control channel.  This method provides access to report data for devices that
        /// do not use the interrupt channel to communicate for specific usages.
        /// </summary>
        /// <param name="reportId">The report ID to read from the device</param>
        /// <returns>The HID report that is read.  The report will contain the success status of the read request</returns>
        ///
        public HidReport ReadReportSync(byte reportId)
        {
            byte[] cmdBuffer = new byte[Capabilities.InputReportByteLength];
            cmdBuffer[0] = reportId;
            bool          bSuccess   = NativeMethods.HidD_GetInputReport(Handle, cmdBuffer, cmdBuffer.Length);
            HidDeviceData deviceData = new HidDeviceData(cmdBuffer, bSuccess ? HidDeviceData.ReadStatus.Success : HidDeviceData.ReadStatus.NoDataRead);

            return(new HidReport(Capabilities.InputReportByteLength, deviceData));
        }