Changes in / [eb87adb:f1a9e87] in mainline
- Location:
- uspace
- Files:
-
- 7 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vuhid/Makefile
reb87adb rf1a9e87 47 47 48 48 SOURCES_INTERFACES = \ 49 hids/bootkbd.c \ 50 hids/logitech_wireless.c 49 hids/bootkbd.c 51 50 52 51 SOURCES = \ … … 54 53 device.c \ 55 54 ifaces.c \ 56 life.c \57 55 stdreq.c \ 58 56 $(SOURCES_INTERFACES) -
uspace/app/vuhid/hids/bootkbd.c
reb87adb rf1a9e87 93 93 0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 94 94 }; 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 }; 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 } 102 125 103 126 static int on_data_out(vuhid_interface_t *iface, … … 118 141 } 119 142 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 120 156 vuhid_interface_t vuhid_interface_bootkbd = { 121 157 .id = "boot", … … 128 164 129 165 .in_data_size = INPUT_SIZE, 130 .on_data_in = interface_live_on_data_in,166 .on_data_in = on_data_in, 131 167 132 168 .out_data_size = 1, 133 169 .on_data_out = on_data_out, 134 170 135 .live = interface_life_live,171 .live = live, 136 172 137 .interface_data = &boot_life,138 173 .vuhid_data = NULL 139 174 }; -
uspace/app/vuhid/ifaces.c
reb87adb rf1a9e87 38 38 39 39 extern vuhid_interface_t vuhid_interface_bootkbd; 40 extern vuhid_interface_t vuhid_interface_logitech_wireless_1;41 40 42 41 vuhid_interface_t *available_hid_interfaces[] = { 43 42 &vuhid_interface_bootkbd, 44 &vuhid_interface_logitech_wireless_1,45 43 NULL 46 44 }; -
uspace/app/vuhid/virthid.h
reb87adb rf1a9e87 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 be88 * <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 {107 84 uint8_t length; 108 85 uint8_t type; … … 117 94 void wait_for_interfaces_death(usbvirt_device_t *); 118 95 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 123 96 #endif 124 97 /** -
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
reb87adb rf1a9e87 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; 77 78 78 79 /*----------------------------------------------------------------------------*/ … … 396 397 /*----------------------------------------------------------------------------*/ 397 398 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 440 399 int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data) 441 400 { … … 455 414 } 456 415 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)); 416 mouse_dev->buttons = (int32_t *)calloc(USB_MOUSE_BUTTON_COUNT, 417 sizeof(int32_t)); 466 418 467 419 if (mouse_dev->buttons == NULL) { 468 usb_log_ error(NAME ": out of memory, giving up on device!\n");420 usb_log_fatal("No memory!\n"); 469 421 free(mouse_dev); 470 422 return ENOMEM; 471 423 } 472 473 424 474 425 // save the Mouse device structure into the HID device structure 475 426 *data = mouse_dev; -
uspace/drv/bus/usb/usbhid/mouse/mousedev.h
reb87adb rf1a9e87 50 50 async_sess_t *wheel_sess; 51 51 52 /* Mouse buttons statuses. */53 52 int32_t *buttons; 54 size_t buttons_count;55 53 56 54 ddf_dev_ops_t ops; -
uspace/drv/bus/usb/vhc/connhost.c
reb87adb rf1a9e87 440 440 int rc = vhc_virtdev_add_transfer(vhc, transfer); 441 441 if (rc != EOK) { 442 if (transfer->setup_buffer != NULL) { 443 free(transfer->setup_buffer); 444 } 442 free(transfer->setup_buffer); 445 443 free(transfer); 446 444 return rc; -
uspace/lib/usbhid/src/hidpath.c
reb87adb rf1a9e87 76 76 int32_t usage_page, int32_t usage) 77 77 { 78 usb_hid_report_usage_path_t *item 79 = malloc(sizeof(usb_hid_report_usage_path_t)); 80 81 if (item == NULL) { 78 usb_hid_report_usage_path_t *item; 79 80 if(!(item=malloc(sizeof(usb_hid_report_usage_path_t)))) { 82 81 return ENOMEM; 83 82 }
Note:
See TracChangeset
for help on using the changeset viewer.