Changes in / [a82889e:b04967a] in mainline
- Location:
- uspace/lib/usb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/classes/hidparser.h
ra82889e rb04967a 88 88 /** */ 89 89 int depth; 90 uint8_t report_id; 90 91 91 92 /** */ 92 93 link_t link; 94 93 95 } usb_hid_report_path_t; 94 96 … … 155 157 /** */ 156 158 link_t feature; 159 160 int use_report_id; 161 162 /** */ 163 link_t stack; 157 164 } usb_hid_report_parser_t; 158 165 … … 166 173 * @param arg Custom argument. 167 174 */ 168 void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t modifiers, void *arg);175 void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t report_id, void *arg); 169 176 } usb_hid_report_in_callbacks_t; 170 177 … … 269 276 270 277 /** */ 278 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, uint8_t report_id); 279 280 /** */ 271 281 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, int32_t usage_page, int32_t usage); 272 282 -
uspace/lib/usb/src/hidparser.c
ra82889e rb04967a 64 64 int usb_hid_report_reset_local_items(); 65 65 void usb_hid_free_report_list(link_t *head); 66 66 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item); 67 67 /* 68 68 * Data translation private functions … … 106 106 list_initialize(&(parser->feature)); 107 107 108 list_initialize(&(parser->stack)); 109 110 parser->use_report_id = 0; 108 111 return EOK; 109 112 } … … 186 189 tmp_usage_path = NULL; 187 190 191 usb_hid_report_path_set_report_id(report_item->usage_path, report_item->id); 192 if(report_item->id != 0){ 193 parser->use_report_id = 1; 194 } 188 195 189 196 switch(tag) { … … 215 222 if(!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) { 216 223 return ENOMEM; 217 } 224 } 218 225 memcpy(new_report_item,report_item, sizeof(usb_hid_report_item_t)); 226 link_initialize(&(new_report_item->link)); 227 219 228 /* reset local items */ 220 229 new_report_item->usage_minimum = 0; 221 230 new_report_item->usage_maximum = 0; 231 new_report_item->designator_index = 0; 232 new_report_item->designator_minimum = 0; 233 new_report_item->designator_maximum = 0; 234 new_report_item->string_index = 0; 235 new_report_item->string_minimum = 0; 236 new_report_item->string_maximum = 0; 237 238 /* reset usage from current usage path */ 239 usb_hid_report_usage_path_t *path = list_get_instance(&usage_path->link, usb_hid_report_usage_path_t, link); 240 path->usage = 0; 222 241 223 link_initialize(&(new_report_item->link));224 242 report_item = new_report_item; 225 243 … … 227 245 case USB_HID_REPORT_TAG_PUSH: 228 246 // push current state to stack 229 // not yet implemented 247 new_report_item = usb_hid_report_item_clone(report_item); 248 list_prepend (&parser->stack, &new_report_item->link); 249 230 250 break; 231 251 case USB_HID_REPORT_TAG_POP: 232 252 // restore current state from stack 233 // not yet implemented 253 if(list_empty (&parser->stack)) { 254 return EINVAL; 255 } 256 257 report_item = list_get_instance(&parser->stack, usb_hid_report_item_t, link); 258 list_remove (parser->stack.next); 259 234 260 break; 235 261 … … 647 673 } 648 674 675 parser->use_report_id = 0; 676 649 677 usb_hid_free_report_list(&parser->input); 650 678 usb_hid_free_report_list(&parser->output); … … 676 704 size_t i=0; 677 705 size_t j=0; 706 uint8_t report_id = 0; 678 707 679 708 if(parser == NULL) { … … 686 715 if(!(keys = malloc(sizeof(uint8_t) * key_count))){ 687 716 return ENOMEM; 717 } 718 719 if(parser->use_report_id != 0) { 720 report_id = data[0]; 721 usb_hid_report_path_set_report_id(path, report_id); 688 722 } 689 723 … … 693 727 694 728 item = list_get_instance(list_item, usb_hid_report_item_t, link); 729 695 730 if(!USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) && 696 731 (usb_hid_report_compare_usage_path(item->usage_path, path, flags) == EOK)) { … … 715 750 } 716 751 717 callbacks->keyboard(keys, key_count, 0, arg);752 callbacks->keyboard(keys, key_count, report_id, arg); 718 753 719 754 free(keys); … … 739 774 int32_t mask; 740 775 const uint8_t *foo; 741 776 742 777 // now only common numbers llowed 743 778 if(item->size > 32) { … … 758 793 (usb_pow(10,(item->unit_exponent)))); 759 794 } 795 760 796 offset = item->offset + (j * item->size); 797 if(item->id != 0) { 798 offset += 8; 799 usb_log_debug("MOVED OFFSET BY 1Byte, REPORT_ID(%d)\n", item->id); 800 } 761 801 762 802 // FIXME … … 942 982 943 983 int only_page; 984 985 if(report_path->report_id != path->report_id) { 986 return 1; 987 } 944 988 945 989 if(path->depth == 0){ … … 1038 1082 else { 1039 1083 path->depth = 0; 1084 path->report_id = 0; 1040 1085 list_initialize(&path->link); 1041 1086 return path; … … 1155 1200 return 0; 1156 1201 } 1157 1202 1158 1203 item = parser->output.next; 1159 1204 while(&parser->output != item) { … … 1195 1240 int length; 1196 1241 int32_t tmp_value; 1242 size_t offset_prefix = 0; 1197 1243 1198 1244 if(parser == NULL) { 1199 1245 return EINVAL; 1246 } 1247 1248 if(parser->use_report_id != 0) { 1249 buffer[0] = path->report_id; 1250 offset_prefix = 8; 1200 1251 } 1201 1252 … … 1218 1269 // // variable item 1219 1270 value = usb_hid_translate_data_reverse(report_item, data[idx++]); 1220 offset = report_item->offset + (i * report_item->size) ;1271 offset = report_item->offset + (i * report_item->size) + offset_prefix; 1221 1272 length = report_item->size; 1222 1273 } … … 1224 1275 //bitmap 1225 1276 value += usb_hid_translate_data_reverse(report_item, data[idx++]); 1226 offset = report_item->offset ;1277 offset = report_item->offset + offset_prefix; 1227 1278 length = report_item->size * report_item->count; 1228 1279 } … … 1323 1374 1324 1375 1376 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id) 1377 { 1378 if(path == NULL){ 1379 return EINVAL; 1380 } 1381 1382 path->report_id = report_id; 1383 return EOK; 1384 } 1385 1386 1387 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item) 1388 { 1389 usb_hid_report_item_t *new_report_item; 1390 1391 if(!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) { 1392 return NULL; 1393 } 1394 memcpy(new_report_item,item, sizeof(usb_hid_report_item_t)); 1395 link_initialize(&(new_report_item->link)); 1396 1397 return new_report_item; 1398 } 1399 1325 1400 /** 1326 1401 * @}
Note:
See TracChangeset
for help on using the changeset viewer.