Esempio n. 1
0
        internal HidDevice(HidControl control, string devicePath)
        {
            controller = control;

            dev = new DeviceAccess(devicePath);

            if (dev.OpenDeviceForIoctl())
            {
                NativeApi.HidD_GetAttributes(dev.Handle, ref Attributes);

                using (HidPreparsedData preparsedData = new HidPreparsedData(dev.Handle))
                {
                    NativeApi.HidP_GetCaps(preparsedData.Handle, ref Capabilities);
                }

                if (dev.OpenDeviceForRead())
                {
                    ReadThread = new DeviceReadThread(new DeviceAccess(devicePath), new ReceivedReportDelegate(InputPipeReportHandler));
                }
                else
                {
                    ReadThread = null;
                }
            }
            else
            {
                throw new Exception("Unable to access device!");
            }
        }
Esempio n. 2
0
        public string GetDeviceString(int idx)
        {
            StringBuilder buf = new StringBuilder(256);

            if (dev.OpenDeviceForIoctl())
            {
                NativeApi.HidD_GetIndexedString(dev.Handle, idx, buf, buf.Capacity);
            }
            return(buf.ToString());
        }