Changeset d600874 in mainline
- Timestamp:
- 2011-05-30T11:40:58Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b2387c2
- Parents:
- 98e15b1 (diff), 3dfdcb7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/lib/usbhid/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hiddescriptor.c
r98e15b1 rd600874 187 187 188 188 field = malloc(sizeof(usb_hid_report_field_t)); 189 if(field == NULL) { 190 return ENOMEM; 191 } 192 189 193 memset(field, 0, sizeof(usb_hid_report_field_t)); 190 194 list_initialize(&field->link); … … 216 220 } 217 221 else { 218 usage = 222 usage = report_item->usages[ 219 223 report_item->usages_count- 1]; 220 224 } … … 241 245 242 246 field->size = report_item->size; 243 244 size_t offset_byte = (report_item->offset + (i * 245 report_item->size)) / 8; 246 247 size_t offset_bit = 8 - ((report_item->offset + (i * 248 report_item->size)) % 8) - report_item->size; 249 250 field->offset = 8 * offset_byte + offset_bit; 251 if(report_item->id != 0) { 247 248 if(report_item->type == USB_HID_REPORT_TYPE_INPUT) { 249 int offset = report_item->offset + report_item->size * i; 250 int field_offset = (offset/8)*8 + (offset/8 + 1) * 8 - 251 offset - report_item->size; 252 if(field_offset < 0) { 253 field->offset = 0; 254 } 255 else { 256 field->offset = field_offset; 257 } 258 } 259 else { 260 field->offset = report_item->offset + (i * report_item->size); 261 } 262 263 264 if(report->use_report_ids != 0) { 252 265 field->offset += 8; 253 266 report->use_report_ids = 1; 254 267 } 268 255 269 field->item_flags = report_item->item_flags; 256 270 -
uspace/lib/usbhid/src/hidparser.c
r98e15b1 rd600874 153 153 154 154 155 report_des = usb_hid_report_find_description(report, *report_id, type); 155 report_des = usb_hid_report_find_description(report, *report_id, 156 type); 157 156 158 if(report_des == NULL) { 157 159 return EINVAL; … … 167 169 if(USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) { 168 170 169 if(USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0) 171 if(USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0){ 170 172 171 173 // array … … 174 176 175 177 item->usage = USB_HID_EXTENDED_USAGE( 176 item->usages[item->value - item->physical_minimum]); 177 178 item->usage_page = USB_HID_EXTENDED_USAGE_PAGE( 179 item->usages[item->value - item->physical_minimum]); 180 181 usb_hid_report_set_last_item (item->collection_path, 182 USB_HID_TAG_CLASS_GLOBAL, item->usage_page); 183 184 usb_hid_report_set_last_item (item->collection_path, 178 item->usages[ 179 item->value - item->physical_minimum]); 180 181 item->usage_page = 182 USB_HID_EXTENDED_USAGE_PAGE( 183 item->usages[ 184 item->value - item->physical_minimum]); 185 186 usb_hid_report_set_last_item ( 187 item->collection_path, 188 USB_HID_TAG_CLASS_GLOBAL, 189 item->usage_page); 190 191 usb_hid_report_set_last_item ( 192 item->collection_path, 185 193 USB_HID_TAG_CLASS_LOCAL, item->usage); 186 194 … … 188 196 else { 189 197 // variable item 190 item->value = usb_hid_translate_data(item, data); 191 } 198 item->value = usb_hid_translate_data(item, 199 data); 200 } 192 201 } 193 202 list_item = list_item->next; … … 213 222 214 223 int32_t value=0; 215 int32_t mask ;216 const uint8_t *foo ;224 int32_t mask=0; 225 const uint8_t *foo=0; 217 226 218 227 // now only shot tags are allowed … … 240 249 if((size_t)(offset/8) != (size_t)((offset+item->size-1)/8)) { 241 250 242 part_size = ((offset+item->size)%8);251 part_size = 0; 243 252 244 253 size_t i=0; … … 246 255 if(i == (size_t)(offset/8)) { 247 256 // the higher one 257 part_size = 8 - (offset % 8); 248 258 foo = data + i; 249 259 mask = ((1 << (item->size-part_size))-1); 250 value = (*foo & mask) << part_size;260 value = (*foo & mask); 251 261 } 252 262 else if(i == ((offset+item->size-1)/8)){ 253 263 // the lower one 254 264 foo = data + i; 255 mask = ((1 << part_size)-1) << (8-part_size); 256 value += ((*foo & mask) >> (8-part_size)); 265 mask = ((1 << (item->size - part_size)) - 1) 266 << (8 - (item->size - part_size)); 267 268 value = (((*foo & mask) >> (8 - 269 (item->size - part_size))) << part_size ) 270 + value; 257 271 } 258 272 else { 259 value = value << 8;260 value += *(data + 1);273 value = (*(data + 1) << (part_size + 8)) + value; 274 part_size += 8; 261 275 } 262 276 } … … 375 389 report_item = list_get_instance(item, usb_hid_report_field_t, link); 376 390 377 if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0) { 378 379 // array 380 value = usb_hid_translate_data_reverse(report_item, 381 report_item->value); 382 383 offset = report_item->offset; 384 length = report_item->size; 385 } 386 else { 387 // variable item 388 value = usb_hid_translate_data_reverse(report_item, 389 report_item->value); 390 391 offset = report_item->offset; 392 length = report_item->size; 393 } 394 391 value = usb_hid_translate_data_reverse(report_item, 392 report_item->value); 393 394 offset = report_des->bit_length - report_item->offset - 1; 395 length = report_item->size; 396 395 397 usb_log_debug("\ttranslated value: %x\n", value); 396 398 … … 617 619 return report_des->report_id; 618 620 } 621 622 report_it = report_it->next; 619 623 } 620 624
Note:
See TracChangeset
for help on using the changeset viewer.