Exemplo n.º 1
0
        private void InitializeFileStream()
        {
            if (dev.OpenDeviceForIoctl())
            {
                using (HidPreparsedData preparsedData = new HidPreparsedData(dev.Handle))
                {
                    NativeApi.HIDP_CAPS Capabilities = new NativeApi.HIDP_CAPS();
                    NativeApi.HidP_GetCaps(preparsedData.Handle, ref Capabilities);
                    bufferSize = Capabilities.InputReportByteLength;
                }

                if (dev.OpenDeviceForRead())
                {
                    state = new DeviceReadState(new FileStream(dev.Handle, FileAccess.Read), new byte[bufferSize]);
                }
                else
                {
                    throw new Exception("Unable to open device for Read");
                }
            }
        }
Exemplo n.º 2
0
        private void InitializeFileStream()
        {
            if (dev.OpenDeviceForIoctl())
            {
                using (HidPreparsedData preparsedData = new HidPreparsedData(dev.Handle))
                {
                    NativeApi.HIDP_CAPS Capabilities = new NativeApi.HIDP_CAPS();
                    NativeApi.HidP_GetCaps(preparsedData.Handle, ref Capabilities);
                    bufferSize = Capabilities.InputReportByteLength;
                }

                if (dev.OpenDeviceForRead())
                {
                    state = new DeviceReadState(new FileStream(dev.Handle, FileAccess.Read), new byte[bufferSize]);
                }
                else
                {
                    throw new Exception("Unable to open device for Read");
                }
            }
        }