Changes in uspace/app/mkbd/main.c [a35b458:1b20da0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkbd/main.c
ra35b458 r1b20da0 66 66 if (*report == NULL) 67 67 return ENOMEM; 68 68 69 69 errno_t rc = usb_hid_report_init(*report); 70 70 if (rc != EOK) { … … 73 73 return rc; 74 74 } 75 75 76 76 /* Get the report descriptor length from the device */ 77 77 size_t report_desc_size; … … 83 83 return rc; 84 84 } 85 85 86 86 if (report_desc_size == 0) { 87 87 usb_hid_report_deinit(*report); … … 90 90 return EINVAL; 91 91 } 92 92 93 93 uint8_t *desc = (uint8_t *) malloc(report_desc_size); 94 94 if (desc == NULL) { … … 97 97 return ENOMEM; 98 98 } 99 99 100 100 /* Get the report descriptor from the device */ 101 101 size_t actual_size; … … 108 108 return rc; 109 109 } 110 110 111 111 if (actual_size != report_desc_size) { 112 112 usb_hid_report_deinit(*report); … … 116 116 return EINVAL; 117 117 } 118 118 119 119 /* Initialize the report parser */ 120 120 121 121 rc = usb_hid_parse_report_descriptor(*report, desc, report_desc_size); 122 122 free(desc); 123 123 124 124 return rc; 125 125 } … … 129 129 assert(buffer != NULL); 130 130 assert(report != NULL); 131 131 132 132 uint8_t report_id; 133 133 errno_t rc = usb_hid_parse_report(report, buffer, size, &report_id); 134 134 if (rc != EOK) 135 135 return; 136 136 137 137 usb_hid_report_path_t *path = usb_hid_report_path(); 138 138 if (path == NULL) { 139 139 return; 140 140 } 141 141 142 142 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0); 143 143 144 144 usb_hid_report_path_set_report_id(path, report_id); 145 145 … … 148 148 | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 149 149 USB_HID_REPORT_TYPE_INPUT); 150 150 151 151 while (field != NULL) { 152 152 if (field->value != 0) { … … 155 155 printf("Pressed key: %s\n", key_str); 156 156 } 157 157 158 158 field = usb_hid_report_get_sibling( 159 159 report, field, path, USB_HID_PATH_COMPARE_END … … 161 161 USB_HID_REPORT_TYPE_INPUT); 162 162 } 163 163 164 164 usb_hid_report_path_free(path); 165 165 } … … 208 208 { 209 209 int act_event = -1; 210 210 211 211 if (argc <= 1) { 212 212 print_usage(argv[0]); 213 213 return -1; 214 214 } 215 215 216 216 char *devpath = argv[1]; 217 217 218 218 devman_handle_t dev_handle = 0; 219 219 220 220 errno_t rc = usb_resolve_device_handle(devpath, &dev_handle); 221 221 if (rc != EOK) { … … 224 224 return rc; 225 225 } 226 226 227 227 async_sess_t *sess = devman_device_connect(dev_handle, 0); 228 228 if (!sess) { … … 231 231 return errno; 232 232 } 233 233 234 234 dev_sess = sess; 235 235 236 236 char path[MAX_PATH_LENGTH]; 237 237 rc = devman_fun_get_path(dev_handle, path, MAX_PATH_LENGTH); … … 241 241 return ENOMEM; 242 242 } 243 243 244 244 printf("Device path: %s\n", path); 245 246 245 246 247 247 usb_hid_report_t *report = NULL; 248 248 rc = initialize_report_parser(dev_sess, &report); … … 252 252 return rc; 253 253 } 254 254 255 255 assert(report != NULL); 256 256 257 257 size_t size; 258 258 rc = usbhid_dev_get_event_length(dev_sess, &size); … … 261 261 return rc; 262 262 } 263 263 264 264 uint8_t *event = (uint8_t *)malloc(size); 265 265 if (event == NULL) { … … 268 268 return ENOMEM; 269 269 } 270 270 271 271 fid_t quit_fibril = fibril_create(wait_for_quit_fibril, NULL); 272 272 if (quit_fibril == 0) { … … 278 278 size_t actual_size; 279 279 int event_nr; 280 280 281 281 while (true) { 282 282 /** @todo Try blocking call. */ … … 289 289 break; 290 290 } 291 291 292 292 if (event_nr > act_event) { 293 293 print_key(event, size, report); 294 294 act_event = event_nr; 295 295 } 296 296 297 297 async_usleep(10000); 298 298 } 299 299 300 300 return 0; 301 301 }
Note:
See TracChangeset
for help on using the changeset viewer.