ReactOS 0.4.16-dev-306-g647d351
hidparser.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS HID Parser Library
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/drivers/hidparser/hidparser.c
5 * PURPOSE: HID Parser
6 * PROGRAMMERS:
7 * Michael Martin (michael.martin@reactos.org)
8 * Johannes Anderwald (johannes.anderwald@reactos.org)
9 */
10
11#include "parser.h"
12
13#define NDEBUG
14#include <debug.h>
15
19 IN PHIDP_REPORT_DESCRIPTOR ReportDesc,
20 IN ULONG DescLength,
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}
160
161VOID
162NTAPI
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}
189
190HIDAPI
192NTAPI
194 IN PVOID CollectionContext,
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}
249
250HIDAPI
251ULONG
252NTAPI
254 IN PVOID CollectionContext,
255 IN HIDP_REPORT_TYPE ReportType,
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}
303
304#undef HidParser_GetButtonCaps
305
306HIDAPI
308NTAPI
310 IN PVOID CollectionContext,
311 IN HIDP_REPORT_TYPE ReportType,
314{
316}
317
318HIDAPI
320NTAPI
322 IN PVOID CollectionContext,
323 IN HIDP_REPORT_TYPE ReportType,
326 IN USAGE Usage,
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}
371
372HIDAPI
374NTAPI
376 IN PUSAGE PreviousUsageList,
377 IN PUSAGE CurrentUsageList,
378 OUT PUSAGE BreakUsageList,
379 OUT PUSAGE MakeUsageList,
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}
500
501HIDAPI
503NTAPI
505 IN PVOID CollectionContext,
506 IN HIDP_REPORT_TYPE ReportType,
509 OUT USAGE *UsageList,
511 IN PCHAR Report,
513{
514 NTSTATUS ParserStatus;
515
516 //
517 // FIXME: implement searching in specific collection
518 //
520
521 if (ReportType == HidP_Input)
522 {
523 //
524 // input report
525 //
526 ParserStatus = HidParser_GetUsagesWithReport(CollectionContext, HID_REPORT_TYPE_INPUT, UsagePage, UsageList, UsageLength, Report, ReportLength);
527 }
528 else if (ReportType == HidP_Output)
529 {
530 //
531 // input report
532 //
533 ParserStatus = HidParser_GetUsagesWithReport(CollectionContext, HID_REPORT_TYPE_OUTPUT, UsagePage, UsageList, UsageLength, Report, ReportLength);
534 }
535 else if (ReportType == HidP_Feature)
536 {
537 //
538 // input report
539 //
540 ParserStatus = HidParser_GetUsagesWithReport(CollectionContext, HID_REPORT_TYPE_FEATURE, UsagePage, UsageList, UsageLength, Report, ReportLength);
541 }
542 else
543 {
544 //
545 // invalid report type
546 //
548 }
549
550 //
551 // return status
552 //
553 return ParserStatus;
554}
555
556HIDAPI
558NTAPI
560 IN PVOID CollectionContext,
561 IN HIDP_REPORT_TYPE ReportType,
564 IN USAGE Usage,
565 OUT PLONG UsageValue,
566 IN PCHAR Report,
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}
610
611HIDAPI
613NTAPI
615 IN PUSAGE_AND_PAGE ChangedUsageList,
617 IN HIDP_KEYBOARD_DIRECTION KeyAction,
619 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
620 IN PVOID InsertCodesContext)
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}
669
670
671HIDAPI
673NTAPI
675 IN PVOID CollectionContext,
676 IN HIDP_REPORT_TYPE ReportType,
680 IN PCHAR Report,
682{
683 return HidParser_GetUsages(CollectionContext, ReportType, HID_USAGE_PAGE_UNDEFINED, LinkCollection, (PUSAGE)ButtonList, UsageLength, Report, ReportLength);
684}
685
686HIDAPI
688NTAPI
690 IN PUSAGE_AND_PAGE PreviousUsageList,
691 IN PUSAGE_AND_PAGE CurrentUsageList,
692 OUT PUSAGE_AND_PAGE BreakUsageList,
693 OUT PUSAGE_AND_PAGE MakeUsageList,
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}
814
815HIDAPI
817NTAPI
819 IN PVOID CollectionContext,
820 IN HIDP_REPORT_TYPE ReportType,
823 IN USAGE Usage,
826{
828 ASSERT(FALSE);
830}
831
832
833HIDAPI
835NTAPI
837 IN PVOID CollectionContext,
838 IN HIDP_REPORT_TYPE ReportType,
841 IN PCHAR Report,
843{
845 ASSERT(FALSE);
847}
848
849HIDAPI
851NTAPI
853 IN PVOID CollectionContext,
854 IN HIDP_REPORT_TYPE ReportType,
858{
860 ASSERT(FALSE);
862}
863
864HIDAPI
866NTAPI
868 IN PVOID CollectionContext,
869 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
871{
873 ASSERT(FALSE);
875}
876
877HIDAPI
879NTAPI
881 IN PVOID CollectionContext,
882 IN HIDP_REPORT_TYPE ReportType,
885 IN USAGE Usage,
886 OUT PULONG UsageValue,
887 IN PCHAR Report,
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}
931
933NTAPI
935 IN PVOID CollectionContext,
936 IN PCHAR HidPacket,
937 IN USHORT HidPacketLength,
939{
941 ASSERT(FALSE);
943}
944
946NTAPI
948 IN PVOID CollectionContext,
950{
952 ASSERT(FALSE);
954}
955
956HIDAPI
958NTAPI
960 IN PVOID CollectionContext,
961 IN HIDP_REPORT_TYPE ReportType,
964 IN USAGE Usage,
965 OUT PCHAR UsageValue,
966 IN USHORT UsageValueByteLength,
967 IN PCHAR Report,
969{
971 ASSERT(FALSE);
973}
974
975HIDAPI
977NTAPI
979 IN PVOID CollectionContext,
980 IN HIDP_REPORT_TYPE ReportType,
983 IN PUSAGE UsageList,
985 IN OUT PCHAR Report,
987{
989 ASSERT(FALSE);
991}
992
993HIDAPI
995NTAPI
997 IN PUSAGE ChangedUsageList,
999 IN HIDP_KEYBOARD_DIRECTION KeyAction,
1000 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
1001 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
1002 IN PVOID InsertCodesContext)
1003{
1005 ASSERT(FALSE);
1007}
1008
1009HIDAPI
1011NTAPI
1013 IN PVOID CollectionContext,
1014 IN HIDP_REPORT_TYPE ReportType,
1017 IN PUSAGE UsageList,
1019 IN OUT PCHAR Report,
1021{
1023 ASSERT(FALSE);
1025}
1026
1027HIDAPI
1029NTAPI
1031 IN PVOID CollectionContext,
1032 IN HIDP_REPORT_TYPE ReportType,
1035 IN USAGE Usage,
1036 IN PCHAR UsageValue,
1037 IN USHORT UsageValueByteLength,
1038 OUT PCHAR Report,
1040{
1042 ASSERT(FALSE);
1044}
1045
1046HIDAPI
1048NTAPI
1050 IN PVOID CollectionContext,
1051 IN HIDP_REPORT_TYPE ReportType,
1054 IN USAGE Usage,
1055 IN ULONG UsageValue,
1056 IN OUT PCHAR Report,
1058{
1060 ASSERT(FALSE);
1062}
1063
1064HIDAPI
1066NTAPI
1068 IN PVOID CollectionContext,
1069 IN HIDP_REPORT_TYPE ReportType,
1072 IN USAGE Usage,
1073 IN LONG UsageValue,
1074 IN OUT PCHAR Report,
1076{
1078 ASSERT(FALSE);
1080}
1081
1082HIDAPI
1084NTAPI
1086 IN PVOID CollectionContext,
1087 IN HIDP_REPORT_TYPE ReportType,
1090 IN OUT PCHAR Report,
1092{
1094 ASSERT(FALSE);
1096}
1097
1098HIDAPI
1099ULONG
1100NTAPI
1102 IN PVOID CollectionContext,
1103 IN HIDP_REPORT_TYPE ReportType)
1104{
1106 ASSERT(FALSE);
1107 return 0;
1108}
1109
1110HIDAPI
1112NTAPI
1114 IN PVOID CollectionContext,
1115 IN HIDP_REPORT_TYPE ReportType,
1117 IN OUT PCHAR Report,
1119{
1121 ASSERT(FALSE);
1123}
1124
1125#undef HidParser_GetValueCaps
1126
1127HIDAPI
1129NTAPI
1131 IN PVOID CollectionContext,
1132 HIDP_REPORT_TYPE ReportType,
1135{
1137 ASSERT(FALSE);
1139}
LONG NTSTATUS
Definition: precomp.h:26
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:25
VOID NTAPI ZeroFunction(IN PVOID Item, IN ULONG ItemSize)
Definition: hid.c:61
VOID __cdecl DebugFunction(IN LPCSTR FormatStr,...)
Definition: hid.c:80
PVOID NTAPI AllocFunction(IN ULONG ItemSize)
Definition: hid.c:45
VOID NTAPI FreeFunction(IN PVOID Item)
Definition: hid.c:53
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
HIDAPI NTSTATUS NTAPI HidParser_GetCaps(IN PVOID CollectionContext, OUT PHIDP_CAPS Capabilities)
Definition: hidparser.c:193
HIDAPI NTSTATUS NTAPI HidParser_UsageListDifference(IN PUSAGE PreviousUsageList, IN PUSAGE CurrentUsageList, OUT PUSAGE BreakUsageList, OUT PUSAGE MakeUsageList, IN ULONG UsageListLength)
Definition: hidparser.c:375
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: hidparser.c:559
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: hidparser.c:959
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: hidparser.c:1030
NTSTATUS NTAPI HidParser_SysPowerCaps(IN PVOID CollectionContext, OUT PULONG OutputBuffer)
Definition: hidparser.c:947
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: hidparser.c:321
NTSTATUS NTAPI HidParser_SysPowerEvent(IN PVOID CollectionContext, IN PCHAR HidPacket, IN USHORT HidPacketLength, OUT PULONG OutputBuffer)
Definition: hidparser.c:934
NTSTATUS NTAPI HidParser_GetCollectionDescription(IN PHIDP_REPORT_DESCRIPTOR ReportDesc, IN ULONG DescLength, IN POOL_TYPE PoolType, OUT PHIDP_DEVICE_DESC DeviceDescription)
Definition: hidparser.c:18
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: hidparser.c:1067
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: hidparser.c:689
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: hidparser.c:1049
HIDAPI NTSTATUS NTAPI HidParser_GetLinkCollectionNodes(IN PVOID CollectionContext, OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, IN OUT PULONG LinkCollectionNodesLength)
Definition: hidparser.c:867
HIDAPI NTSTATUS NTAPI HidParser_GetValueCaps(IN PVOID CollectionContext, HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PULONG ValueCapsLength)
Definition: hidparser.c:1130
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: hidparser.c:1085
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: hidparser.c:880
HIDAPI ULONG NTAPI HidParser_MaxUsageListLength(IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage OPTIONAL)
Definition: hidparser.c:253
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: hidparser.c:614
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: hidparser.c:978
HIDAPI NTSTATUS NTAPI HidParser_InitializeReportForID(IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN UCHAR ReportID, IN OUT PCHAR Report, IN ULONG ReportLength)
Definition: hidparser.c:1113
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: hidparser.c:996
HIDAPI NTSTATUS NTAPI HidParser_GetButtonCaps(IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType, IN PHIDP_BUTTON_CAPS ButtonCaps, IN PUSHORT ButtonCapsLength)
Definition: hidparser.c:309
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: hidparser.c:818
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
HIDAPI ULONG NTAPI HidParser_MaxDataListLength(IN PVOID CollectionContext, IN HIDP_REPORT_TYPE ReportType)
Definition: hidparser.c:1101
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: hidparser.c:836
VOID NTAPI HidParser_FreeCollectionDescription(IN PHIDP_DEVICE_DESC DeviceDescription)
Definition: hidparser.c:163
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: hidparser.c:674
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: hidparser.c:1012
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: hidparser.c:852
struct _HIDP_COLLECTION_DESC * PHIDP_COLLECTION_DESC
struct _HIDP_REPORT_IDS * PHIDP_REPORT_IDS
#define HIDP_STATUS_INVALID_REPORT_TYPE
Definition: hidpi.h:251
#define HIDP_STATUS_SUCCESS
Definition: hidpi.h:248
_Must_inspect_result_ _In_ UCHAR ReportID
Definition: hidpi.h:482
_Must_inspect_result_ _Inout_ PULONG LinkCollectionNodesLength
Definition: hidpi.h:358
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_BUTTON_CAPS _Inout_ PUSHORT ButtonCapsLength
Definition: hidpi.h:386
#define HIDP_LINK_COLLECTION_UNSPECIFIED
Definition: hidpi.h:185
_Must_inspect_result_ _In_ USAGE UsagePage
Definition: hidpi.h:382
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_BUTTON_CAPS ButtonCaps
Definition: hidpi.h:385
BOOLEAN(NTAPI * PHIDP_INSERT_SCANCODES)(_In_opt_ PVOID Context, _In_reads_bytes_(Length) PCHAR NewScanCodes, _In_ ULONG Length)
Definition: hidpi.h:73
_Must_inspect_result_ _In_ USHORT _Inout_updates_to_ UsageLength PUSAGE_AND_PAGE ButtonList
Definition: hidpi.h:425
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_VALUE_CAPS _Inout_ PUSHORT ValueCapsLength
Definition: hidpi.h:400
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES _Inout_ OUT PULONG LengthAttributes
Definition: hidpi.h:349
@ HidP_Input
Definition: hidpi.h:238
@ HidP_Feature
Definition: hidpi.h:240
@ HidP_Output
Definition: hidpi.h:239
#define HIDAPI
Definition: hidpi.h:35
_Must_inspect_result_ _In_ USHORT _Inout_updates_to_ UsageLength PUSAGE_AND_PAGE _Inout_ ULONG * UsageLength
Definition: hidpi.h:426
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_VALUE_CAPS ValueCaps
Definition: hidpi.h:399
_Must_inspect_result_ _In_ ULONG UsageListLength
Definition: hidpi.h:647
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG _In_ PHIDP_PREPARSED_DATA _In_ ULONG ReportLength
Definition: hidpi.h:337
enum _HIDP_KEYBOARD_DIRECTION HIDP_KEYBOARD_DIRECTION
enum _HIDP_REPORT_TYPE HIDP_REPORT_TYPE
#define HIDP_STATUS_I8042_TRANS_UNKNOWN
Definition: hidpi.h:258
PUCHAR PHIDP_REPORT_DESCRIPTOR
Definition: hidpi.h:38
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA DataList
Definition: hidpi.h:333
_Must_inspect_result_ _In_ USAGE _In_ USHORT LinkCollection
Definition: hidpi.h:383
_Must_inspect_result_ _In_ USHORT DataIndex
Definition: hidpi.h:346
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
USHORT USAGE
Definition: hidusage.h:30
USHORT * PUSAGE
Definition: hidusage.h:30
#define HID_USAGE_PAGE_UNDEFINED
Definition: hidusage.h:175
#define HID_USAGE_PAGE_KEYBOARD
Definition: hidusage.h:181
#define HID_USAGE_PAGE_CONSUMER
Definition: hidusage.h:186
#define ASSERT(a)
Definition: mode.c:44
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
ULONG HidParser_UsesReportId(IN PVOID CollectionContext, IN UCHAR ReportType)
Definition: api.c:524
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_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
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
NTSTATUS HidParser_GetUsagesWithReport(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage, OUT USAGE *UsageList, IN OUT PULONG UsageLength, IN PCHAR ReportDescriptor, IN ULONG ReportDescriptorLength)
Definition: api.c:343
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_GetMaxUsageListLengthWithReportAndPage(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage OPTIONAL)
Definition: api.c:210
ULONG HidParser_GetReportItemTypeCountFromReportType(IN PVOID CollectionContext, IN UCHAR ReportType, IN ULONG bData)
Definition: api.c:158
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
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
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
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
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
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
USAGE UsagePage
Definition: hidpi.h:80
USAGE Usage
Definition: hidpi.h:79
uint32_t * PULONG
Definition: typedefs.h:59
INT POOL_TYPE
Definition: typedefs.h:78
#define NTAPI
Definition: typedefs.h:36
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
#define STATUS_NO_DATA_DETECTED
Definition: udferr_usr.h:131
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define HID_REPORT_TYPE_INPUT
#define HID_REPORT_TYPE_FEATURE
#define HID_REPORT_TYPE_OUTPUT
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432
unsigned char UCHAR
Definition: xmlstorage.h:181