Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhid/src/hidpath.c

    rf3b39b4 r5499a8b  
    225225       
    226226        switch(flags){
    227         /* path is somewhere in report_path */
    228         case USB_HID_PATH_COMPARE_ANYWHERE:
    229                 if(path->depth != 1){
    230                         return 1;
    231                 }
    232 
    233                 report_link = report_path->head.next;
    234                 path_link = path->head.next;
    235                 path_item = list_get_instance(path_link,
    236                         usb_hid_report_usage_path_t, link);
    237 
    238                 while(report_link != &report_path->head) {
    239                         report_item = list_get_instance(report_link,
     227                /* path is somewhere in report_path */
     228                case USB_HID_PATH_COMPARE_ANYWHERE:
     229                        if(path->depth != 1){
     230                                return 1;
     231                        }
     232
     233                        report_link = report_path->head.next;
     234                        path_link = path->head.next;
     235                        path_item = list_get_instance(path_link,
    240236                                usb_hid_report_usage_path_t, link);
     237
     238                        while(report_link != &report_path->head) {
     239                                report_item = list_get_instance(report_link,
     240                                        usb_hid_report_usage_path_t, link);
    241241                               
    242                         if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    243                                 path_item->usage_page)){
     242                                if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
     243                                        path_item->usage_page)){
    244244                                       
    245                                 if(only_page == 0){
    246                                         if(USB_HID_SAME_USAGE(
    247                                                 report_item->usage,
    248                                                 path_item->usage)) {
     245                                        if(only_page == 0){
     246                                                if(USB_HID_SAME_USAGE(report_item->usage,
     247                                                        path_item->usage)) {
    249248                                                       
     249                                                        return EOK;
     250                                                }
     251                                        }
     252                                        else {
    250253                                                return EOK;
    251254                                        }
    252255                                }
     256
     257                                report_link = report_link->next;
     258                        }
     259
     260                        return 1;
     261                        break;
     262                /* the paths must be identical */
     263                case USB_HID_PATH_COMPARE_STRICT:
     264                                if(report_path->depth != path->depth){
     265                                        return 1;
     266                                }
     267               
     268                /* path is prefix of the report_path */
     269                case USB_HID_PATH_COMPARE_BEGIN:
     270       
     271                                report_link = report_path->head.next;
     272                                path_link = path->head.next;
     273                       
     274                                while((report_link != &report_path->head) &&
     275                                      (path_link != &path->head)) {
     276                                                 
     277                                        report_item = list_get_instance(report_link,
     278                        usb_hid_report_usage_path_t, link);
     279                                                 
     280                                        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                                                path_item->usage))) {
     287                                                       
     288                                                   return 1;
     289                                        } else {
     290                                                report_link = report_link->next;
     291                                                path_link = path_link->next;                   
     292                                        }
     293                       
     294                                }
     295
     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                                       
     301                                        return EOK;
     302                                }
    253303                                else {
     304                                        return 1;
     305                                }                                               
     306                        break;
     307
     308                /* path is suffix of report_path */
     309                case USB_HID_PATH_COMPARE_END:
     310
     311                                report_link = report_path->head.prev;
     312                                path_link = path->head.prev;
     313
     314                                if(list_empty(&path->head)){
    254315                                        return EOK;
    255316                                }
    256                         }
    257 
    258                         report_link = report_link->next;
    259                 }
    260 
    261                 return 1;
    262                 break;
    263 
    264         /* the paths must be identical */
    265         case USB_HID_PATH_COMPARE_STRICT:
    266                 if(report_path->depth != path->depth){
    267                         return 1;
    268                 }
    269                
    270         /* path is prefix of the report_path */
    271         case USB_HID_PATH_COMPARE_BEGIN:
    272        
    273                 report_link = report_path->head.next;
    274                 path_link = path->head.next;
    275317                       
    276                 while((report_link != &report_path->head) &&
    277                       (path_link != &path->head)) {
    278                                          
    279                         report_item = list_get_instance(report_link,
    280                                 usb_hid_report_usage_path_t, link);
    281                                          
    282                         path_item = list_get_instance(path_link,
    283                                 usb_hid_report_usage_path_t, link);
    284 
    285                         if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    286                                 path_item->usage_page) || ((only_page == 0) &&
    287                             !USB_HID_SAME_USAGE(report_item->usage,
    288                                 path_item->usage))) {
     318                                while((report_link != &report_path->head) &&
     319                                      (path_link != &path->head)) {
     320                                                 
     321                                        report_item = list_get_instance(report_link,
     322                                                usb_hid_report_usage_path_t, link);
     323
     324                                        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;
     333                                        } else {
     334                                                report_link = report_link->prev;
     335                                                path_link = path_link->prev;                   
     336                                        }
    289337                       
    290                                 return 1;
    291                         }
    292                         else {
    293                                 report_link = report_link->next;
    294                                 path_link = path_link->next;                   
    295                         }
     338                                }
     339
     340                                if(path_link == &path->head) {
     341                                        return EOK;
     342                                }
     343                                else {
     344                                        return 1;
     345                                }                                               
    296346                       
    297                                 }
    298 
    299                 if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
    300                         (path_link == &path->head)) ||
    301                    ((report_link == &report_path->head) &&
    302                         (path_link == &path->head))) {
    303                                
    304                         return EOK;
    305                 }
    306                 else {
    307                         return 1;
    308                 }                                               
    309                 break;
    310 
    311         /* path is suffix of report_path */
    312         case USB_HID_PATH_COMPARE_END:
    313 
    314                 report_link = report_path->head.prev;
    315                 path_link = path->head.prev;
    316 
    317                 if(list_empty(&path->head)){
    318                         return EOK;
    319                 }
    320                        
    321                 while((report_link != &report_path->head) &&
    322                       (path_link != &path->head)) {
    323                                                  
    324                         report_item = list_get_instance(report_link,
    325                                 usb_hid_report_usage_path_t, link);
    326 
    327                         path_item = list_get_instance(path_link,
    328                                 usb_hid_report_usage_path_t, link);             
    329                                                  
    330                         if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    331                                 path_item->usage_page) || ((only_page == 0) &&
    332                             !USB_HID_SAME_USAGE(report_item->usage,
    333                                 path_item->usage))) {
    334                                                
    335                                         return 1;
    336                         } else {
    337                                 report_link = report_link->prev;
    338                                 path_link = path_link->prev;                   
    339                         }
    340 
    341                 }
    342 
    343                 if(path_link == &path->head) {
    344                         return EOK;
    345                 }
    346                 else {
    347                         return 1;
    348                 }                                               
    349                        
    350                 break;
    351 
    352         default:
    353                 return EINVAL;
     347                        break;
     348
     349                default:
     350                        return EINVAL;
    354351        }
    355352}
     
    421418        path_link = usage_path->head.next;
    422419        while(path_link != &usage_path->head) {
    423                 path_item = list_get_instance(path_link,
    424                         usb_hid_report_usage_path_t, link);
    425 
     420                path_item = list_get_instance(path_link, usb_hid_report_usage_path_t,
     421                                              link);
    426422                new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
    427423                if(new_path_item == NULL) {
Note: See TracChangeset for help on using the changeset viewer.