1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** USBX Component */
17 /** */
18 /** HID Class */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29 #include "ux_host_class_hid.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_host_class_hid_report_decompress PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function will decompress a raw report into a client buffer. */
46 /* */
47 /* INPUT */
48 /* */
49 /* hid Pointer to HID class */
50 /* client_report Pointer to client report */
51 /* report_buffer Pointer to report buffer */
52 /* report_length Length of report */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* Completion Status */
57 /* */
58 /* CALLS */
59 /* */
60 /* _ux_host_class_hid_field_decompress Decompress field */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* HID Class */
65 /* */
66 /* RELEASE HISTORY */
67 /* */
68 /* DATE NAME DESCRIPTION */
69 /* */
70 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
71 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
72 /* resulting in version 6.1 */
73 /* */
74 /**************************************************************************/
_ux_host_class_hid_report_decompress(UX_HOST_CLASS_HID * hid,UX_HOST_CLASS_HID_CLIENT_REPORT * client_report,UCHAR * report_buffer,ULONG report_length)75 UINT _ux_host_class_hid_report_decompress(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS_HID_CLIENT_REPORT *client_report,
76 UCHAR *report_buffer, ULONG report_length)
77 {
78
79 UX_HOST_CLASS_HID_REPORT *hid_report;
80 UX_HOST_CLASS_HID_FIELD *hid_field;
81
82 UX_PARAMETER_NOT_USED(hid);
83
84 /* Get the report pointer from the caller. */
85 hid_report = client_report -> ux_host_class_hid_client_report;
86
87 /* Check if this report has a ID field in the front. An ID field is required
88 if report ID is non null. */
89 if (hid_report -> ux_host_class_hid_report_id != 0)
90 {
91
92 /* We have an ID tag in the report. The ID tag is the first byte of the report. Skip the
93 ID tag and adjust the length. */
94 report_buffer++;
95 report_length--;
96 }
97
98 /* Get the first field associated with the report. */
99 hid_field = hid_report -> ux_host_class_hid_report_field;
100
101 /* We need to decompress each field defined in the report. */
102 while (hid_field != UX_NULL)
103 {
104
105 /* Decompress a field. */
106 _ux_host_class_hid_field_decompress(hid_field, report_buffer, client_report);
107
108 /* Move to the next field. */
109 hid_field = hid_field -> ux_host_class_hid_field_next_field;
110 }
111
112 /* Return successful completion. */
113 return(UX_SUCCESS);
114 }
115
116