/// <summary> /// Tries to get an HID device for the udev device. /// </summary> /// <param name="hidrawUdev">The udev device for an hidraw node</param> /// <returns>The HID device or <c>null</c> if we don't have permission to use the hidraw device.</return> static IEnumerable <Device> TryGetHidDevices(Dandy.Linux.Udev.Device hidrawUdev) { try { var hidUdev = hidrawUdev.TryGetAncestor("hid"); var hidraw = new Hidraw(hidrawUdev.DevNode); return(hidraw.GetReports().Select(x => new Device(x, hidraw))); } catch (UnauthorizedAccessException) { return(null); } }
public Device(ReportCollection application, Hidraw hidraw) { this.application = application ?? throw new ArgumentNullException(nameof(application)); this.hidraw = hidraw ?? throw new ArgumentNullException(nameof(hidraw)); }