Changeset d012590 in mainline
- Timestamp:
- 2011-03-29T19:35:27Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2f4b3a4, fc883bb
- Parents:
- 79e1abd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hidparser.c
r79e1abd rd012590 1204 1204 report_item = list_get_instance(item, usb_hid_report_item_t, link); 1205 1205 1206 for(i=0; i<report_item->count; i++ , idx++) {1206 for(i=0; i<report_item->count; i++) { 1207 1207 1208 1208 if(idx >= data_size) { … … 1217 1217 //variable item 1218 1218 value = usb_hid_translate_data_reverse(report_item, data[idx]); 1219 idx++; 1219 1220 } 1220 1221 1221 1222 if((USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0) || 1222 1223 ((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0))) { 1224 1223 1225 // // variable item 1224 1226 offset = report_item->offset + (i * report_item->size); … … 1231 1233 } 1232 1234 1233 if((offset/8) == ((offset+length )/8)) {1235 if((offset/8) == ((offset+length-1)/8)) { 1234 1236 // je to v jednom bytu 1235 if(((size_t)(offset/8) >= size) || ((size_t)(offset+length )/8) >= size) {1237 if(((size_t)(offset/8) >= size) || ((size_t)(offset+length-1)/8) >= size) { 1236 1238 break; // TODO ErrorCode 1237 1239 } 1238 1240 1239 value = value << (8- ((offset+length)%8)); 1240 value = value & (((1 << length)-1) << (8- ((offset+length)%8))); 1241 size_t shift=0; 1242 if(((offset+length)%8) > 0) { 1243 shift = (8- ((offset+length)%8)); 1244 } 1245 1246 value = value << shift; 1247 value = value & (((1 << length)-1) << shift); 1241 1248 buffer[offset/8] = buffer[offset/8] | value; 1242 1243 1249 } 1244 1250 else { … … 1247 1253 // konec prvniho 1248 1254 tmp_value = value; 1249 tmp_value = tmp_value >> (8 - (offset%8)); 1250 tmp_value = tmp_value & ((1 << (8-(offset%8)))-1); 1255 tmp_value = tmp_value >> (8 - (offset%8) - 1); 1256 tmp_value = tmp_value & ((1 << (8-(offset%8)))-1); 1257 1251 1258 buffer[offset/8] = buffer[offset/8] | tmp_value; 1252 1259 1253 1260 // a ted druhej 1254 value = value & (((1 << report_item->size) - ((8 - (offset%8))))-1); 1255 buffer[(offset+length)/8] = buffer[(offset+length)/8] | value; 1261 value = value & ((1 << (length - (8 - (offset%8))))-1); 1262 value = value << (8 - (length - (8 - (offset%8)))); 1263 1264 buffer[(offset+length-1)/8] = buffer[(offset+length-1)/8] | value; 1256 1265 } 1257 1266 … … 1276 1285 int resolution; 1277 1286 1278 if((USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0) || 1279 ((item->usage_minimum == 0) && (item->usage_maximum == 0))) { 1287 if((USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0)) { 1280 1288 1281 1289 // variable item
Note:
See TracChangeset
for help on using the changeset viewer.