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