Example #1
0
 private static extern int HidP_GetCaps(int PreparsedData, ref HIDP_CAPS Capabilities);
Example #2
0
        private bool GetFeature(int hDevice, byte[] array_out, int out_len)
        {
            bool FeatureStatus;
            bool Status;
            int i;
            byte[] FeatureReportBuffer = new byte[512];
            int Ppd = 0;
            HIDP_CAPS Caps = new HIDP_CAPS();

            if (!HidD_GetPreparsedData(hDevice, ref Ppd)) return false;

            if (HidP_GetCaps(Ppd, ref Caps) <= 0)
            {
                HidD_FreePreparsedData(Ppd);
                return false;
            }

            Status = true;

            FeatureReportBuffer[0] = 1;

            FeatureStatus = HidD_GetFeature(hDevice, FeatureReportBuffer, Caps.FeatureReportByteLength);
            if (FeatureStatus)
            {
                for (i = 0; i < out_len; i++)
                {
                    array_out[i] = FeatureReportBuffer[i];
                }
            }

            Status = Status && FeatureStatus;
            HidD_FreePreparsedData(Ppd);

            return Status;
        }
Example #3
0
        private bool SetFeature(int hDevice, byte[] array_in, int in_len)
        {
            bool FeatureStatus;
            bool Status;
            int i;
            byte[] FeatureReportBuffer = new byte[512];
            int Ppd = 0;
            HIDP_CAPS Caps = new HIDP_CAPS();

            if (!HidD_GetPreparsedData(hDevice, ref Ppd)) return false;

            if (HidP_GetCaps(Ppd, ref Caps) <= 0)
            {
                HidD_FreePreparsedData(Ppd);
                return false;
            }

            Status = true;

            FeatureReportBuffer[0] = 2;

            for (i = 0; i < in_len; i++)
            {
                FeatureReportBuffer[i + 1] = array_in[i + 1];

            }
            FeatureStatus = HidD_SetFeature(hDevice, FeatureReportBuffer, Caps.FeatureReportByteLength);

            Status = Status && FeatureStatus;
            HidD_FreePreparsedData(Ppd);

            return Status;
        }