Changeset 63517c2 in mainline for uspace/drv/usbhid


Ignore:
Timestamp:
2011-04-21T08:33:44Z (15 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
020559c9
Parents:
da1dd48 (diff), e50cd7f (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:

Changes to HID parser (report structure)

Location:
uspace/drv/usbhid
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/kbd/kbddev.c

    rda1dd48 r63517c2  
    320320        // TODO: COMPOSE and KANA
    321321       
    322         usb_log_debug("Creating output report.\n");
    323        
    324         int rc = usb_hid_report_output_translate(hid_dev->parser,
    325             kbd_dev->led_path,
    326             USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    327             kbd_dev->output_buffer,
    328             kbd_dev->output_size, kbd_dev->led_data, kbd_dev->led_output_size);
     322        usb_log_debug("Creating output report: %s\n", usb_debug_str_buffer ((uint8_t *)kbd_dev->led_data, kbd_dev->led_output_size * 4, 0));
     323
     324        usb_hid_report_output_set_data(hid_dev->parser, kbd_dev->led_path,
     325                                       USB_HID_PATH_COMPARE_END , kbd_dev->led_data,
     326                                       kbd_dev->led_output_size);
     327        int rc = usb_hid_report_output_translate(hid_dev->parser, 0,
     328            kbd_dev->output_buffer, kbd_dev->output_size);
    329329       
    330330        if (rc != EOK) {
     
    649649        //usb_hid_report_path_set_report_id(path, 0);
    650650       
    651         int rc = usb_hid_parse_report(hid_dev->parser, buffer,
    652             actual_size, path,
    653             USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    654             &usb_kbd_parser_callbacks, hid_dev);
    655 
     651        int rc = usb_hid_parse_report(hid_dev->parser, buffer, actual_size);   
     652        usb_hid_report_field_t *field = usb_hid_report_get_sibling(hid_dev->parser,
     653                            NULL, path, USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     654                                                USB_HID_REPORT_TYPE_INPUT);
     655       
     656        while(field != NULL) {
     657                usb_log_debug("FIELD (%X) - VALUE(%X) USAGE(%X)\n", field, field->value, field->usage);
     658                field = usb_hid_report_get_sibling(hid_dev->parser, field, path,
     659                                                   USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     660                                                   USB_HID_REPORT_TYPE_INPUT);
     661        }
     662               
     663       
    656664        usb_hid_report_path_free(path);
    657665       
     
    766774        kbd_dev->output_size = 0;
    767775        kbd_dev->output_buffer = usb_hid_report_output(hid_dev->parser,
    768             &kbd_dev->output_size);
    769         if (kbd_dev->output_buffer == NULL && kbd_dev->output_size != 0) {
     776            &kbd_dev->output_size, 0x00);
     777        if (kbd_dev->output_buffer == NULL) {
    770778                usb_log_warning("Error creating output report buffer.\n");
    771779                free(kbd_dev->keys);
    772                 free(kbd_dev);
    773                 return ENOMEM;
     780                return ENOMEM;  /* TODO: other error code */
    774781        }
    775782       
  • uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c

    rda1dd48 r63517c2  
    8181        usb_hid_report_path_t *path = usb_hid_report_path();
    8282        usb_hid_report_path_append_item(path, 0xc, 0);
    83         usb_hid_report_path_set_report_id(path, 1);
     83        usb_hid_report_path_set_report_id(path, 0);
    8484       
    85         int rc = usb_hid_parse_report(hid_dev->parser, buffer,
    86             buffer_size, path,
    87             USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    88             &usb_lgtch_parser_callbacks, hid_dev);
     85        int rc = usb_hid_parse_report(hid_dev->parser, buffer, buffer_size);
     86
     87        usb_hid_report_field_t *field = usb_hid_report_get_sibling(hid_dev->parser, NULL, path, USB_HID_PATH_COMPARE_END , USB_HID_REPORT_TYPE_INPUT);
     88        while(field != NULL) {
     89                usb_log_debug("KEY VALUE(%X) USAGE(%X)\n", field->value, field->usage);
     90        }
     91       
    8992
    9093        usb_hid_report_path_free(path);
  • uspace/drv/usbhid/usbhid.c

    rda1dd48 r63517c2  
    341341        }
    342342       
    343         hid_dev->parser = (usb_hid_report_parser_t *)(malloc(sizeof(
    344             usb_hid_report_parser_t)));
     343        hid_dev->parser = (usb_hid_report_t *)(malloc(sizeof(
     344            usb_hid_report_t)));
    345345        if (hid_dev->parser == NULL) {
    346346                usb_log_fatal("No memory!\n");
     
    382382                return rc;
    383383        }
    384        
    385         /* Initialize the report parser. */
    386         rc = usb_hid_parser_init(hid_dev->parser);
    387         if (rc != EOK) {
    388                 usb_log_error("Failed to initialize report parser.\n");
    389                 //usb_hid_free(&hid_dev);
    390                 return rc;
    391         }
    392        
     384               
    393385        /* Get the report descriptor and parse it. */
    394386        rc = usb_hid_process_report_descriptor(hid_dev->usb_dev,
     
    592584        // destroy the parser
    593585        if ((*hid_dev)->parser != NULL) {
    594                 usb_hid_free_report_parser((*hid_dev)->parser);
     586                usb_hid_free_report((*hid_dev)->parser);
    595587        }
    596588
  • uspace/drv/usbhid/usbhid.h

    rda1dd48 r63517c2  
    9191       
    9292        /** HID Report parser. */
    93         usb_hid_report_parser_t *parser;
     93        usb_hid_report_t *parser;
    9494       
    9595        /** Arbitrary data (e.g. a special structure for handling keyboard). */
Note: See TracChangeset for help on using the changeset viewer.