Changeset e141281 in mainline for uspace/lib/usbhid/src
- Timestamp:
- 2017-05-04T22:17:36Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 31a30fa
- Parents:
- dc12262
- Location:
- uspace/lib/usbhid/src
- Files:
-
- 2 edited
-
hiddescriptor.c (modified) (3 diffs)
-
hidpath.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hiddescriptor.c
rdc12262 re141281 737 737 * @return Error code 738 738 */ 739 int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, 740 size_t item_size, usb_hid_report_item_t *report_item, 741 usb_hid_report_path_t *usage_path)739 int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, 740 size_t item_size, usb_hid_report_item_t *report_item, 741 usb_hid_report_path_t *usage_path) 742 742 { 743 743 int32_t extended_usage; 744 744 745 switch (tag) {745 switch (tag) { 746 746 case USB_HID_REPORT_TAG_USAGE: 747 switch (report_item->in_delimiter) {747 switch (report_item->in_delimiter) { 748 748 case INSIDE_DELIMITER_SET: 749 /* nothing to do 750 * we catch only the first one 749 /* 750 * Nothing to do. 751 * We catch only the first one 751 752 */ 752 753 break; 753 754 754 755 case START_DELIMITER_SET: 755 756 report_item->in_delimiter = INSIDE_DELIMITER_SET; … … 757 758 case OUTSIDE_DELIMITER_SET: 758 759 extended_usage = ((report_item->usage_page) << 16); 759 extended_usage += usb_hid_report_tag_data_uint32(760 data,item_size);761 762 report_item->usages[report_item->usages_count] = 763 extended_usage;764 760 extended_usage += 761 usb_hid_report_tag_data_uint32(data, item_size); 762 763 report_item->usages[report_item->usages_count] = 764 extended_usage; 765 765 766 report_item->usages_count++; 766 767 break; … … 768 769 break; 769 770 770 case USB_HID_REPORT_TAG_USAGE_MINIMUM: 771 case USB_HID_REPORT_TAG_USAGE_MINIMUM: 771 772 if (item_size == 3) { 772 // usage extended usages 773 report_item->extended_usage_page = 773 /* Usage extended usages */ 774 report_item->extended_usage_page = 775 USB_HID_EXTENDED_USAGE_PAGE( 776 usb_hid_report_tag_data_uint32(data, item_size)); 777 778 779 report_item->usage_minimum = 780 USB_HID_EXTENDED_USAGE( 781 usb_hid_report_tag_data_uint32(data, item_size)); 782 } else { 783 report_item->usage_minimum = 784 usb_hid_report_tag_data_uint32(data, item_size); 785 } 786 break; 787 788 case USB_HID_REPORT_TAG_USAGE_MAXIMUM: 789 if (item_size == 3) { 790 if (report_item->extended_usage_page != 791 USB_HID_EXTENDED_USAGE_PAGE( 792 usb_hid_report_tag_data_uint32(data, item_size))) { 793 return EINVAL; 794 } 795 796 /* Usage extended usages */ 797 report_item->extended_usage_page = 774 798 USB_HID_EXTENDED_USAGE_PAGE( 775 799 usb_hid_report_tag_data_uint32(data,item_size)); 776 777 778 report_item->usage_minimum = 800 801 report_item->usage_maximum = 779 802 USB_HID_EXTENDED_USAGE( 780 803 usb_hid_report_tag_data_uint32(data,item_size)); 781 } 782 else { 783 report_item->usage_minimum = 804 } else { 805 report_item->usage_maximum = 784 806 usb_hid_report_tag_data_uint32(data,item_size); 785 807 } 786 break; 787 788 case USB_HID_REPORT_TAG_USAGE_MAXIMUM: 789 if (item_size == 3) { 790 if(report_item->extended_usage_page != 791 USB_HID_EXTENDED_USAGE_PAGE( 792 usb_hid_report_tag_data_uint32(data,item_size))) { 793 794 return EINVAL; 795 } 796 797 // usage extended usages 798 report_item->extended_usage_page = 799 USB_HID_EXTENDED_USAGE_PAGE( 800 usb_hid_report_tag_data_uint32(data,item_size)); 801 802 report_item->usage_maximum = 803 USB_HID_EXTENDED_USAGE( 804 usb_hid_report_tag_data_uint32(data,item_size)); 805 } 806 else { 807 report_item->usage_maximum = 808 usb_hid_report_tag_data_uint32(data,item_size); 809 } 810 811 // vlozit zaznamy do pole usages 812 int32_t i; 813 for(i = report_item->usage_minimum; 808 809 /* Put the records into the usages array */ 810 for (int32_t i = report_item->usage_minimum; 814 811 i <= report_item->usage_maximum; i++) { 815 816 if(report_item->extended_usage_page) { 817 report_item->usages[report_item->usages_count++] = 818 (report_item->extended_usage_page << 16) + i; 819 } 820 else { 821 report_item->usages[report_item->usages_count++] = 822 (report_item->usage_page << 16) + i; 812 813 if (report_item->extended_usage_page) { 814 report_item->usages[report_item->usages_count++] = 815 (report_item->extended_usage_page << 16) + i; 816 } else { 817 report_item->usages[report_item->usages_count++] = 818 (report_item->usage_page << 16) + i; 823 819 } 824 820 } 825 821 report_item->extended_usage_page = 0; 826 822 827 823 break; 828 824 829 825 case USB_HID_REPORT_TAG_DESIGNATOR_INDEX: 830 report_item->designator_index = 831 usb_hid_report_tag_data_uint32(data,item_size);826 report_item->designator_index = 827 usb_hid_report_tag_data_uint32(data, item_size); 832 828 break; 833 829 834 830 case USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM: 835 report_item->designator_minimum = 836 usb_hid_report_tag_data_uint32(data,item_size);837 break; 838 831 report_item->designator_minimum = 832 usb_hid_report_tag_data_uint32(data, item_size); 833 break; 834 839 835 case USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM: 840 report_item->designator_maximum = 841 usb_hid_report_tag_data_uint32(data,item_size);842 break; 843 836 report_item->designator_maximum = 837 usb_hid_report_tag_data_uint32(data, item_size); 838 break; 839 844 840 case USB_HID_REPORT_TAG_STRING_INDEX: 845 report_item->string_index = 846 usb_hid_report_tag_data_uint32(data,item_size);847 break; 848 841 report_item->string_index = 842 usb_hid_report_tag_data_uint32(data, item_size); 843 break; 844 849 845 case USB_HID_REPORT_TAG_STRING_MINIMUM: 850 report_item->string_minimum = 851 usb_hid_report_tag_data_uint32(data,item_size);852 break; 853 846 report_item->string_minimum = 847 usb_hid_report_tag_data_uint32(data, item_size); 848 break; 849 854 850 case USB_HID_REPORT_TAG_STRING_MAXIMUM: 855 report_item->string_maximum = 856 usb_hid_report_tag_data_uint32(data,item_size);857 break; 858 851 report_item->string_maximum = 852 usb_hid_report_tag_data_uint32(data, item_size); 853 break; 854 859 855 case USB_HID_REPORT_TAG_DELIMITER: 860 report_item->in_delimiter = 861 usb_hid_report_tag_data_uint32(data,item_size);862 break; 863 856 report_item->in_delimiter = 857 usb_hid_report_tag_data_uint32(data, item_size); 858 break; 859 864 860 default: 865 861 return USB_HID_NO_ACTION; 866 862 } 867 863 868 864 return EOK; 869 865 } 870 871 866 872 867 /** -
uspace/lib/usbhid/src/hidpath.c
rdc12262 re141281 185 185 } 186 186 187 188 /** 189 * Compares two usage paths structures 190 * 191 * 192 * @param report_path usage path structure to compare with @path 193 * @param path usage patrh structure to compare 194 * @param flags Flags determining the mode of comparison 187 /** Compare two usage paths structures 188 * 189 * @param report_path Usage path structure to compare with @path 190 * @param path Usage patrh structure to compare 191 * @param flags Flags determining the mode of comparison 192 * 195 193 * @return EOK if both paths are identical, non zero number otherwise 196 * /197 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 198 usb_hid_report_path_t *path,199 int flags)194 * 195 */ 196 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 197 usb_hid_report_path_t *path, int flags) 200 198 { 201 199 usb_hid_report_usage_path_t *report_item; 202 200 usb_hid_report_usage_path_t *path_item; 203 201 204 202 link_t *report_link; 205 203 link_t *path_link; 206 204 207 205 int only_page; 208 209 if (report_path->report_id != path->report_id) {210 if (path->report_id != 0) {206 207 if (report_path->report_id != path->report_id) { 208 if (path->report_id != 0) { 211 209 return 1; 212 210 } 213 211 } 214 212 215 213 // Empty path match all others 216 if (path->depth == 0){214 if (path->depth == 0) { 217 215 return EOK; 218 216 } 219 220 221 if((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0){ 217 218 if ((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0) { 222 219 flags -= USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY; 223 220 } 224 221 225 switch (flags){226 /* path is somewhere in report_path */222 switch (flags) { 223 /* Path is somewhere in report_path */ 227 224 case USB_HID_PATH_COMPARE_ANYWHERE: 228 if (path->depth != 1){225 if (path->depth != 1) { 229 226 return 1; 230 227 } 231 228 232 229 path_link = list_first(&path->items); 233 230 path_item = list_get_instance(path_link, 234 usb_hid_report_usage_path_t, rpath_items_link);235 231 usb_hid_report_usage_path_t, rpath_items_link); 232 236 233 list_foreach(report_path->items, rpath_items_link, 237 234 usb_hid_report_usage_path_t, report_item) { 238 239 235 if (USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 240 path_item->usage_page)) {236 path_item->usage_page)) { 241 237 242 238 if (only_page == 0) { … … 244 240 path_item->usage)) 245 241 return EOK; 246 } 247 else { 242 } else { 248 243 return EOK; 249 244 } 250 245 } 251 246 } 252 247 253 248 return 1; 254 249 break; 255 256 /* the paths must be identical */250 251 /* The paths must be identical */ 257 252 case USB_HID_PATH_COMPARE_STRICT: 258 if (report_path->depth != path->depth){253 if (report_path->depth != path->depth) { 259 254 return 1; 260 255 } 261 256 /* Fallthrough */ 262 263 /* path is prefix of the report_path */257 258 /* Path is prefix of the report_path */ 264 259 case USB_HID_PATH_COMPARE_BEGIN: 265 266 260 report_link = report_path->items.head.next; 267 261 path_link = path->items.head.next; … … 270 264 (path_link != &path->items.head)) { 271 265 272 report_item = list_get_instance(report_link, 266 report_item = list_get_instance(report_link, 273 267 usb_hid_report_usage_path_t, rpath_items_link); 274 268 275 269 path_item = list_get_instance(path_link, 276 usb_hid_report_usage_path_t, rpath_items_link);277 278 if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 279 path_item->usage_page) || ((only_page == 0) && 280 !USB_HID_SAME_USAGE(report_item->usage, 270 usb_hid_report_usage_path_t, rpath_items_link); 271 272 if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 273 path_item->usage_page) || ((only_page == 0) && 274 !USB_HID_SAME_USAGE(report_item->usage, 281 275 path_item->usage))) { 282 276 return 1; … … 286 280 } 287 281 } 288 289 if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 290 (path_link == &path->items.head)) || 291 ((report_link == &report_path->items.head) && 282 283 if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 284 (path_link == &path->items.head)) || 285 ((report_link == &report_path->items.head) && 292 286 (path_link == &path->items.head))) { 293 287 return EOK; … … 296 290 } 297 291 break; 298 299 /* path is suffix of report_path */292 293 /* Path is suffix of report_path */ 300 294 case USB_HID_PATH_COMPARE_END: 301 302 295 report_link = report_path->items.head.prev; 303 296 path_link = path->items.head.prev; 304 305 if (list_empty(&path->items)){297 298 if (list_empty(&path->items)) { 306 299 return EOK; 307 300 } 301 302 while ((report_link != &report_path->items.head) && 303 (path_link != &path->items.head)) { 304 report_item = list_get_instance(report_link, 305 usb_hid_report_usage_path_t, rpath_items_link); 308 306 309 while((report_link != &report_path->items.head) && 310 (path_link != &path->items.head)) { 311 312 report_item = list_get_instance(report_link, 313 usb_hid_report_usage_path_t, rpath_items_link); 314 315 path_item = list_get_instance(path_link, 316 usb_hid_report_usage_path_t, rpath_items_link); 317 318 if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 319 path_item->usage_page) || ((only_page == 0) && 320 !USB_HID_SAME_USAGE(report_item->usage, 321 path_item->usage))) { 322 323 return 1; 307 path_item = list_get_instance(path_link, 308 usb_hid_report_usage_path_t, rpath_items_link); 309 310 if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 311 path_item->usage_page) || ((only_page == 0) && 312 !USB_HID_SAME_USAGE(report_item->usage, 313 path_item->usage))) { 314 return 1; 324 315 } else { 325 316 report_link = report_link->prev; 326 path_link = path_link->prev; 317 path_link = path_link->prev; 327 318 } 328 329 } 330 331 if(path_link == &path->items.head) { 319 } 320 321 if (path_link == &path->items.head) { 332 322 return EOK; 333 } 334 else { 323 } else { 335 324 return 1; 336 } 337 325 } 338 326 break; 339 327 340 328 default: 341 329 return EINVAL; 342 330 } 343 331 } 344 345 332 346 333 /**
Note:
See TracChangeset
for help on using the changeset viewer.
