Changeset bda06a3 in mainline


Ignore:
Timestamp:
2011-04-01T15:02:09Z (13 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a9974ef, ec6bee4
Parents:
70a71e5
Message:

Report IDs support

Location:
uspace/lib/usb
Files:
2 edited

Legend:

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

    r70a71e5 rbda06a3  
    8888        /** */ 
    8989        int depth;     
     90        uint8_t report_id;
    9091       
    9192        /** */ 
     
    155156        /** */ 
    156157        link_t feature;
     158       
     159        int use_report_id;
     160       
    157161} usb_hid_report_parser_t;     
    158162
     
    166170         * @param arg Custom argument.
    167171         */
    168         void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t modifiers, void *arg);
     172        void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t report_id, void *arg);
    169173} usb_hid_report_in_callbacks_t;
    170174
     
    269273
    270274/** */
     275int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, uint8_t report_id);
     276
     277/** */
    271278int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, int32_t usage_page, int32_t usage);
    272279
  • uspace/lib/usb/src/hidparser.c

    r70a71e5 rbda06a3  
    106106    list_initialize(&(parser->feature));
    107107
     108        parser->use_report_id = 0;
    108109    return EOK;   
    109110}
     
    186187                                        tmp_usage_path = NULL;
    187188
     189                                        usb_hid_report_path_set_report_id(report_item->usage_path, report_item->id);   
     190                                        if(report_item->id != 0){
     191                                                parser->use_report_id = 1;
     192                                        }
    188193                                       
    189194                                        switch(tag) {
     
    647652        }
    648653
     654        parser->use_report_id = 0;
     655
    649656        usb_hid_free_report_list(&parser->input);
    650657        usb_hid_free_report_list(&parser->output);
     
    676683        size_t i=0;
    677684        size_t j=0;
     685        uint8_t report_id = 0;
    678686
    679687        if(parser == NULL) {
     
    686694        if(!(keys = malloc(sizeof(uint8_t) * key_count))){
    687695                return ENOMEM;
     696        }
     697
     698        if(parser->use_report_id != 0) {
     699                report_id = data[0];
     700                usb_hid_report_path_set_report_id(path, report_id);
    688701        }
    689702
     
    693706
    694707                item = list_get_instance(list_item, usb_hid_report_item_t, link);
     708
    695709                if(!USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) &&
    696710                   (usb_hid_report_compare_usage_path(item->usage_path, path, flags) == EOK)) {
     
    715729        }
    716730
    717         callbacks->keyboard(keys, key_count, 0, arg);
     731        callbacks->keyboard(keys, key_count, report_id, arg);
    718732           
    719733        free(keys);     
     
    739753        int32_t mask;
    740754        const uint8_t *foo;
    741        
     755
    742756        // now only common numbers llowed
    743757        if(item->size > 32) {
     
    758772                (usb_pow(10,(item->unit_exponent))));
    759773        }
     774
    760775        offset = item->offset + (j * item->size);
     776        if(item->id != 0) {
     777                offset += 8;
     778                usb_log_debug("MOVED OFFSET BY 1Byte, REPORT_ID(%d)\n", item->id);
     779        }
    761780       
    762781        // FIXME
     
    942961
    943962        int only_page;
     963
     964        if(report_path->report_id != path->report_id) {
     965                return 1;
     966        }
    944967
    945968        if(path->depth == 0){
     
    10381061        else {
    10391062                path->depth = 0;
     1063                path->report_id = 0;
    10401064                list_initialize(&path->link);
    10411065                return path;
     
    11551179                return 0;
    11561180        }
    1157        
     1181
    11581182        item = parser->output.next;
    11591183        while(&parser->output != item) {
     
    11951219        int length;
    11961220        int32_t tmp_value;
     1221        size_t offset_prefix = 0;
    11971222       
    11981223        if(parser == NULL) {
    11991224                return EINVAL;
     1225        }
     1226
     1227        if(parser->use_report_id != 0) {
     1228                buffer[0] = path->report_id;
     1229                offset_prefix = 8;
    12001230        }
    12011231
     
    12181248//                              // variable item
    12191249                                value = usb_hid_translate_data_reverse(report_item, data[idx++]);
    1220                                 offset = report_item->offset + (i * report_item->size);
     1250                                offset = report_item->offset + (i * report_item->size) + offset_prefix;
    12211251                                length = report_item->size;
    12221252                        }
     
    12241254                                //bitmap
    12251255                                value += usb_hid_translate_data_reverse(report_item, data[idx++]);
    1226                                 offset = report_item->offset;
     1256                                offset = report_item->offset + offset_prefix;
    12271257                                length = report_item->size * report_item->count;
    12281258                        }
     
    13231353
    13241354
     1355int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id)
     1356{
     1357        if(path == NULL){
     1358                return EINVAL;
     1359        }
     1360
     1361        path->report_id = report_id;
     1362        return EOK;
     1363}
     1364
    13251365/**
    13261366 * @}
Note: See TracChangeset for help on using the changeset viewer.