Changes in uspace/lib/usbhid/src/hidpath.c [5499a8b:160b75e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hidpath.c
r5499a8b r160b75e 41 41 #include <assert.h> 42 42 43 /*---------------------------------------------------------------------------*/ 44 /** 45 * Compares two usages if they are same or not or one of the usages is not 46 * set. 47 * 48 * @param usage1 49 * @param usage2 50 * @return boolean 51 */ 52 #define USB_HID_SAME_USAGE(usage1, usage2) \ 53 ((usage1 == usage2) || (usage1 == 0) || (usage2 == 0)) 54 55 /** 56 * Compares two usage pages if they are same or not or one of them is not set. 57 * 58 * @param page1 59 * @param page2 60 * @return boolean 61 */ 62 #define USB_HID_SAME_USAGE_PAGE(page1, page2) \ 63 ((page1 == page2) || (page1 == 0) || (page2 == 0)) 64 65 /*---------------------------------------------------------------------------*/ 43 66 44 /** 67 45 * Appends one item (couple of usage_path and usage) into the usage path … … 92 70 } 93 71 94 /*---------------------------------------------------------------------------*/95 72 /** 96 73 * Removes last item from the usage path structure … … 111 88 } 112 89 113 /*---------------------------------------------------------------------------*/114 90 /** 115 91 * Nulls last item of the usage path structure. … … 123 99 124 100 if(!list_empty(&usage_path->head)){ 125 item = list_get_instance(usage_path->head.prev, 126 usb_hid_report_usage_path_t, link); 127 101 item = list_get_instance(usage_path->head.prev, usb_hid_report_usage_path_t, link); 128 102 memset(item, 0, sizeof(usb_hid_report_usage_path_t)); 129 103 } 130 104 } 131 105 132 /*---------------------------------------------------------------------------*/133 106 /** 134 107 * Modifies last item of usage path structure by given usage page or usage … … 161 134 } 162 135 163 /*---------------------------------------------------------------------------*/ 164 /** 165 * 166 * 167 * 168 * 169 */ 136 170 137 void usb_hid_print_usage_path(usb_hid_report_path_t *path) 171 138 { … … 177 144 while(item != &path->head) { 178 145 179 path_item = list_get_instance(item, usb_hid_report_usage_path_t, 180 link); 181 146 path_item = list_get_instance(item, usb_hid_report_usage_path_t, link); 182 147 usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page); 183 148 usb_log_debug("\tUSAGE: %X\n", path_item->usage); 184 149 usb_log_debug("\tFLAGS: %d\n", path_item->flags); 185 150 186 item = item->next; 187 } 188 } 189 190 /*---------------------------------------------------------------------------*/ 151 item = item->next; 152 } 153 } 154 191 155 /** 192 156 * Compares two usage paths structures … … 231 195 } 232 196 197 // projit skrz cestu a kdyz nekde sedi tak vratim EOK 198 // dojduli az za konec tak nnesedi 233 199 report_link = report_path->head.next; 234 200 path_link = path->head.next; 235 path_item = list_get_instance(path_link, 236 usb_hid_report_usage_path_t, link); 201 path_item = list_get_instance(path_link, usb_hid_report_usage_path_t, link); 237 202 238 203 while(report_link != &report_path->head) { 239 report_item = list_get_instance(report_link, 240 usb_hid_report_usage_path_t, link); 241 242 if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 243 path_item->usage_page)){ 244 204 report_item = list_get_instance(report_link, usb_hid_report_usage_path_t, link); 205 if(report_item->usage_page == path_item->usage_page){ 245 206 if(only_page == 0){ 246 if(USB_HID_SAME_USAGE(report_item->usage, 247 path_item->usage)) { 248 207 if(report_item->usage == path_item->usage) { 249 208 return EOK; 250 209 } … … 276 235 277 236 report_item = list_get_instance(report_link, 278 usb_hid_report_usage_path_t, link); 237 usb_hid_report_usage_path_t, 238 link); 279 239 280 240 path_item = list_get_instance(path_link, 281 usb_hid_report_usage_path_t, link); 282 283 if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 284 path_item->usage_page) || ((only_page == 0) &&285 !USB_HID_SAME_USAGE(report_item->usage,286 241 usb_hid_report_usage_path_t, 242 link); 243 244 if((report_item->usage_page != path_item->usage_page) || 245 ((only_page == 0) && 246 (report_item->usage != path_item->usage))) { 287 247 288 248 return 1; … … 294 254 } 295 255 296 if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 297 (path_link == &path->head)) || 298 ((report_link == &report_path->head) && 299 (path_link == &path->head))) { 300 256 if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && (path_link == &path->head)) || 257 ((report_link == &report_path->head) && (path_link == &path->head))) { 301 258 return EOK; 302 259 } … … 320 277 321 278 report_item = list_get_instance(report_link, 322 usb_hid_report_usage_path_t, link);323 279 usb_hid_report_usage_path_t, 280 link); 324 281 path_item = list_get_instance(path_link, 325 usb_hid_report_usage_path_t, link); 326 327 if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 328 path_item->usage_page) || ((only_page == 0) && 329 !USB_HID_SAME_USAGE(report_item->usage, 330 path_item->usage))) { 331 332 return 1; 282 usb_hid_report_usage_path_t, 283 link); 284 285 if((report_item->usage_page != path_item->usage_page) || 286 ((only_page == 0) && 287 (report_item->usage != path_item->usage))) { 288 return 1; 333 289 } else { 334 290 report_link = report_link->prev; … … 352 308 } 353 309 354 /*---------------------------------------------------------------------------*/355 310 /** 356 311 * Allocates and initializes new usage path structure. … … 374 329 } 375 330 376 /*---------------------------------------------------------------------------*/377 331 /** 378 332 * Releases given usage path structure. … … 391 345 } 392 346 393 /*---------------------------------------------------------------------------*/ 347 394 348 /** 395 349 * Clone content of given usage path to the new one … … 398 352 * @return New copy of given usage path structure 399 353 */ 400 usb_hid_report_path_t *usb_hid_report_path_clone( 401 usb_hid_report_path_t *usage_path) 354 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path) 402 355 { 403 356 link_t *path_link; … … 418 371 path_link = usage_path->head.next; 419 372 while(path_link != &usage_path->head) { 420 path_item = list_get_instance(path_link, usb_hid_report_usage_path_t, 373 path_item = list_get_instance(path_link, usb_hid_report_usage_path_t, 421 374 link); 422 375 new_path_item = malloc(sizeof(usb_hid_report_usage_path_t)); … … 439 392 } 440 393 441 /*---------------------------------------------------------------------------*/ 394 442 395 /** 443 396 * Sets report id in usage path structure … … 447 400 * @return Error code 448 401 */ 449 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, 450 uint8_t report_id) 402 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id) 451 403 { 452 404 if(path == NULL){
Note:
See TracChangeset
for help on using the changeset viewer.