Skip to content

Commit c91f5e2

Browse files
committed
HidDevice: add GetTopLevelUsage to simply retrieve the top level collection type
Signed-off-by: Benedek Kupper <kupper.benedek@gmail.com>
1 parent b7d4490 commit c91f5e2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

HidSharp/HidDevice.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ under the License. */
1919
using System.ComponentModel;
2020
using System.Globalization;
2121
using System.IO;
22+
using System.Linq;
2223
using System.Runtime.InteropServices;
2324
using HidSharp.Reports;
2425

@@ -99,6 +100,13 @@ public virtual byte[] GetRawReportDescriptor()
99100
throw new NotSupportedException(); // Windows reconstructs it. Linux can retrieve it. MacOS 10.8+ can retrieve it as well.
100101
}
101102

103+
public uint GetTopLevelUsage()
104+
{
105+
var reportDescriptor = GetReportDescriptor();
106+
var ditem = reportDescriptor.DeviceItems.FirstOrDefault();
107+
return ditem.Usages.GetAllValues().FirstOrDefault();
108+
}
109+
102110
/*
103111
TODO
104112
public virtual string[] GetDevicePathHierarchy()

0 commit comments

Comments
 (0)