public override HidStream Open()
        {
            var stream = new LinuxHidStream();

            try { stream.Init(_path, this); return(stream); }
            catch { stream.Close(); throw; }
        }
示例#2
0
        protected override DeviceStream OpenDeviceDirectly(OpenConfiguration openConfig)
        {
            RequiresGetInfo();

            var stream = new LinuxHidStream(this);

            try { stream.Init(_path); return(stream); }
            catch { stream.Close(); throw; }
        }
示例#3
0
        bool TryParseReportDescriptor(out Reports.ReportDescriptor parser, out byte[] reportDescriptor)
        {
            parser = null; reportDescriptor = null;

            int handle;

            try { handle = LinuxHidStream.DeviceHandleFromPath(_path, this, NativeMethods.oflag.NONBLOCK); }
            catch (FileNotFoundException) { throw DeviceException.CreateIOException(this, "Failed to read report descriptor."); }

            try
            {
                uint descsize;
                if (NativeMethods.ioctl(handle, NativeMethods.HIDIOCGRDESCSIZE, out descsize) < 0)
                {
                    return(false);
                }
                if (descsize > NativeMethods.HID_MAX_DESCRIPTOR_SIZE)
                {
                    return(false);
                }

                var desc = new NativeMethods.hidraw_report_descriptor()
                {
                    size = descsize
                };
                if (NativeMethods.ioctl(handle, NativeMethods.HIDIOCGRDESC, ref desc) < 0)
                {
                    return(false);
                }

                Array.Resize(ref desc.value, (int)descsize);
                parser           = new Reports.ReportDescriptor(desc.value);
                reportDescriptor = desc.value; return(true);
            }
            finally
            {
                NativeMethods.retry(() => NativeMethods.close(handle));
            }
        }
示例#4
0
 public override HidStream Open()
 {
     var stream = new LinuxHidStream();
     try { stream.Init(_path, this); return stream; }
     catch { stream.Close(); throw; }
 }