Changeset 5499a8b in mainline for uspace/lib/usbhid/src/hidpath.c


Ignore:
Timestamp:
2011-05-20T13:43:09Z (13 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
14e7959
Parents:
74b1e40
Message:

usb hid parser doxygen

File:
1 edited

Legend:

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

    r74b1e40 r5499a8b  
    4141#include <assert.h>
    4242
    43 
    44 #define USB_HID_SAME_USAGE(usage1, usage2)      ((usage1 == usage2) || (usage1 == 0) || (usage2 == 0))
    45 #define USB_HID_SAME_USAGE_PAGE(page1, page2)   ((page1 == page2) || (page1 == 0) || (page2 == 0))
    46 
     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/*---------------------------------------------------------------------------*/
    4766/**
    4867 * Appends one item (couple of usage_path and usage) into the usage path
     
    7392}
    7493
     94/*---------------------------------------------------------------------------*/
    7595/**
    7696 * Removes last item from the usage path structure
     
    91111}
    92112
     113/*---------------------------------------------------------------------------*/
    93114/**
    94115 * Nulls last item of the usage path structure.
     
    102123       
    103124        if(!list_empty(&usage_path->head)){     
    104                 item = list_get_instance(usage_path->head.prev, usb_hid_report_usage_path_t, link);
     125                item = list_get_instance(usage_path->head.prev,
     126                        usb_hid_report_usage_path_t, link);
     127
    105128                memset(item, 0, sizeof(usb_hid_report_usage_path_t));
    106129        }
    107130}
    108131
     132/*---------------------------------------------------------------------------*/
    109133/**
    110134 * Modifies last item of usage path structure by given usage page or usage
     
    137161}
    138162
    139 
     163/*---------------------------------------------------------------------------*/
     164/**
     165 *
     166 *
     167 *
     168 *
     169 */
    140170void usb_hid_print_usage_path(usb_hid_report_path_t *path)
    141171{
     
    147177        while(item != &path->head) {
    148178
    149                 path_item = list_get_instance(item, usb_hid_report_usage_path_t, link);
     179                path_item = list_get_instance(item, usb_hid_report_usage_path_t,
     180                        link);
     181
    150182                usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page);
    151183                usb_log_debug("\tUSAGE: %X\n", path_item->usage);
    152184                usb_log_debug("\tFLAGS: %d\n", path_item->flags);               
    153185               
    154                 item = item->next;
    155         }
    156 }
    157 
     186        item = item->next;
     187        }
     188}
     189
     190/*---------------------------------------------------------------------------*/
    158191/**
    159192 * Compares two usage paths structures
     
    198231                        }
    199232
    200                         // projit skrz cestu a kdyz nekde sedi tak vratim EOK
    201                         // dojduli az za konec tak nnesedi
    202233                        report_link = report_path->head.next;
    203234                        path_link = path->head.next;
    204                         path_item = list_get_instance(path_link, usb_hid_report_usage_path_t, link);
     235                        path_item = list_get_instance(path_link,
     236                                usb_hid_report_usage_path_t, link);
    205237
    206238                        while(report_link != &report_path->head) {
    207                                 report_item = list_get_instance(report_link, usb_hid_report_usage_path_t, link);
    208                                 if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page)){
     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                                       
    209245                                        if(only_page == 0){
    210                                                 if(USB_HID_SAME_USAGE(report_item->usage, path_item->usage)) {
     246                                                if(USB_HID_SAME_USAGE(report_item->usage,
     247                                                        path_item->usage)) {
     248                                                       
    211249                                                        return EOK;
    212250                                                }
     
    238276                                                 
    239277                                        report_item = list_get_instance(report_link,
    240                                                                         usb_hid_report_usage_path_t,
    241                                                                         link);
     278                        usb_hid_report_usage_path_t, link);
    242279                                                 
    243280                                        path_item = list_get_instance(path_link,
    244                                                                       usb_hid_report_usage_path_t,
    245                                                                       link);           
    246 
    247                                         if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page) ||
    248                                            ((only_page == 0) &&
    249                                             !USB_HID_SAME_USAGE(report_item->usage, path_item->usage))) {
     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))) {
    250287                                                       
    251288                                                   return 1;
     
    257294                                }
    258295
    259                                 if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && (path_link == &path->head)) ||
    260                                    ((report_link == &report_path->head) && (path_link == &path->head))) {
     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                                       
    261301                                        return EOK;
    262302                                }
     
    280320                                                 
    281321                                        report_item = list_get_instance(report_link,
    282                                                                         usb_hid_report_usage_path_t,
    283                                                                         link);
     322                                                usb_hid_report_usage_path_t, link);
     323
    284324                                        path_item = list_get_instance(path_link,
    285                                                                       usb_hid_report_usage_path_t,
    286                                                                       link);           
     325                                                usb_hid_report_usage_path_t, link);             
    287326                                                 
    288                                         if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page) ||
    289                                            ((only_page == 0) &&
    290                                             !USB_HID_SAME_USAGE(report_item->usage, path_item->usage))) {
     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                                               
    291332                                                        return 1;
    292333                                        } else {
     
    311352}
    312353
     354/*---------------------------------------------------------------------------*/
    313355/**
    314356 * Allocates and initializes new usage path structure.
     
    332374}
    333375
     376/*---------------------------------------------------------------------------*/
    334377/**
    335378 * Releases given usage path structure.
     
    348391}
    349392
    350 
     393/*---------------------------------------------------------------------------*/
    351394/**
    352395 * Clone content of given usage path to the new one
     
    355398 * @return New copy of given usage path structure
    356399 */
    357 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path)
     400usb_hid_report_path_t *usb_hid_report_path_clone(
     401        usb_hid_report_path_t *usage_path)
    358402{
    359403        link_t *path_link;
     
    374418        path_link = usage_path->head.next;
    375419        while(path_link != &usage_path->head) {
    376                 path_item = list_get_instance(path_link, usb_hid_report_usage_path_t, 
     420                path_item = list_get_instance(path_link, usb_hid_report_usage_path_t,
    377421                                              link);
    378422                new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
     
    395439}
    396440
    397 
     441/*---------------------------------------------------------------------------*/
    398442/**
    399443 * Sets report id in usage path structure
     
    403447 * @return Error code
    404448 */
    405 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id)
     449int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path,
     450        uint8_t report_id)
    406451{
    407452        if(path == NULL){
Note: See TracChangeset for help on using the changeset viewer.