sl@0
|
1 |
using Microsoft.Win32.SafeHandles;
|
sl@0
|
2 |
using System;
|
sl@0
|
3 |
using System.Runtime.InteropServices;
|
sl@0
|
4 |
|
sl@0
|
5 |
namespace GenericHid
|
sl@0
|
6 |
{
|
sl@0
|
7 |
/// <summary>
|
sl@0
|
8 |
/// API declarations for HID communications.
|
sl@0
|
9 |
/// </summary>
|
sl@0
|
10 |
internal sealed partial class Hid
|
sl@0
|
11 |
{
|
sl@0
|
12 |
internal static class NativeMethods
|
sl@0
|
13 |
{
|
sl@0
|
14 |
// from hidpi.h
|
sl@0
|
15 |
// Typedef enum defines a set of integer constants for HidP_Report_Type
|
sl@0
|
16 |
|
sl@0
|
17 |
internal const Int16 HidP_Input = 0;
|
sl@0
|
18 |
internal const Int16 HidP_Output = 1;
|
sl@0
|
19 |
internal const Int16 HidP_Feature = 2;
|
sl@0
|
20 |
|
sl@0
|
21 |
[StructLayout(LayoutKind.Sequential)]
|
sl@0
|
22 |
internal struct HIDD_ATTRIBUTES
|
sl@0
|
23 |
{
|
sl@0
|
24 |
internal Int32 Size;
|
sl@0
|
25 |
internal UInt16 VendorID;
|
sl@0
|
26 |
internal UInt16 ProductID;
|
sl@0
|
27 |
internal UInt16 VersionNumber;
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
internal struct HIDP_CAPS
|
sl@0
|
31 |
{
|
sl@0
|
32 |
internal Int16 Usage;
|
sl@0
|
33 |
internal Int16 UsagePage;
|
sl@0
|
34 |
internal Int16 InputReportByteLength;
|
sl@0
|
35 |
internal Int16 OutputReportByteLength;
|
sl@0
|
36 |
internal Int16 FeatureReportByteLength;
|
sl@0
|
37 |
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] internal Int16[] Reserved;
|
sl@0
|
38 |
internal Int16 NumberLinkCollectionNodes;
|
sl@0
|
39 |
internal Int16 NumberInputButtonCaps;
|
sl@0
|
40 |
internal Int16 NumberInputValueCaps;
|
sl@0
|
41 |
internal Int16 NumberInputDataIndices;
|
sl@0
|
42 |
internal Int16 NumberOutputButtonCaps;
|
sl@0
|
43 |
internal Int16 NumberOutputValueCaps;
|
sl@0
|
44 |
internal Int16 NumberOutputDataIndices;
|
sl@0
|
45 |
internal Int16 NumberFeatureButtonCaps;
|
sl@0
|
46 |
internal Int16 NumberFeatureValueCaps;
|
sl@0
|
47 |
internal Int16 NumberFeatureDataIndices;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
// If IsRange is false, UsageMin is the Usage and UsageMax is unused.
|
sl@0
|
51 |
// If IsStringRange is false, StringMin is the String index and StringMax is unused.
|
sl@0
|
52 |
// If IsDesignatorRange is false, DesignatorMin is the designator index and DesignatorMax is unused.
|
sl@0
|
53 |
|
sl@0
|
54 |
internal struct HidP_Value_Caps
|
sl@0
|
55 |
{
|
sl@0
|
56 |
internal Int16 UsagePage;
|
sl@0
|
57 |
internal Byte ReportID;
|
sl@0
|
58 |
internal Int32 IsAlias;
|
sl@0
|
59 |
internal Int16 BitField;
|
sl@0
|
60 |
internal Int16 LinkCollection;
|
sl@0
|
61 |
internal Int16 LinkUsage;
|
sl@0
|
62 |
internal Int16 LinkUsagePage;
|
sl@0
|
63 |
internal Int32 IsRange;
|
sl@0
|
64 |
internal Int32 IsStringRange;
|
sl@0
|
65 |
internal Int32 IsDesignatorRange;
|
sl@0
|
66 |
internal Int32 IsAbsolute;
|
sl@0
|
67 |
internal Int32 HasNull;
|
sl@0
|
68 |
internal Byte Reserved;
|
sl@0
|
69 |
internal Int16 BitSize;
|
sl@0
|
70 |
internal Int16 ReportCount;
|
sl@0
|
71 |
internal Int16 Reserved2;
|
sl@0
|
72 |
internal Int16 Reserved3;
|
sl@0
|
73 |
internal Int16 Reserved4;
|
sl@0
|
74 |
internal Int16 Reserved5;
|
sl@0
|
75 |
internal Int16 Reserved6;
|
sl@0
|
76 |
internal Int32 LogicalMin;
|
sl@0
|
77 |
internal Int32 LogicalMax;
|
sl@0
|
78 |
internal Int32 PhysicalMin;
|
sl@0
|
79 |
internal Int32 PhysicalMax;
|
sl@0
|
80 |
internal Int16 UsageMin;
|
sl@0
|
81 |
internal Int16 UsageMax;
|
sl@0
|
82 |
internal Int16 StringMin;
|
sl@0
|
83 |
internal Int16 StringMax;
|
sl@0
|
84 |
internal Int16 DesignatorMin;
|
sl@0
|
85 |
internal Int16 DesignatorMax;
|
sl@0
|
86 |
internal Int16 DataIndexMin;
|
sl@0
|
87 |
internal Int16 DataIndexMax;
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
91 |
internal static extern Boolean HidD_FlushQueue(SafeFileHandle HidDeviceObject);
|
sl@0
|
92 |
|
sl@0
|
93 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
94 |
internal static extern Boolean HidD_FreePreparsedData(IntPtr PreparsedData);
|
sl@0
|
95 |
|
sl@0
|
96 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
97 |
internal static extern Boolean HidD_GetAttributes(SafeFileHandle HidDeviceObject, ref HIDD_ATTRIBUTES Attributes);
|
sl@0
|
98 |
|
sl@0
|
99 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
100 |
internal static extern Boolean HidD_GetFeature(SafeFileHandle HidDeviceObject, Byte[] lpReportBuffer,
|
sl@0
|
101 |
Int32 ReportBufferLength);
|
sl@0
|
102 |
|
sl@0
|
103 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
104 |
internal static extern Boolean HidD_GetInputReport(SafeFileHandle HidDeviceObject, Byte[] lpReportBuffer,
|
sl@0
|
105 |
Int32 ReportBufferLength);
|
sl@0
|
106 |
|
sl@0
|
107 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
108 |
internal static extern void HidD_GetHidGuid(ref Guid HidGuid);
|
sl@0
|
109 |
|
sl@0
|
110 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
111 |
internal static extern Boolean HidD_GetNumInputBuffers(SafeFileHandle HidDeviceObject, ref Int32 NumberBuffers);
|
sl@0
|
112 |
|
sl@0
|
113 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
114 |
internal static extern Boolean HidD_GetPreparsedData(SafeFileHandle HidDeviceObject, ref IntPtr PreparsedData);
|
sl@0
|
115 |
|
sl@0
|
116 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
117 |
internal static extern Boolean HidD_SetFeature(SafeFileHandle HidDeviceObject, Byte[] lpReportBuffer,
|
sl@0
|
118 |
Int32 ReportBufferLength);
|
sl@0
|
119 |
|
sl@0
|
120 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
121 |
internal static extern Boolean HidD_SetNumInputBuffers(SafeFileHandle HidDeviceObject, Int32 NumberBuffers);
|
sl@0
|
122 |
|
sl@0
|
123 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
124 |
internal static extern Boolean HidD_SetOutputReport(SafeFileHandle HidDeviceObject, Byte[] lpReportBuffer,
|
sl@0
|
125 |
Int32 ReportBufferLength);
|
sl@0
|
126 |
|
sl@0
|
127 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
128 |
internal static extern Int32 HidP_GetCaps(IntPtr PreparsedData, ref HIDP_CAPS Capabilities);
|
sl@0
|
129 |
|
sl@0
|
130 |
[DllImport("hid.dll", SetLastError = true)]
|
sl@0
|
131 |
internal static extern Int32 HidP_GetValueCaps(Int32 ReportType, Byte[] ValueCaps, ref Int32 ValueCapsLength,
|
sl@0
|
132 |
IntPtr PreparsedData);
|
sl@0
|
133 |
}
|
sl@0
|
134 |
}
|
sl@0
|
135 |
}
|