ReactOS 0.4.15-dev-5667-ged97270
hidparser.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NTSTATUS NTAPI HidParser_GetCollectionDescription (IN PHIDP_REPORT_DESCRIPTOR ReportDesc, IN ULONG DescLength, IN POOL_TYPE PoolType, OUT PHIDP_DEVICE_DESC DeviceDescription)
 
VOID NTAPI HidParser_FreeCollectionDescription (IN PHIDP_DEVICE_DESC DeviceDescription)
 
HIDAPI NTSTATUS NTAPI HidParser_GetCaps (IN PVOID CollectionContext, OUT PHIDP_CAPS Capabilities)
 
HIDAPI NTSTATUS NTAPI HidParser_GetSpecificValueCaps (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection, IN USAGE Usage, OUT PHIDP_VALUE_CAPS ValueCaps, IN OUT PUSHORT ValueCapsLength)
 
HIDAPI NTSTATUS NTAPI HidParser_GetButtonCaps (IN PVOID CollectionContext, HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength)
 
HIDAPI NTSTATUS NTAPI HidParser_GetSpecificButtonCaps (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection, IN USAGE Usage, OUT PHIDP_BUTTON_CAPS ButtonCaps, IN OUT PULONG ButtonCapsLength)
 
HIDAPI NTSTATUS NTAPI HidParser_GetScaledUsageValue (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection OPTIONAL, IN USAGE Usage, OUT PLONG UsageValue, IN PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_GetData (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, OUT PHIDP_DATA DataList, IN OUT PULONG DataLength, IN PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_GetExtendedAttributes (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USHORT DataIndex, OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, IN OUT PULONG LengthAttributes)
 
HIDAPI NTSTATUS NTAPI HidParser_GetLinkCollectionNodes (IN PVOID CollectionContext, OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, IN OUT PULONG LinkCollectionNodesLength)
 
HIDAPI NTSTATUS NTAPI HidParser_GetUsageValue (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection, IN USAGE Usage, OUT PULONG UsageValue, IN PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_UsageListDifference (IN PUSAGE PreviousUsageList, IN PUSAGE CurrentUsageList, OUT PUSAGE BreakUsageList, OUT PUSAGE MakeUsageList, IN ULONG UsageListLength)
 
HIDAPI ULONG NTAPI HidParser_MaxUsageListLength (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage OPTIONAL)
 
HIDAPI NTSTATUS NTAPI HidParser_GetUsages (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection OPTIONAL, OUT USAGE *UsageList, IN OUT ULONG *UsageLength, IN PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_GetUsagesEx (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USHORT LinkCollection, OUT PUSAGE_AND_PAGE ButtonList, IN OUT ULONG *UsageLength, IN PCHAR Report, IN ULONG ReportLength)
 
NTSTATUS NTAPI HidParser_SysPowerEvent (IN PVOID CollectionContext, IN PCHAR HidPacket, IN USHORT HidPacketLength, OUT PULONG OutputBuffer)
 
NTSTATUS NTAPI HidParser_SysPowerCaps (IN PVOID CollectionContext, OUT PULONG OutputBuffer)
 
HIDAPI NTSTATUS NTAPI HidParser_GetUsageValueArray (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection OPTIONAL, IN USAGE Usage, OUT PCHAR UsageValue, IN USHORT UsageValueByteLength, IN PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_UsageAndPageListDifference (IN PUSAGE_AND_PAGE PreviousUsageList, IN PUSAGE_AND_PAGE CurrentUsageList, OUT PUSAGE_AND_PAGE BreakUsageList, OUT PUSAGE_AND_PAGE MakeUsageList, IN ULONG UsageListLength)
 
HIDAPI NTSTATUS NTAPI HidParser_UnsetUsages (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection, IN PUSAGE UsageList, IN OUT PULONG UsageLength, IN OUT PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_TranslateUsagesToI8042ScanCodes (IN PUSAGE ChangedUsageList, IN ULONG UsageListLength, IN HIDP_KEYBOARD_DIRECTION KeyAction, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, IN PHIDP_INSERT_SCANCODES InsertCodesProcedure, IN PVOID InsertCodesContext)
 
HIDAPI NTSTATUS NTAPI HidParser_TranslateUsageAndPagesToI8042ScanCodes (IN PUSAGE_AND_PAGE ChangedUsageList, IN ULONG UsageListLength, IN HIDP_KEYBOARD_DIRECTION KeyAction, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, IN PHIDP_INSERT_SCANCODES InsertCodesProcedure, IN PVOID InsertCodesContext)
 
HIDAPI NTSTATUS NTAPI HidParser_SetUsages (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection, IN PUSAGE UsageList, IN OUT PULONG UsageLength, IN OUT PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_SetUsageValueArray (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection OPTIONAL, IN USAGE Usage, IN PCHAR UsageValue, IN USHORT UsageValueByteLength, OUT PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_SetUsageValue (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection, IN USAGE Usage, IN ULONG UsageValue, IN OUT PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_SetScaledUsageValue (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection OPTIONAL, IN USAGE Usage, IN LONG UsageValue, IN OUT PCHAR Report, IN ULONG ReportLength)
 
HIDAPI NTSTATUS NTAPI HidParser_SetData (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN PHIDP_DATA DataList, IN OUT PULONG DataLength, IN OUT PCHAR Report, IN ULONG ReportLength)
 
HIDAPI ULONG NTAPI HidParser_MaxDataListLength (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType)
 
HIDAPI NTSTATUS NTAPI HidParser_InitializeReportForID (IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN UCHAR ReportID, IN OUT PCHAR Report, IN ULONG ReportLength)
 
NTSTATUS HidParser_TranslateKbdUsage (IN USAGE Usage, IN HIDP_KEYBOARD_DIRECTION KeyAction, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, IN PHIDP_INSERT_SCANCODES InsertCodesProcedure, IN PVOID InsertCodesContext)
 
NTSTATUS HidParser_TranslateCustUsage (IN USAGE Usage, IN HIDP_KEYBOARD_DIRECTION KeyAction, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, IN PHIDP_INSERT_SCANCODES InsertCodesProcedure, IN PVOID InsertCodesContext)
 
HIDAPI NTSTATUS NTAPI HidParser_GetValueCaps (IN PVOID CollectionContext, HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PULONG ValueCapsLength)
 

Function Documentation

◆ HidParser_FreeCollectionDescription()

VOID NTAPI HidParser_FreeCollectionDescription ( IN PHIDP_DEVICE_DESC  DeviceDescription)

Definition at line 163 of file hidparser.c.

165{
166 ULONG Index;
167
168 //
169 // first free all context
170 //
171 for(Index = 0; Index < DeviceDescription->CollectionDescLength; Index++)
172 {
173 //
174 // free collection context
175 //
176 FreeFunction(DeviceDescription->CollectionDesc[Index].PreparsedData);
177 }
178
179 //
180 // now free collection description
181 //
182 FreeFunction(DeviceDescription->CollectionDesc);
183
184 //
185 // free report description
186 //
188}
VOID NTAPI FreeFunction(IN PVOID Item)
Definition: hid.c:53
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432

Referenced by HidP_FreeCollectionDescription().

◆ HidParser_GetButtonCaps()

HIDAPI NTSTATUS NTAPI HidParser_GetButtonCaps ( IN PVOID  CollectionContext,
HIDP_REPORT_TYPE  ReportType,
PHIDP_BUTTON_CAPS  ButtonCaps,
PUSHORT  ButtonCapsLength 
)

◆ HidParser_GetCaps()

HIDAPI NTSTATUS NTAPI HidParser_GetCaps ( IN PVOID  CollectionContext,
OUT PHIDP_CAPS  Capabilities 
)

Definition at line 193 of file hidparser.c.

196{
197 //
198 // zero capabilities
199 //
201
202 //
203 // init capabilities
204 //
209
210 //
211 // always pre-prend report id
212 //
216
217 //
218 // get number of link collection nodes
219 //
221
222 //
223 // get data indices
224 //
228
229 //
230 // get value caps
231 //
235
236
237 //
238 // get button caps
239 //
243
244 //
245 // done
246 //
247 return HIDP_STATUS_SUCCESS;
248}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID NTAPI ZeroFunction(IN PVOID Item, IN ULONG ItemSize)
Definition: hid.c:61
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
#define HIDP_STATUS_SUCCESS
Definition: hidpi.h:248
ULONG HidParser_GetReportItemCountFromReportType(IN PVOID CollectionContext, IN UCHAR ReportType)
Definition: api.c:132
ULONG HidParser_GetReportLength(IN PVOID CollectionContext, IN UCHAR ReportType)
Definition: api.c:93
ULONG HidParser_GetReportItemTypeCountFromReportType(IN PVOID CollectionContext, IN UCHAR ReportType, IN ULONG bData)
Definition: api.c:158
NTSTATUS HidParser_GetCollectionUsagePage(IN PVOID CollectionContext, OUT PUSHORT Usage, OUT PUSHORT UsagePage)
Definition: api.c:65
ULONG HidParser_GetTotalCollectionCount(IN PVOID Context)
Definition: context.c:330
USHORT NumberLinkCollectionNodes
Definition: hidpi.h:156
USHORT NumberInputButtonCaps
Definition: hidpi.h:157
USHORT NumberOutputButtonCaps
Definition: hidpi.h:160
USHORT NumberFeatureButtonCaps
Definition: hidpi.h:163
USAGE UsagePage
Definition: hidpi.h:151
USHORT NumberInputValueCaps
Definition: hidpi.h:158
USHORT FeatureReportByteLength
Definition: hidpi.h:154
USHORT NumberOutputValueCaps
Definition: hidpi.h:161
USHORT OutputReportByteLength
Definition: hidpi.h:153
USHORT InputReportByteLength
Definition: hidpi.h:152
USHORT NumberFeatureDataIndices
Definition: hidpi.h:165
USHORT NumberInputDataIndices
Definition: hidpi.h:159
USHORT NumberFeatureValueCaps
Definition: hidpi.h:164
USHORT NumberOutputDataIndices
Definition: hidpi.h:162
USAGE Usage
Definition: hidpi.h:150
#define HID_REPORT_TYPE_INPUT
#define HID_REPORT_TYPE_FEATURE
#define HID_REPORT_TYPE_OUTPUT

Referenced by HidP_GetCaps().

◆ HidParser_GetCollectionDescription()

NTSTATUS NTAPI HidParser_GetCollectionDescription ( IN PHIDP_REPORT_DESCRIPTOR  ReportDesc,
IN ULONG  DescLength,
IN POOL_TYPE  PoolType,
OUT PHIDP_DEVICE_DESC  DeviceDescription 
)

Definition at line 18 of file hidparser.c.

23{
24 NTSTATUS ParserStatus;
25 ULONG CollectionCount;
27 PVOID ParserContext;
28
29 //
30 // first parse the report descriptor
31 //
32 ParserStatus = HidParser_ParseReportDescriptor(ReportDesc, DescLength, &ParserContext);
33 if (ParserStatus != HIDP_STATUS_SUCCESS)
34 {
35 //
36 // failed to parse report descriptor
37 //
38 DebugFunction("[HIDPARSER] Failed to parse report descriptor with %x\n", ParserStatus);
39 return ParserStatus;
40 }
41
42 //
43 // get collection count
44 //
45 CollectionCount = HidParser_NumberOfTopCollections(ParserContext);
46 if (CollectionCount == 0)
47 {
48 //
49 // no top level collections found
50 //
53 }
54
55 //
56 // zero description
57 //
59
60 //
61 // allocate collection
62 //
63 DeviceDescription->CollectionDesc = (PHIDP_COLLECTION_DESC)AllocFunction(sizeof(HIDP_COLLECTION_DESC) * CollectionCount);
64 if (!DeviceDescription->CollectionDesc)
65 {
66 //
67 // no memory
68 //
70 }
71
72 //
73 // allocate report description
74 //
75 DeviceDescription->ReportIDs = (PHIDP_REPORT_IDS)AllocFunction(sizeof(HIDP_REPORT_IDS) * CollectionCount);
76 if (!DeviceDescription->ReportIDs)
77 {
78 //
79 // no memory
80 //
81 FreeFunction(DeviceDescription->CollectionDesc);
83 }
84
85 for(Index = 0; Index < CollectionCount; Index++)
86 {
87 //
88 // set preparsed data length
89 //
90 DeviceDescription->CollectionDesc[Index].PreparsedDataLength = HidParser_GetContextSize(ParserContext, Index);
91 ParserStatus = HidParser_BuildContext(ParserContext, Index, DeviceDescription->CollectionDesc[Index].PreparsedDataLength, (PVOID*)&DeviceDescription->CollectionDesc[Index].PreparsedData);
92 if (ParserStatus != HIDP_STATUS_SUCCESS)
93 {
94 //
95 // no memory
96 //
97 FreeFunction(DeviceDescription->CollectionDesc);
99 return ParserStatus;
100 }
101
102 //
103 // init report description
104 //
105 DeviceDescription->ReportIDs[Index].CollectionNumber = Index + 1;
106 DeviceDescription->ReportIDs[Index].ReportID = Index; //FIXME
107 DeviceDescription->ReportIDs[Index].InputLength = HidParser_GetReportLength((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_INPUT);
108 DeviceDescription->ReportIDs[Index].OutputLength = HidParser_GetReportLength((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_OUTPUT);
109 DeviceDescription->ReportIDs[Index].FeatureLength = HidParser_GetReportLength((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_FEATURE);
110
111
112 DeviceDescription->ReportIDs[Index].InputLength += (HidParser_UsesReportId((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_INPUT) ? 1 : 0);
113 DeviceDescription->ReportIDs[Index].OutputLength += (HidParser_UsesReportId((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_OUTPUT) ? 1 : 0);
114 DeviceDescription->ReportIDs[Index].FeatureLength += (HidParser_UsesReportId((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_FEATURE) ? 1 : 0);
115
116
117 //
118 // init collection description
119 //
120 DeviceDescription->CollectionDesc[Index].CollectionNumber = Index + 1;
121
122 //
123 // get collection usage page
124 //
125 ParserStatus = HidParser_GetCollectionUsagePage((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, &DeviceDescription->CollectionDesc[Index].Usage, &DeviceDescription->CollectionDesc[Index].UsagePage);
126 if (ParserStatus != HIDP_STATUS_SUCCESS)
127 {
128 // collection not found
129 FreeFunction(DeviceDescription->CollectionDesc);
131 return ParserStatus;
132 }
133
134 //
135 // windows seems to prepend the report id, regardless if it is required
136 //
137 DeviceDescription->CollectionDesc[Index].CollectionNumber = Index + 1;
138 DeviceDescription->CollectionDesc[Index].InputLength = DeviceDescription->ReportIDs[Index].InputLength;
139 DeviceDescription->CollectionDesc[Index].OutputLength = DeviceDescription->ReportIDs[Index].OutputLength;
140 DeviceDescription->CollectionDesc[Index].FeatureLength = DeviceDescription->ReportIDs[Index].FeatureLength;
141
142 DeviceDescription->CollectionDesc[Index].InputLength += (HidParser_UsesReportId((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_INPUT) == FALSE ? 1 : 0);
143 DeviceDescription->CollectionDesc[Index].OutputLength += (HidParser_UsesReportId((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_OUTPUT) == FALSE ? 1 : 0);
144 DeviceDescription->CollectionDesc[Index].FeatureLength += (HidParser_UsesReportId((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_FEATURE) == FALSE ? 1 : 0);
145
146
147 }
148
149 //
150 // store collection & report count
151 //
152 DeviceDescription->CollectionDescLength = CollectionCount;
153 DeviceDescription->ReportIDsLength = CollectionCount;
154
155 //
156 // done
157 //
158 return STATUS_SUCCESS;
159}
LONG NTSTATUS
Definition: precomp.h:26
VOID __cdecl DebugFunction(IN LPCSTR FormatStr,...)
Definition: hid.c:80
PVOID NTAPI AllocFunction(IN ULONG ItemSize)
Definition: hid.c:45
struct _HIDP_COLLECTION_DESC * PHIDP_COLLECTION_DESC
struct _HIDP_REPORT_IDS * PHIDP_REPORT_IDS
#define ASSERT(a)
Definition: mode.c:44
ULONG HidParser_UsesReportId(IN PVOID CollectionContext, IN UCHAR ReportType)
Definition: api.c:524
ULONG HidParser_GetContextSize(IN PVOID ParserContext, IN ULONG CollectionIndex)
Definition: parser.c:1351
NTSTATUS HidParser_BuildContext(IN PVOID ParserContext, IN ULONG CollectionIndex, IN ULONG ContextSize, OUT PVOID *CollectionContext)
Definition: parser.c:1303
NTSTATUS HidParser_ParseReportDescriptor(IN PUCHAR ReportDescriptor, IN ULONG ReportLength, OUT PVOID *OutParser)
Definition: parser.c:707
ULONG HidParser_NumberOfTopCollections(IN PVOID ParserCtx)
Definition: parser.c:1279
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_NO_DATA_DETECTED
Definition: udferr_usr.h:131
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by HidP_GetCollectionDescription().

◆ HidParser_GetData()

HIDAPI NTSTATUS NTAPI HidParser_GetData ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
OUT PHIDP_DATA  DataList,
IN OUT PULONG  DataLength,
IN PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 836 of file hidparser.c.

843{
845 ASSERT(FALSE);
847}
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

◆ HidParser_GetExtendedAttributes()

HIDAPI NTSTATUS NTAPI HidParser_GetExtendedAttributes ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USHORT  DataIndex,
OUT PHIDP_EXTENDED_ATTRIBUTES  Attributes,
IN OUT PULONG  LengthAttributes 
)

Definition at line 852 of file hidparser.c.

858{
860 ASSERT(FALSE);
862}

◆ HidParser_GetLinkCollectionNodes()

HIDAPI NTSTATUS NTAPI HidParser_GetLinkCollectionNodes ( IN PVOID  CollectionContext,
OUT PHIDP_LINK_COLLECTION_NODE  LinkCollectionNodes,
IN OUT PULONG  LinkCollectionNodesLength 
)

Definition at line 867 of file hidparser.c.

871{
873 ASSERT(FALSE);
875}

◆ HidParser_GetScaledUsageValue()

HIDAPI NTSTATUS NTAPI HidParser_GetScaledUsageValue ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT LinkCollection  OPTIONAL,
IN USAGE  Usage,
OUT PLONG  UsageValue,
IN PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 559 of file hidparser.c.

568{
569 NTSTATUS ParserStatus;
570
571 //
572 // FIXME: implement searching in specific collection
573 //
575
576 if (ReportType == HidP_Input)
577 {
578 //
579 // input report
580 //
581 ParserStatus = HidParser_GetScaledUsageValueWithReport(CollectionContext, HID_REPORT_TYPE_INPUT, UsagePage, Usage, UsageValue, Report, ReportLength);
582 }
583 else if (ReportType == HidP_Output)
584 {
585 //
586 // input report
587 //
588 ParserStatus = HidParser_GetScaledUsageValueWithReport(CollectionContext, HID_REPORT_TYPE_OUTPUT, UsagePage, Usage, UsageValue, Report, ReportLength);
589 }
590 else if (ReportType == HidP_Feature)
591 {
592 //
593 // input report
594 //
595 ParserStatus = HidParser_GetScaledUsageValueWithReport(CollectionContext, HID_REPORT_TYPE_FEATURE, UsagePage, Usage, UsageValue, Report, ReportLength);
596 }
597 else
598 {
599 //
600 // invalid report type
601 //
603 }
604
605 //
606 // return status
607 //
608 return ParserStatus;
609}
#define HIDP_STATUS_INVALID_REPORT_TYPE
Definition: hidpi.h:251
#define HIDP_LINK_COLLECTION_UNSPECIFIED
Definition: hidpi.h:185
_Must_inspect_result_ _In_ USAGE UsagePage
Definition: hidpi.h:382
@ HidP_Input
Definition: hidpi.h:238
@ HidP_Feature
Definition: hidpi.h:240
@ HidP_Output
Definition: hidpi.h:239
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG _In_ PHIDP_PREPARSED_DATA _In_ ULONG ReportLength
Definition: hidpi.h:337
_Must_inspect_result_ _In_ USAGE _In_ USHORT LinkCollection
Definition: hidpi.h:383
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
NTSTATUS HidParser_GetScaledUsageValueWithReport(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage, IN USAGE Usage, OUT PLONG UsageValue, IN PCHAR ReportDescriptor, IN ULONG ReportDescriptorLength)
Definition: api.c:646

Referenced by HidP_GetScaledUsageValue().

◆ HidParser_GetSpecificButtonCaps()

HIDAPI NTSTATUS NTAPI HidParser_GetSpecificButtonCaps ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT  LinkCollection,
IN USAGE  Usage,
OUT PHIDP_BUTTON_CAPS  ButtonCaps,
IN OUT PULONG  ButtonCapsLength 
)

Definition at line 818 of file hidparser.c.

826{
828 ASSERT(FALSE);
830}

Referenced by HidParser_GetButtonCaps().

◆ HidParser_GetSpecificValueCaps()

HIDAPI NTSTATUS NTAPI HidParser_GetSpecificValueCaps ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT  LinkCollection,
IN USAGE  Usage,
OUT PHIDP_VALUE_CAPS  ValueCaps,
IN OUT PUSHORT  ValueCapsLength 
)

Definition at line 321 of file hidparser.c.

329{
330 NTSTATUS ParserStatus;
331
332 //
333 // FIXME: implement searching in specific collection
334 //
336
337 if (ReportType == HidP_Input)
338 {
339 //
340 // input report
341 //
343 }
344 else if (ReportType == HidP_Output)
345 {
346 //
347 // input report
348 //
350 }
351 else if (ReportType == HidP_Feature)
352 {
353 //
354 // input report
355 //
357 }
358 else
359 {
360 //
361 // invalid report type
362 //
364 }
365
366 //
367 // return status
368 //
369 return ParserStatus;
370}
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_VALUE_CAPS _Inout_ PUSHORT ValueCapsLength
Definition: hidpi.h:400
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_VALUE_CAPS ValueCaps
Definition: hidpi.h:399
NTSTATUS HidParser_GetSpecificValueCapsWithReport(IN PVOID CollectionContext, IN UCHAR ReportType, IN USHORT UsagePage, IN USHORT Usage, OUT PHIDP_VALUE_CAPS ValueCaps, IN OUT PUSHORT ValueCapsLength)
Definition: api.c:254

Referenced by HidP_GetSpecificValueCaps().

◆ HidParser_GetUsages()

HIDAPI NTSTATUS NTAPI HidParser_GetUsages ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT LinkCollection  OPTIONAL,
OUT USAGE UsageList,
IN OUT ULONG UsageLength,
IN PCHAR  Report,
IN ULONG  ReportLength 
)

◆ HidParser_GetUsagesEx()

HIDAPI NTSTATUS NTAPI HidParser_GetUsagesEx ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USHORT  LinkCollection,
OUT PUSAGE_AND_PAGE  ButtonList,
IN OUT ULONG UsageLength,
IN PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 674 of file hidparser.c.

682{
683 return HidParser_GetUsages(CollectionContext, ReportType, HID_USAGE_PAGE_UNDEFINED, LinkCollection, (PUSAGE)ButtonList, UsageLength, Report, ReportLength);
684}
HIDAPI NTSTATUS NTAPI HidParser_GetUsages(IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, IN USHORT LinkCollection OPTIONAL, OUT USAGE *UsageList, IN OUT PULONG UsageLength, IN PCHAR Report, IN ULONG ReportLength)
Definition: hidparser.c:504
_Must_inspect_result_ _In_ USHORT _Inout_updates_to_ UsageLength PUSAGE_AND_PAGE ButtonList
Definition: hidpi.h:425
_Must_inspect_result_ _In_ USHORT _Inout_updates_to_ UsageLength PUSAGE_AND_PAGE _Inout_ ULONG * UsageLength
Definition: hidpi.h:426
USHORT * PUSAGE
Definition: hidusage.h:30
#define HID_USAGE_PAGE_UNDEFINED
Definition: hidusage.h:175

◆ HidParser_GetUsageValue()

HIDAPI NTSTATUS NTAPI HidParser_GetUsageValue ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT  LinkCollection,
IN USAGE  Usage,
OUT PULONG  UsageValue,
IN PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 880 of file hidparser.c.

889{
890 NTSTATUS ParserStatus;
891
892 //
893 // FIXME: implement searching in specific collection
894 //
896
897 if (ReportType == HidP_Input)
898 {
899 //
900 // input report
901 //
902 ParserStatus = HidParser_GetUsageValueWithReport(CollectionContext, HID_REPORT_TYPE_INPUT, UsagePage, Usage, UsageValue, Report, ReportLength);
903 }
904 else if (ReportType == HidP_Output)
905 {
906 //
907 // input report
908 //
909 ParserStatus = HidParser_GetUsageValueWithReport(CollectionContext, HID_REPORT_TYPE_OUTPUT, UsagePage, Usage, UsageValue, Report, ReportLength);
910 }
911 else if (ReportType == HidP_Feature)
912 {
913 //
914 // input report
915 //
916 ParserStatus = HidParser_GetUsageValueWithReport(CollectionContext, HID_REPORT_TYPE_FEATURE, UsagePage, Usage, UsageValue, Report, ReportLength);
917 }
918 else
919 {
920 //
921 // invalid report type
922 //
924 }
925
926 //
927 // return status
928 //
929 return ParserStatus;
930}
NTSTATUS HidParser_GetUsageValueWithReport(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage, IN USAGE Usage, OUT PULONG UsageValue, IN PCHAR ReportDescriptor, IN ULONG ReportDescriptorLength)
Definition: api.c:550

Referenced by HidP_GetUsageValue().

◆ HidParser_GetUsageValueArray()

HIDAPI NTSTATUS NTAPI HidParser_GetUsageValueArray ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT LinkCollection  OPTIONAL,
IN USAGE  Usage,
OUT PCHAR  UsageValue,
IN USHORT  UsageValueByteLength,
IN PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 959 of file hidparser.c.

969{
971 ASSERT(FALSE);
973}

◆ HidParser_GetValueCaps()

HIDAPI NTSTATUS NTAPI HidParser_GetValueCaps ( IN PVOID  CollectionContext,
HIDP_REPORT_TYPE  ReportType,
PHIDP_VALUE_CAPS  ValueCaps,
PULONG  ValueCapsLength 
)

Definition at line 1130 of file hidparser.c.

1135{
1137 ASSERT(FALSE);
1139}

◆ HidParser_InitializeReportForID()

HIDAPI NTSTATUS NTAPI HidParser_InitializeReportForID ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN UCHAR  ReportID,
IN OUT PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 1113 of file hidparser.c.

1119{
1121 ASSERT(FALSE);
1123}

◆ HidParser_MaxDataListLength()

HIDAPI ULONG NTAPI HidParser_MaxDataListLength ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType 
)

Definition at line 1101 of file hidparser.c.

1104{
1106 ASSERT(FALSE);
1107 return 0;
1108}

◆ HidParser_MaxUsageListLength()

HIDAPI ULONG NTAPI HidParser_MaxUsageListLength ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE UsagePage  OPTIONAL 
)

Definition at line 253 of file hidparser.c.

257{
258 //
259 // FIXME test what should be returned when usage page is not defined
260 //
262 {
263 //
264 // implement me
265 //
267
268 //
269 // invalid report
270 //
271 return 0;
272 }
273
274 if (ReportType == HidP_Input)
275 {
276 //
277 // input report
278 //
280 }
281 else if (ReportType == HidP_Output)
282 {
283 //
284 // input report
285 //
287 }
288 else if (ReportType == HidP_Feature)
289 {
290 //
291 // input report
292 //
294 }
295 else
296 {
297 //
298 // invalid report type
299 //
300 return 0;
301 }
302}
ULONG HidParser_GetMaxUsageListLengthWithReportAndPage(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage OPTIONAL)
Definition: api.c:210

Referenced by HidP_MaxUsageListLength().

◆ HidParser_SetData()

HIDAPI NTSTATUS NTAPI HidParser_SetData ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN PHIDP_DATA  DataList,
IN OUT PULONG  DataLength,
IN OUT PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 1085 of file hidparser.c.

1092{
1094 ASSERT(FALSE);
1096}

◆ HidParser_SetScaledUsageValue()

HIDAPI NTSTATUS NTAPI HidParser_SetScaledUsageValue ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT LinkCollection  OPTIONAL,
IN USAGE  Usage,
IN LONG  UsageValue,
IN OUT PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 1067 of file hidparser.c.

1076{
1078 ASSERT(FALSE);
1080}

◆ HidParser_SetUsages()

HIDAPI NTSTATUS NTAPI HidParser_SetUsages ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT  LinkCollection,
IN PUSAGE  UsageList,
IN OUT PULONG  UsageLength,
IN OUT PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 1012 of file hidparser.c.

1021{
1023 ASSERT(FALSE);
1025}

◆ HidParser_SetUsageValue()

HIDAPI NTSTATUS NTAPI HidParser_SetUsageValue ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT  LinkCollection,
IN USAGE  Usage,
IN ULONG  UsageValue,
IN OUT PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 1049 of file hidparser.c.

1058{
1060 ASSERT(FALSE);
1062}

◆ HidParser_SetUsageValueArray()

HIDAPI NTSTATUS NTAPI HidParser_SetUsageValueArray ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT LinkCollection  OPTIONAL,
IN USAGE  Usage,
IN PCHAR  UsageValue,
IN USHORT  UsageValueByteLength,
OUT PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 1030 of file hidparser.c.

1040{
1042 ASSERT(FALSE);
1044}

◆ HidParser_SysPowerCaps()

NTSTATUS NTAPI HidParser_SysPowerCaps ( IN PVOID  CollectionContext,
OUT PULONG  OutputBuffer 
)

Definition at line 947 of file hidparser.c.

950{
952 ASSERT(FALSE);
954}

◆ HidParser_SysPowerEvent()

NTSTATUS NTAPI HidParser_SysPowerEvent ( IN PVOID  CollectionContext,
IN PCHAR  HidPacket,
IN USHORT  HidPacketLength,
OUT PULONG  OutputBuffer 
)

Definition at line 934 of file hidparser.c.

939{
941 ASSERT(FALSE);
943}

◆ HidParser_TranslateCustUsage()

NTSTATUS HidParser_TranslateCustUsage ( IN USAGE  Usage,
IN HIDP_KEYBOARD_DIRECTION  KeyAction,
IN OUT PHIDP_KEYBOARD_MODIFIER_STATE  ModifierState,
IN PHIDP_INSERT_SCANCODES  InsertCodesProcedure,
IN PVOID  InsertCodesContext 
)

Definition at line 913 of file api.c.

919{
921
922 //
923 // get scan code
924 //
926 if (!ScanCode)
927 {
928 //
929 // invalid lookup or no scan code available
930 //
931 DPRINT1("No Scan code for Usage %x\n", Usage);
933 }
934
935 if (ScanCode & 0xFF00)
936 {
937 //
938 // swap scan code
939 //
941 }
942
943 //
944 // FIXME: translate modifier states
945 //
946 HidParser_DispatchKey((PCHAR)&ScanCode, KeyAction, InsertCodesProcedure, InsertCodesContext);
947
948 //
949 // done
950 //
951 return HIDP_STATUS_SUCCESS;
952}
#define DPRINT1
Definition: precomp.h:8
#define HIDP_STATUS_I8042_TRANS_UNKNOWN
Definition: hidpi.h:258
ULONG ScanCode
Definition: api.c:39
ULONG HidParser_GetScanCodeFromCustUsage(IN USAGE Usage)
Definition: api.c:776
VOID HidParser_DispatchKey(IN PCHAR ScanCodes, IN HIDP_KEYBOARD_DIRECTION KeyAction, IN PHIDP_INSERT_SCANCODES InsertCodesProcedure, IN PVOID InsertCodesContext)
Definition: api.c:802
USAGE Usage
Definition: api.c:38
#define NTOHS(n)
Definition: api.c:62
char * PCHAR
Definition: typedefs.h:51

Referenced by HidParser_TranslateUsageAndPagesToI8042ScanCodes().

◆ HidParser_TranslateKbdUsage()

NTSTATUS HidParser_TranslateKbdUsage ( IN USAGE  Usage,
IN HIDP_KEYBOARD_DIRECTION  KeyAction,
IN OUT PHIDP_KEYBOARD_MODIFIER_STATE  ModifierState,
IN PHIDP_INSERT_SCANCODES  InsertCodesProcedure,
IN PVOID  InsertCodesContext 
)

Definition at line 851 of file api.c.

857{
859 CHAR FakeShift[] = {0xE0, 0x2A, 0x00};
860 CHAR FakeCtrl[] = {0xE1, 0x1D, 0x00};
861
862 //
863 // get scan code
864 //
866 if (!ScanCode)
867 {
868 //
869 // invalid lookup or no scan code available
870 //
871 DPRINT1("No Scan code for Usage %x\n", Usage);
873 }
874
875 if (ScanCode & 0xFF00)
876 {
877 //
878 // swap scan code
879 //
881 }
882
883 if (Usage == 0x46 && KeyAction == HidP_Keyboard_Make)
884 {
885 // Print Screen generates additional FakeShift
886 HidParser_DispatchKey(FakeShift, KeyAction, InsertCodesProcedure, InsertCodesContext);
887 }
888
889 if (Usage == 0x48)
890 {
891 // Pause/Break generates additional FakeCtrl. Note: it's always before key press/release.
892 HidParser_DispatchKey(FakeCtrl, KeyAction, InsertCodesProcedure, InsertCodesContext);
893 }
894
895 //
896 // FIXME: translate modifier states
897 //
898 HidParser_DispatchKey((PCHAR)&ScanCode, KeyAction, InsertCodesProcedure, InsertCodesContext);
899
900 if (Usage == 0x46 && KeyAction == HidP_Keyboard_Break)
901 {
902 // Print Screen generates additional FakeShift
903 HidParser_DispatchKey(FakeShift, KeyAction, InsertCodesProcedure, InsertCodesContext);
904 }
905
906 //
907 // done
908 //
909 return HIDP_STATUS_SUCCESS;
910}
@ HidP_Keyboard_Break
Definition: hidpi.h:48
@ HidP_Keyboard_Make
Definition: hidpi.h:49
ULONG HidParser_GetScanCodeFromKbdUsage(IN USAGE Usage)
Definition: api.c:758
char CHAR
Definition: xmlstorage.h:175

Referenced by HidParser_TranslateUsageAndPagesToI8042ScanCodes().

◆ HidParser_TranslateUsageAndPagesToI8042ScanCodes()

HIDAPI NTSTATUS NTAPI HidParser_TranslateUsageAndPagesToI8042ScanCodes ( IN PUSAGE_AND_PAGE  ChangedUsageList,
IN ULONG  UsageListLength,
IN HIDP_KEYBOARD_DIRECTION  KeyAction,
IN OUT PHIDP_KEYBOARD_MODIFIER_STATE  ModifierState,
IN PHIDP_INSERT_SCANCODES  InsertCodesProcedure,
IN PVOID  InsertCodesContext 
)

Definition at line 614 of file hidparser.c.

621{
622 ULONG Index;
624
625 for(Index = 0; Index < UsageListLength; Index++)
626 {
627 //
628 // check current usage
629 //
630 if (ChangedUsageList[Index].UsagePage == HID_USAGE_PAGE_KEYBOARD)
631 {
632 //
633 // process keyboard usage
634 //
635 Status = HidParser_TranslateKbdUsage(ChangedUsageList[Index].Usage, KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
636 }
637 else if (ChangedUsageList[Index].UsagePage == HID_USAGE_PAGE_CONSUMER)
638 {
639 //
640 // process consumer usage
641 //
642 Status = HidParser_TranslateCustUsage(ChangedUsageList[Index].Usage, KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
643 }
644 else
645 {
646 //
647 // invalid page / end of usage list page
648 //
650 }
651
652 //
653 // check status
654 //
656 {
657 //
658 // failed
659 //
660 return Status;
661 }
662 }
663
664 //
665 // return status
666 //
667 return Status;
668}
Status
Definition: gdiplustypes.h:25
_Must_inspect_result_ _In_ ULONG UsageListLength
Definition: hidpi.h:647
#define HID_USAGE_PAGE_KEYBOARD
Definition: hidusage.h:181
#define HID_USAGE_PAGE_CONSUMER
Definition: hidusage.h:186
NTSTATUS HidParser_TranslateCustUsage(IN USAGE Usage, IN HIDP_KEYBOARD_DIRECTION KeyAction, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, IN PHIDP_INSERT_SCANCODES InsertCodesProcedure, IN PVOID InsertCodesContext)
Definition: api.c:913
NTSTATUS HidParser_TranslateKbdUsage(IN USAGE Usage, IN HIDP_KEYBOARD_DIRECTION KeyAction, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, IN PHIDP_INSERT_SCANCODES InsertCodesProcedure, IN PVOID InsertCodesContext)
Definition: api.c:851

Referenced by HidP_TranslateUsageAndPagesToI8042ScanCodes().

◆ HidParser_TranslateUsagesToI8042ScanCodes()

HIDAPI NTSTATUS NTAPI HidParser_TranslateUsagesToI8042ScanCodes ( IN PUSAGE  ChangedUsageList,
IN ULONG  UsageListLength,
IN HIDP_KEYBOARD_DIRECTION  KeyAction,
IN OUT PHIDP_KEYBOARD_MODIFIER_STATE  ModifierState,
IN PHIDP_INSERT_SCANCODES  InsertCodesProcedure,
IN PVOID  InsertCodesContext 
)

Definition at line 996 of file hidparser.c.

1003{
1005 ASSERT(FALSE);
1007}

◆ HidParser_UnsetUsages()

HIDAPI NTSTATUS NTAPI HidParser_UnsetUsages ( IN PVOID  CollectionContext,
IN HIDP_REPORT_TYPE  ReportType,
IN USAGE  UsagePage,
IN USHORT  LinkCollection,
IN PUSAGE  UsageList,
IN OUT PULONG  UsageLength,
IN OUT PCHAR  Report,
IN ULONG  ReportLength 
)

Definition at line 978 of file hidparser.c.

987{
989 ASSERT(FALSE);
991}

◆ HidParser_UsageAndPageListDifference()

HIDAPI NTSTATUS NTAPI HidParser_UsageAndPageListDifference ( IN PUSAGE_AND_PAGE  PreviousUsageList,
IN PUSAGE_AND_PAGE  CurrentUsageList,
OUT PUSAGE_AND_PAGE  BreakUsageList,
OUT PUSAGE_AND_PAGE  MakeUsageList,
IN ULONG  UsageListLength 
)

Definition at line 689 of file hidparser.c.

695{
696 ULONG Index, SubIndex, BreakUsageListIndex = 0, MakeUsageListIndex = 0, bFound;
697 PUSAGE_AND_PAGE CurrentUsage, Usage;
698
699 if (UsageListLength)
700 {
701 /* process removed usages */
702 Index = 0;
703 do
704 {
705 /* get usage from current index */
706 CurrentUsage = &PreviousUsageList[Index];
707
708 /* end of list reached? */
709 if (CurrentUsage->Usage == 0 && CurrentUsage->UsagePage == 0)
710 break;
711
712 /* search in current list */
713 SubIndex = 0;
714 bFound = FALSE;
715 do
716 {
717 /* get usage */
718 Usage = &CurrentUsageList[SubIndex];
719
720 /* end of list reached? */
721 if (Usage->Usage == 0 && Usage->UsagePage == 0)
722 break;
723
724 /* does it match */
725 if (Usage->Usage == CurrentUsage->Usage && Usage->UsagePage == CurrentUsage->UsagePage)
726 {
727 /* found match */
728 bFound = TRUE;
729 }
730
731 /* move to next index */
732 SubIndex++;
733
734 }while(SubIndex < UsageListLength);
735
736 if (!bFound)
737 {
738 /* store it in break usage list */
739 BreakUsageList[BreakUsageListIndex].Usage = CurrentUsage->Usage;
740 BreakUsageList[BreakUsageListIndex].UsagePage = CurrentUsage->UsagePage;
741 BreakUsageListIndex++;
742 }
743
744 /* move to next index */
745 Index++;
746
747 }while(Index < UsageListLength);
748
749 /* process new usages */
750 Index = 0;
751 do
752 {
753 /* get usage from current index */
754 CurrentUsage = &CurrentUsageList[Index];
755
756 /* end of list reached? */
757 if (CurrentUsage->Usage == 0 && CurrentUsage->UsagePage == 0)
758 break;
759
760 /* search in current list */
761 SubIndex = 0;
762 bFound = FALSE;
763 do
764 {
765 /* get usage */
766 Usage = &PreviousUsageList[SubIndex];
767
768 /* end of list reached? */
769 if (Usage->Usage == 0 && Usage->UsagePage == 0)
770 break;
771
772 /* does it match */
773 if (Usage->Usage == CurrentUsage->Usage && Usage->UsagePage == CurrentUsage->UsagePage)
774 {
775 /* found match */
776 bFound = TRUE;
777 }
778
779 /* move to next index */
780 SubIndex++;
781
782 }while(SubIndex < UsageListLength);
783
784 if (!bFound)
785 {
786 /* store it in break usage list */
787 MakeUsageList[MakeUsageListIndex].Usage = CurrentUsage->Usage;
788 MakeUsageList[MakeUsageListIndex].UsagePage = CurrentUsage->UsagePage;
789 MakeUsageListIndex++;
790 }
791
792 /* move to next index */
793 Index++;
794 }while(Index < UsageListLength);
795 }
796
797 /* are there remaining free list entries */
798 if (BreakUsageListIndex < UsageListLength)
799 {
800 /* zero them */
801 RtlZeroMemory(&BreakUsageList[BreakUsageListIndex], (UsageListLength - BreakUsageListIndex) * sizeof(USAGE_AND_PAGE));
802 }
803
804 /* are there remaining free list entries */
805 if (MakeUsageListIndex < UsageListLength)
806 {
807 /* zero them */
808 RtlZeroMemory(&MakeUsageList[MakeUsageListIndex], (UsageListLength - MakeUsageListIndex) * sizeof(USAGE_AND_PAGE));
809 }
810
811 /* done */
812 return HIDP_STATUS_SUCCESS;
813}
USAGE UsagePage
Definition: hidpi.h:80
USAGE Usage
Definition: hidpi.h:79
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by HidP_UsageAndPageListDifference().

◆ HidParser_UsageListDifference()

HIDAPI NTSTATUS NTAPI HidParser_UsageListDifference ( IN PUSAGE  PreviousUsageList,
IN PUSAGE  CurrentUsageList,
OUT PUSAGE  BreakUsageList,
OUT PUSAGE  MakeUsageList,
IN ULONG  UsageListLength 
)

Definition at line 375 of file hidparser.c.

381{
382 ULONG Index, SubIndex, bFound, BreakUsageIndex = 0, MakeUsageIndex = 0;
383 USAGE CurrentUsage, Usage;
384
385 if (UsageListLength)
386 {
387 Index = 0;
388 do
389 {
390 /* get current usage */
391 CurrentUsage = PreviousUsageList[Index];
392
393 /* is the end of list reached? */
394 if (!CurrentUsage)
395 break;
396
397 /* start searching in current usage list */
398 SubIndex = 0;
399 bFound = FALSE;
400 do
401 {
402 /* get usage of current list */
403 Usage = CurrentUsageList[SubIndex];
404
405 /* end of list reached? */
406 if (!Usage)
407 break;
408
409 /* check if it matches the current one */
410 if (CurrentUsage == Usage)
411 {
412 /* it does */
413 bFound = TRUE;
414 break;
415 }
416
417 /* move to next usage */
418 SubIndex++;
419 }while(SubIndex < UsageListLength);
420
421 /* was the usage found ?*/
422 if (!bFound)
423 {
424 /* store it in the break usage list */
425 BreakUsageList[BreakUsageIndex] = CurrentUsage;
426 BreakUsageIndex++;
427 }
428
429 /* move to next usage */
430 Index++;
431
432 }while(Index < UsageListLength);
433
434 /* now process the new items */
435 Index = 0;
436 do
437 {
438 /* get current usage */
439 CurrentUsage = CurrentUsageList[Index];
440
441 /* is the end of list reached? */
442 if (!CurrentUsage)
443 break;
444
445 /* start searching in current usage list */
446 SubIndex = 0;
447 bFound = FALSE;
448 do
449 {
450 /* get usage of previous list */
451 Usage = PreviousUsageList[SubIndex];
452
453 /* end of list reached? */
454 if (!Usage)
455 break;
456
457 /* check if it matches the current one */
458 if (CurrentUsage == Usage)
459 {
460 /* it does */
461 bFound = TRUE;
462 break;
463 }
464
465 /* move to next usage */
466 SubIndex++;
467 }while(SubIndex < UsageListLength);
468
469 /* was the usage found ?*/
470 if (!bFound)
471 {
472 /* store it in the make usage list */
473 MakeUsageList[MakeUsageIndex] = CurrentUsage;
474 MakeUsageIndex++;
475 }
476
477 /* move to next usage */
478 Index++;
479
480 }while(Index < UsageListLength);
481 }
482
483 /* does the break list contain empty entries */
484 if (BreakUsageIndex < UsageListLength)
485 {
486 /* zeroize entries */
487 RtlZeroMemory(&BreakUsageList[BreakUsageIndex], sizeof(USAGE) * (UsageListLength - BreakUsageIndex));
488 }
489
490 /* does the make usage list contain empty entries */
491 if (MakeUsageIndex < UsageListLength)
492 {
493 /* zeroize entries */
494 RtlZeroMemory(&MakeUsageList[MakeUsageIndex], sizeof(USAGE) * (UsageListLength - MakeUsageIndex));
495 }
496
497 /* done */
498 return HIDP_STATUS_SUCCESS;
499}
USHORT USAGE
Definition: hidusage.h:30

Referenced by HidP_UsageListDifference().