-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathRawInputHid.cs
28 lines (20 loc) · 893 Bytes
/
RawInputHid.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
using System;
using Linearstar.RawInput.Native;
namespace Linearstar.RawInput
{
public class RawInputHid : RawInputDevice
{
readonly Lazy<HidReader> hidReader;
public override HidUsageAndPage UsageAndPage => DeviceInfo.Hid.UsageAndPage;
public override int VendorId => DeviceInfo.Hid.VendorId;
public override int ProductId => DeviceInfo.Hid.ProductId;
public int Version => DeviceInfo.Hid.VersionNumber;
public HidReader Reader => hidReader.Value;
public RawInputHid(RawInputDeviceHandle device, RawInputDeviceInfo deviceInfo)
: base(device, deviceInfo)
{
if (deviceInfo.Type != RawInputDeviceType.Hid) throw new ArgumentException($"Device type must be {RawInputDeviceType.Hid}.", nameof(deviceInfo));
hidReader = new Lazy<HidReader>(() => new HidReader(GetPreparsedData()));
}
}
}