Changeset 266fcd8 in mainline
- Timestamp:
- 2011-05-27T09:27:02Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 81d2f6a
- Parents:
- 3c9eb46
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkbd/main.c
r3c9eb46 r266fcd8 140 140 assert(report != NULL); 141 141 142 printf("Calling usb_hid_parse_report() with size %zu and "143 "buffer: \n", size);144 for (size_t i = 0; i < size; ++i) {145 printf(" %X ", buffer[i]);146 }147 printf("\n");142 // printf("Calling usb_hid_parse_report() with size %zu and " 143 // "buffer: \n", size); 144 // for (size_t i = 0; i < size; ++i) { 145 // printf(" %X ", buffer[i]); 146 // } 147 // printf("\n"); 148 148 149 149 uint8_t report_id; 150 150 int rc = usb_hid_parse_report(report, buffer, size, &report_id); 151 151 if (rc != EOK) { 152 printf("Error parsing report: %s\n", str_error(rc));152 // printf("Error parsing report: %s\n", str_error(rc)); 153 153 return; 154 154 } … … 168 168 USB_HID_REPORT_TYPE_INPUT); 169 169 170 // printf("Field: %p\n", field); 171 170 172 while (field != NULL) { 173 // printf("Field usage: %u, field value: %d\n", field->usage, 174 // field->value); 171 175 if (field->value != 0) { 172 176 const char *key_str = … … 179 183 | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 180 184 USB_HID_REPORT_TYPE_INPUT); 185 // printf("Next field: %p\n", field); 181 186 } 182 187 … … 200 205 int main(int argc, char *argv[]) 201 206 { 207 int act_event = -1; 202 208 203 209 if (argc <= 1) { … … 255 261 } 256 262 257 printf("Event length: %zu\n", size);263 // printf("Event length: %zu\n", size); 258 264 uint8_t *event = (uint8_t *)malloc(size); 259 265 if (event == NULL) { … … 262 268 } 263 269 264 printf("Event length: %zu\n", size);270 // printf("Event length: %zu\n", size); 265 271 266 272 size_t actual_size; 273 int event_nr; 267 274 268 275 while (1) { 269 276 // get event from the driver 270 printf("Getting event from the driver.\n");277 // printf("Getting event from the driver.\n"); 271 278 272 279 /** @todo Try blocking call. */ 273 280 rc = usbhid_dev_get_event(dev_phone, event, size, &actual_size, 274 0);281 &event_nr, 0); 275 282 if (rc != EOK) { 276 283 // hangup phone? … … 280 287 } 281 288 282 printf("Got buffer: %p, size: %zu, max size: %zu\n", event, 283 actual_size, size); 284 285 print_key(event, size, report); 286 287 async_usleep(10000); 289 // printf("Got buffer: %p, size: %zu, max size: %zu\n", event, 290 // actual_size, size); 291 292 // printf("Event number: %d, my actual event: %d\n", event_nr, 293 // act_event); 294 if (event_nr > act_event) { 295 print_key(event, size, report); 296 act_event = event_nr; 297 } 298 299 async_usleep(100000); 288 300 } 289 301 -
uspace/drv/usbhid/generic/hiddev.c
r3c9eb46 r266fcd8 63 63 64 64 static int usb_generic_hid_get_event(ddf_fun_t *fun, uint8_t *buffer, 65 size_t size, size_t *act_size, unsigned int flags);65 size_t size, size_t *act_size, int *event_nr, unsigned int flags); 66 66 67 67 static int usb_generic_hid_client_connected(ddf_fun_t *fun); … … 108 108 109 109 static int usb_generic_hid_get_event(ddf_fun_t *fun, uint8_t *buffer, 110 size_t size, size_t *act_size, unsigned int flags)110 size_t size, size_t *act_size, int *event_nr, unsigned int flags) 111 111 { 112 112 usb_log_debug2("Generic HID: Get event.\n"); 113 113 114 if (fun == NULL || fun->driver_data == NULL) { 114 if (fun == NULL || fun->driver_data == NULL || buffer == NULL 115 || act_size == NULL || event_nr == NULL) { 115 116 usb_log_debug("No function"); 116 117 return EINVAL; … … 137 138 hid_dev->input_report_size); 138 139 *act_size = hid_dev->input_report_size; 140 *event_nr = usb_hid_report_number(hid_dev); 139 141 140 142 // clear the buffer so that it will not be received twice -
uspace/lib/drv/generic/remote_usbhid.c
r3c9eb46 r266fcd8 130 130 131 131 size_t act_length; 132 rc = hid_iface->get_event(fun, data, len, &act_length, flags); 132 int event_nr; 133 rc = hid_iface->get_event(fun, data, len, &act_length, &event_nr, flags); 133 134 if (rc != EOK) { 134 135 free(data); … … 147 148 free(data); 148 149 149 async_answer_ 0(callid, EOK);150 async_answer_1(callid, EOK, event_nr); 150 151 } 151 152 -
uspace/lib/drv/include/usbhid_iface.h
r3c9eb46 r266fcd8 109 109 */ 110 110 int (*get_event)(ddf_fun_t *fun, uint8_t *buffer, size_t size, 111 size_t *act_size, unsigned int flags);111 size_t *act_size, int *event_nr, unsigned int flags); 112 112 113 113 /** Get size of the report descriptor in bytes. -
uspace/lib/usbhid/include/usb/hid/iface.h
r3c9eb46 r266fcd8 39 39 40 40 int usbhid_dev_get_event_length(int, size_t *); 41 int usbhid_dev_get_event(int, uint8_t *, size_t, size_t *, 41 int usbhid_dev_get_event(int, uint8_t *, size_t, size_t *, int *, 42 42 unsigned int); 43 43 int usbhid_dev_get_report_descriptor_length(int, size_t *); -
uspace/lib/usbhid/src/hidiface.c
r3c9eb46 r266fcd8 77 77 */ 78 78 int usbhid_dev_get_event(int dev_phone, uint8_t *buf, 79 size_t size, size_t *actual_size, unsigned int flags)79 size_t size, size_t *actual_size, int *event_nr, unsigned int flags) 80 80 { 81 81 if (dev_phone < 0) { … … 99 99 } 100 100 101 ipc_call_t opening_request_call; 101 102 aid_t opening_request = async_send_2(dev_phone, 102 103 DEV_IFACE_ID(USBHID_DEV_IFACE), IPC_M_USBHID_GET_EVENT, 103 flags, NULL);104 flags, &opening_request_call); 104 105 if (opening_request == 0) { 105 106 free(buffer); … … 143 144 *actual_size = act_size; 144 145 } 146 147 if (event_nr != NULL) { 148 *event_nr = IPC_GET_ARG1(opening_request_call); 149 } 145 150 146 151 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.