1
10
13
14
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
111
112
113
114
116
117
134
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_class_hid.h"
#include "ux_host_stack.h"
...
...
UINT _ux_host_class_hid_report_compress(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS_HID_CLIENT_REPORT *client_report,
UCHAR *report_buffer, ULONG report_length)
{
UX_HOST_CLASS_HID_REPORT *hid_report;
UX_HOST_CLASS_HID_FIELD *hid_field;
ULONG field_usage;
ULONG field_report_count;
ULONG field_report_size;
ULONG *client_buffer;
ULONG client_value;
UCHAR value;
ULONG data_offset_bit;
UCHAR is_valid_usage;
UX_PARAMETER_NOT_USED(hid);
UX_PARAMETER_NOT_USED(report_length);
hid_report = client_report -> ux_host_class_hid_client_report;
client_buffer = client_report -> ux_host_class_hid_client_report_buffer;
hid_field = hid_report -> ux_host_class_hid_report_field;
data_offset_bit = 0;
while (hid_field != UX_NULL)
{
/* ... */
for (field_report_count = 0; field_report_count < hid_field -> ux_host_class_hid_field_report_count; field_report_count++)
{
/* ... */
is_valid_usage = UX_FALSE;
if (hid_field -> ux_host_class_hid_field_value & UX_HOST_CLASS_HID_ITEM_VARIABLE)
{
for (field_usage = 0; field_usage < hid_field -> ux_host_class_hid_field_number_usage; field_usage++)
{
if (*client_buffer == hid_field -> ux_host_class_hid_field_usages[field_usage])
{
is_valid_usage = UX_TRUE;
break;
}if (*client_buffer == hid_field -> ux_host_class_hid_field_usages[field_usage]) { ... }
}for (field_usage = 0; field_usage < hid_field -> ux_host_class_hid_field_number_usage; field_usage++) { ... }
}if (hid_field -> ux_host_class_hid_field_value & UX_HOST_CLASS_HID_ITEM_VARIABLE) { ... }
else
{
if (((*client_buffer & 0xffff0000) >> 16) == hid_field -> ux_host_class_hid_field_usage_page)
{
if ((*client_buffer & 0xffff) >= hid_field -> ux_host_class_hid_field_usage_min &&
(*client_buffer & 0xffff) <= hid_field -> ux_host_class_hid_field_usage_max)
{
is_valid_usage = UX_TRUE;
}if ((*client_buffer & 0xffff) >= hid_field -> ux_host_class_hid_field_usage_min && (*client_buffer & 0xffff) <= hid_field -> ux_host_class_hid_field_usage_max) { ... }
}if (((*client_buffer & 0xffff0000) >> 16) == hid_field -> ux_host_class_hid_field_usage_page) { ... }
}else { ... }
if (is_valid_usage == UX_FALSE)
{
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_HID_REPORT_ERROR);
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_HID_REPORT_ERROR, hid, 0, 0, UX_TRACE_ERRORS, 0, 0)
return(UX_HOST_CLASS_HID_REPORT_ERROR);
}if (is_valid_usage == UX_FALSE) { ... }
client_buffer++;
client_value = *client_buffer++;
for (field_report_size = hid_field -> ux_host_class_hid_field_report_size; field_report_size > 0; field_report_size--)
{
value = (UCHAR) client_value & 1;
value = (UCHAR)(value << data_offset_bit);
*report_buffer |= value;
data_offset_bit++;
if ((data_offset_bit & 7) == 0)
{
report_buffer++;
data_offset_bit = 0;
}if ((data_offset_bit & 7) == 0) { ... }
client_value = client_value >> 1;
}for (field_report_size = hid_field -> ux_host_class_hid_field_report_size; field_report_size > 0; field_report_size--) { ... }
}for (field_report_count = 0; field_report_count < hid_field -> ux_host_class_hid_field_report_count; field_report_count++) { ... }
hid_field = hid_field -> ux_host_class_hid_field_next_field;
}while (hid_field != UX_NULL) { ... }
return(UX_SUCCESS);
}{ ... }