Changeset 113093a in mainline
- Timestamp:
- 2011-09-24T21:39:41Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1924bd43, f9d8c3a
- Parents:
- b3bf143 (diff), 024fcc5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vuhid/Makefile
rb3bf143 r113093a 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
rb3bf143 r113093a 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
rb3bf143 r113093a 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
rb3bf143 r113093a 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
rb3bf143 r113093a 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
rb3bf143 r113093a 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
rb3bf143 r113093a 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
rb3bf143 r113093a 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 } -
uspace/srv/hid/console/console.c
rb3bf143 r113093a 344 344 } 345 345 346 static console_t *cons_get_active_uspace(void) 347 { 348 fibril_mutex_lock(&switch_mtx); 349 350 console_t *active_uspace = active_console; 351 if (active_uspace == kernel_console) { 352 active_uspace = prev_console; 353 } 354 assert(active_uspace != kernel_console); 355 356 fibril_mutex_unlock(&switch_mtx); 357 358 return active_uspace; 359 } 360 346 361 static ssize_t limit(ssize_t val, ssize_t lo, ssize_t hi) 347 362 { … … 466 481 event->c = c; 467 482 468 prodcons_produce(&active_console->input_pc, &event->link); 483 /* Kernel console does not read events 484 * from us, so we will redirect them 485 * to the (last) active userspace console 486 * if necessary. 487 */ 488 console_t *target_console = cons_get_active_uspace(); 489 490 prodcons_produce(&target_console->input_pc, 491 &event->link); 469 492 } 470 493 … … 904 927 atomic_set(&consoles[i].refcnt, 0); 905 928 fibril_mutex_initialize(&consoles[i].mtx); 929 prodcons_initialize(&consoles[i].input_pc); 906 930 907 931 if (graphics_state == GRAPHICS_FULL) { … … 942 966 } 943 967 944 prodcons_initialize(&consoles[i].input_pc);945 968 cons_redraw_state(&consoles[i]); 946 969
Note:
See TracChangeset
for help on using the changeset viewer.