@@ -41,7 +41,7 @@ typedef struct {
41
41
42
42
uint16_t Pos ; /* Store current pos in descriptor */
43
43
uint8_t Item ; /* Store current Item */
44
- long Value ; /* Store current Value */
44
+ uint32_t Value ; /* Store current Value */
45
45
46
46
HIDData_t Data ; /* Store current environment */
47
47
@@ -121,10 +121,10 @@ static uint8_t *GetReportOffset(HIDParser_t* pParser, const uint8_t ReportID, co
121
121
}
122
122
123
123
/*
124
- * FormatValue(long Value, uint8_t Size)
124
+ * FormatValue(uint32_t Value, uint8_t Size)
125
125
* Format Value to fit with long format with respect of negative values
126
126
* -------------------------------------------------------------------------- */
127
- static long FormatValue (long Value , uint8_t Size )
127
+ static long FormatValue (uint32_t Value , uint8_t Size )
128
128
{
129
129
switch (Size )
130
130
{
@@ -150,27 +150,16 @@ static long FormatValue(long Value, uint8_t Size)
150
150
* -------------------------------------------------------------------------- */
151
151
static int HIDParse (HIDParser_t * pParser , HIDData_t * pData )
152
152
{
153
- int Found = -1 ;
153
+ int Found = -1 , i ;
154
154
155
155
while ((Found < 0 ) && (pParser -> Pos < pParser -> ReportDescSize )) {
156
156
/* Get new pParser->Item if current pParser->Count is empty */
157
157
if (pParser -> Count == 0 ) {
158
158
pParser -> Item = pParser -> ReportDesc [pParser -> Pos ++ ];
159
159
pParser -> Value = 0 ;
160
- #if (defined (WORDS_BIGENDIAN )) && (WORDS_BIGENDIAN )
161
- {
162
- int i ;
163
- unsigned long valTmp = 0 ;
164
-
165
- for (i = 0 ; i < ItemSize [pParser -> Item & SIZE_MASK ]; i ++ ) {
166
- memcpy (& valTmp , & pParser -> ReportDesc [(pParser -> Pos )+ i ], 1 );
167
- pParser -> Value += valTmp >> ((3 - i )* 8 );
168
- valTmp = 0 ;
169
- }
160
+ for (i = 0 ; i < ItemSize [pParser -> Item & SIZE_MASK ]; i ++ ) {
161
+ pParser -> Value += pParser -> ReportDesc [(pParser -> Pos )+ i ] << (8 * i );
170
162
}
171
- #else
172
- memcpy (& pParser -> Value , & pParser -> ReportDesc [pParser -> Pos ], ItemSize [pParser -> Item & SIZE_MASK ]);
173
- #endif
174
163
/* Pos on next item */
175
164
pParser -> Pos += ItemSize [pParser -> Item & SIZE_MASK ];
176
165
}
0 commit comments