Changes in / [f1a9e87:eb87adb] in mainline
- Location:
- uspace
- Files:
-
- 7 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vuhid/Makefile
rf1a9e87 reb87adb 47 47 48 48 SOURCES_INTERFACES = \ 49 hids/bootkbd.c 49 hids/bootkbd.c \ 50 hids/logitech_wireless.c 50 51 51 52 SOURCES = \ … … 53 54 device.c \ 54 55 ifaces.c \ 56 life.c \ 55 57 stdreq.c \ 56 58 $(SOURCES_INTERFACES) -
uspace/app/vuhid/hids/bootkbd.c
rf1a9e87 reb87adb 93 93 0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 94 94 }; 95 static size_t in_data_count = sizeof(in_data)/INPUT_SIZE; 96 // FIXME - locking 97 static size_t in_data_position = 0; 98 99 static int on_data_in(vuhid_interface_t *iface, 100 void *buffer, size_t buffer_size, size_t *act_buffer_size) 101 { 102 static size_t last_pos = (size_t) -1; 103 size_t pos = in_data_position; 104 if (pos >= in_data_count) { 105 return EBADCHECKSUM; 106 } 107 108 if (last_pos == pos) { 109 return ENAK; 110 } 111 112 if (buffer_size > INPUT_SIZE) { 113 buffer_size = INPUT_SIZE; 114 } 115 116 if (act_buffer_size != NULL) { 117 *act_buffer_size = buffer_size; 118 } 119 120 memcpy(buffer, in_data + pos * INPUT_SIZE, buffer_size); 121 last_pos = pos; 122 123 return EOK; 124 } 95 static vuhid_interface_life_t boot_life = { 96 .data_in = in_data, 97 .data_in_count = sizeof(in_data)/INPUT_SIZE, 98 .data_in_pos_change_delay = 500, 99 .msg_born = "Boot keyboard comes to life...", 100 .msg_die = "Boot keyboard died." 101 }; 125 102 126 103 static int on_data_out(vuhid_interface_t *iface, … … 141 118 } 142 119 143 144 static void live(vuhid_interface_t *iface)145 {146 async_usleep(1000 * 1000 * 5);147 usb_log_debug("Boot keyboard comes to life...\n");148 while (in_data_position < in_data_count) {149 async_usleep(1000 * 500);150 in_data_position++;151 }152 usb_log_debug("Boot keyboard died.\n");153 }154 155 156 120 vuhid_interface_t vuhid_interface_bootkbd = { 157 121 .id = "boot", … … 164 128 165 129 .in_data_size = INPUT_SIZE, 166 .on_data_in = on_data_in,130 .on_data_in = interface_live_on_data_in, 167 131 168 132 .out_data_size = 1, 169 133 .on_data_out = on_data_out, 170 134 171 .live = live,135 .live = interface_life_live, 172 136 137 .interface_data = &boot_life, 173 138 .vuhid_data = NULL 174 139 }; -
uspace/app/vuhid/ifaces.c
rf1a9e87 reb87adb 38 38 39 39 extern vuhid_interface_t vuhid_interface_bootkbd; 40 extern vuhid_interface_t vuhid_interface_logitech_wireless_1; 40 41 41 42 vuhid_interface_t *available_hid_interfaces[] = { 42 43 &vuhid_interface_bootkbd, 44 &vuhid_interface_logitech_wireless_1, 43 45 NULL 44 46 }; -
uspace/app/vuhid/virthid.h
rf1a9e87 reb87adb 82 82 83 83 typedef struct { 84 /** Buffer with data from device to the host. */ 85 uint8_t *data_in; 86 /** Number of items in @c data_in. 87 * The total size of @c data_in buffer shall be 88 * <code>data_in_count * vuhid_interface_t.in_data_size</code>. 89 */ 90 size_t data_in_count; 91 92 /** Current position in the data buffer. */ 93 size_t data_in_pos; 94 /** Previous position. */ 95 size_t data_in_last_pos; 96 97 /** Delay between transition to "next" input buffer (in ms). */ 98 size_t data_in_pos_change_delay; 99 100 /** Message to print when interface becomes alive. */ 101 const char *msg_born; 102 /** Message to print when interface dies. */ 103 const char *msg_die; 104 } vuhid_interface_life_t; 105 106 typedef struct { 84 107 uint8_t length; 85 108 uint8_t type; … … 94 117 void wait_for_interfaces_death(usbvirt_device_t *); 95 118 119 void interface_life_live(vuhid_interface_t *); 120 int interface_live_on_data_in(vuhid_interface_t *, void *, size_t, size_t *); 121 122 96 123 #endif 97 124 /** -
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
rf1a9e87 reb87adb 75 75 /** Default idle rate for mouses. */ 76 76 static const uint8_t IDLE_RATE = 0; 77 static const size_t USB_MOUSE_BUTTON_COUNT = 3;78 77 79 78 /*----------------------------------------------------------------------------*/ … … 397 396 /*----------------------------------------------------------------------------*/ 398 397 398 /** Get highest index of a button mentioned in given report. 399 * 400 * @param report HID report. 401 * @param report_id Report id we are interested in. 402 * @return Highest button mentioned in the report. 403 * @retval 1 No button was mentioned. 404 * 405 */ 406 static size_t usb_mouse_get_highest_button(usb_hid_report_t *report, uint8_t report_id) 407 { 408 size_t highest_button = 0; 409 410 usb_hid_report_path_t *path = usb_hid_report_path(); 411 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_BUTTON, 0); 412 usb_hid_report_path_set_report_id(path, report_id); 413 414 usb_hid_report_field_t *field = NULL; 415 416 /* Break from within. */ 417 while (1) { 418 field = usb_hid_report_get_sibling( 419 report, field, path, 420 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 421 USB_HID_REPORT_TYPE_INPUT); 422 /* No more buttons? */ 423 if (field == NULL) { 424 break; 425 } 426 427 size_t current_button = field->usage - field->usage_minimum; 428 if (current_button > highest_button) { 429 highest_button = current_button; 430 } 431 } 432 433 usb_hid_report_path_free(path); 434 435 return highest_button; 436 } 437 438 /*----------------------------------------------------------------------------*/ 439 399 440 int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data) 400 441 { … … 414 455 } 415 456 416 mouse_dev->buttons = (int32_t *)calloc(USB_MOUSE_BUTTON_COUNT, 417 sizeof(int32_t)); 457 // FIXME: This may not be optimal since stupid hardware vendor may 458 // use buttons 1, 2, 3 and 6000 and we would allocate array of 459 // 6001*4B and use only 4 items in it. 460 // Since I doubt that hardware producers would do that, I think 461 // that the current solution is good enough. 462 /* Adding 1 because we will be accessing buttons[highest]. */ 463 mouse_dev->buttons_count = usb_mouse_get_highest_button(hid_dev->report, 464 hid_dev->report_id) + 1; 465 mouse_dev->buttons = calloc(mouse_dev->buttons_count, sizeof(int32_t)); 418 466 419 467 if (mouse_dev->buttons == NULL) { 420 usb_log_ fatal("No memory!\n");468 usb_log_error(NAME ": out of memory, giving up on device!\n"); 421 469 free(mouse_dev); 422 470 return ENOMEM; 423 471 } 424 472 473 425 474 // save the Mouse device structure into the HID device structure 426 475 *data = mouse_dev; -
uspace/drv/bus/usb/usbhid/mouse/mousedev.h
rf1a9e87 reb87adb 50 50 async_sess_t *wheel_sess; 51 51 52 /* Mouse buttons statuses. */ 52 53 int32_t *buttons; 54 size_t buttons_count; 53 55 54 56 ddf_dev_ops_t ops; -
uspace/drv/bus/usb/vhc/connhost.c
rf1a9e87 reb87adb 440 440 int rc = vhc_virtdev_add_transfer(vhc, transfer); 441 441 if (rc != EOK) { 442 free(transfer->setup_buffer); 442 if (transfer->setup_buffer != NULL) { 443 free(transfer->setup_buffer); 444 } 443 445 free(transfer); 444 446 return rc; -
uspace/lib/usbhid/src/hidpath.c
rf1a9e87 reb87adb 76 76 int32_t usage_page, int32_t usage) 77 77 { 78 usb_hid_report_usage_path_t *item; 79 80 if(!(item=malloc(sizeof(usb_hid_report_usage_path_t)))) { 78 usb_hid_report_usage_path_t *item 79 = malloc(sizeof(usb_hid_report_usage_path_t)); 80 81 if (item == NULL) { 81 82 return ENOMEM; 82 83 }
Note:
See TracChangeset
for help on using the changeset viewer.