Changeset e3b5129 in mainline


Ignore:
Timestamp:
2011-04-12T19:00:00Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
11d2e96a, c7dd69d
Parents:
a6610d4
Message:

Report IDs in subdriver mappings, sample driver for Logitech kbd

Location:
uspace/drv/usbhid
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/Makefile

    ra6610d4 re3b5129  
    4646        generic/hiddev.c \
    4747        mouse/mousedev.c \
     48        lgtch-ultrax/lgtch-ultrax.c \
    4849        $(STOLEN_LAYOUT_SOURCES)
    4950
  • uspace/drv/usbhid/subdrivers.c

    ra6610d4 re3b5129  
    3737#include "usb/classes/hidut.h"
    3838
     39#include "lgtch-ultrax/lgtch-ultrax.h"
     40
    3941static usb_hid_subdriver_usage_t path_kbd[] = {
    4042        {USB_HIDUT_PAGE_KEYBOARD, 0},
     43        {0, 0}
     44};
     45
     46static usb_hid_subdriver_usage_t lgtch_path[] = {
     47        {0xc, 0},
    4148        {0, 0}
    4249};
     
    4552        {
    4653                path_kbd,
     54                -1,
    4755                USB_HID_PATH_COMPARE_END
    4856                | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     
    5765               
    5866        },
    59         {NULL, 0, 0, 0, {NULL, NULL, NULL, NULL}}
     67        {
     68                lgtch_path,
     69                1,
     70                USB_HID_PATH_COMPARE_END
     71                | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     72                0x046d,
     73                0xc30e,
     74                {
     75                        .init = NULL,
     76                        .deinit = NULL,
     77                        .poll = usb_lgtch_polling_callback,
     78                        .poll_end = NULL
     79                }
     80        },
     81        {NULL, -1, 0, 0, 0, {NULL, NULL, NULL, NULL}}
    6082};
    6183
  • uspace/drv/usbhid/subdrivers.h

    ra6610d4 re3b5129  
    5454typedef struct usb_hid_subdriver_mapping {
    5555        const usb_hid_subdriver_usage_t *usage_path;
     56        int report_id;
    5657        int compare;
    5758        uint16_t vendor_id;
  • uspace/drv/usbhid/usbhid.c

    ra6610d4 re3b5129  
    164164
    165165static bool usb_hid_path_matches(usb_hid_dev_t *hid_dev,
    166     const usb_hid_subdriver_usage_t *path, int compare)
     166    const usb_hid_subdriver_mapping_t *mapping)
    167167{
    168168        assert(hid_dev != NULL);
    169         assert(path != NULL);
     169        assert(mapping != NULL);
    170170       
    171171        usb_hid_report_path_t *usage_path = usb_hid_report_path();
     
    175175        }
    176176        int i = 0;
    177         while (path[i].usage != 0 || path[i].usage_page != 0) {
     177        while (mapping->usage_path[i].usage != 0
     178            || mapping->usage_path[i].usage_page != 0) {
    178179                if (usb_hid_report_path_append_item(usage_path,
    179                     path[i].usage_page, path[i].usage) != EOK) {
     180                    mapping->usage_path[i].usage_page,
     181                    mapping->usage_path[i].usage) != EOK) {
    180182                        usb_log_debug("Failed to append to usage path.\n");
    181183                        usb_hid_report_path_free(usage_path);
     
    185187        }
    186188       
     189        if (mapping->report_id >= 0) {
     190                usb_hid_report_path_set_report_id(usage_path,
     191                    mapping->report_id);
     192        }
     193       
    187194        assert(hid_dev->parser != NULL);
    188195       
    189         usb_log_debug("Compare flags: %d\n", compare);
     196        usb_log_debug("Compare flags: %d\n", mapping->compare);
    190197        size_t size = usb_hid_report_input_length(hid_dev->parser, usage_path,
    191             compare);
     198            mapping->compare);
    192199        usb_log_debug("Size of the input report: %d\n", size);
    193200       
     
    273280                if (mapping->usage_path != NULL) {
    274281                        usb_log_debug("Comparing device against usage path.\n");
    275                         if (usb_hid_path_matches(hid_dev,
    276                             mapping->usage_path, mapping->compare)) {
     282                        if (usb_hid_path_matches(hid_dev, mapping)) {
    277283                                // does not matter if IDs were matched
    278284                                matched = true;
Note: See TracChangeset for help on using the changeset viewer.