Changeset bb41b85 in mainline


Ignore:
Timestamp:
2011-03-18T14:21:00Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fc5ed5d
Parents:
6e3b9a58 (diff), c32688d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged changes from branch maklf

Location:
uspace/lib/usb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/classes/hidparser.h

    r6e3b9a58 rbb41b85  
    5252 * Input/Output/Feature Item flags
    5353 */
    54 #define USB_HID_ITEM_FLAG_CONSTANT(flags)       (flags & 0x1)
    55 #define USB_HID_ITEM_FLAG_VARIABLE(flags)       (flags & 0x2)
    56 #define USB_HID_ITEM_FLAG_RELATIVE(flags)       (flags & 0x4)
    57 #define USB_HID_ITEM_FLAG_WRAP(flags)           (flags & 0x8)
    58 #define USB_HID_ITEM_FLAG_LINEAR(flags)         (flags & 0x10)
    59 #define USB_HID_ITEM_FLAG_PREFERRED(flags)      (flags & 0x20)
    60 #define USB_HID_ITEM_FLAG_POSITION(flags)       (flags & 0x40)
    61 #define USB_HID_ITEM_FLAG_VOLATILE(flags)       (flags & 0x80)
    62 #define USB_HID_ITEM_FLAG_BUFFERED(flags)       (flags & 0x100)
    63 
     54/** Constant (1) / Variable (0) */
     55#define USB_HID_ITEM_FLAG_CONSTANT(flags)       ((flags & 0x1) == 0x1)
     56/** Variable (1) / Array (0) */
     57#define USB_HID_ITEM_FLAG_VARIABLE(flags)       ((flags & 0x2) == 0x2)
     58/** Absolute / Relative*/
     59#define USB_HID_ITEM_FLAG_RELATIVE(flags)       ((flags & 0x4) == 0x4)
     60/** Wrap / No Wrap */
     61#define USB_HID_ITEM_FLAG_WRAP(flags)           ((flags & 0x8) == 0x8)
     62#define USB_HID_ITEM_FLAG_LINEAR(flags)         ((flags & 0x10) == 0x10)
     63#define USB_HID_ITEM_FLAG_PREFERRED(flags)      ((flags & 0x20) == 0x20)
     64#define USB_HID_ITEM_FLAG_POSITION(flags)       ((flags & 0x40) == 0x40)
     65#define USB_HID_ITEM_FLAG_VOLATILE(flags)       ((flags & 0x80) == 0x80)
     66#define USB_HID_ITEM_FLAG_BUFFERED(flags)       ((flags & 0x100) == 0x100)
     67
     68
     69/**
     70 * Description of path of usage pages and usages in report descriptor
     71 */
     72typedef struct {
     73        int32_t usage_page;
     74} usb_hid_report_path_t;
    6475
    6576/**
     
    185196    const usb_hid_report_in_callbacks_t *callbacks, void *arg);
    186197
     198int usb_hid_report_input_length(const usb_hid_report_parser_t *parser,
     199        const usb_hid_report_path_t *path);
     200
    187201
    188202void usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
  • uspace/lib/usb/src/hidparser.c

    r6e3b9a58 rbb41b85  
    178178                                        }
    179179                                        memcpy(new_report_item,report_item, sizeof(usb_hid_report_item_t));
     180                                        /* reset local items */
     181                                        new_report_item->usage_minimum = 0;
     182                                        new_report_item->usage_maximum = 0;
     183                                       
    180184                                        link_initialize(&(new_report_item->link));
    181185                                        report_item = new_report_item;
     
    501505                usb_log_debug("\tCOUNT: %X\n", report_item->count);
    502506                usb_log_debug("\tSIZE: %X\n", report_item->size);
    503                 usb_log_debug("\tCONSTANT: %X\n", USB_HID_ITEM_FLAG_CONSTANT(report_item->item_flags));
     507                usb_log_debug("\tCONSTANT/VAR: %X\n", USB_HID_ITEM_FLAG_CONSTANT(report_item->item_flags));
     508                usb_log_debug("\tVARIABLE/ARRAY: %X\n", USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags));
    504509                usb_log_debug("\tUSAGE: %X\n", report_item->usage);
    505510                usb_log_debug("\tUSAGE PAGE: %X\n", report_item->usage_page);
     
    508513                usb_log_debug("\tPHYMIN: %X\n", report_item->physical_minimum);         
    509514                usb_log_debug("\tPHYMAX: %X\n", report_item->physical_maximum);                         
     515                usb_log_debug("\tUSAGEMIN: %X\n", report_item->usage_minimum);
     516                usb_log_debug("\tUSAGEMAX: %X\n", report_item->usage_maximum);
     517               
    510518                usb_log_debug("\n");           
    511519
     
    602610        usb_hid_report_item_t *item;
    603611        uint8_t *keys;
     612        uint8_t item_value;
    604613        size_t key_count=0;
    605614        size_t i=0;
     
    607616
    608617        // get the size of result keycodes array
    609         list_item = parser->input.next;   
    610         while(list_item != &(parser->input)) {
    611 
    612                 item = list_get_instance(list_item, usb_hid_report_item_t, link);
    613                 if(item->usage_page == BAD_HACK_USAGE_PAGE) {
    614                         key_count += item->count;
    615                 }
    616 
    617                 list_item = list_item->next;
    618         }
    619 
    620        
     618        usb_hid_report_path_t path;
     619        path.usage_page = BAD_HACK_USAGE_PAGE;
     620        key_count = usb_hid_report_input_length(parser, &path);
     621
    621622        if(!(keys = malloc(sizeof(uint8_t) * key_count))){
    622623                return ENOMEM;
     
    628629
    629630                item = list_get_instance(list_item, usb_hid_report_item_t, link);
    630                 if(item->usage_page == BAD_HACK_USAGE_PAGE) {
     631                if(!USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) &&
     632                   (item->usage_page == path.usage_page)) {
    631633                        for(j=0; j<(size_t)(item->count); j++) {
    632                                 keys[i++] = usb_hid_translate_data(item, data,j);
     634                                if((USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0) ||
     635                                   ((item->usage_minimum == 0) && (item->usage_maximum == 0))) {
     636                                        // variable item
     637                                        keys[i++] = usb_hid_translate_data(item, data,j);
     638                                }
     639                                else {
     640                                        // bitmapa
     641                                        if((item_value = usb_hid_translate_data(item, data, j)) != 0) {
     642                                                keys[i++] = j + item->usage_minimum;
     643                                        }
     644                                        else {
     645                                                keys[i++] = 0;
     646                                        }
     647                                }
    633648                        }
    634649                }
     
    719734       
    720735}
     736
     737int usb_hid_report_input_length(const usb_hid_report_parser_t *parser,
     738        const usb_hid_report_path_t *path)
     739{
     740        int ret = 0;
     741        link_t *item;
     742        usb_hid_report_item_t *report_item;
     743
     744        item = (&parser->input)->next;
     745        while(&parser->input != item) {
     746                report_item = list_get_instance(item, usb_hid_report_item_t, link);
     747                if(!USB_HID_ITEM_FLAG_CONSTANT(report_item->item_flags) &&
     748                   (report_item->usage_page == path->usage_page)) {
     749                        ret += report_item->count;
     750                }
     751
     752                item = item->next;
     753        }
     754
     755        return ret;
     756}
     757
     758
     759
    721760/**
    722761 * @}
Note: See TracChangeset for help on using the changeset viewer.