예제 #1
0
 /// <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);
     }
 }
예제 #2
0
 public Device(ReportCollection application, Hidraw hidraw)
 {
     this.application = application ?? throw new ArgumentNullException(nameof(application));
     this.hidraw      = hidraw ?? throw new ArgumentNullException(nameof(hidraw));
 }