-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathRawInputKeyboard.cs
33 lines (27 loc) · 1.4 KB
/
RawInputKeyboard.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
using System;
using System.Globalization;
using Linearstar.Windows.RawInput.Native;
namespace Linearstar.Windows.RawInput;
public class RawInputKeyboard : RawInputDevice
{
public override HidUsageAndPage UsageAndPage => HidUsageAndPage.Keyboard;
public override int VendorId =>
DevicePath?.Contains("VID_") == true
? int.Parse(DevicePath.Substring(DevicePath.IndexOf("VID_", StringComparison.Ordinal) + 4, 4), NumberStyles.HexNumber)
: 0;
public override int ProductId =>
DevicePath?.Contains("PID_") == true
? int.Parse(DevicePath.Substring(DevicePath.IndexOf("PID_", StringComparison.Ordinal) + 4, 4), NumberStyles.HexNumber)
: 0;
public int KeyboardType => DeviceInfo.Keyboard.KeyboardType;
public int KeyboardSubType => DeviceInfo.Keyboard.KeyboardSubType;
public int KeyboardMode => DeviceInfo.Keyboard.KeyboardMode;
public int FunctionKeyCount => DeviceInfo.Keyboard.FunctionKeyCount;
public int IndicatorCount => DeviceInfo.Keyboard.IndicatorCount;
public int TotalKeyCount => DeviceInfo.Keyboard.TotalKeyCount;
internal RawInputKeyboard(RawInputDeviceHandle device, RawInputDeviceInfo deviceInfo)
: base(device, deviceInfo)
{
if (deviceInfo.Type != RawInputDeviceType.Keyboard) throw new ArgumentException($"Device type must be {RawInputDeviceType.Keyboard}", nameof(deviceInfo));
}
}