Changes in uspace/app/mkbd/main.c [a35b458:1b20da0] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/mkbd/main.c

    ra35b458 r1b20da0  
    6666        if (*report == NULL)
    6767                return ENOMEM;
    68 
     68       
    6969        errno_t rc = usb_hid_report_init(*report);
    7070        if (rc != EOK) {
     
    7373                return rc;
    7474        }
    75 
     75       
    7676        /* Get the report descriptor length from the device */
    7777        size_t report_desc_size;
     
    8383                return rc;
    8484        }
    85 
     85       
    8686        if (report_desc_size == 0) {
    8787                usb_hid_report_deinit(*report);
     
    9090                return EINVAL;
    9191        }
    92 
     92       
    9393        uint8_t *desc = (uint8_t *) malloc(report_desc_size);
    9494        if (desc == NULL) {
     
    9797                return ENOMEM;
    9898        }
    99 
     99       
    100100        /* Get the report descriptor from the device */
    101101        size_t actual_size;
     
    108108                return rc;
    109109        }
    110 
     110       
    111111        if (actual_size != report_desc_size) {
    112112                usb_hid_report_deinit(*report);
     
    116116                return EINVAL;
    117117        }
    118 
     118       
    119119        /* Initialize the report parser */
    120 
     120       
    121121        rc = usb_hid_parse_report_descriptor(*report, desc, report_desc_size);
    122122        free(desc);
    123 
     123       
    124124        return rc;
    125125}
     
    129129        assert(buffer != NULL);
    130130        assert(report != NULL);
    131 
     131       
    132132        uint8_t report_id;
    133133        errno_t rc = usb_hid_parse_report(report, buffer, size, &report_id);
    134134        if (rc != EOK)
    135135                return;
    136 
     136       
    137137        usb_hid_report_path_t *path = usb_hid_report_path();
    138138        if (path == NULL) {
    139139                return;
    140140        }
    141 
     141       
    142142        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0);
    143 
     143       
    144144        usb_hid_report_path_set_report_id(path, report_id);
    145145
     
    148148            | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    149149            USB_HID_REPORT_TYPE_INPUT);
    150 
     150       
    151151        while (field != NULL) {
    152152                if (field->value != 0) {
     
    155155                        printf("Pressed key: %s\n", key_str);
    156156                }
    157 
     157               
    158158                field = usb_hid_report_get_sibling(
    159159                    report, field, path, USB_HID_PATH_COMPARE_END
     
    161161                    USB_HID_REPORT_TYPE_INPUT);
    162162        }
    163 
     163       
    164164        usb_hid_report_path_free(path);
    165165}
     
    208208{
    209209        int act_event = -1;
    210 
     210       
    211211        if (argc <= 1) {
    212212                print_usage(argv[0]);
    213213                return -1;
    214214        }
    215 
     215       
    216216        char *devpath = argv[1];
    217 
     217       
    218218        devman_handle_t dev_handle = 0;
    219 
     219       
    220220        errno_t rc = usb_resolve_device_handle(devpath, &dev_handle);
    221221        if (rc != EOK) {
     
    224224                return rc;
    225225        }
    226 
     226       
    227227        async_sess_t *sess = devman_device_connect(dev_handle, 0);
    228228        if (!sess) {
     
    231231                return errno;
    232232        }
    233 
     233       
    234234        dev_sess = sess;
    235 
     235       
    236236        char path[MAX_PATH_LENGTH];
    237237        rc = devman_fun_get_path(dev_handle, path, MAX_PATH_LENGTH);
     
    241241                return ENOMEM;
    242242        }
    243 
     243       
    244244        printf("Device path: %s\n", path);
    245 
    246 
     245       
     246       
    247247        usb_hid_report_t *report = NULL;
    248248        rc = initialize_report_parser(dev_sess, &report);
     
    252252                return rc;
    253253        }
    254 
     254       
    255255        assert(report != NULL);
    256 
     256       
    257257        size_t size;
    258258        rc = usbhid_dev_get_event_length(dev_sess, &size);
     
    261261                return rc;
    262262        }
    263 
     263       
    264264        uint8_t *event = (uint8_t *)malloc(size);
    265265        if (event == NULL) {
     
    268268                return ENOMEM;
    269269        }
    270 
     270       
    271271        fid_t quit_fibril = fibril_create(wait_for_quit_fibril, NULL);
    272272        if (quit_fibril == 0) {
     
    278278        size_t actual_size;
    279279        int event_nr;
    280 
     280       
    281281        while (true) {
    282282                /** @todo Try blocking call. */
     
    289289                        break;
    290290                }
    291 
     291               
    292292                if (event_nr > act_event) {
    293293                        print_key(event, size, report);
    294294                        act_event = event_nr;
    295295                }
    296 
     296               
    297297                async_usleep(10000);
    298298        }
    299 
     299       
    300300        return 0;
    301301}
Note: See TracChangeset for help on using the changeset viewer.