1 | /*
|
---|
2 | * hidpi.h
|
---|
3 | *
|
---|
4 | * Public Interface for HID parsing library.
|
---|
5 | *
|
---|
6 | * This file is part of the mingw-w64 package.
|
---|
7 | *
|
---|
8 | * Contributors:
|
---|
9 | * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
|
---|
10 | * Extended by Kai Tietz
|
---|
11 | *
|
---|
12 | * THIS SOFTWARE IS NOT COPYRIGHTED
|
---|
13 | *
|
---|
14 | * This source code is offered for use in the public domain. You may
|
---|
15 | * use, modify or distribute it freely.
|
---|
16 | *
|
---|
17 | * This code is distributed in the hope that it will be useful but
|
---|
18 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
---|
19 | * DISCLAIMED. This includes but is not limited to warranties of
|
---|
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
21 | *
|
---|
22 | */
|
---|
23 |
|
---|
24 | #include <winapifamily.h>
|
---|
25 |
|
---|
26 | #ifndef __HIDPI_H__
|
---|
27 | #define __HIDPI_H__
|
---|
28 |
|
---|
29 | #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
|
---|
30 |
|
---|
31 | #include <pshpack4.h>
|
---|
32 |
|
---|
33 | #define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1)
|
---|
34 | #define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0)
|
---|
35 |
|
---|
36 | #define HidP_IsSameUsageAndPage(u1, u2) ((*((PULONG) &u1)) == (*((PULONG) &u2)))
|
---|
37 | #define HidP_SetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) HidP_SetUsages (Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)
|
---|
38 | #define HidP_UnsetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) HidP_UnsetUsages (Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)
|
---|
39 | #define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) HidP_GetUsages (Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)
|
---|
40 | #define HidP_GetButtonsEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe) HidP_GetUsagesEx (Rty, LCo, BLi, ULe, Ppd, Rep, RLe)
|
---|
41 |
|
---|
42 | typedef PUCHAR PHIDP_REPORT_DESCRIPTOR;
|
---|
43 | typedef struct _HIDP_PREPARSED_DATA *PHIDP_PREPARSED_DATA;
|
---|
44 |
|
---|
45 | typedef enum _HIDP_REPORT_TYPE {
|
---|
46 | HidP_Input,
|
---|
47 | HidP_Output,
|
---|
48 | HidP_Feature
|
---|
49 | } HIDP_REPORT_TYPE;
|
---|
50 |
|
---|
51 | typedef struct _USAGE_AND_PAGE {
|
---|
52 | USAGE Usage;
|
---|
53 | USAGE UsagePage;
|
---|
54 | } USAGE_AND_PAGE,*PUSAGE_AND_PAGE;
|
---|
55 |
|
---|
56 | typedef struct _HIDP_BUTTON_CAPS {
|
---|
57 | USAGE UsagePage;
|
---|
58 | UCHAR ReportID;
|
---|
59 | BOOLEAN IsAlias;
|
---|
60 | USHORT BitField;
|
---|
61 | USHORT LinkCollection;
|
---|
62 | USAGE LinkUsage;
|
---|
63 | USAGE LinkUsagePage;
|
---|
64 | BOOLEAN IsRange;
|
---|
65 | BOOLEAN IsStringRange;
|
---|
66 | BOOLEAN IsDesignatorRange;
|
---|
67 | BOOLEAN IsAbsolute;
|
---|
68 | ULONG Reserved[10];
|
---|
69 | __C89_NAMELESS union {
|
---|
70 | struct {
|
---|
71 | USAGE UsageMin, UsageMax;
|
---|
72 | USHORT StringMin, StringMax;
|
---|
73 | USHORT DesignatorMin, DesignatorMax;
|
---|
74 | USHORT DataIndexMin, DataIndexMax;
|
---|
75 | } Range;
|
---|
76 | struct {
|
---|
77 | USAGE Usage, Reserved1;
|
---|
78 | USHORT StringIndex, Reserved2;
|
---|
79 | USHORT DesignatorIndex, Reserved3;
|
---|
80 | USHORT DataIndex, Reserved4;
|
---|
81 | } NotRange;
|
---|
82 | };
|
---|
83 | } HIDP_BUTTON_CAPS,*PHIDP_BUTTON_CAPS;
|
---|
84 |
|
---|
85 | typedef struct _HIDP_VALUE_CAPS {
|
---|
86 | USAGE UsagePage;
|
---|
87 | UCHAR ReportID;
|
---|
88 | BOOLEAN IsAlias;
|
---|
89 | USHORT BitField;
|
---|
90 | USHORT LinkCollection;
|
---|
91 | USAGE LinkUsage;
|
---|
92 | USAGE LinkUsagePage;
|
---|
93 | BOOLEAN IsRange;
|
---|
94 | BOOLEAN IsStringRange;
|
---|
95 | BOOLEAN IsDesignatorRange;
|
---|
96 | BOOLEAN IsAbsolute;
|
---|
97 | BOOLEAN HasNull;
|
---|
98 | UCHAR Reserved;
|
---|
99 | USHORT BitSize;
|
---|
100 | USHORT ReportCount;
|
---|
101 | USHORT Reserved2[5];
|
---|
102 | ULONG UnitsExp;
|
---|
103 | ULONG Units;
|
---|
104 | LONG LogicalMin, LogicalMax;
|
---|
105 | LONG PhysicalMin, PhysicalMax;
|
---|
106 | __C89_NAMELESS union {
|
---|
107 | struct {
|
---|
108 | USAGE UsageMin, UsageMax;
|
---|
109 | USHORT StringMin, StringMax;
|
---|
110 | USHORT DesignatorMin, DesignatorMax;
|
---|
111 | USHORT DataIndexMin, DataIndexMax;
|
---|
112 | } Range;
|
---|
113 | struct {
|
---|
114 | USAGE Usage, Reserved1;
|
---|
115 | USHORT StringIndex, Reserved2;
|
---|
116 | USHORT DesignatorIndex, Reserved3;
|
---|
117 | USHORT DataIndex, Reserved4;
|
---|
118 | } NotRange;
|
---|
119 | };
|
---|
120 | } HIDP_VALUE_CAPS,*PHIDP_VALUE_CAPS;
|
---|
121 |
|
---|
122 | typedef struct _HIDP_LINK_COLLECTION_NODE {
|
---|
123 | USAGE LinkUsage;
|
---|
124 | USAGE LinkUsagePage;
|
---|
125 | USHORT Parent;
|
---|
126 | USHORT NumberOfChildren;
|
---|
127 | USHORT NextSibling;
|
---|
128 | USHORT FirstChild;
|
---|
129 | ULONG CollectionType: 8;
|
---|
130 | ULONG IsAlias : 1;
|
---|
131 | ULONG Reserved: 23;
|
---|
132 | PVOID UserContext;
|
---|
133 | } HIDP_LINK_COLLECTION_NODE,*PHIDP_LINK_COLLECTION_NODE;
|
---|
134 |
|
---|
135 | typedef struct _HIDP_CAPS {
|
---|
136 | USAGE Usage;
|
---|
137 | USAGE UsagePage;
|
---|
138 | USHORT InputReportByteLength;
|
---|
139 | USHORT OutputReportByteLength;
|
---|
140 | USHORT FeatureReportByteLength;
|
---|
141 | USHORT Reserved[17];
|
---|
142 | USHORT NumberLinkCollectionNodes;
|
---|
143 | USHORT NumberInputButtonCaps;
|
---|
144 | USHORT NumberInputValueCaps;
|
---|
145 | USHORT NumberInputDataIndices;
|
---|
146 | USHORT NumberOutputButtonCaps;
|
---|
147 | USHORT NumberOutputValueCaps;
|
---|
148 | USHORT NumberOutputDataIndices;
|
---|
149 | USHORT NumberFeatureButtonCaps;
|
---|
150 | USHORT NumberFeatureValueCaps;
|
---|
151 | USHORT NumberFeatureDataIndices;
|
---|
152 | } HIDP_CAPS,*PHIDP_CAPS;
|
---|
153 |
|
---|
154 | typedef struct _HIDP_DATA {
|
---|
155 | USHORT DataIndex;
|
---|
156 | USHORT Reserved;
|
---|
157 | __C89_NAMELESS union {
|
---|
158 | ULONG RawValue;
|
---|
159 | BOOLEAN On;
|
---|
160 | };
|
---|
161 | } HIDP_DATA,*PHIDP_DATA;
|
---|
162 |
|
---|
163 | typedef struct _HIDP_UNKNOWN_TOKEN {
|
---|
164 | UCHAR Token;
|
---|
165 | UCHAR Reserved[3];
|
---|
166 | ULONG BitField;
|
---|
167 | } HIDP_UNKNOWN_TOKEN,*PHIDP_UNKNOWN_TOKEN;
|
---|
168 |
|
---|
169 | typedef struct _HIDP_EXTENDED_ATTRIBUTES {
|
---|
170 | UCHAR NumGlobalUnknowns;
|
---|
171 | UCHAR Reserved [3];
|
---|
172 | PHIDP_UNKNOWN_TOKEN GlobalUnknowns;
|
---|
173 | ULONG Data [1];
|
---|
174 | } HIDP_EXTENDED_ATTRIBUTES,*PHIDP_EXTENDED_ATTRIBUTES;
|
---|
175 |
|
---|
176 | typedef enum _HIDP_KEYBOARD_DIRECTION {
|
---|
177 | HidP_Keyboard_Break,
|
---|
178 | HidP_Keyboard_Make
|
---|
179 | } HIDP_KEYBOARD_DIRECTION;
|
---|
180 |
|
---|
181 | typedef struct _HIDP_KEYBOARD_MODIFIER_STATE {
|
---|
182 | __C89_NAMELESS union {
|
---|
183 | struct {
|
---|
184 | ULONG LeftControl: 1;
|
---|
185 | ULONG LeftShift: 1;
|
---|
186 | ULONG LeftAlt: 1;
|
---|
187 | ULONG LeftGUI: 1;
|
---|
188 | ULONG RightControl: 1;
|
---|
189 | ULONG RightShift: 1;
|
---|
190 | ULONG RightAlt: 1;
|
---|
191 | ULONG RigthGUI: 1;
|
---|
192 | ULONG CapsLock: 1;
|
---|
193 | ULONG ScollLock: 1;
|
---|
194 | ULONG NumLock: 1;
|
---|
195 | ULONG Reserved: 21;
|
---|
196 | };
|
---|
197 | ULONG ul;
|
---|
198 | };
|
---|
199 | } HIDP_KEYBOARD_MODIFIER_STATE,*PHIDP_KEYBOARD_MODIFIER_STATE;
|
---|
200 |
|
---|
201 | typedef BOOLEAN (*PHIDP_INSERT_SCANCODES) (PVOID Context, PCHAR NewScanCodes, ULONG Length);
|
---|
202 |
|
---|
203 | NTSTATUS NTAPI HidP_GetCaps (PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities);
|
---|
204 | NTSTATUS NTAPI HidP_GetLinkCollectionNodes (PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, PULONG LinkCollectionNodesLength, PHIDP_PREPARSED_DATA PreparsedData);
|
---|
205 | NTSTATUS NTAPI HidP_GetSpecificButtonCaps (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
|
---|
206 | NTSTATUS NTAPI HidP_GetButtonCaps (HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
|
---|
207 | NTSTATUS NTAPI HidP_GetSpecificValueCaps (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
|
---|
208 | NTSTATUS NTAPI HidP_GetValueCaps (HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
|
---|
209 | NTSTATUS NTAPI HidP_GetExtendedAttributes (HIDP_REPORT_TYPE ReportType, USHORT DataIndex, PHIDP_PREPARSED_DATA PreparsedData, PHIDP_EXTENDED_ATTRIBUTES Attributes, PULONG LengthAttributes);
|
---|
210 | NTSTATUS NTAPI HidP_InitializeReportForID (HIDP_REPORT_TYPE ReportType, UCHAR ReportID, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
211 | NTSTATUS NTAPI HidP_SetData (HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
212 | NTSTATUS NTAPI HidP_GetData (HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
213 | ULONG NTAPI HidP_MaxDataListLength (HIDP_REPORT_TYPE ReportType, PHIDP_PREPARSED_DATA PreparsedData);
|
---|
214 | NTSTATUS NTAPI HidP_SetUsages (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, PUSAGE UsageList, PULONG UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
215 | NTSTATUS NTAPI HidP_UnsetUsages (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, PUSAGE UsageList, PULONG UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
216 | NTSTATUS NTAPI HidP_GetUsages (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, PUSAGE UsageList, PULONG UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
217 | NTSTATUS NTAPI HidP_GetUsagesEx (HIDP_REPORT_TYPE ReportType, USHORT LinkCollection, PUSAGE_AND_PAGE ButtonList, ULONG *UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
218 | ULONG NTAPI HidP_MaxUsageListLength (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, PHIDP_PREPARSED_DATA PreparsedData);
|
---|
219 | NTSTATUS NTAPI HidP_SetUsageValue (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, ULONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
220 | NTSTATUS NTAPI HidP_SetScaledUsageValue (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, LONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
221 | NTSTATUS NTAPI HidP_SetUsageValueArray (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PCHAR UsageValue, USHORT UsageValueByteLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
222 | NTSTATUS NTAPI HidP_GetUsageValue (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PULONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
223 | NTSTATUS NTAPI HidP_GetScaledUsageValue (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PLONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
224 | NTSTATUS NTAPI HidP_GetUsageValueArray (HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PCHAR UsageValue, USHORT UsageValueByteLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
|
---|
225 | NTSTATUS NTAPI HidP_UsageListDifference (PUSAGE PreviousUsageList, PUSAGE CurrentUsageList, PUSAGE BreakUsageList, PUSAGE MakeUsageList, ULONG UsageListLength);
|
---|
226 | NTSTATUS NTAPI HidP_UsageAndPageListDifference (PUSAGE_AND_PAGE PreviousUsageList, PUSAGE_AND_PAGE CurrentUsageList, PUSAGE_AND_PAGE BreakUsageList, PUSAGE_AND_PAGE MakeUsageList, ULONG UsageListLength);
|
---|
227 | NTSTATUS NTAPI HidP_TranslateUsageAndPagesToI8042ScanCodes (PUSAGE_AND_PAGE ChangedUsageList, ULONG UsageListLength, HIDP_KEYBOARD_DIRECTION KeyAction, PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, PHIDP_INSERT_SCANCODES InsertCodesProcedure, PVOID InsertCodesContext);
|
---|
228 | NTSTATUS NTAPI HidP_TranslateUsagesToI8042ScanCodes (PUSAGE ChangedUsageList, ULONG UsageListLength, HIDP_KEYBOARD_DIRECTION KeyAction, PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, PHIDP_INSERT_SCANCODES InsertCodesProcedure, PVOID InsertCodesContext);
|
---|
229 |
|
---|
230 | #ifndef FACILITY_HID_ERROR_CODE
|
---|
231 | #define FACILITY_HID_ERROR_CODE 0x11
|
---|
232 | #endif
|
---|
233 |
|
---|
234 | #define HIDP_ERROR_CODES(SEV, CODE) ((NTSTATUS) (((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE)))
|
---|
235 |
|
---|
236 | #define HIDP_STATUS_SUCCESS (HIDP_ERROR_CODES (0x0, 0))
|
---|
237 | #define HIDP_STATUS_NULL (HIDP_ERROR_CODES (0x8, 1))
|
---|
238 | #define HIDP_STATUS_INVALID_PREPARSED_DATA (HIDP_ERROR_CODES (0xc, 1))
|
---|
239 | #define HIDP_STATUS_INVALID_REPORT_TYPE (HIDP_ERROR_CODES (0xc, 2))
|
---|
240 | #define HIDP_STATUS_INVALID_REPORT_LENGTH (HIDP_ERROR_CODES (0xc, 3))
|
---|
241 | #define HIDP_STATUS_USAGE_NOT_FOUND (HIDP_ERROR_CODES (0xc, 4))
|
---|
242 | #define HIDP_STATUS_VALUE_OUT_OF_RANGE (HIDP_ERROR_CODES (0xc, 5))
|
---|
243 | #define HIDP_STATUS_BAD_LOG_PHY_VALUES (HIDP_ERROR_CODES (0xc, 6))
|
---|
244 | #define HIDP_STATUS_BUFFER_TOO_SMALL (HIDP_ERROR_CODES (0xc, 7))
|
---|
245 | #define HIDP_STATUS_INTERNAL_ERROR (HIDP_ERROR_CODES (0xc, 8))
|
---|
246 | #define HIDP_STATUS_I8042_TRANS_UNKNOWN (HIDP_ERROR_CODES (0xc, 9))
|
---|
247 | #define HIDP_STATUS_INCOMPATIBLE_REPORT_ID (HIDP_ERROR_CODES (0xc, 0xa))
|
---|
248 | #define HIDP_STATUS_NOT_VALUE_ARRAY (HIDP_ERROR_CODES (0xc, 0xb))
|
---|
249 | #define HIDP_STATUS_IS_VALUE_ARRAY (HIDP_ERROR_CODES (0xc, 0xc))
|
---|
250 | #define HIDP_STATUS_DATA_INDEX_NOT_FOUND (HIDP_ERROR_CODES (0xc, 0xd))
|
---|
251 | #define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE (HIDP_ERROR_CODES (0xc, 0xe))
|
---|
252 | #define HIDP_STATUS_BUTTON_NOT_PRESSED (HIDP_ERROR_CODES (0xc, 0xf))
|
---|
253 | #define HIDP_STATUS_REPORT_DOES_NOT_EXIST (HIDP_ERROR_CODES (0xc, 0x10))
|
---|
254 | #define HIDP_STATUS_NOT_IMPLEMENTED (HIDP_ERROR_CODES (0xc, 0x20))
|
---|
255 |
|
---|
256 | #define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN
|
---|
257 |
|
---|
258 | #include <poppack.h>
|
---|
259 |
|
---|
260 | #endif
|
---|
261 | #endif
|
---|