-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathHidButton.cs
35 lines (25 loc) · 1.07 KB
/
HidButton.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Linq;
using Linearstar.Windows.RawInput.Native;
namespace Linearstar.Windows.RawInput;
public class HidButton
{
internal readonly HidReader reader;
internal readonly HidPButtonCaps buttonCaps;
public int ReportId => buttonCaps.ReportID;
public HidUsageAndPage UsageAndPage { get; }
public HidUsageAndPage LinkUsageAndPage => new(buttonCaps.LinkUsagePage, buttonCaps.LinkUsage);
public int LinkCollection => buttonCaps.LinkCollection;
internal HidButton(HidReader reader, HidPButtonCaps buttonCaps, ushort usage)
{
this.reader = reader;
this.buttonCaps = buttonCaps;
UsageAndPage = new HidUsageAndPage(buttonCaps.UsagePage, usage);
}
public HidButtonState GetState(ArraySegment<byte> report) =>
GetState(report.ToArray(), report.Count);
public HidButtonState GetState(byte[] report, int reportLength) =>
new(this, report, reportLength);
public override string ToString() =>
$"{ReportId}, {LinkCollection}, Link: {{{LinkUsageAndPage}}}, Usage: {{{UsageAndPage}}}";
}